qsort: elf_link_add_object_symbols weak aliases
authorAlan Modra <amodra@gmail.com>
Mon, 14 Oct 2019 03:21:19 +0000 (13:51 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 14 Oct 2019 06:17:13 +0000 (16:47 +1030)
commit3a3f4bf76a4790e81ee186ea76731a7f67dba1c8
tree96600b9d8a31fed33b8736b59eb0807963f09e05
parent48db3297342d798e58a00771a67b9b4c93412920
qsort: elf_link_add_object_symbols weak aliases

This particular sort almost certainly does not need to be stable for
the ELF linker to work correctly.  However it is conceivable that an
unstable sort could affect linker output, and thus different output be
seen with differing qsort implementations.  The argument goes like
this:  Given more than one strong alias symbol of equal section, value,
and size, the aliases will compare equal by elf_sort_symbol and thus
which one is chosen as the "real" symbol to be made dynamic depends on
qsort.  Why would anyone define two symbols at the same address?
Well, sometimes the fact that there are more than one strong alias
symbol is due to linker script symbols like __bss_start being made
dynamic.  This will match the first symbol defined in .bss if it
doesn't have correct size, and forgetting to properly set size and
type of symbols isn't as rare as it should be.

This patch adds some more heuristics to elf_sort_symbol.

* elflink.c (elf_sort_symbol): Sort on type and name as well.
(elf_link_add_object_symbols): Style fix.
bfd/ChangeLog
bfd/elflink.c
This page took 0.033581 seconds and 4 git commands to generate.