blob: 6d48a7601be8b7c69438df6e9969505e4089a89c [file] [log] [blame]
Patrick Williams8dd68482022-10-04 07:57:18 -05001From cf2a2451f4e9300532d677bb3a8315494a3b3a82 Mon Sep 17 00:00:00 2001
Patrick Williams92b42cb2022-09-03 06:53:57 -05002From: Jerome Forissier <jerome.forissier@linaro.org>
3Date: Fri, 5 Aug 2022 09:48:03 +0200
4Subject: [PATCH] core: link: add --no-warn-rwx-segments
5
Patrick Williams8dd68482022-10-04 07:57:18 -05006Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
7Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/5474]
8
Patrick Williams92b42cb2022-09-03 06:53:57 -05009binutils ld.bfd generates one RWX LOAD segment by merging several sections
10with mixed R/W/X attributes (.text, .rodata, .data). After version 2.38 it
11also warns by default when that happens [1], which breaks the build due to
12--fatal-warnings. The RWX segment is not a problem for the TEE core, since
13that information is not used to set memory permissions. Therefore, silence
14the warning.
15
16Link: [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107
17Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29448
18Reported-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
19Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
20Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Patrick Williams8dd68482022-10-04 07:57:18 -050021
Patrick Williams92b42cb2022-09-03 06:53:57 -050022---
23 core/arch/arm/kernel/link.mk | 8 ++++++--
24 1 file changed, 6 insertions(+), 2 deletions(-)
25
26diff --git a/core/arch/arm/kernel/link.mk b/core/arch/arm/kernel/link.mk
Patrick Williams8dd68482022-10-04 07:57:18 -050027index 7eed333a..c39d43cb 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050028--- a/core/arch/arm/kernel/link.mk
29+++ b/core/arch/arm/kernel/link.mk
30@@ -31,6 +31,7 @@ link-ldflags += -T $(link-script-pp) -Map=$(link-out-dir)/tee.map
31 link-ldflags += --sort-section=alignment
32 link-ldflags += --fatal-warnings
33 link-ldflags += --gc-sections
34+link-ldflags += $(call ld-option,--no-warn-rwx-segments)
35
36 link-ldadd = $(LDADD)
37 link-ldadd += $(ldflags-external)
38@@ -55,6 +56,7 @@ link-script-cppflags := \
39 $(cppflagscore))
40
41 ldargs-all_objs := -T $(link-script-dummy) --no-check-sections \
42+ $(call ld-option,--no-warn-rwx-segments) \
43 $(link-objs) $(link-ldadd) $(libgcccore)
44 cleanfiles += $(link-out-dir)/all_objs.o
45 $(link-out-dir)/all_objs.o: $(objs) $(libdeps) $(MAKEFILE_LIST)
46@@ -67,7 +69,8 @@ $(link-out-dir)/unpaged_entries.txt: $(link-out-dir)/all_objs.o
47 $(q)$(NMcore) $< | \
48 $(AWK) '/ ____keep_pager/ { printf "-u%s ", $$3 }' > $@
49
50-unpaged-ldargs = -T $(link-script-dummy) --no-check-sections --gc-sections
51+unpaged-ldargs := -T $(link-script-dummy) --no-check-sections --gc-sections \
52+ $(call ld-option,--no-warn-rwx-segments)
53 unpaged-ldadd := $(objs) $(link-ldadd) $(libgcccore)
54 cleanfiles += $(link-out-dir)/unpaged.o
55 $(link-out-dir)/unpaged.o: $(link-out-dir)/unpaged_entries.txt
56@@ -95,7 +98,8 @@ $(link-out-dir)/init_entries.txt: $(link-out-dir)/all_objs.o
57 $(q)$(NMcore) $< | \
58 $(AWK) '/ ____keep_init/ { printf "-u%s ", $$3 }' > $@
59
60-init-ldargs := -T $(link-script-dummy) --no-check-sections --gc-sections
61+init-ldargs := -T $(link-script-dummy) --no-check-sections --gc-sections \
62+ $(call ld-option,--no-warn-rwx-segments)
63 init-ldadd := $(link-objs-init) $(link-out-dir)/version.o $(link-ldadd) \
64 $(libgcccore)
65 cleanfiles += $(link-out-dir)/init.o