0003-Turn-on-Wl-z-relro-z-now-by-default.patch (1445B)
1 From ef512b8fcf9c7628267ff2dbb127aa094f6754f3 Mon Sep 17 00:00:00 2001 2 From: Ariadne Conill <ariadne@dereferenced.org> 3 Date: Fri, 21 Aug 2020 06:45:49 +0000 4 Subject: [PATCH] Turn on -Wl,-z,relro,-z,now by default. 5 6 --- 7 gcc/doc/invoke.texi | 3 +++ 8 gcc/gcc.c | 1 + 9 2 files changed, 4 insertions(+) 10 11 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi 12 index cd31b522e42..17d371ef432 100644 13 --- a/gcc/doc/invoke.texi 14 +++ b/gcc/doc/invoke.texi 15 @@ -14663,6 +14663,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the 16 linker. When using the GNU linker, you can also get the same effect with 17 @option{-Wl,-Map=output.map}. 18 19 +NOTE: In Alpine Linux, for LDFLAGS, the option 20 +@option{-Wl,-z,relro,now} is used. To disable, use @option{-Wl,-z,norelro}. 21 + 22 @item -u @var{symbol} 23 @opindex u 24 Pretend the symbol @var{symbol} is undefined, to force linking of 25 diff --git a/gcc/gcc.c b/gcc/gcc.c 26 index b2200c5185a..625c9ab7902 100644 27 --- a/gcc/gcc.c 28 +++ b/gcc/gcc.c 29 @@ -1039,6 +1039,7 @@ proper position among the other output files. */ 30 "%{flto|flto=*:%<fcompare-debug*} \ 31 %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \ 32 "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ 33 + "-z relro -z now " \ 34 "%X %{o*} %{e*} %{N} %{n} %{r}\ 35 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ 36 %{Wno-poison-system-directories:--no-poison-system-directories} \ 37 -- 38 2.31.1 39