mirror of
https://github.com/bitwiseworks/gcc-os2.git
synced 2026-02-14 06:04:44 +00:00
Make -fstack-protector work w/o passing it in LDFLAGS #18
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SilvanScherrer on GitHub (Jan 28, 2020).
if -fstack-protection is used while compiling I guess -lssp should automatically be added to the LDFLAGS. IIRC it was the case with gcc4.
@dmik commented on GitHub (Apr 7, 2020):
It's not even that, the problem is bigger. Stack protection needs a review. Given this sample code:
the compile and link command
gcc -Zomf -fstack-protector sandbox.cfails with:I.e. for some reason gcc wants a non-shared version which we don't provide (at least not in RPM).
The compile command
gcc -c -Zomf -fstack-protector sandbox.cworks but a subsequent link commandgcc -Zomf sandbox.ofails with:This is expected as the linker needs
-fstack-protectoras well. Once we add this option to the above link command, we will get the same error about the missingssp_nonshared_s.alibrary as the above. The only link command that works here afterwards is this one:This is certainly not the right flow of things. We should look into that at some point.
See https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html for GCC docs on that.
@dmik commented on GitHub (Apr 7, 2020):
Sorry for the hassle and discard the previous comment: it's actually solved by simply doing
yum install libssp-devel. It provides all the necessary static libraries and the example compiles and links w/o errors.@SilvanScherrer what about your problem, there is no way to achieve what you want if the compile and link steps are run as separate commands — the second invocation doesn't have access to the first invocation's compile options. So the only way to go here is to put
-fstack-protectorboth in CFLAGS and LDFLAGS. This will always work.Looking at Linux, it looks like
__stack_chk_failis provided by libc. I guess we should do the same to get rid of the whole libssp hassle. No SSP.DLL will be needed (except for the forwarder for old software), no libssp-devel and no-fstack-protectorin LDFLAGS. But that's postponed for now.