[PATCH 4/4] efi_loader: use include in ARM EFI linker script
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Tue Jan 14 11:29:53 CET 2025
Use the same include as arm64 for the linker script.
Adjust the 32-bit ARM PE-COFF header accordingly and harmonize it with the
64-bit ARM header.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
arch/arm/lib/crt0_arm_efi.S | 37 ++++++++++---------
arch/arm/lib/elf_arm_efi.lds | 71 +-----------------------------------
2 files changed, 20 insertions(+), 88 deletions(-)
diff --git a/arch/arm/lib/crt0_arm_efi.S b/arch/arm/lib/crt0_arm_efi.S
index b5dfd4e3819..590fcf515da 100644
--- a/arch/arm/lib/crt0_arm_efi.S
+++ b/arch/arm/lib/crt0_arm_efi.S
@@ -14,11 +14,11 @@
/*
* Magic "MZ" signature for PE/COFF
*/
- .globl image_base
-image_base:
+ .globl ImageBase
+ImageBase:
.short IMAGE_DOS_SIGNATURE /* 'MZ' */
.skip 58 /* 'MZ' + pad + offset == 64 */
- .long pe_header - image_base /* Offset to the PE header */
+ .long pe_header - ImageBase /* Offset to the PE header */
pe_header:
.long IMAGE_NT_SIGNATURE /* 'PE' */
coff_header:
@@ -38,16 +38,16 @@ optional_header:
.short IMAGE_NT_OPTIONAL_HDR32_MAGIC /* PE32 format */
.byte 0x02 /* MajorLinkerVersion */
.byte 0x14 /* MinorLinkerVersion */
- .long _edata - _start /* SizeOfCode */
+ .long _etext - _start /* SizeOfCode */
.long 0 /* SizeOfInitializedData */
.long 0 /* SizeOfUninitializedData */
- .long _start - image_base /* AddressOfEntryPoint */
- .long _start - image_base /* BaseOfCode */
+ .long _start - ImageBase /* AddressOfEntryPoint */
+ .long _start - ImageBase /* BaseOfCode */
.long 0 /* BaseOfData */
extra_header_fields:
- .long 0 /* image_base */
- .long 0x200 /* SectionAlignment */
+ .long 0 /* ImageBase */
+ .long 0x1000 /* SectionAlignment */
.long 0x200 /* FileAlignment */
.short 0 /* MajorOperatingSystemVersion */
.short 0 /* MinorOperatingSystemVersion */
@@ -57,14 +57,14 @@ extra_header_fields:
.short 0 /* MinorSubsystemVersion */
.long 0 /* Win32VersionValue */
- .long _edata - image_base /* SizeOfImage */
+ .long _edata - ImageBase /* SizeOfImage */
/*
* Everything before the kernel image is considered part of the header
*/
- .long _start - image_base /* SizeOfHeaders */
+ .long _start - ImageBase /* SizeOfHeaders */
.long 0 /* CheckSum */
- .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
+ .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
#if CONFIG_VENDOR_EFI
.short 0 /* DllCharacteristics */
#else
@@ -84,6 +84,7 @@ extra_header_fields:
.quad 0 /* CertificationTable */
.quad 0 /* BaseRelocationTable */
+ /* Section table */
section_table:
/*
@@ -111,10 +112,10 @@ section_table:
.byte 0
.byte 0
.byte 0 /* end of 0 padding of section name */
- .long _text_size /* VirtualSize */
- .long _start - image_base /* VirtualAddress */
- .long _text_size /* SizeOfRawData */
- .long _start - image_base /* PointerToRawData */
+ .long _etext - _start /* VirtualSize */
+ .long _start - ImageBase /* VirtualAddress */
+ .long _etext - _start /* SizeOfRawData */
+ .long _start - ImageBase /* PointerToRawData */
.long 0 /* PointerToRelocations */
.long 0 /* PointerToLineNumbers */
.short 0 /* NumberOfRelocations */
@@ -129,9 +130,9 @@ section_table:
.byte 0
.byte 0 /* end of 0 padding of section name */
.long _data_size /* VirtualSize */
- .long _data - image_base /* VirtualAddress */
+ .long _data - ImageBase /* VirtualAddress */
.long _data_size /* SizeOfRawData */
- .long _data - image_base /* PointerToRawData */
+ .long _data - ImageBase /* PointerToRawData */
.long 0 /* PointerToRelocations */
.long 0 /* PointerToLineNumbers */
.short 0 /* NumberOfRelocations */
@@ -148,7 +149,7 @@ _start:
adr r1, .L_DYNAMIC
ldr r0, [r1]
add r1, r0, r1
- adrl r0, image_base
+ adrl r0, ImageBase
bl _relocate
teq r0, #0
bne 0f
diff --git a/arch/arm/lib/elf_arm_efi.lds b/arch/arm/lib/elf_arm_efi.lds
index 41440594aa6..eb16fae74cf 100644
--- a/arch/arm/lib/elf_arm_efi.lds
+++ b/arch/arm/lib/elf_arm_efi.lds
@@ -8,73 +8,4 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
-PHDRS
-{
- data PT_LOAD FLAGS(3); /* PF_W | PF_X */
-}
-
-ENTRY(_start)
-SECTIONS
-{
- .text 0x0 : {
- _text = .;
- *(.text.head)
- *(.text)
- *(.text.*)
- *(.gnu.linkonce.t.*)
- *(.srodata)
- *(.rodata*)
- . = ALIGN(16);
- *(.dynamic);
- . = ALIGN(512);
- }
- _etext = .;
- _text_size = . - _text;
- . = ALIGN(4096);
- .data : {
- _data = .;
- *(.sdata)
- *(.data)
- *(.data1)
- *(.data.*)
- *(.got.plt)
- *(.got)
-
- /*
- * The EFI loader doesn't seem to like a .bss section, so we
- * stick it all into .data:
- */
- . = ALIGN(16);
- _bss = .;
- *(.sbss)
- *(.scommon)
- *(.dynbss)
- *(.bss)
- *(.bss.*)
- *(COMMON)
- . = ALIGN(512);
- _bss_end = .;
- _edata = .;
- } :data
- _data_size = . - _data;
-
- /DISCARD/ : {
- /*
- * We don't support relocations. These would have to be
- * translated from ELF to PE format and added to the .reloc
- * section.
- */
- *(.rel.dyn)
- *(.rel.plt)
- *(.rel.got)
- *(.rel.data)
- *(.rel.data*)
- *(.rel.reloc)
- *(.eh_frame)
- *(.note.GNU-stack)
- *(.dynsym)
- *(.dynstr)
- *(.note.gnu.build-id)
- *(.comment)
- }
-}
+INCLUDE lib/efi_loader/elf_efi.ldsi
--
2.47.1
More information about the U-Boot
mailing list