This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/pie/static created. glibc-2.26.9000-997-gc393eee
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 16 Dec 2017 02:27:38 -0000
- Subject: GNU C Library master sources branch hjl/pie/static created. glibc-2.26.9000-997-gc393eee
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/pie/static has been created
at c393eee146d198c12eb913ce87d5301751b00940 (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c393eee146d198c12eb913ce87d5301751b00940
commit c393eee146d198c12eb913ce87d5301751b00940
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Dec 15 18:18:25 2017 -0800
Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614]
After --enable-static-pie is added to configure, libc_cv_pie_default is
set to yes when either --enable-static-pie is used to configure glibc
or GCC defaults to PIE. We should set no-pie-ldflag to -no-pie, which
is supported on GCC 6 and later, only if GCC defaults to PIE, not when
--enable-static-pie is used to configure glibc.
Tested on x32 with --enable-static-pie using GCC 5 and without
--enable-static-pie using GCC 7.
[BZ #22614]
* Makeconfig (no-pie-ldflag): Set to -no-pie only if
$(cc-pie-default) == yes.
* config.make.in (cc-pie-default): New.
* configure.ac (libc_cv_pie_default): Renamed to ...
(libc_cv_cc_pie_default): This.
(libc_cv_pie_default): Set to $libc_cv_cc_pie_default.
* configure: Regenerated.
diff --git a/Makeconfig b/Makeconfig
index 99cc136..80c498e 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -464,8 +464,10 @@ endif
# Commands for linking programs with the C library.
ifndef +link
ifeq (yes,$(build-shared))
-ifeq (yes,$(build-pie-default))
+ifeq (yes,$(cc-pie-default))
no-pie-ldflag = -no-pie
+endif
+ifeq (yes,$(build-pie-default))
+link = $(+link-pie)
+link-tests = $(+link-pie-tests)
+link-printers-tests = $(+link-pie-printers-tests)
diff --git a/config.make.in b/config.make.in
index 04513db..9e5e24b 100644
--- a/config.make.in
+++ b/config.make.in
@@ -89,6 +89,7 @@ static-nss-crypt = @libc_cv_static_nss_crypt@
build-shared = @shared@
build-pic-default= @libc_cv_pic_default@
build-pie-default= @libc_cv_pie_default@
+cc-pie-default= @libc_cv_cc_pie_default@
build-profile = @profile@
build-static-nss = @static_nss@
cross-compiling = @cross_compiling@
diff --git a/configure b/configure
index 9da9fb2..7a8bd3f 100755
--- a/configure
+++ b/configure
@@ -596,6 +596,7 @@ static_nss
profile
libc_cv_multidir
libc_cv_pie_default
+libc_cv_cc_pie_default
libc_cv_pic_default
shared
static
@@ -6748,22 +6749,24 @@ $as_echo "$libc_cv_pic_default" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -fPIE is default" >&5
$as_echo_n "checking whether -fPIE is default... " >&6; }
-if ${libc_cv_pie_default+:} false; then :
+if ${libc_cv_cc_pie_default+:} false; then :
$as_echo_n "(cached) " >&6
else
- libc_cv_pie_default=yes
+ libc_cv_cc_pie_default=yes
cat > conftest.c <<EOF
#if defined __PIE__ || defined __pie__ || defined PIE || defined pie
# error PIE is default.
#endif
EOF
if eval "${CC-cc} -S conftest.c 2>&5 1>&5"; then
- libc_cv_pie_default=no
+ libc_cv_cc_pie_default=no
fi
rm -f conftest.*
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_pie_default" >&5
-$as_echo "$libc_cv_pie_default" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_pie_default" >&5
+$as_echo "$libc_cv_cc_pie_default" >&6; }
+libc_cv_pie_default=$libc_cv_cc_pie_default
+
# Set the `multidir' variable by grabbing the variable from the compiler.
diff --git a/configure.ac b/configure.ac
index 8e4006f..ca1282a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1794,17 +1794,19 @@ fi
rm -f conftest.*])
AC_SUBST(libc_cv_pic_default)
-AC_CACHE_CHECK([whether -fPIE is default], libc_cv_pie_default,
-[libc_cv_pie_default=yes
+AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
+[libc_cv_cc_pie_default=yes
cat > conftest.c <<EOF
#if defined __PIE__ || defined __pie__ || defined PIE || defined pie
# error PIE is default.
#endif
EOF
if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
- libc_cv_pie_default=no
+ libc_cv_cc_pie_default=no
fi
rm -f conftest.*])
+libc_cv_pie_default=$libc_cv_cc_pie_default
+AC_SUBST(libc_cv_cc_pie_default)
AC_SUBST(libc_cv_pie_default)
# Set the `multidir' variable by grabbing the variable from the compiler.
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2516b61f06bbac449fb14605b73dc36050872fe4
commit 2516b61f06bbac449fb14605b73dc36050872fe4
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Sep 27 16:47:29 2017 -0700
Add --enable-static-pie to build-many-glibcs.py
diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 5453000..bac9916 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -1338,6 +1338,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,
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=967b89cfc59d976aad2ccae36d241cbb65a5a53d
commit 967b89cfc59d976aad2ccae36d241cbb65a5a53d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Sep 28 16:13:54 2017 -0700
sparc: Check PIC instead of SHARED in start.S
Since start.o may be compiled as PIC, we should check PIC instead of
SHARED.
* sysdeps/sparc/sparc32/start.S (_start): Check PIC instead of
SHARED.
* sysdeps/sparc/sparc64/start.S (_start): Likewise.
diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S
index a06568d..b882d1e 100644
--- a/sysdeps/sparc/sparc32/start.S
+++ b/sysdeps/sparc/sparc32/start.S
@@ -42,7 +42,7 @@
.global _start
.type _start,#function
_start:
-#ifdef SHARED
+#ifdef PIC
SETUP_PIC_REG(l7)
#endif
@@ -57,7 +57,7 @@ _start:
add %sp, 23*4, %o2
/* Load the addresses of the user entry points. */
-#ifndef SHARED
+#ifndef PIC
sethi %hi(main), %o0
sethi %hi(__libc_csu_init), %o3
sethi %hi(__libc_csu_fini), %o4
diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S
index fcd4721..21d16de 100644
--- a/sysdeps/sparc/sparc64/start.S
+++ b/sysdeps/sparc/sparc64/start.S
@@ -42,7 +42,7 @@
.global _start
.type _start,#function
_start:
-#ifdef SHARED
+#ifdef PIC
SETUP_PIC_REG(l7)
#endif
@@ -58,7 +58,7 @@ _start:
add %sp, STACK_BIAS+23*8, %o2
/* Load the addresses of the user entry points. */
-#ifndef SHARED
+#ifndef PIC
sethi %hi(main), %o0
sethi %hi(__libc_csu_init), %o3
sethi %hi(__libc_csu_fini), %o4
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c332c8d087b340376e73d9cfb96b34a3499e88e2
commit c332c8d087b340376e73d9cfb96b34a3499e88e2
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Sep 28 16:13:22 2017 -0700
microblaze: Check PIC instead of SHARED in start.S
Since start.o may be compiled as PIC, we should check PIC instead of
SHARED.
* sysdeps/microblaze/start.S (_start): Check PIC instead of SHARED.
diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S
index f94e816..d9b13d0 100644
--- a/sysdeps/microblaze/start.S
+++ b/sysdeps/microblaze/start.S
@@ -58,7 +58,7 @@ _start:
sw r6,r1,r0
addik r7,r1,4
addik r1,r1,-24
-#ifdef SHARED
+#ifdef PIC
/* Setup PIC. */
mfs r20,rpc
addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=9fe5ea04c3a7f0f50908de1dac5ec12cf67cd865
commit 9fe5ea04c3a7f0f50908de1dac5ec12cf67cd865
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Sep 28 14:55:18 2017 -0700
sh: Update elf_machine_load_address for static PIE
When --enable-static-pie is used to configure glibc, we need to use
_dl_relocate_static_pie to compute load address in static PIE.
* sysdeps/sh/dl-machine.h (elf_machine_load_address): Use
_dl_relocate_static_pie instead of _dl_start to compute load
address in static PIE.
diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h
index 7106afb..cfcc4d9 100644
--- a/sysdeps/sh/dl-machine.h
+++ b/sysdeps/sh/dl-machine.h
@@ -50,6 +50,7 @@ static inline Elf32_Addr __attribute__ ((unused))
elf_machine_load_address (void)
{
Elf32_Addr addr;
+#ifdef SHARED
asm ("mov.l 1f,r0\n\
mov.l 3f,r2\n\
add r12,r2\n\
@@ -61,6 +62,19 @@ elf_machine_load_address (void)
3: .long _dl_start@GOTOFF\n\
2: mov r2,%0"
: "=r" (addr) : : "r0", "r1", "r2");
+#else
+ asm ("mov.l 1f,r0\n\
+ mov.l 3f,r2\n\
+ add r12,r2\n\
+ mov.l @(r0,r12),r0\n\
+ bra 2f\n\
+ sub r0,r2\n\
+ .align 2\n\
+ 1: .long _dl_relocate_static_pie@GOT\n\
+ 3: .long _dl_relocate_static_pie@GOTOFF\n\
+ 2: mov r2,%0"
+ : "=r" (addr) : : "r0", "r1", "r2");
+#endif
return addr;
}
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f6a00f95e09abaf4daf109662d9a6fd443106e30
commit f6a00f95e09abaf4daf109662d9a6fd443106e30
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Sep 28 14:53:06 2017 -0700
s390: Update elf_machine_load_address for static PIE
When --enable-static-pie is used to configure glibc, we need to use
_dl_relocate_static_pie to compute load address in static PIE.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_dynamic): Use
_dl_relocate_static_pie instead of _dl_start to compute load
address in static PIE.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_dynamic):
Likewise.
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
index c302c9d..da6817e 100644
--- a/sysdeps/s390/s390-32/dl-machine.h
+++ b/sysdeps/s390/s390-32/dl-machine.h
@@ -70,6 +70,7 @@ elf_machine_load_address (void)
{
Elf32_Addr addr;
+#ifdef SHARED
__asm__( " bras 1,2f\n"
"1: .long _GLOBAL_OFFSET_TABLE_ - 1b\n"
" .long (_dl_start - 1b - 0x80000000) & 0x00000000ffffffff\n"
@@ -78,6 +79,16 @@ elf_machine_load_address (void)
" al 1,0(1)\n"
" sl %0,_dl_start@GOT(1)"
: "=&d" (addr) : : "1" );
+#else
+ __asm__( " bras 1,2f\n"
+ "1: .long _GLOBAL_OFFSET_TABLE_ - 1b\n"
+ " .long (_dl_relocate_static_pie - 1b - 0x80000000) & 0x00000000ffffffff\n"
+ "2: l %0,4(1)\n"
+ " ar %0,1\n"
+ " al 1,0(1)\n"
+ " sl %0,_dl_relocate_static_pie@GOT(1)"
+ : "=&d" (addr) : : "1" );
+#endif
return addr;
}
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
index 7513520..5ef1c60 100644
--- a/sysdeps/s390/s390-64/dl-machine.h
+++ b/sysdeps/s390/s390-64/dl-machine.h
@@ -63,11 +63,19 @@ elf_machine_load_address (void)
{
Elf64_Addr addr;
+#ifdef SHARED
__asm__( " larl %0,_dl_start\n"
" larl 1,_GLOBAL_OFFSET_TABLE_\n"
" lghi 2,_dl_start@GOT\n"
" slg %0,0(2,1)"
: "=&d" (addr) : : "1", "2" );
+#else
+ __asm__( " larl %0,_dl_relocate_static_pie\n"
+ " larl 1,_GLOBAL_OFFSET_TABLE_\n"
+ " lghi 2,_dl_relocate_static_pie@GOT\n"
+ " slg %0,0(2,1)"
+ : "=&d" (addr) : : "1", "2" );
+#endif
return addr;
}
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=13be4b4c4ecb244d2bc3a10cecaf26bf8dabb3e9
commit 13be4b4c4ecb244d2bc3a10cecaf26bf8dabb3e9
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Fri Nov 24 07:13:10 2017 -0800
aarch64: fix start code for static pie
with upcoming static pie patches there are three flavors of the crt startup code:
1) crt1.o used for non-pie static linking (executable has no relocs),
2) Scrt1.o used for dynamic linking (dynamic linker relocates),
3) rcrt1.o used for static pie linking (self relocation is needed)
when crt1.o and rcrt1.o is built in the --enable-static-pie case -DPIC is passed,
when Scrt1.o is built then -DPIC -DSHARED is passed.
(crt1.o gets a dummy _dl_relocate_static_pie that interposes the one in
libc so no self-relocation is done in that case in __libc_start_main)
the Scrt1.o code is position independent but it relies on GOT entries that
need to be relocated which happens later and the static linker cannot relax
the GOT loads, so rcrt1.o needs separate implementation.
This implementation works with .text <= 4G files, which is fine, currently
the toolchain does not support larger position independent executables.
tests pass with ld/22269 and ld/22263 binutils bugs fixed.
this patch is on top of master but assumes the static pie patches.
* sysdeps/aarch64/start.S (_start): Handle PIC && !SHARED case.
diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
index c20433a..cd7ba7d 100644
--- a/sysdeps/aarch64/start.S
+++ b/sysdeps/aarch64/start.S
@@ -60,7 +60,8 @@ _start:
/* Setup stack limit in argument register */
mov x6, sp
-#ifdef SHARED
+#ifdef PIC
+# ifdef SHARED
adrp x0, :got:main
ldr PTR_REG (0), [x0, #:got_lo12:main]
@@ -69,6 +70,15 @@ _start:
adrp x4, :got:__libc_csu_fini
ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
+
+# else
+ adrp x0, main
+ add x0, x0, :lo12:main
+ adrp x3, __libc_csu_init
+ add x3, x3, :lo12:__libc_csu_init
+ adrp x4, __libc_csu_fini
+ add x4, x4, :lo12:__libc_csu_fini
+# endif
#else
/* Set up the other arguments in registers */
MOVL (0, main)
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f7204295e49f2d115f3227bcfbbfdcf4b7c1387e
commit f7204295e49f2d115f3227bcfbbfdcf4b7c1387e
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Dec 1 09:49:25 2017 -0800
nios2: Don't use MIN in dl-machine.h
MIN is used, but param.h may not be included, so expand its single use
inline.
* sysdeps/nios2/dl-machine.h (elf_machine_rela): Expand MIN.
diff --git a/sysdeps/nios2/dl-machine.h b/sysdeps/nios2/dl-machine.h
index b5fdd9b..67d8c89 100644
--- a/sysdeps/nios2/dl-machine.h
+++ b/sysdeps/nios2/dl-machine.h
@@ -271,7 +271,8 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
- MIN (sym->st_size, refsym->st_size));
+ sym->st_size < refsym->st_size
+ ? sym->st_size : refsym->st_size);
break;
case R_NIOS2_GLOB_DAT:
case R_NIOS2_JUMP_SLOT:
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources