This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 08/12] De-PLTize __stack_chk_fail internal calls within libc.so.
- From: Nix <nix at esperi dot org dot uk>
- To: libc-alpha at sourceware dot org
- Cc: fweimer at redhat dot com, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Date: Mon, 28 Nov 2016 12:32:24 +0000
- Subject: [PATCH 08/12] De-PLTize __stack_chk_fail internal calls within libc.so.
- Authentication-results: sourceware.org; auth=none
- References: <20161128123228.30856-1-nix@esperi.org.uk>
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
We use the same assembler-macro trick we use to de-PLTize
compiler-generated libcalls to memcpy and memset to redirect
__stack_chk_fail to __stack_chk_fail_local.
v5: New.
v6: Only do it within the shared library: with __stack_chk_fail_local
in libc_pic.a now we don't need to worry about calls from inside
other routines in libc_nonshared.a any more.
v8: Merge #ifdef blocks.
* sysdeps/generic/symbol-hacks.h (__stack_chk_fail): Add internal
alias.
---
sysdeps/generic/symbol-hacks.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index ce576c9..36908b5 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -4,4 +4,8 @@
asm ("memmove = __GI_memmove");
asm ("memset = __GI_memset");
asm ("memcpy = __GI_memcpy");
+
+/* -fstack-protector generates calls to __stack_chk_fail, which need
+ similar adjustments to avoid going through the PLT. */
+asm ("__stack_chk_fail = __stack_chk_fail_local");
#endif
--
2.10.1.208.gbec66bc