efi_loader: use INCLUDE in EFI linker scripts
Except for the architecture specific lines ARM and RISC-V can use the same
linker script. Move the common lines to an include.
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
(cherry picked from commit 6a628c1503)
Changes from original cherry-pick:
- Add -L $(srctree) to Makefile u-boot link commands for out-of-tree
builds
- Create arch/arm/lib/elf_aarch64_efi_app.lds for full U-Boot EFI app
with different structure (.hash/.gnu.hash at start, no PHDRS block)
- Update board/efi/efi-arm_app/Kconfig to use the app-specific linker
script
- Simple EFI apps (helloworld.efi) use lib/efi_loader/elf_efi.ldsi with
PHDRS block
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
committed by
Simon Glass
parent
1c2d0f5a52
commit
507a37fabe
4
Makefile
4
Makefile
@@ -1828,7 +1828,7 @@ quiet_cmd_u-boot__ ?= LTO $@
|
||||
$(CC) -nostdlib -nostartfiles \
|
||||
$(LTO_FINAL_LDFLAGS) $(c_flags) \
|
||||
$(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_u-boot:%=-Wl,%) -o $@ \
|
||||
-T u-boot.lds $(u-boot-init) \
|
||||
-Wl,-L -Wl,$(srctree) -T u-boot.lds $(u-boot-init) \
|
||||
-Wl,--whole-archive \
|
||||
$(u-boot-main) \
|
||||
$(u-boot-keep-syms-lto) \
|
||||
@@ -1839,7 +1839,7 @@ quiet_cmd_u-boot__ ?= LTO $@
|
||||
else
|
||||
quiet_cmd_u-boot__ ?= LD $@
|
||||
cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \
|
||||
-T u-boot.lds $(u-boot-init) \
|
||||
-L $(srctree) -T u-boot.lds $(u-boot-init) \
|
||||
--whole-archive \
|
||||
$(u-boot-main) \
|
||||
--no-whole-archive \
|
||||
|
||||
@@ -7,94 +7,5 @@
|
||||
|
||||
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
|
||||
OUTPUT_ARCH(aarch64)
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
image_base = .;
|
||||
/* .hash and/or .gnu.hash MUST come first! */
|
||||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
. = ALIGN(4096);
|
||||
.eh_frame : { *(.eh_frame) }
|
||||
. = ALIGN(4096);
|
||||
.text : {
|
||||
_text = .;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.srodata)
|
||||
*(.rodata*)
|
||||
. = ALIGN(16);
|
||||
*(.dynamic);
|
||||
. = ALIGN(512);
|
||||
}
|
||||
.reloc : {
|
||||
KEEP (*(.reloc))
|
||||
}
|
||||
_etext = .;
|
||||
_text_size = . - _text;
|
||||
. = ALIGN(4096);
|
||||
. = ALIGN(4096);
|
||||
.data : {
|
||||
_data = .;
|
||||
*(.sdata)
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
/* U-Boot lists and device tree */
|
||||
. = ALIGN(8);
|
||||
KEEP(*(SORT(__u_boot_list*)));
|
||||
. = ALIGN(8);
|
||||
|
||||
/*
|
||||
* 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 = .;
|
||||
_end = .;
|
||||
}
|
||||
_data_size = _edata - _data;
|
||||
|
||||
. = ALIGN(4096);
|
||||
.rela : {
|
||||
*(.rela.text*)
|
||||
*(.rela.data*)
|
||||
*(.rela.got)
|
||||
*(.rela.dyn)
|
||||
*(.rela.stab)
|
||||
*(.rela.init_array*)
|
||||
*(.rela.fini_array*)
|
||||
*(.rela.ctors*)
|
||||
*(.rela.dtors*)
|
||||
*(.rela__u_boot_list*)
|
||||
}
|
||||
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
/DISCARD/ : {
|
||||
*(.rel.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.embedded_dtb : {
|
||||
*(.embedded_dtb)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
INCLUDE lib/efi_loader/elf_efi.ldsi
|
||||
|
||||
101
arch/arm/lib/elf_aarch64_efi_app.lds
Normal file
101
arch/arm/lib/elf_aarch64_efi_app.lds
Normal file
@@ -0,0 +1,101 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
/*
|
||||
* U-Boot aarch64 EFI application linker script
|
||||
*
|
||||
* This is for U-Boot running as an EFI application on aarch64.
|
||||
* It includes symbols and sections needed by U-Boot core.
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
|
||||
OUTPUT_ARCH(aarch64)
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
image_base = .;
|
||||
/* .hash and/or .gnu.hash MUST come first! */
|
||||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
. = ALIGN(4096);
|
||||
.eh_frame : { *(.eh_frame) }
|
||||
. = ALIGN(4096);
|
||||
.text : {
|
||||
_text = .;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.srodata)
|
||||
*(.rodata*)
|
||||
. = ALIGN(16);
|
||||
*(.dynamic);
|
||||
. = ALIGN(512);
|
||||
}
|
||||
.reloc : {
|
||||
KEEP (*(.reloc))
|
||||
}
|
||||
_etext = .;
|
||||
_text_size = . - _text;
|
||||
. = ALIGN(4096);
|
||||
. = ALIGN(4096);
|
||||
.data : {
|
||||
_data = .;
|
||||
*(.sdata)
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
/* U-Boot lists and device tree */
|
||||
. = ALIGN(8);
|
||||
KEEP(*(SORT(__u_boot_list*)));
|
||||
. = ALIGN(8);
|
||||
|
||||
/*
|
||||
* 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 = .;
|
||||
_end = .;
|
||||
}
|
||||
_data_size = _edata - _data;
|
||||
|
||||
. = ALIGN(4096);
|
||||
.rela : {
|
||||
*(.rela.text*)
|
||||
*(.rela.data*)
|
||||
*(.rela.got)
|
||||
*(.rela.dyn)
|
||||
*(.rela.stab)
|
||||
*(.rela.init_array*)
|
||||
*(.rela.fini_array*)
|
||||
*(.rela.ctors*)
|
||||
*(.rela.dtors*)
|
||||
*(.rela__u_boot_list*)
|
||||
}
|
||||
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
/DISCARD/ : {
|
||||
*(.rel.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.embedded_dtb : {
|
||||
*(.embedded_dtb)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
@@ -8,70 +8,4 @@
|
||||
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
|
||||
OUTPUT_ARCH(riscv)
|
||||
|
||||
PHDRS
|
||||
{
|
||||
data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
|
||||
}
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x0 : {
|
||||
_text = .;
|
||||
*(.text.head)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.srodata)
|
||||
*(.rodata*)
|
||||
. = ALIGN(16);
|
||||
*(.dynamic);
|
||||
. = ALIGN(512);
|
||||
}
|
||||
.rela.dyn : { *(.rela.dyn) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rela.data : { *(.rela.data) *(.rela.data*) }
|
||||
_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 = _edata - _data;
|
||||
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
/DISCARD/ : {
|
||||
*(.rel.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
INCLUDE lib/efi_loader/elf_efi.ldsi
|
||||
|
||||
@@ -8,70 +8,4 @@
|
||||
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
|
||||
OUTPUT_ARCH(riscv)
|
||||
|
||||
PHDRS
|
||||
{
|
||||
data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
|
||||
}
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x0 : {
|
||||
_text = .;
|
||||
*(.text.head)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.srodata)
|
||||
*(.rodata*)
|
||||
. = ALIGN(16);
|
||||
*(.dynamic);
|
||||
. = ALIGN(512);
|
||||
}
|
||||
.rela.dyn : { *(.rela.dyn) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rela.data : { *(.rela.data) *(.rela.data*) }
|
||||
_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 = _edata - _data;
|
||||
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
/DISCARD/ : {
|
||||
*(.rel.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
INCLUDE lib/efi_loader/elf_efi.ldsi
|
||||
|
||||
@@ -14,6 +14,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
|
||||
imply VIDEO_EFI
|
||||
|
||||
config SYS_LDSCRIPT
|
||||
default "arch/arm/lib/elf_aarch64_efi.lds"
|
||||
default "arch/arm/lib/elf_aarch64_efi_app.lds"
|
||||
|
||||
endif
|
||||
|
||||
74
lib/efi_loader/elf_efi.ldsi
Normal file
74
lib/efi_loader/elf_efi.ldsi
Normal file
@@ -0,0 +1,74 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
/*
|
||||
* U-Boot EFI linker script include
|
||||
*
|
||||
* Modified from elf_aarch64_efi.lds in gnu-efi
|
||||
*/
|
||||
|
||||
PHDRS
|
||||
{
|
||||
data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
|
||||
}
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x0 : {
|
||||
_text = .;
|
||||
*(.text.head)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.srodata)
|
||||
*(.rodata*)
|
||||
. = ALIGN(16);
|
||||
*(.dynamic);
|
||||
. = ALIGN(512);
|
||||
}
|
||||
.rela.dyn : { *(.rela.dyn) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rela.data : { *(.rela.data) *(.rela.data*) }
|
||||
. = ALIGN(4096);
|
||||
_etext = .;
|
||||
_text_size = . - _text;
|
||||
.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 = _edata - _data;
|
||||
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
/DISCARD/ : {
|
||||
*(.rel.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
Reference in New Issue
Block a user