aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/0003-specs-turn-on-Wl-z-now-by-default.patch
blob: 303d7cb198cd56f7eb771c1ec7529ed52cefeb4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 767b97ca271e82601a435015190fd15bfb28ae12 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:45:49 +0000
Subject: [PATCH] specs: turn on -Wl,-z,now by default

Previously, we also used to turn on -z relro here, but we now build
binutils with --enable-relro, which is functionally equivalent.

Binutils does not appear to have a similar option for enabling -z
now by default.
---
 gcc/doc/invoke.texi | 3 +++
 gcc/gcc.c           | 1 +
 2 files changed, 4 insertions(+)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 9d1126e9751..4b8335bbd1f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -15920,6 +15920,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
 linker.  When using the GNU linker, you can also get the same effect with
 @option{-Wl,-Map=output.map}.
 
+NOTE: In Alpine Linux, for LDFLAGS, the option
+@option{-Wl,-z,now} is used.  To disable, use @option{-Wl,-z,nonow}.
+
 @item -u @var{symbol}
 @opindex u
 Pretend the symbol @var{symbol} is undefined, to force linking of
diff --git a/gcc/gcc.c b/gcc/gcc.c
index a83ba34ac4b..faf9ce76b3d 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1150,6 +1150,7 @@ proper position among the other output files.  */
    "%{flto|flto=*:%<fcompare-debug*} \
     %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \
    "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
+   "-z now " \
    "%X %{o*} %{e*} %{N} %{n} %{r}\
     %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
     %{Wno-poison-system-directories:--no-poison-system-directories} \
-- 
2.34.1