Patchwork PING: [PATCH] Add --enable-static-pie to build static PIE

login
register
mail settings
Submitter H.J. Lu
Date Oct. 12, 2017, 10:06 p.m.
Message ID <CAMe9rOpVguCXiaAOpwLnJN7fyN8vuz_X1HcU7V=a=Nsb3to-fA@mail.gmail.com>
Download mbox | patch
Permalink /patch/23518/
State New
Headers show

Comments

H.J. Lu - Oct. 12, 2017, 10:06 p.m.
On 10/5/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> On 10/5/17, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>> On 05/10/17 14:11, H.J. Lu wrote:
>>> On 9/29/17, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> I submitted patches for other targets to address obvious issues with
>>>> static
>>>> PIE.  Build results of build-many-glibcs.py with --enable-static-pie
>>>> with
>>>> all
>>>> patches for static PIE applied are
>>>>
>>>> PASS: glibcs-aarch64_be-linux-gnu build
>>>> PASS: glibcs-aarch64-linux-gnu build
>>
>> can you tell me the binutils version used?
>> building fails with recent binutils master:
>>
>> builddir/libc.a(dl-reloc-static-pie.o): In function
>> `elf_get_dynamic_info':
>> srcdir/elf/get-dynamic-info.h:73:(.text+0x4c): relocation truncated to
>> fit:
>> R_AARCH64_ADR_PREL_PG_HI21 against
>> symbol `_dl_main_map' defined in .data.rel.local section in
>> builddir/libc.a(dl-support.o)
>> srcdir/elf/get-dynamic-info.h:70:(.text+0x50): relocation truncated to
>> fit:
>> R_AARCH64_ADR_PREL_PG_HI21 against
>> symbol `_dl_main_map' defined in .data.rel.local section in
>> builddir/libc.a(dl-support.o)
>>
>> and
>>
>> $ objdump -t builddir/elf/dl-support.o
>> ...
>> 0000000000000000 g     O .data.rel.local	0000000000000468 .hidden
>> _dl_main_map
>> ...
>> $ objdump -r builddir/elf/dl-reloc-static-pie.o
>> ...
>> 000000000000004c R_AARCH64_ADR_PREL_PG_HI21
>> _dl_main_map+0x000000037ffffa40
>> 0000000000000050 R_AARCH64_ADR_PREL_PG_HI21
>> _dl_main_map+0x000000037ffff1e0
>> ...
>>
>> those offsets look wrong, i'll need to investigate
>>
>>
>
> Did you mean addend?  In any case, I checked a workaround
> into hjl/pie/static.  Please give it a try,

Here is the updated patch.  The main change is that gPcrt1.o is also added
to create static PIE with -pg.

OK for master?
Joseph Myers - Oct. 12, 2017, 10:15 p.m.
On Thu, 12 Oct 2017, H.J. Lu wrote:

> Here is the updated patch.  The main change is that gPcrt1.o is also added
> to create static PIE with -pg.

The attached build-many-glibcs.py patch is definitely inappropriate for 
master.  If --enable-static-pie is approved, it would be appropriate to 
build one or two additional glibc variants in build-many-glibcs.py with 
this option.  It is *not* appropriate to add it to all builds there, 
because of how (as discussed) the option is different from 
--enable-profile, changing how the normal static libc is built instead of 
adding a new variable.

Patch

From 1798eb01da55411ce2c74ad0241801c03a1b67e6 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 27 Sep 2017 16:47:29 -0700
Subject: [PATCH 11/11] Add --enable-static-pie to build-many-glibcs.py

---
 scripts/build-many-glibcs.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index a6c01f9cc4..2b6b132bb4 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -1342,6 +1342,7 @@  class Glibc(object):
         cmdlist.create_copy_dir(srcdir, srcdir_copy)
         cfg_cmd = [os.path.join(srcdir_copy, 'configure'),
                    '--prefix=/usr',
+                   '--enable-static-pie',
                    '--enable-profile',
                    '--build=%s' % self.ctx.build_triplet,
                    '--host=%s' % self.triplet,
-- 
2.13.6