
From: Simon Glass <sjg@chromium.org> Add a proper linker script (u-boot-lib.lds) for building libu-boot.so to ensure correct section alignment and placement, particularly for the linker lists. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org> --- arch/sandbox/cpu/u-boot-lib.lds | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 arch/sandbox/cpu/u-boot-lib.lds diff --git a/arch/sandbox/cpu/u-boot-lib.lds b/arch/sandbox/cpu/u-boot-lib.lds new file mode 100644 index 00000000000..f57292b0a8d --- /dev/null +++ b/arch/sandbox/cpu/u-boot-lib.lds @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2025 Canonical + * Written by Simon Glass <simon.glass@canonical.com> + * + * Linker script for U-Boot shared library (libu-boot.so) + */ + +SECTIONS +{ + /* Text sections first */ + .text : { + *(.text*) + } + + . = ALIGN(32); + __u_boot_list : { + KEEP(*(SORT(__u_boot_list*))); + } + + _u_boot_sandbox_getopt : { + *(_u_boot_sandbox_getopt_start) + KEEP(*(_u_boot_sandbox_getopt)) + *(_u_boot_sandbox_getopt_end) + } + + efi_runtime : { + __efi_runtime_start = .; + *(efi_runtime_text) + *(efi_runtime_data) + __efi_runtime_stop = .; + } + + efi_runtime_rel : { + __efi_runtime_rel_start = .; + *(.relefi_runtime_text) + *(.relefi_runtime_data) + __efi_runtime_rel_stop = .; + } + + /* Read-only data */ + . = ALIGN(8); + .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } + + /* Data sections */ + . = ALIGN(8); + .data : { + *(.data*) + } + + /* BSS section */ + . = ALIGN(8); + .bss : { + __bss_start = .; + *(.bss*) + *(COMMON) + . = ALIGN(8); + __bss_end = .; + } + + /* Dynamic linking sections for shared library */ + .dynamic : { *(.dynamic) } + .dynsym : { + __dyn_sym_start = .; + *(.dynsym) + __dyn_sym_end = .; + } + .dynstr : { *(.dynstr) } + .gnu.hash : { *(.gnu.hash) } + .hash : { *(.hash) } + .got : { *(.got) } + .got.plt : { *(.got.plt) } + .plt : { *(.plt) } + .rela.dyn : { *(.rela.dyn) } + .rela.plt : { *(.rela.plt) } + + /* Debugging sections */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_ranges 0 : { *(.debug_ranges) } + .debug_line 0 : { *(.debug_line) } + .debug_str 0 : { *(.debug_str) } + .debug_frame 0 : { *(.debug_frame) } + .debug_loc 0 : { *(.debug_loc) } + + /DISCARD/ : { *(.note*) } +} -- 2.43.0