mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 01:28:46 +00:00
ld: Load the object only section when opening the mixed object file
Load the object only section when opening the mixed object file, instead of loading it after all other input files have been loaded. This fixed .../ld/collect-ld: /tmp/ccZAoUIW.obj-only.o: in function `main': .../ld/testsuite/ld-plugin/lto-10a.c:4: multiple definition of `main'; /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0x0): first defined here .../ld/collect-ld: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0xc5): undefined reference to `WinMain' collect2: error: ld returned 1 exit status ... FAIL: LTO 10 for x86_64-w64-mingw32 so that mixing LTO and non-LTO relocatable files for "ld -r" works for both ELF and non-ELF platforms. * ld.texi: Remove "On ELF platforms" from documentation of mixing LTO and non-LTO relocatable files for "ld -r". * ldlang.c (cmdline_load_object_only_section): New. (cmdline_check_object_only_section): Call it. * testsuite/ld-plugin/lto.exp: Enable mixed LTO and non-LTO relocatable output tests for all. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
31
ld/ldlang.c
31
ld/ldlang.c
@@ -10966,6 +10966,34 @@ cmdline_extract_object_only_section (bfd *abfd)
|
||||
return name;
|
||||
}
|
||||
|
||||
/* Load the object-only section. */
|
||||
|
||||
static void
|
||||
cmdline_load_object_only_section (const char *name)
|
||||
{
|
||||
lang_input_statement_type *entry
|
||||
= new_afile (name, lang_input_file_is_file_enum, NULL, NULL);
|
||||
|
||||
if (!entry)
|
||||
abort ();
|
||||
|
||||
ldfile_open_file (entry);
|
||||
|
||||
if (trace_files || verbose)
|
||||
info_msg ("%pI\n", entry);
|
||||
|
||||
if (entry->flags.missing_file
|
||||
|| bfd_get_format (entry->the_bfd) != bfd_object)
|
||||
abort ();
|
||||
|
||||
ldlang_add_file (entry);
|
||||
|
||||
if (bfd_link_add_symbols (entry->the_bfd, &link_info))
|
||||
entry->flags.loaded = true;
|
||||
else
|
||||
einfo (_("%F%P: %pB: error adding symbols: %E\n"), entry->the_bfd);
|
||||
}
|
||||
|
||||
/* Check and handle the object-only section. */
|
||||
|
||||
void
|
||||
@@ -10987,8 +11015,7 @@ cmdline_check_object_only_section (bfd *abfd, bool lto)
|
||||
abort ();
|
||||
case lto_mixed_object:
|
||||
filename = cmdline_extract_object_only_section (abfd);
|
||||
lang_add_input_file (filename,
|
||||
lang_input_file_is_file_enum, NULL);
|
||||
cmdline_load_object_only_section (filename);
|
||||
break;
|
||||
case lto_non_ir_object:
|
||||
case lto_slim_ir_object:
|
||||
|
||||
Reference in New Issue
Block a user