From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69136 invoked by alias); 9 Dec 2017 23:06:33 -0000 Mailing-List: contact gnu-gabi-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: gnu-gabi-owner@sourceware.org Received: (qmail 69107 invoked by uid 89); 9 Dec 2017 23:06:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=investigated X-Spam-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: albireo.enyo.de Received: from albireo.enyo.de (HELO albireo.enyo.de) (5.158.152.32) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Dec 2017 23:06:30 +0000 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1eNoCR-0003gJ-61; Sat, 09 Dec 2017 23:06:27 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.89) (envelope-from ) id 1eNoCQ-0004tI-UP; Sun, 10 Dec 2017 00:06:26 +0100 From: Florian Weimer To: "Rahul Chaudhry via gnu-gabi" Cc: Sriraman Tallam , Rahul Chaudhry , hegdesmailbox@gmail.com, Florian Weimer , David Edelsohn , Rafael Avila de Espindola , Binutils Development , Alan Modra , Cary Coutant , Xinliang David Li , Sterling Augustine , Paul Pluzhnikov , Ian Lance Taylor , "H.J. Lu" , Luis Lozano , Peter Collingbourne , Rui Ueyama , llvm-dev@lists.llvm.org Subject: Re: Reducing code size of Position Independent Executables (PIE) by shrinking the size of dynamic relocations section References: <8737cosnym.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me> <7e698a5f-32d7-6549-7e23-8850b85e6c10@gmail.com> Date: Sun, 01 Jan 2017 00:00:00 -0000 In-Reply-To: (Rahul Chaudhry via gnu-gabi's message of "Thu, 7 Dec 2017 14:51:20 -0800") Message-ID: <874lozec25.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-q4/txt/msg00008.txt.bz2 * Rahul Chaudhry via gnu-gabi: > 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: > > typedef struct > { > Elf64_Xword r_data; /* jump and bitmap for relative relocations */ > } Elf64_Relrz; > > #define ELF64_R_JUMP(val) ((val) >> 56) > #define ELF64_R_BITS(val) ((val) & 0xffffffffffffff) > > #ifdef DO_RELRZ > { > ElfW(Addr) offset =3D 0; > for (; relative < end; ++relative) > { > ElfW(Addr) jump =3D ELFW(R_JUMP) (relative->r_data); > ElfW(Addr) bits =3D ELFW(R_BITS) (relative->r_data); > offset +=3D jump * sizeof(ElfW(Addr)); > if (jump =3D=3D 0) > { > ++relative; > offset =3D relative->r_data; > } > ElfW(Addr) r_offset =3D offset; > for (; bits !=3D 0; bits >>=3D 1) > { > if ((bits&1) !=3D 0) > elf_machine_relrz_relative (l_addr, (void *) (l_addr + r_of= fset)); > r_offset +=3D sizeof(ElfW(Addr)); > } > } > } > #endif That data-dependent =E2=80=9Cif ((bits&1) !=3D 0)=E2=80=9D branch looks a b= it nasty. Have you investigated whether some sort of RLE-style encoding would be beneficial? If there are blocks of relative relocations, it might even be possible to use vector instructions to process them (although more than four relocations at a time are probably not achievable in a power-efficient manner on current x86-64).