[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reducing code size of Position Independent Executables (PIE) by shrinking the size of dynamic relocations section
- To: Rahul Chaudhry <rahulchaudhry@google.com>
- Subject: Re: Reducing code size of Position Independent Executables (PIE) by shrinking the size of dynamic relocations section
- From: Cary Coutant <ccoutant@gmail.com>
- Date: Fri, 8 Dec 2017 22:36:22 -0800
- Authentication-results: sourceware.org; auth=none
- Cc: Sriraman Tallam <tmsriram@google.com>, Suprateeka R Hegde <hegdesmailbox@gmail.com>, Florian Weimer <fweimer@redhat.com>, David Edelsohn <dje.gcc@gmail.com>, Rafael Avila de Espindola <rafael.espindola@gmail.com>, Binutils Development <binutils@sourceware.org>, Alan Modra <amodra@gmail.com>, gnu-gabi@sourceware.org, Xinliang David Li <davidxl@google.com>, Sterling Augustine <saugustine@google.com>, Paul Pluzhnikov <ppluzhnikov@google.com>, Ian Lance Taylor <iant@google.com>, "H.J. Lu" <hjl.tools@gmail.com>, Luis Lozano <llozano@google.com>, Peter Collingbourne <pcc@google.com>, Rui Ueyama <ruiu@google.com>, llvm-dev@lists.llvm.org
- Delivered-to: listarch-gnu-gabi@sourceware.org
- Delivered-to: mailing list gnu-gabi@sourceware.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=PAiWNMlRJEpmKLX3t/g47JmlA6aMcAmRS7NzHc6SbO8=; b=FKxvPZ+E82SkfoQODMqD1BJWO8F79n9jklh3cgp01t7pIkPGU63IsOSO6kAKZw5sd6 wgcy1whRe523oVZ2Y1cuZ3eSZjgyWcDUHRdlK1ooIm8SSt6oSYS49p3tcSLn42yQ2Aap fAOahcqIAKh9bTG2SrqPsCSaG9pDKuhjLFuJENMDzyQNMZzadRnVZZaS7+NGLaJlb+s+ 9tOYeTKAAswQtTyHxiHRBydJnJ6bmPMM6YlIvpZJGeAYVLVnFxHW2g7eTMlww2a6/Pnt rL9OgpWk3y0u4HAR84AltMrsHFkn2mnDjHwQYKFUslk/VOVOgsHrOI5DgKidPYabzksW CjXw==
- In-reply-to: <CAJRD=ooGubyUOLE6W7LHdeU2ZNDEG1A=84+P=1iOvfmD7-7GNg@mail.gmail.com>
- List-help: <mailto:gnu-gabi-help@sourceware.org>
- List-id: <gnu-gabi.sourceware.org>
- List-post: <mailto:gnu-gabi@sourceware.org>
- List-subscribe: <mailto:gnu-gabi-subscribe@sourceware.org>
- Mailing-list: contact gnu-gabi-help@sourceware.org; run by ezmlm
- References: <CAGWvnynFwXFGLj3tAVgDatn0zmuHcWHyRNuDvR+wRZCXLnar_A@mail.gmail.com> <8737cosnym.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me> <CAGWvnynEe3QkhDMGc=Tx8Vr44egtv3xLuh1yiVcAhv+e3GLtZg@mail.gmail.com> <a3e5c76c-8cb9-fc53-a30a-96b2c85079e1@gmail.com> <a68a5d29-09d6-e758-8680-d94f42762adf@redhat.com> <7e698a5f-32d7-6549-7e23-8850b85e6c10@gmail.com> <CAAs8Hmziqc0hebPndiGuZN=buFm=M+O+2fGCfsv_rvDro9zJZA@mail.gmail.com> <CAJRD=ooGubyUOLE6W7LHdeU2ZNDEG1A=84+P=1iOvfmD7-7GNg@mail.gmail.com>
- Sender: gnu-gabi-owner@sourceware.org
> We've taken the '.relr.dyn' section from Cary's prototype, and implemented a
> custom encoding to compactly represent the list of offsets. We're calling the
> new compressed section '.relrz.dyn' (for relocations-relative-compressed).
I'd suggest just using .relr.dyn -- your encoding is straightforward
enough that I'd just make that the standard representation for this
section type.
> The encoding used is a simple combination of delta-encoding and a bitmap of
> offsets. The section consists of 64-bit entries: higher 8-bits contain delta
> since last offset, and lower 56-bits contain a bitmap for which words to apply
> the relocation to. This is best described by showing the code for decoding the
> section:
>
> ...
>
> The above code is the entirety of the implementation for decoding and
> processing '.relrz.dyn' sections in glibc dynamic loader.
>
> This encoding can represent up to 56 relocation offsets in a single 64-bit
> word. For many of the binaries we tested, this encoding provides >40x
> compression for storing offsets over the original `.relr.dyn` section.
>
> For 32-bit targets, we use 32-bit entries: 8-bits for 'jump' and 24-bits for
> the bitmap.
Very nice! Simple and effective.
> Here are three real world examples that demonstrate the savings:
Impressive numbers. I've gotta admit, the savings are better than I expected.
> However, before that can happen, we need agreement on the ABI side for the new
> section type and the encoding. We haven't worked on a change of this magnitude
> before that touches so many different pieces from the linker, elf tools, and
> the dynamic loader. Specifically, we need agreement and/or guidance on where
> and how should the new section type and its encoding be documented. We're
> proposing adding new defines for SHT_RELRZ, DT_RELRZ, DT_RELRZSZ, DT_RELRZENT,
> and DT_RELRZCOUNT that all the different parts of the toolchains can agree on.
Yes, as Ian mentioned, the generic ABI discussion is at
generic-abi@googlegroups.com. Most people who would be interested are
already on the gnu-gabi@sourceware.org list, but there are a few who
are not, and who may not yet have seen this discussion. I'll support
the proposal.
Thanks for taking this idea the extra mile!
-cary