[PATCH 19/27] x86: efi: Sync up the two link scripts somewhat

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


The 32- and 64-bit scripts are more different than they need to be.
Make some changes to both so that it is easier to see the necessary
differences.

For the 32-bit script this is mostly just whitespace. For the 64-bit
script the eh_frame section is discarded and the .data section is
reordered.

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

 arch/x86/lib/elf_ia32_efi.lds   | 26 ++++++++++++++------------
 arch/x86/lib/elf_x86_64_efi.lds | 25 +++++++++----------------
 2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/arch/x86/lib/elf_ia32_efi.lds b/arch/x86/lib/elf_ia32_efi.lds
index 37a6c386b81..a3ff0068b40 100644
--- a/arch/x86/lib/elf_ia32_efi.lds
+++ b/arch/x86/lib/elf_ia32_efi.lds
@@ -13,12 +13,12 @@ SECTIONS
 	image_base = .;
 	.hash : { *(.hash) }	/* this MUST come first, EFI expects it */
 	. = ALIGN(4096);
-	.text :
-	{
+	.text : {
 		*(.text)
 		*(.text.*)
 		*(.gnu.linkonce.t.*)
 	}
+
 	. = ALIGN(4096);
 	.sdata :
 	{
@@ -29,9 +29,9 @@ SECTIONS
 		*(.sbss)
 		*(.scommon)
 	}
+
 	. = ALIGN(4096);
-	.data :
-	{
+	.data : {
 		*(.rodata*)
 		*(.data)
 		*(.data1)
@@ -57,7 +57,8 @@ SECTIONS
 	}
 
 	. = ALIGN(4096);
-	.dynamic  : { *(.dynamic) }
+	.dynamic : { *(.dynamic) }
+
 	. = ALIGN(4096);
 	.rel :
 	{
@@ -71,18 +72,19 @@ SECTIONS
 		*(.data.rel*)
 		*(.rel__u_boot_list*)
 	}
+
 	. = ALIGN(4096);
-		.reloc :	/* This is the PECOFF .reloc section! */
-	{
-	*(.reloc)
+	.reloc : {	/* This is the PECOFF .reloc section! */
+		*(.reloc)
 	}
+
 	. = ALIGN(4096);
-	.dynsym   : { *(.dynsym) }
+	.dynsym : { *(.dynsym) }
 	. = ALIGN(4096);
-	.dynstr   : { *(.dynstr) }
+	.dynstr : { *(.dynstr) }
 	. = ALIGN(4096);
-	/DISCARD/ :
-	{
+
+	/DISCARD/ : {
 		*(.rel.reloc)
 		*(.eh_frame)
 		*(.note.GNU-stack)
diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds
index cb656ac46ea..5e1e8714351 100644
--- a/arch/x86/lib/elf_x86_64_efi.lds
+++ b/arch/x86/lib/elf_x86_64_efi.lds
@@ -13,12 +13,6 @@ SECTIONS
 	image_base = .;
 	.hash : { *(.hash) }	/* this MUST come first, EFI expects it */
 	. = ALIGN(4096);
-	.eh_frame : {
-		*(.eh_frame)
-	}
-
-	. = ALIGN(4096);
-
 	.text : {
 		*(.text)
 		*(.text.*)
@@ -26,21 +20,21 @@ SECTIONS
 	}
 
 	. = ALIGN(4096);
-
 	.reloc : {
 		*(.reloc)
 	}
 
 	. = ALIGN(4096);
-
 	.data : {
 		*(.rodata*)
-		*(.got.plt)
-		*(.got)
 		*(.data*)
 		*(.sdata)
-		/* the EFI loader doesn't seem to like a .bss section, so we stick
-		 * it all into .data: */
+		*(.got.plt)
+		*(.got)
+		/*
+		 * the EFI loader doesn't seem to like a .bss section, so we
+		 * stick it all into .data:
+		 */
 		*(.sbss)
 		*(.scommon)
 		*(.dynbss)
@@ -57,8 +51,8 @@ SECTIONS
 
 	. = ALIGN(4096);
 	.dynamic : { *(.dynamic) }
-	. = ALIGN(4096);
 
+	. = ALIGN(4096);
 	.rela : {
 		*(.rela.data*)
 		*(.rela.got)
@@ -72,10 +66,9 @@ SECTIONS
 	.dynstr : { *(.dynstr) }
 	. = ALIGN(4096);
 
-        /DISCARD/ : { *(.eh_frame) }
-
-	.ignored.reloc : {
+	/DISCARD/ : {
 		*(.rela.reloc)
+		*(.eh_frame)
 		*(.note.GNU-stack)
 	}
 
-- 
2.43.0



More information about the U-Boot mailing list