as: Replace the removed symbol with the versioned symbol
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 16 Aug 2021 13:46:44 +0000 (06:46 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 16 Aug 2021 13:46:44 +0000 (06:46 -0700)
commiteb09df162bafa67abee713be594a99bd20bd6825
tree8cea62798489a53661cacaa7eab76421d8340463
parent70069e7823d412a01d983379504222c557319cbd
as: Replace the removed symbol with the versioned symbol

When a symbol removed by .symver is used in relocation and there is one
and only one versioned symbol, don't remove the symbol.  Instead, mark
it to be removed and replace the removed symbol used in relocation with
the versioned symbol before generating relocation.

PR gas/28157
* symbols.c (symbol_flags): Add removed.
(symbol_entry_find): Updated.
(symbol_mark_removed): New function.
(symbol_removed_p): Likewise.
* symbols.h (symbol_mark_removed): New prototype.
(symbol_removed_p): Likewise.
* write.c (write_relocs): Call obj_fixup_removed_symbol on
removed fixp->fx_addsy and fixp->fx_subsy if defined.
(set_symtab): Don't add a symbol if symbol_removed_p returns true.
* config/obj-elf.c (elf_frob_symbol):  Don't remove the symbol
if it is used on relocation.  Instead, mark it as to be removed
and issue an error if the symbol has more than one versioned name.
(elf_fixup_removed_symbol): New function.
* config/obj-elf.h (elf_fixup_removed_symbol): New prototype.
(obj_fixup_removed_symbol): New.
* testsuite/gas/symver/symver11.d: Updated expected error
message.
* testsuite/gas/symver/symver16.d: New file.
* testsuite/gas/symver/symver16.s: Likewise.
gas/config/obj-elf.c
gas/config/obj-elf.h
gas/symbols.c
gas/symbols.h
gas/testsuite/gas/symver/symver11.d
gas/testsuite/gas/symver/symver16.d [new file with mode: 0644]
gas/testsuite/gas/symver/symver16.s [new file with mode: 0644]
gas/write.c