2
1

0001-PATCH-feat-build-add-support-for-new-binutils-versio.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 5e1beb793c06352e87c46eca1144ff1fe8555103 Mon Sep 17 00:00:00 2001
  2. From: Heiko Thiery <heiko.thiery@gmail.com>
  3. Date: Mon, 10 Jul 2023 10:43:03 +0200
  4. Subject: [PATCH] [PATCH] feat(build): add support for new binutils versions
  5. Users of GNU ld (BPF) from binutils 2.39+ will observe multiple instaces
  6. of a new warning when linking the bl*.elf in the form:
  7. ld.bfd: warning: stm32mp1_helper.o: missing .note.GNU-stack section implies executable stack
  8. ld.bfd: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
  9. ld.bfd: warning: bl2.elf has a LOAD segment with RWX permissions
  10. ld.bfd: warning: bl32.elf has a LOAD segment with RWX permissions
  11. These new warnings are enbaled by default to secure elf binaries:
  12. - https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107
  13. - https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0d38576a34ec64a1b4500c9277a8e9d0f07e6774
  14. Fix it in a similar way to what the Linux kernel does, see:
  15. https://lore.kernel.org/all/20220810222442.2296651-1-ndesaulniers@google.com/
  16. Following the reasoning there, we set "-z noexecstack" for all linkers
  17. (although LLVM's LLD defaults to it) and optional add
  18. --no-warn-rwx-segments since this a ld.bfd related.
  19. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
  20. Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
  21. Change-Id: I9430f5fa5036ca88da46cd3b945754d62616b617
  22. Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
  23. Upstream: https://github.com/ARM-software/arm-trusted-firmware/commit/1f49db5f25cdd4e43825c9bcc0575070b80f628c
  24. ---
  25. Makefile | 7 ++++++-
  26. 1 file changed, 6 insertions(+), 1 deletion(-)
  27. diff --git a/Makefile b/Makefile
  28. index 721246d51..5893cf422 100644
  29. --- a/Makefile
  30. +++ b/Makefile
  31. @@ -297,11 +297,16 @@ endif
  32. GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
  33. +TF_LDFLAGS += -z noexecstack
  34. +
  35. ifneq ($(findstring armlink,$(notdir $(LD))),)
  36. TF_LDFLAGS += --diag_error=warning --lto_level=O1
  37. TF_LDFLAGS += --remove --info=unused,unusedsymbols
  38. else
  39. -TF_LDFLAGS += --fatal-warnings -O1
  40. +# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
  41. +# are not loaded by a elf loader.
  42. +TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
  43. +TF_LDFLAGS += -O1
  44. TF_LDFLAGS += --gc-sections
  45. endif
  46. TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
  47. --
  48. 2.30.2