[PATCH v2] sandbox: cleanup linker scripts and sections

Simon Glass sjg at chromium.org
Mon Jul 15 15:31:42 CEST 2024


commit 6e2228fb052b ("Merge patch series "Clean up arm linker scripts"")
was cleaning up linker scripts for armv7 and v8 in a similar fashion.

Several commits in the past -- e.g
commit d0b5d9da5de2 ("arm: make _end compiler-generated")
was moving symbols to be compiler generated. They were defined as c
variables in its own section to force the compiler emit relative a
reference. However, defining those in the linker script will do the
same thing since [0].

So let's remove the special sections from the linker scripts, the
variable definitions from sections.c, and define them as a symbols.
It's worth noting that the linker was discarding the symbols in the
older binary completely since the symbol definition had an extra _.

- new binary
$~ aarch64-linux-gnu-readelf -sW u-boot | grep efi_runtim
   246: 000000000004acbe    13 FUNC    LOCAL  DEFAULT   14
vbe_req_efi_runtime_rand
  3198: 0000000000318690    16 OBJECT  LOCAL  DEFAULT   29 efi_runtime_mmio
  6359: 00000000000dedff   217 FUNC    LOCAL  DEFAULT   14 efi_runtime_relocate
  7942: 00000000003074c0   136 OBJECT  GLOBAL HIDDEN    29 efi_runtime_services
  8869: 0000000000305e20     0 NOTYPE  GLOBAL DEFAULT   27
__efi_runtime_rel_stop
  9159: 0000000000305e20     0 NOTYPE  GLOBAL DEFAULT   27 __efi_runtime_stop
  9410: 0000000000305e20     0 NOTYPE  GLOBAL DEFAULT   27 __efi_runtime_start
 10137: 00000000005981bd     0 NOTYPE  WEAK   HIDDEN    33
efi_runtime.c.de5bed54
 10470: 0000000000305e20     0 NOTYPE  GLOBAL DEFAULT   27
__efi_runtime_rel_start

- old binary
$~ aarch64-linux-gnu-readelf -sW u-boot.old | grep efi_runtim
   246: 000000000004acbe    13 FUNC    LOCAL  DEFAULT   14
vbe_req_efi_runtime_rand
  3198: 0000000000318690    16 OBJECT  LOCAL  DEFAULT   29 efi_runtime_mmio
  6359: 00000000000dedff   221 FUNC    LOCAL  DEFAULT   14 efi_runtime_relocate
  7942: 00000000003074c0   136 OBJECT  GLOBAL HIDDEN    29 efi_runtime_services
 10135: 0000000000598320     0 NOTYPE  WEAK   HIDDEN    33
efi_runtime.c.de5bed54

$~ bloat-o-meter u-bool.old u-boot
add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-4 (3)
Function                                     old     new   delta
efi_memory_init                              343     350      +7
efi_runtime_relocate                         221     217      -4
Total: Before=2009902, After=2009905, chg +0.00%

[0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic
only for shared object")

Tested-by: Heinrich Schuchardt <xypron.glpk at gmx.de> #
sandbox_defconfig on amd64, arm64, riscv64
Reviewed-by: Simon Glass <sjg at chromium.org>
Fixes: commit aac53d3d96a2 ("sandbox: Rename EFI runtime sections")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---
Changes since v1:
- Added Fixes tag
- Collected tags from Heinrich and Simon

 arch/sandbox/cpu/u-boot.lds | 20 ++++----------------
 arch/sandbox/lib/Makefile   |  2 +-
 arch/sandbox/lib/sections.c | 13 -------------
 3 files changed, 5 insertions(+), 30 deletions(-)
 delete mode 100644 arch/sandbox/lib/sections.c

Applied to u-boot-dm, thanks!


More information about the U-Boot mailing list