add_symbols entry point will call ldlang_add_file, via the
add_archive_element callback, for each element of the archive
which is used. */
- if (bfd_get_format (entry->the_bfd) == bfd_object)
+ switch (bfd_get_format (entry->the_bfd))
{
+ default:
+ break;
+
+ case bfd_object:
ldlang_add_file (entry);
if (trace_files || trace_file_tries)
info_msg ("%I\n", entry);
+ break;
+
+ case bfd_archive:
+ if (whole_archive)
+ {
+ bfd *member = bfd_openr_next_archived_file (entry->the_bfd,
+ (bfd *) NULL);
+ while (member != NULL)
+ {
+ if (! bfd_check_format (member, bfd_object))
+ einfo ("%F%B: object %B in archive is not object\n",
+ entry->the_bfd, member);
+ if (! ((*link_info.callbacks->add_archive_element)
+ (&link_info, member, "-whole-archive")))
+ abort ();
+ if (! bfd_link_add_symbols (member, &link_info))
+ einfo ("%F%B: could not read symbols: %E\n", member);
+ member = bfd_openr_next_archived_file (entry->the_bfd,
+ member);
+ }
+
+ entry->loaded = true;
+
+ return;
+ }
}
if (! bfd_link_add_symbols (entry->the_bfd, &link_info))
fprintf (config.map_file, "Output address %08x\n", b);
}
if (output_section_statement->section_alignment >= 0
- || output_section_statement->section_alignment >= 0)
+ || output_section_statement->subsection_alignment >= 0)
{
fprintf (config.map_file, "\t\t\t\t\tforced alignment ");
if (output_section_statement->section_alignment >= 0)
}
/* Check that the architecture of all the input files is compatible
- with the output file. */
+ with the output file. Also call the backend to let it do any
+ other checking that is needed. */
static void
lang_check ()
einfo ("%P: warning: %s architecture of input file `%B' is incompatible with %s output\n",
bfd_printable_name (input_bfd), input_bfd,
bfd_printable_name (output_bfd));
+
+ else
+ bfd_merge_private_bfd_data (input_bfd, output_bfd);
}
}
bfd_link_hash_traverse (link_info.hash, lang_one_common, (PTR) NULL);
else
{
- unsigned int power;
+ int power;
- for (power = 1; power < 4; power++)
+ for (power = 4; power >= 0; power--)
bfd_link_hash_traverse (link_info.hash, lang_one_common,
(PTR) &power);
}
return true;
size = h->u.c.size;
- power_of_two = h->u.c.alignment_power;
+ power_of_two = h->u.c.p->alignment_power;
if (config.sort_common
- && power_of_two < *(unsigned int *) info
- && *(unsigned int *) info < 4)
+ && power_of_two < *(int *) info)
return true;
- section = h->u.c.section;
+ section = h->u.c.p->section;
/* Increase the size of the section. */
section->_raw_size = ALIGN_N (section->_raw_size,
called by ENTRY in a linker script. Command line arguments take
precedence. */
+/* WINDOWS_NT. When an entry point has been specified, we will also force
+ this symbol to be defined by calling ldlang_add_undef (equivalent to
+ having switch -u entry_name on the command line). The reason we do
+ this is so that the user doesn't have to because they would have to use
+ the -u switch if they were specifying an entry point other than
+ _mainCRTStartup. Specifically, if creating a windows application, entry
+ point _WinMainCRTStartup must be specified.
+ What I have found for non console applications (entry not _mainCRTStartup)
+ is that the .obj that contains mainCRTStartup is brought in since it is
+ the first encountered in libc.lib and it has other symbols in it which will
+ be pulled in by the link process. To avoid this, adding -u with the entry
+ point name specified forces the correct .obj to be used. We can avoid
+ making the user do this by always adding the entry point name as an
+ undefined symbol. */
+
void
lang_add_entry (name, cmdline)
CONST char *name;
entry_symbol = name;
from_cmdline = cmdline;
}
+#ifdef 0 /* WINDOWS_NT */
+ /* don't do this yet. It seems to work (the executables run), but the
+ image created is very different from what I was getting before indicating
+ that something else is being pulled in. When everything else is working,
+ then try to put this back in to see if it will do the right thing for
+ other more complicated applications */
+ ldlang_add_undef (name);
+#endif
}
void