This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On 2017.09.28 at 05:26 -0700, H.J. Lu wrote:
> On 9/28/17, Markus Trippelsdorf <markus@trippelsdorf.de> wrote:
> > On 2017.09.27 at 01:30 -0700, H.J. Lu wrote:
> >> No separate PIE copy of libc.a, is used for static PIE to minimize
> >> GCC driver change.  To improve system security, glibc can be built with
> >> --enable-static-pie, and the same libc.a can be used to build both static
> >> executable and static PIE.
> >
> > It doesn't work:
> >
> >  ~ % echo "int main(){}" | gcc -x c - -static
> > /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../lib64/libc.a(dl-support.o):
> > In function `elf_machine_load_address':
> > /home/markus/glibc/elf/../sysdeps/x86_64/dl-machine.h:59: undefined
> > reference to `_DYNAMIC'
> > /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../lib64/libc.a(dl-support.o):
> > In function `elf_get_dynamic_info':
> > /home/markus/glibc/elf/get-dynamic-info.h:48: undefined reference to
> > `_DYNAMIC'
> > /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../x86_64-pc-linux-gnu/bin/ld:
> > a.out: hidden symbol `_DYNAMIC' isn't defined
> > /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../x86_64-pc-linux-gnu/bin/ld:
> > final link failed: Bad value
> > collect2: error: ld returned 1 exit status
> >
>
> Thanks for your test.   Fixed on hjl/pie/static branch.

Thanks. It now works fine. 

This has nothing to do with your patch, however valgrind reports (also for
-static-pie):

 ~ % echo "int main(){}" | gcc -x c - -static
 ~ % valgrind ./a.out
==15601== Memcheck, a memory error detector
==15601== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==15601== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==15601== Command: ./a.out
==15601== 
==15601== Conditional jump or move depends on uninitialised value(s)
==15601==    at 0x422849: __libc_malloc (malloc.c:3032)
==15601==    by 0x422849: malloc_hook_ini (hooks.c:32)
==15601==    by 0x465CD1: _dl_get_origin (dl-origin.c:50)
==15601==    by 0x432FCE: _dl_non_dynamic_init (dl-support.c:348)
==15601==    by 0x434760: __libc_init_first (init-first.c:74)
==15601==    by 0x4044DE: (below main) (libc-start.c:244)
==15601== 
==15601== Conditional jump or move depends on uninitialised value(s)
==15601==    at 0x422941: tcache_init (malloc.c:2981)
==15601==    by 0x422941: __libc_malloc (malloc.c:3032)
==15601==    by 0x422941: malloc_hook_ini (hooks.c:32)
==15601==    by 0x465CD1: _dl_get_origin (dl-origin.c:50)
==15601==    by 0x432FCE: _dl_non_dynamic_init (dl-support.c:348)
==15601==    by 0x434760: __libc_init_first (init-first.c:74)
==15601==    by 0x4044DE: (below main) (libc-start.c:244)
==15601== 
==15601== Conditional jump or move depends on uninitialised value(s)
==15601==    at 0x421BC8: _int_malloc (malloc.c:3673)
==15601==    by 0x421BC8: tcache_init.part.9 (malloc.c:2985)
==15601==    by 0x42294B: tcache_init (malloc.c:2981)
==15601==    by 0x42294B: __libc_malloc (malloc.c:3032)
==15601==    by 0x42294B: malloc_hook_ini (hooks.c:32)
==15601==    by 0x465CD1: _dl_get_origin (dl-origin.c:50)
==15601==    by 0x432FCE: _dl_non_dynamic_init (dl-support.c:348)
==15601==    by 0x434760: __libc_init_first (init-first.c:74)
==15601==    by 0x4044DE: (below main) (libc-start.c:244)

-- 
Markus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]