[09/14] Link various tests with -fno-stack-protector.

Message ID 1456270777-9083-10-git-send-email-nix@esperi.org.uk
State New, archived
Headers

Commit Message

Nix Feb. 23, 2016, 11:39 p.m. UTC
  From: Nick Alcock <nick.alcock@oracle.com>

These tests do not link with libc, so cannot see __stack_chk_fail().
---
 elf/Makefile            | 6 ++++++
 stdlib/Makefile         | 4 ++++
 sysdeps/x86_64/Makefile | 3 +++
 3 files changed, 13 insertions(+)
  

Comments

Andreas Schwab Feb. 24, 2016, 9:45 a.m. UTC | #1
Nix <nix@esperi.org.uk> writes:

> +ifeq ($(have-ssp),yes)
> +# These do not link against libc.
> +CFLAGS-filtmod1.c = -fno-stack-protector
> +CFLAGS-filtmod2.c = -fno-stack-protector
> +endif

Please add a variable no-stack-protector to config.make, defined to
-fno-stack-protector depending on have-ssp.

Andreas.
  
Nix Feb. 24, 2016, 1:06 p.m. UTC | #2
On 24 Feb 2016, Andreas Schwab uttered the following:

> Nix <nix@esperi.org.uk> writes:
>
>> +ifeq ($(have-ssp),yes)
>> +# These do not link against libc.
>> +CFLAGS-filtmod1.c = -fno-stack-protector
>> +CFLAGS-filtmod2.c = -fno-stack-protector
>> +endif
>
> Please add a variable no-stack-protector to config.make, defined to
> -fno-stack-protector depending on have-ssp.

... and then drop all the $(have-ssp) ifeqs?

Will do! (I thought it would increase the amount of overhead, but given
the number of one-line additions, this change makes a lot of sense.)

(This changes numerous patches, so I'll post this change when I post
v3 as a whole.)
  

Patch

diff --git a/elf/Makefile b/elf/Makefile
index dcf44c8..22baac6 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -751,6 +751,12 @@  $(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
 		  $< -Wl,-F,$(objpfx)filtmod2.so
 $(objpfx)filter: $(objpfx)filtmod1.so
 
+ifeq ($(have-ssp),yes)
+# These do not link against libc.
+CFLAGS-filtmod1.c = -fno-stack-protector
+CFLAGS-filtmod2.c = -fno-stack-protector
+endif
+
 $(objpfx)unload: $(libdl)
 $(objpfx)unload.out: $(objpfx)unloadmod.so
 
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 26fe67a..bb9d4b1 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -164,6 +164,10 @@  LDFLAGS-tst-putenv = $(no-as-needed)
 
 $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
 	$(build-module)
+# This is not only not in libc, it's not even linked with it.
+ifeq ($(have-ssp),yes)
+CFLAGS-tst-putenvmod.c += -fno-stack-protector
+endif
 libof-tst-putenvmod = extramodules
 
 $(objpfx)bug-getcontext: $(libm)
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index 67ed5ba..3183cb3 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -40,6 +40,9 @@  quad-pie-test += tst-quad1pie tst-quad2pie
 tests += $(quad-pie-test)
 tests-pie += $(quad-pie-test)
 
+CFLAGS-tst-quad1pie.c = -fno-stack-protector
+CFLAGS-tst-quad2pie.c = -fno-stack-protector
+
 $(objpfx)tst-quad1pie: $(objpfx)tst-quadmod1pie.o
 $(objpfx)tst-quad2pie: $(objpfx)tst-quadmod2pie.o