[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: Thu, 14 Dec 2017 00:11:29 -0800
- Authentication-results: sourceware.org; auth=none
- Cc: Roland McGrath <roland@hack.frob.com>, Sriraman Tallam <tmsriram@google.com>, Florian Weimer <fw@deneb.enyo.de>, Rahul Chaudhry via gnu-gabi <gnu-gabi@sourceware.org>, 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>, 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=AIMVa/YqUTScEdCdpQ4+4ApFA5UEsWfkwjNX1rRQaXI=; b=ANEBUQ/gdIQbADmShf0IpaUaLA3o6Qb0oL/7OLwwXitK3XY78JVVl1IZhxm1Dd9W+4 01/MaBDqLYc962+jjZVcKmR05AVXsqZUelJ1yGosVHg2dbqAM55oD1RQxuQwMFhKFUZB 60zb4XmC3SVZhQdBhw33cIbec/5JwXMNGKSSwQDw0MsD0RK2KFQ6N03N9EdqtGrQBMlS 51aFmhsBZ1ibOCg/zwyPdS3f0gTjTC8OBrOSQO85wvJRgfbS3tPD/tcbmWGG/M6jO4Wc xzr2aWvuPXiXhACiBC/p0N39D5j4PkDODR+RkwNqYdPGujxm3hYwWlzpJank9902GOgE 1Grg==
- In-reply-to: <CAJRD=opERJszwQMFfaKMVdOYF-YAbqqYW0iNWWMqNp3pq2njzw@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> <874lozec25.fsf@mid.deneb.enyo.de> <CAAs8HmwMRTjyLjvUAbP9drkagbpedonHOGGRvoFQVr1TE7wyCQ@mail.gmail.com> <CAJRD=opP96vFuSKK-1d1jw3nOKeTDE1T_E5hDwj3Zy-VUeAnRA@mail.gmail.com> <CAORpzuMftCGpXUObOyoFY0=jorMBDWEDbQJ23DifTNW3v-WA6Q@mail.gmail.com> <CAJRD=opERJszwQMFfaKMVdOYF-YAbqqYW0iNWWMqNp3pq2njzw@mail.gmail.com>
- Sender: gnu-gabi-owner@sourceware.org
> While adding a 'stride' field is definitely an improvement over simple
> delta+count encoding, it doesn't compare well against the bitmap based
> encoding.
>
> I took a look inside the encoding for the Vim binary. There are some instances
> in the bitmap based encoding like
> [0x3855555555555555 0x3855555555555555 0x3855555555555555 ...]
> that encode sequences of relocations applying to alternate words. The stride
> based encoding works very well on these and turns it into much more compact
> [0x0ff010ff 0x0ff010ff 0x0ff010ff ...]
> using stride==0x10 and count==0xff.
Have you looked much at where the RELATIVE relocations are coming from?
I've looked at a PIE build of gold, and they're almost all for
vtables, which mostly have consecutive entries with 8-byte strides.
There are a few for the GOT, a few for static constructors (in
.init_array), and a few for other initialized data, but vtables seem
to account for the vast majority. (Gold has almost 19,000 RELATIVE
dynamic relocs, and only about 500 non-RELATIVE dynamic relocs.)
Where do the 16-byte strides come from? Vim is plain C, right? I'm
guessing its RELATIVE relocation count is fairly low compared to big
C++ apps. I'm also guessing that the pattern comes from some large
structure or structures in the source code where initialized pointers
alternate with non-pointer values. I'm also curious about Roland's
app.
In my opinion, the data and my intuition both support your choice of a
jump + bit vector representation.
-cary