2
1

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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From 0f75b03c008eacb9818af3a56dc088e72a623d17 Mon Sep 17 00:00:00 2001
  2. From: Marco Felsch <m.felsch@pengutronix.de>
  3. Date: Wed, 9 Nov 2022 12:59:09 +0100
  4. Subject: [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 1ddb7b844..470956b19 100644
  29. --- a/Makefile
  30. +++ b/Makefile
  31. @@ -416,6 +416,8 @@ endif
  32. GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
  33. +TF_LDFLAGS += -z noexecstack
  34. +
  35. # LD = armlink
  36. ifneq ($(findstring armlink,$(notdir $(LD))),)
  37. TF_LDFLAGS += --diag_error=warning --lto_level=O1
  38. @@ -442,7 +444,10 @@ TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
  39. # LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
  40. else
  41. -TF_LDFLAGS += --fatal-warnings -O1
  42. +# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
  43. +# are not loaded by a elf loader.
  44. +TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
  45. +TF_LDFLAGS += -O1
  46. TF_LDFLAGS += --gc-sections
  47. # ld.lld doesn't recognize the errata flags,
  48. # therefore don't add those in that case
  49. --
  50. 2.30.2