This is the mail archive of the
mailing list for the binutils project.
Re: Preventing preemption of 'protected' symbols in GNU ld 2.26
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Joe Groff <jgroff at apple dot com>
- Cc: Alan Modra <amodra at gmail dot com>, Cary Coutant <ccoutant at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Tue, 29 Mar 2016 15:04:55 -0700
- Subject: Re: Preventing preemption of 'protected' symbols in GNU ld 2.26
- Authentication-results: sourceware.org; auth=none
- References: <AB592ABD-D6D7-4D2F-A0D6-45738F168DC4 at apple dot com> <BEDD88C6-7F80-45DA-9021-10587244AAE5 at apple dot com> <CAMe9rOq6rmvH458nufzfZnnU_=_n1yysbLzERNy-LWvEmjmN1A at mail dot gmail dot com> <983472E1-A1BC-4970-9CF9-0138A6BAD16D at apple dot com> <CAMe9rOqTTwirymAY6ORp6D_GnCsMc_hYEdy1NbZpG6x5vQc5DQ at mail dot gmail dot com> <6AAD87D2-90F9-4AD7-A195-AC91B76EA6AE at apple dot com> <CAMe9rOqNcYnm1YocG-m7XNDE0g68YQAGe=ULP-G98gaatpxSeA at mail dot gmail dot com>
On Tue, Mar 29, 2016 at 12:54 PM, H.J. Lu <firstname.lastname@example.org> wrote:
> On Tue, Mar 29, 2016 at 12:51 PM, Joe Groff <email@example.com> wrote:
>>> On Mar 29, 2016, at 12:43 PM, H.J. Lu <firstname.lastname@example.org> wrote:
>>> The link-time shared library may be very different from the run-time
>>> shared library. Since copy relocation works correctly against protected
>>> symbol with the current gcc, binutils and glibc, we can't simply disallow
>>> copy relocation against protected symbol at link-time.
>> However, protected doesn't work this way in older binutils, or with alternative tools like llvm or gold, and it sounds like protected was never intended to work this way either. Rather If gcc is interested in pursuing this optimization, it seems more responsible to me they could investigate introducing language-level annotations that let libraries opt into the optimization, instead of unilaterally breaking things for other binutils clients and introducing new complexity to get back to the original behavior.
> Protected symbol never worked correctly on x86 before. My
> change closed a few long-standing bugs. There is no going-back.
If you want to avoid copy relocation, you can do
1. Pass -z noextern-protected-data to build the shared object.
2. Use GOT to access external data in executable.