summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2009-06-28 23:51:39 +0000
committerkan <kan@FreeBSD.org>2009-06-28 23:51:39 +0000
commitf780ef8f1980f918f04365b9374ef3f0b5c8652b (patch)
tree601ae0a8f92e47fd15b2574968520ee80c372d0e /lib
parent54f24c117ae26fcfb1000a0fe7ab5f376997f7f6 (diff)
downloadFreeBSD-src-f780ef8f1980f918f04365b9374ef3f0b5c8652b.zip
FreeBSD-src-f780ef8f1980f918f04365b9374ef3f0b5c8652b.tar.gz
Eliminate .text relocations in shared libraries compiled with stack protector.
Use libssp_nonshared library to pull __stack_chk_fail_local symbol into each library that needs it instead of pulling it from libc. GCC generates local calls to this function which result in absolute relocations put into position-independent code segment, making dynamic loader do extra work everys time given shared library is being relocated and making affected text pages non-shareable. Reviewed by: kib Approved by: re (kensmith)
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/Makefile2
-rw-r--r--lib/libc/sys/Symbol.map1
-rw-r--r--lib/libc/sys/stack_protector.c7
3 files changed, 2 insertions, 8 deletions
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index cf9ef3a..4f13f8e 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -26,7 +26,7 @@ PRECIOUSLIB=
#
DPADD+= ${LIBGCC}
LDFLAGS+= -nodefaultlibs
-LDADD+= -lgcc
+LDADD+= -lgcc -lssp_nonshared
# Define (empty) variables so that make doesn't give substitution
# errors if the included makefiles don't change these:
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
index 88bc779..41f34ae 100644
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -282,7 +282,6 @@ FBSD_1.0 {
socket;
socketpair;
__stack_chk_fail;
- __stack_chk_fail_local;
__stack_chk_guard;
stat;
statfs;
diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c
index f753fcd..63beebc 100644
--- a/lib/libc/sys/stack_protector.c
+++ b/lib/libc/sys/stack_protector.c
@@ -47,7 +47,6 @@ static void __guard_setup(void) __attribute__((__constructor__, __used__));
static void __fail(const char *);
void __stack_chk_fail(void);
void __chk_fail(void);
-void __stack_chk_fail_local(void);
/*LINTED used*/
static void
@@ -109,8 +108,4 @@ __chk_fail(void)
__fail("buffer overflow detected; terminated");
}
-void
-__stack_chk_fail_local(void)
-{
- __stack_chk_fail();
-}
+__sym_compat(__stack_chk_fail_local, __stack_chk_fail, FBSD_1.0);
OpenPOWER on IntegriCloud