This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Read-only data in ELF libraries may be remapped writable at runtime (upcoming NDSS'17 paper)
- From: Alan Modra <amodra at gmail dot com>
- To: Richard Henderson <rth at twiddle dot net>
- Cc: Cary Coutant <ccoutant at gmail dot com>, Mathias Payer <mathias dot payer at nebelwelt dot net>, Florian Weimer <fweimer at redhat dot com>, Binutils <binutils at sourceware dot org>, libc-alpha at sourceware dot org, Xinyang Ge <xxg113 at cse dot psu dot edu>, Trent Jaeger <tjaeger at cse dot psu dot edu>
- Date: Fri, 6 Jan 2017 15:18:31 +1030
- Subject: Re: Read-only data in ELF libraries may be remapped writable at runtime (upcoming NDSS'17 paper)
- Authentication-results: sourceware.org; auth=none
- References: <5bb116b9-2633-bb9d-bd93-edece2fc56ec@redhat.com> <20161223143554.GG2896@bubble.grove.modra.org> <b4ef9e7d-0c69-e08c-cd08-b4033835b999@nebelwelt.net> <b0462cbd-5322-c7ab-66bb-d9f46a0991b2@redhat.com> <A492920E-0B50-400F-B3FA-0A142364018F@nebelwelt.net> <1f4b9a13-3d00-9782-1190-23dc6eb0d804@redhat.com> <b0b8ef76-28d8-5b2d-d3e8-ac28b22c075d@nebelwelt.net> <20161226082913.GD340@bubble.grove.modra.org> <CAJimCsGb732rAhMuqyFZ+ieK-KouG26yj+1LhVcEQ2o-bBevsw@mail.gmail.com> <d8dba75f-daca-a514-e8cc-b463c2f18d4a@twiddle.net>
On Wed, Jan 04, 2017 at 11:47:02AM -0800, Richard Henderson wrote:
> On 12/27/2016 09:48 PM, Cary Coutant wrote:
> >Nevertheless, I'd like to suggest that we're fixing the wrong problem.
> >Copy relocations have many problems, and I think we should focus more
> >on simply eliminating them entirely. The paper talks about that, but
> >only to the extent of using -fpic, which is overkill. It talks about
> >how Windows and macOS deal with the problem, but it overlooks some
> >other Unix platforms like HP-UX that do not use copy relocations at
> >all.
> >
> >On HP-UX, the compiler can be told to assume that any undefined data
> >symbol may be external to the load module, and generates an indirect
> >reference through the linkage table (aka, GOT). The linker is able to
> >rewrite the indirect reference as a direct reference if it determines
> >that the reference is within the same load module. The rewritten
> >sequence involves an extra register copy, but eliminates a much more
> >expensive memory load. The compiler can also make the opposite
> >assumption, and uses "#pragma external" to flag symbols that are known
> >to be external and should use the indirect sequence. All system header
> >files on HP-UX are decorated with these pragmas for all exported
> >variables.
> >
> >A similar technique could be used on most other platforms that today
> >require copy relocations.
>
> Indeed, this is exactly what I did for alpha-elf, back in 1996.
>
> It's a bit of a shame that we didn't do the same thing for one of the
> several reincarnations of ppc64(le)-elf, nor the initial aarch64. Both have
> ISAs and ABIs that would not have suffered at all for having an indirect
> reference that relaxes to a direct reference iff the symbol turns out to be
> local.
Yeah. The powerpc64 compiler generated GOT (TOC) makes this a bit
more difficult but GNU ld support for the ppc64 relaxation has been
there for quite a while. We're missing support in gold (*). I was
hoping to convert powerpc64 gcc away from using a TOC to the more
usual GOT relocs, where this sort of code editing becomes much easier.
Oh well, that never happened.
*) Over the last few days I've been cobbling together the gold
support. Hopefully should be ready before 2.28 goes out.
--
Alan Modra
Australia Development Lab, IBM