[PATCH 20/27] x86: efi: Tidy up the link scripts

Simon Glass sjg at chromium.org
Wed May 28 10:24:46 CEST 2025


Mark important sections with KEEP so that the linker will not remove
them when garbage-collection is (later) enabled.

Provide a _end symbol so that this can be accessed in setup_mon_len()

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/x86/lib/elf_ia32_efi.lds   | 5 +++--
 arch/x86/lib/elf_x86_64_efi.lds | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/lib/elf_ia32_efi.lds b/arch/x86/lib/elf_ia32_efi.lds
index a3ff0068b40..230df63bb48 100644
--- a/arch/x86/lib/elf_ia32_efi.lds
+++ b/arch/x86/lib/elf_ia32_efi.lds
@@ -51,7 +51,7 @@ SECTIONS
 
 		/* U-Boot lists and device tree */
 		. = ALIGN(8);
-		*(SORT(__u_boot_list*));
+		KEEP(*(SORT(__u_boot_list*)));
 		. = ALIGN(8);
 		*(.dtb*);
 	}
@@ -75,7 +75,7 @@ SECTIONS
 
 	. = ALIGN(4096);
 	.reloc : {	/* This is the PECOFF .reloc section! */
-		*(.reloc)
+		KEEP(*(.reloc))
 	}
 
 	. = ALIGN(4096);
@@ -83,6 +83,7 @@ SECTIONS
 	. = ALIGN(4096);
 	.dynstr : { *(.dynstr) }
 	. = ALIGN(4096);
+	_end = .;
 
 	/DISCARD/ : {
 		*(.rel.reloc)
diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds
index 5e1e8714351..e5da5a58952 100644
--- a/arch/x86/lib/elf_x86_64_efi.lds
+++ b/arch/x86/lib/elf_x86_64_efi.lds
@@ -21,7 +21,7 @@ SECTIONS
 
 	. = ALIGN(4096);
 	.reloc : {
-		*(.reloc)
+		KEEP(*(.reloc))
 	}
 
 	. = ALIGN(4096);
@@ -44,7 +44,7 @@ SECTIONS
 
 		/* U-Boot lists and device tree */
 		. = ALIGN(8);
-		*(SORT(__u_boot_list*));
+		KEEP(*(SORT(__u_boot_list*)));
 		. = ALIGN(8);
 		*(.dtb*);
 	}
@@ -65,6 +65,7 @@ SECTIONS
 	. = ALIGN(4096);
 	.dynstr : { *(.dynstr) }
 	. = ALIGN(4096);
+	_end = .;
 
 	/DISCARD/ : {
 		*(.rela.reloc)
-- 
2.43.0



More information about the U-Boot mailing list