Message ID | 20161219111528.14969-10-nix@esperi.org.uk |
---|---|
State | New |
Headers | show |
On 12/19/2016 12:15 PM, Nix wrote: > 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. > v10: Use STACK_PROTECTOR_LEVEL to avoid renaming in files where > stack-protection is suppressed. > > * sysdeps/generic/symbol-hacks.h [STACK_PROTECTOR_LEVEL && > STACK_PROTECTOR_LEVEL > 0] (__stack_chk_fail): Add internal alias. I'm going to fold this into the previous commit. Thanks, Florian
On 21 Dec 2016, Florian Weimer uttered the following: > On 12/19/2016 12:15 PM, Nix wrote: >> 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. >> v10: Use STACK_PROTECTOR_LEVEL to avoid renaming in files where >> stack-protection is suppressed. >> >> * sysdeps/generic/symbol-hacks.h [STACK_PROTECTOR_LEVEL && >> STACK_PROTECTOR_LEVEL > 0] (__stack_chk_fail): Add internal alias. > > I'm going to fold this into the previous commit. I was tempted but thought that it might be a bit presumptuous for a newbie like me to preempt Adhemerval :) -- NULL && (void)
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h index ce576c9..d614c09 100644 --- a/sysdeps/generic/symbol-hacks.h +++ b/sysdeps/generic/symbol-hacks.h @@ -4,4 +4,16 @@ asm ("memmove = __GI_memmove"); asm ("memset = __GI_memset"); asm ("memcpy = __GI_memcpy"); + +/* Some targets do not use __stack_chk_fail_local. In libc.so, + redirect __stack_chk_fail to a hidden reference + __stack_chk_fail_local, to avoid the PLT reference. + __stack_chk_fail itself is a global symbol, exported from libc.so, + and cannot be made hidden. */ + +# if IS_IN (libc) && defined SHARED && \ + defined STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0 +asm (".hidden __stack_chk_fail_local\n" + "__stack_chk_fail = __stack_chk_fail_local"); +# endif #endif
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. v10: Use STACK_PROTECTOR_LEVEL to avoid renaming in files where stack-protection is suppressed. * sysdeps/generic/symbol-hacks.h [STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0] (__stack_chk_fail): Add internal alias. --- sysdeps/generic/symbol-hacks.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.10.1.208.gbec66bc