[08/15] Add a hidden __stack_chk_fail_local alias to libc.so.
Commit Message
From: Nick Alcock <nick.alcock@oracle.com>
This is required by the next commit, which routes all
__stack_chk_fail() calls in libc.so via this symbol to avoid
the PLT.
Also stop all the variants of __stack_chk_fail from being stack-
protected: this makes no sense and risks recursion.
v5: Better explanation. Add no-stack-protection of
__stack_chk_fail_local etc.
v6: Rework as suggested by Andreas: make a shared-only version of
stack_chk_fail_local.c rather than linking libc_nonshared into
libc.
v10: Drop libc-stack_chk_fail_local.c: just use a strong_alias instead.
(Thanks to Florian Weimer.)
* debug/stack_chk_fail.c (__stack_chk_fail): Add strong_alias to
__stack_chk_fail_local.
* debug/Makefile (CFLAGS-stack_chk_fail.c): Use $(no-stack-protector).
(CFLAGS-stack_chk_fail_local.c): Likewise.
---
debug/Makefile | 6 ++++++
debug/stack_chk_fail.c | 2 ++
2 files changed, 8 insertions(+)
@@ -52,6 +52,12 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \
$(static-only-routines)
static-only-routines := warning-nop stack_chk_fail_local
+# Building the stack-protector failure routines with stack protection
+# makes no sense.
+
+CFLAGS-stack_chk_fail.c = $(no-stack-protector)
+CFLAGS-stack_chk_fail_local.c = $(no-stack-protector)
+
CFLAGS-backtrace.c = -fno-omit-frame-pointer
CFLAGS-sprintf_chk.c = $(libio-mtsafe)
CFLAGS-snprintf_chk.c = $(libio-mtsafe)
@@ -27,3 +27,5 @@ __stack_chk_fail (void)
{
__fortify_fail ("stack smashing detected");
}
+
+strong_alias (__stack_chk_fail, __stack_chk_fail_local)