mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-11 07:24:46 +00:00

EFI applications need to be relocatable. Ordinarily, this is achieved through a PE-format .reloc section, but since that requires toolchain tricks to achieve, U-Boot's EFI applications instead embed ELF-flavored relocation information and use it for self-relocation; thus, the .dynamic section needs to be preserved. Before this patch, it was tacked on to the end of .text, but this was not proper: A .text section is SHT_PROGBITS, while the .dynamic section is SHT_DYNAMIC. Attempting to combine them like this creates a section type mismatch. While GNU ld doesn't seem to complain, LLVM's lld considers this a fatal linking error. This patch moves .dynamic out to its own section, so that the output ELF has the correct types. (They're all mashed together when converting to binary anyway, so this patch causes no change in the final .efi output.) Signed-off-by: Sam Edwards <CFSworks@gmail.com> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
74 lines
1.2 KiB
Text
74 lines
1.2 KiB
Text
/* 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 : { *(.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) }
|
|
}
|