__start/__stop symbols not always defined

Alan Modra amodra@gmail.com
Fri Jan 19 02:10:00 GMT 2018

On Wed, Jan 17, 2018 at 06:17:48PM +0100, Michael Matz wrote:
> It is (and was) also documented that these symbols are PROVIDEd, and hence 
> only defined if referenced.

Right, and that documentation goes all the way back to 2008-05-21.

I'm not discounting your comments about dlopen and dlsym, but I
believe the current behaviour is reasonable and likely gives what most
people want, particularly those who are concerned about symbol table

I suppose you could argue that a defined default visibility symbol in
an ELF shared library is also implicitly a reference due to the way
ELF symbol overriding works, so PROVIDE ought to supply definitions in
that case.  That wouldn't help here since we're making __start and
__stop symbols protected visibility..

> linker script to always define these __start/__stop symbols.  Indeed I 
> can't really see a way to somehow force references to those symbols to 
> appear without either wasting code or data space (e.g.
> "void *__unused_global=&__start___verbose"),

-u __start___verbose on the ld command line ought to work.

Alan Modra
Australia Development Lab, IBM

More information about the Binutils mailing list