This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Reason for __ aliases of variables
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 7 Mar 2017 20:06:10 +0000
- Subject: Re: Reason for __ aliases of variables
- Authentication-results: sourceware.org; auth=none
- References: <ebc1a29e-efcc-de16-5ec8-fd23af7e143f@redhat.com>
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