[RFC PATCH 09/10] arm: discard all .dyn* sections

Sam Edwards cfsworks at gmail.com
Sat May 20 22:55:46 CEST 2023


This makes the output ELF friendlier to llvm-objcopy, which
otherwise complains about discarding .dynsym when it's
(potentially) referenced by .rel.dyn.

Since u-boot doesn't actually make use of a dynamic linker,
and these sections are only here because we're building --pie,
it's best to discard what we don't need.

Signed-off-by: Sam Edwards <CFSworks at gmail.com>
---

 arch/arm/cpu/u-boot.lds | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds
index 8cdf08a730..bd4650bd86 100644
--- a/arch/arm/cpu/u-boot.lds
+++ b/arch/arm/cpu/u-boot.lds
@@ -235,10 +235,13 @@ SECTIONS
 	 */
 	/DISCARD/ : { *(.gnu.version*) }
 
-	.dynsym _image_binary_end : { *(.dynsym) }
-	.dynbss : { *(.dynbss) }
-	.dynstr : { *(.dynstr*) }
-	.dynamic : { *(.dynamic*) }
+	/*
+	 * Not needed at runtime: relocations are done directly on .rel.dyn,
+	 * and we're self-relocating so we don't need compatibility with an
+	 * external dynamic linker.
+	 */
+	/DISCARD/ : { *(.dyn*) }
+
 	.plt : { *(.plt*) }
 	.interp : { *(.interp*) }
 	.gnu.hash : { *(.gnu.hash) }
-- 
2.39.2



More information about the U-Boot mailing list