diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2023-03-29 13:06:26 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2023-03-31 08:34:48 -0700 |
commit | 79cfb928f552401e3cec7a208a87eb74aa0d2d8b (patch) | |
tree | 77b7db15ab24daeead73c0919928791c6b7f38c4 /bfd/elflink.c | |
parent | Fix maybe-uninitialized warning in frame.c (diff) | |
download | binutils-gdb-79cfb928f552401e3cec7a208a87eb74aa0d2d8b.tar.gz binutils-gdb-79cfb928f552401e3cec7a208a87eb74aa0d2d8b.tar.bz2 binutils-gdb-79cfb928f552401e3cec7a208a87eb74aa0d2d8b.zip |
lto: Don't add indirect symbols for versioned aliases in IR
Linker adds indirect symbols for versioned symbol aliases, which are
created by ".symver foo, foo@FOO", by checking symbol type, value and
section so that references to foo will be replaced by references to
foo@FOO if foo and foo@FOO have the same symbol type, value and section.
But in IR, since all symbols of the same type have the same value and
section, we can't tell if a symbol is an alias of another symbol by
their types, values and sections. We shouldn't add indirect symbols
for versioned symbol aliases in IR.
bfd/
PR ld/30281
* elflink.c (elf_link_add_object_symbols): Don't add indirect
symbols for ".symver foo, foo@FOO" aliases in IR.
ld/
PR ld/30281
* testsuite/ld-plugin/lto.exp: Add PR ld/30281 test.
* testsuite/ld-plugin/pr30281.t: New file.
* testsuite/ld-plugin/pr30281.c: Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index bab1a36598e..f10faa5f8bd 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -5382,7 +5382,14 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) h->unique_global = (flags & BSF_GNU_UNIQUE) != 0; } - if (definition && !dynamic) + /* Don't add indirect symbols for .symver x, x@FOO aliases + in IR. Since all data or text symbols in IR have the + same type, value and section, we can't tell if a symbol + is an alias of another symbol by their types, values and + sections. */ + if (definition + && !dynamic + && (abfd->flags & BFD_PLUGIN) == 0) { char *p = strchr (name, ELF_VER_CHR); if (p != NULL && p[1] != ELF_VER_CHR) |