Reason for __ aliases of variables
Joseph Myers
joseph@codesourcery.com
Tue Mar 7 20:06:00 GMT 2017
On Tue, 7 Mar 2017, Florian Weimer wrote:
> We have some global variables in glibc which have internal __ aliases (e.g.,
> daylight and __daylight). Why do we do this?
As discussed in the signgam context: if the __ alias is exported at a
public symbol version, as well as the non-__ version as a weak alias, and
glibc internally only references the __ version, then: if an application
references the variable without defining its own copy then the application
will end up with a dynamic relocation against the __ alias (thanks to
static linker magic), while if it defines its own copy then that copy will
be separate. So this provides namespace protection.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list