From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] PR ld/18329: Turn off PROTECTED visibility with -Bsymbolic
Date: Sun, 26 Apr 2015 01:48:00 -0000 [thread overview]
Message-ID: <20150426014835.GA12627@bubble.grove.modra.org> (raw)
In-Reply-To: <20150426004513.GA13051@gmail.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.
Correct?
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))
count (void)
{
var += 1;
}
void
library (void)
{
int i;
if (var != 0)
__builtin_abort ();
for (i = 0; i < 100000000; i++)
count ();
}
EOF
cat > protected_add.c <<EOF
int var __attribute__ ((visibility ("protected"))) = 1;
extern void library (void);
int main ()
{
library ();
if (var != 1)
__builtin_abort ();
return 0;
}
EOF
gcc -O2 -fPIC -shared -o protected.so protected.c
gcc -O2 -fPIC -o protected_app protected_app.c -Wl,-rpath=. protected.so
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2015-04-26 1:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-25 21:46 H.J. Lu
2015-04-25 23:46 ` Alan Modra
2015-04-26 0:45 ` H.J. Lu
2015-04-26 1:48 ` Alan Modra [this message]
2015-04-26 13:38 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150426014835.GA12627@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).