This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] PR ld/18329: Turn off PROTECTED visibility with -Bsymbolic
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Sun, 26 Apr 2015 11:18:35 +0930
- Subject: Re: [PATCH] PR ld/18329: Turn off PROTECTED visibility with -Bsymbolic
- Authentication-results: sourceware.org; auth=none
- References: <20150425214638 dot GA13278 at gmail dot com> <20150425234609 dot GZ12627 at bubble dot grove dot modra dot org> <20150426004513 dot GA13051 at gmail dot com>
On Sat, Apr 25, 2015 at 05:45:13PM -0700, H.J. Lu wrote:
> On Sun, Apr 26, 2015 at 09:16:09AM +0930, Alan Modra wrote:
> > On Sat, Apr 25, 2015 at 02:46:38PM -0700, H.J. Lu wrote:
> > > If a global protected symbol is bound locally by -Bsymbolic, there is no
> > > need to keep protected visibility which hich may have overhead at run-time.
> > For this change to be safe you'd need to show that all ELF targets
> > supporting dynamic objects also properly support -Bsymbolic for both
> > functions and variables. ie. that none emit dynamic relocations for
> > the symbol when -Bsymbolic.
> Good point. Here is a patch to make it backend dependent. I will
> check it in shortly.
Before you do that, I'd like to know for sure what it is you're trying
to accomplish. I'm guessing the "may have overhead at run-time" is
the loop over dynamic relocs in glibc/elf/dl-lookup.c:do_lookup_x.
If that's so, then I think you can do better than just clearing the
visibility when -Bsymbolic. A protected symbol in an executable with
a definition other than in .dynbss, can also avoid the reloc loop.
As in the following testcase.
cat > protected.c <<EOF
int var __attribute__ ((visibility ("protected"))) = 0;
static void __attribute__ ((noinline))
var += 1;
if (var != 0)
for (i = 0; i < 100000000; i++)
cat > protected_add.c <<EOF
int var __attribute__ ((visibility ("protected"))) = 1;
extern void library (void);
int main ()
if (var != 1)
gcc -O2 -fPIC -shared -o protected.so protected.c
gcc -O2 -fPIC -o protected_app protected_app.c -Wl,-rpath=. protected.so
Australia Development Lab, IBM