]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: cleanup linker scripts and sections
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Mon, 17 Jun 2024 15:14:18 +0000 (18:14 +0300)
committerSimon Glass <sjg@chromium.org>
Wed, 3 Jul 2024 06:36:33 +0000 (07:36 +0100)
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@gmx.de> # sandbox_defconfig on amd64, arm64, riscv64
Reviewed-by: Simon Glass <sjg@chromium.org>
Fixes: commit aac53d3d96a2 ("sandbox: Rename EFI runtime sections")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
arch/sandbox/cpu/u-boot.lds
arch/sandbox/lib/Makefile
arch/sandbox/lib/sections.c [deleted file]

index 52f13af3742f6b1dd7ba44f8b972ae5ced334abc..6ee8095b6cbbf3c6eef56363abb2f3a0c8dce423 100644 (file)
@@ -19,30 +19,18 @@ SECTIONS
                *(_u_boot_sandbox_getopt_end)
        }
 
-       efi_runtime_start : {
-               *(___efi_runtime_start)
-       }
-
        efi_runtime : {
+                __efi_runtime_start = .;
                *(efi_runtime_text)
                *(efi_runtime_data)
-       }
-
-       efi_runtime_stop : {
-               *(___efi_runtime_stop)
-       }
-
-       efi_runtime_rel_start : {
-               *(___efi_runtime_rel_start)
+                __efi_runtime_stop = .;
        }
 
        efi_runtime_rel : {
+                __efi_runtime_rel_start = .;
                *(.relefi_runtime_text)
                *(.relefi_runtime_data)
-       }
-
-       efi_runtime_rel_stop : {
-               *(___efi_runtime_rel_stop)
+                __efi_runtime_rel_stop = .;
        }
 
        .dynsym :
index a2bc5a7ee60fe8c44d0dcf91df6da8c509f79db4..d7d15a50bb6c59bf2dd95b8ea3ba6b751fd4c08f 100644 (file)
@@ -5,7 +5,7 @@
 # (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
-obj-y  += fdt_fixup.o interrupts.o sections.o
+obj-y                  += fdt_fixup.o interrupts.o
 obj-$(CONFIG_PCI)      += pci_io.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o
diff --git a/arch/sandbox/lib/sections.c b/arch/sandbox/lib/sections.c
deleted file mode 100644 (file)
index 2f2f3fb..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net>
- *
- */
-#include <linux/compiler.h>
-
-char __efi_runtime_start[0] __section("___efi_runtime_start");
-char __efi_runtime_stop[0] __section("___efi_runtime_stop");
-char __efi_runtime_rel_start[0]
-               __section("___efi_runtime_rel_start");
-char __efi_runtime_rel_stop[0]
-               __section("___efi_runtime_rel_stop");