This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 08/12] De-PLTize __stack_chk_fail internal calls within libc.so.
- From: Nix <nix at esperi dot org dot uk>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha at sourceware dot org, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Date: Thu, 15 Dec 2016 14:15:43 +0000
- Subject: Re: [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> <20161128123228.30856-9-nix@esperi.org.uk> <fbc21429-e5cd-1771-6165-ae5202511223@redhat.com>
On 15 Dec 2016, Florian Weimer said:
> On 11/28/2016 01:32 PM, Nix wrote:
>> From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
[...]
>> 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
>
> We should do this only if we compile glibc with stack protector support enabled, and disable this for the files which we compile
> without stack protector. I hope this will fix an assembler error while compiling __stack_chk_fail.c on ia64:
I don't think we need to disable it for *all* such files -- but at the
very least it must be disabled for debug/stack_chk_fail.c, and if we're
doing that it's probably easier to do as you suggest (though it's
invasive enough I'll have to kick another test cycle off, sigh).
Possible fix, untested:
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index 36908b5..0679354 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -7,5 +7,7 @@ asm ("memcpy = __GI_memcpy");
/* -fstack-protector generates calls to __stack_chk_fail, which need
similar adjustments to avoid going through the PLT. */
+#if defined __SSP__ || defined __SSP_ALL__ || defined __SSP_STRONG__
asm ("__stack_chk_fail = __stack_chk_fail_local");
#endif
+#endif