]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - ld/ChangeLog
Weak references to __start_/__stop_ symbols
authorAlan Modra <amodra@gmail.com>
Mon, 1 Mar 2021 01:10:51 +0000 (11:40 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 1 Mar 2021 03:56:39 +0000 (14:26 +1030)
commit7824c1d22fcab8a68162634d4293f4a6666ca43e
treeba713f8ed77d32992d3588a8cf837ec8f229482e
parent6a1224ec762f7dd59d7abd2e5dc3be26bb157cd1
Weak references to __start_/__stop_ symbols

If a weak reference to a __start_foo or __stop_foo symbol ends up
having no definition due to all the foo sections being removed for
some reason, undef_start_stop currently makes the symbol strong
undefined.  That risks a linker undefined symbol error.  Fix that by
making the symbol undefweak and also undo some dynamic symbol state.

Note that saving the state of the symbol type at the time
lang_init_start_stop runs is not sufficient.  The linker may have
merged in a shared library reference by that point and made what was
an undefweak in regular objects, a strong undefined.  So it is
necessary to look at the ELF symbol flags to decide whether an
undefweak is the proper resolution.

Something probably should be done for COFF/PE too, but I'm unsure how
to do go about that.

* ldlang.c (undef_start_stop): For ELF make undefined start/stop
symbols undefweak if that was how they were referenced.  Undo
dynamic state too.
ld/ChangeLog
ld/ldlang.c