ld: Change visibility of __start_* __stop_* symbols

Fangrui Song maskray@google.com
Tue Jun 2 21:12:52 GMT 2020


GNU ld defined __start_*/__stop_* symbols used to be STV_HIDDEN. They
were made STV_PROTECTED by the resolution in https://sourceware.org/bugzilla/show_bug.cgi?id=21964
The rationale is that "people use dlsym to look them up."

In GCC/clang, -fvisibility=hidden can make definitions STV_HIDDEN (this
is a very good way avoid leaking internal definitions).

However, for the linker defined __start_*/__stop_* , there isn't a counterpart.
Should we have a -z option controlling the visibility?

If yes, what do you think of
-z start-stop-symbols={protected,hidden}
or simply
-z start-stop={protected,hidden}


More information about the Binutils mailing list