Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 1 | From cf2a2451f4e9300532d677bb3a8315494a3b3a82 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jerome Forissier <jerome.forissier@linaro.org> |
| 3 | Date: Fri, 5 Aug 2022 09:48:03 +0200 |
| 4 | Subject: [PATCH] core: link: add --no-warn-rwx-segments |
| 5 | |
| 6 | Signed-off-by: Anton Antonov <Anton.Antonov@arm.com> |
| 7 | Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/5474] |
| 8 | |
| 9 | binutils ld.bfd generates one RWX LOAD segment by merging several sections |
| 10 | with mixed R/W/X attributes (.text, .rodata, .data). After version 2.38 it |
| 11 | also 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 |
| 13 | that information is not used to set memory permissions. Therefore, silence |
| 14 | the warning. |
| 15 | |
| 16 | Link: [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107 |
| 17 | Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29448 |
| 18 | Reported-by: Dominique Martinet <dominique.martinet@atmark-techno.com> |
| 19 | Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> |
| 20 | Acked-by: Jens Wiklander <jens.wiklander@linaro.org> |
| 21 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 22 | diff --git a/core/arch/arm/kernel/link.mk b/core/arch/arm/kernel/link.mk |
| 23 | index 0e96e606c..3fbcb6804 100644 |
| 24 | --- a/core/arch/arm/kernel/link.mk |
| 25 | +++ b/core/arch/arm/kernel/link.mk |
| 26 | @@ -37,6 +37,7 @@ link-ldflags += --sort-section=alignment |
| 27 | link-ldflags += --fatal-warnings |
| 28 | link-ldflags += --gc-sections |
| 29 | link-ldflags += $(link-ldflags-common) |
| 30 | +link-ldflags += $(call ld-option,--no-warn-rwx-segments) |
| 31 | |
| 32 | link-ldadd = $(LDADD) |
| 33 | link-ldadd += $(ldflags-external) |
| 34 | @@ -61,6 +62,7 @@ link-script-cppflags := \ |
| 35 | $(cppflagscore)) |
| 36 | |
| 37 | ldargs-all_objs := -T $(link-script-dummy) --no-check-sections \ |
| 38 | + $(call ld-option,--no-warn-rwx-segments) \ |
| 39 | $(link-ldflags-common) \ |
| 40 | $(link-objs) $(link-ldadd) $(libgcccore) |
| 41 | cleanfiles += $(link-out-dir)/all_objs.o |
| 42 | @@ -75,7 +77,7 @@ $(link-out-dir)/unpaged_entries.txt: $(link-out-dir)/all_objs.o |
| 43 | $(AWK) '/ ____keep_pager/ { printf "-u%s ", $$3 }' > $@ |
| 44 | |
| 45 | unpaged-ldargs := -T $(link-script-dummy) --no-check-sections --gc-sections \ |
| 46 | - $(link-ldflags-common) |
| 47 | + $(link-ldflags-common) $(call ld-option,--no-warn-rwx-segments) |
| 48 | unpaged-ldadd := $(objs) $(link-ldadd) $(libgcccore) |
| 49 | cleanfiles += $(link-out-dir)/unpaged.o |
| 50 | $(link-out-dir)/unpaged.o: $(link-out-dir)/unpaged_entries.txt |
| 51 | @@ -104,7 +106,7 @@ $(link-out-dir)/init_entries.txt: $(link-out-dir)/all_objs.o |
| 52 | $(AWK) '/ ____keep_init/ { printf "-u%s ", $$3 }' > $@ |
| 53 | |
| 54 | init-ldargs := -T $(link-script-dummy) --no-check-sections --gc-sections \ |
| 55 | - $(link-ldflags-common) |
| 56 | + $(link-ldflags-common) $(call ld-option,--no-warn-rwx-segments) |
| 57 | init-ldadd := $(link-objs-init) $(link-out-dir)/version.o $(link-ldadd) \ |
| 58 | $(libgcccore) |
| 59 | cleanfiles += $(link-out-dir)/init.o |