This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reason for __ aliases of variables


On 03/07/2017 09:06 PM, Joseph Myers wrote:
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.

This is quite interesting, thanks. I guess this means that we want to keep exporting both __ and non-__ symbol sets with default (public) versions, just for consistency, but we do not want to define the __ symbols in header files.

(I'll remove the comment in my recent patch which alludes to a binutils bug in this area because this will not matter with two sets of public symbols.)

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]