diff options
author | Alan Modra <amodra@gmail.com> | 2015-02-14 18:38:32 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-02-14 23:41:54 +1030 |
commit | ce875075f9c8acc57bb0ec516ae3ba50064e52b7 (patch) | |
tree | e3957d0a0a9b9931194f532155acd9386bcc71a3 /bfd/elflink.c | |
parent | 0a60f874dc25306c48fab8f7655813eb1bfeca8f (diff) | |
download | gdb-ce875075f9c8acc57bb0ec516ae3ba50064e52b7.zip gdb-ce875075f9c8acc57bb0ec516ae3ba50064e52b7.tar.gz gdb-ce875075f9c8acc57bb0ec516ae3ba50064e52b7.tar.bz2 |
PR ld/17973 LTO file syms
LTO output objects have an STT_FILE symbol using the name of the file,
a temporary file. This results in executables that can't be exactly
reproduced, so the file name needs to be dropped. We don't want to
lose all file symbols when linking a mix of lto and non-lto objects as
a file symbol can be used to figure which source file generated a
given local symbol. So lto output objects need to be marked.
I chose to mark lto output objects with a new bfd flag. This flag is
also used to fix a bug in the link-once handling; An object being
loaded after "loading_lto_outputs" is set might be one extracted from
an archive to satisfy new references from lto objects, not an lto
object itself.
The new flag is copied from archive to elements, and the same done
for no_export. This fixes a bug in that --exclude-libs doesn't work
with thin archives. I'm not completely happy with this part of the
patch and may revist this to avoid the hack in
_bfd_look_for_bfd_in_cache.
PR ld/17973
include/
* bfdlink.h (struct bfd_link_info): Delete loading_lto_outputs.
bfd/
* bfd.c (struct bfd): Add lto_output.
* linker.c (_bfd_handle_already_linked): Explicitly test for
objects added by the lto plugin.
* opncls.c (_bfd_new_bfd_contained_in): Copy lto_output and
no_export flags from archive.
* archive.c (open_nested_file): New function, setting lto_output
and no_export, extracted from..
(find_nested_archive): ..here. Flip params. Rename from
_bfd_find_nested_archive.
(_bfd_get_elt_at_filepos): Correct var typo. Use open_nested_file.
(_bfd_look_for_bfd_in_cache): Copy no_export.
* elflink.c (elf_link_add_object_symbols): Remove now unnecessary
my_archive->no_export test.
(elf_link_input_bfd): Drop existing lto_output STT_FILE syms.
Don't use the file name when adding lto_output STT_FILE sym.
* bfd-in2.h: Regenerate.
ld/
* ldlang.h (struct lang_input_statement_flags): Add lto_output.
* ldlang.c (lang_process): Don't set loading_lto_outputs.
* ldfile.c (ldfile_try_open_bfd): Transfer entry flags.lto_output
to bfd.
* plugin.c (add_input_file, add_input_library): Set flags.lto_output.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 16d9f20..bf28885 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -4085,8 +4085,7 @@ error_free_dyn: requested we not re-export it, then mark it as hidden. */ if (definition && !dynamic - && (abfd->no_export - || (abfd->my_archive && abfd->my_archive->no_export)) + && abfd->no_export && ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL) isym->st_other = (STV_HIDDEN | (isym->st_other & ~ELF_ST_VISIBILITY (-1))); @@ -9520,6 +9519,10 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd) if (ELF_ST_TYPE (isym->st_info) == STT_FILE) { + if (input_bfd->lto_output) + /* -flto puts a temp file name here. This means builds + are not reproducible. Discard the symbol. */ + continue; have_file_sym = TRUE; flinfo->filesym_count += 1; } @@ -9536,8 +9539,10 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd) memset (&osym, 0, sizeof (osym)); osym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE); osym.st_shndx = SHN_ABS; - if (!elf_link_output_sym (flinfo, input_bfd->filename, &osym, - bfd_abs_section_ptr, NULL)) + if (!elf_link_output_sym (flinfo, + (input_bfd->lto_output ? NULL + : input_bfd->filename), + &osym, bfd_abs_section_ptr, NULL)) return FALSE; } |