* [PATCH v2] x86: efi: define _end in the linker scripts
@ 2026-12-01 11:50 Alexander Shiyan
0 siblings, 0 replies; only message in thread
From: Alexander Shiyan @ 2026-12-01 11:50 UTC (permalink / raw)
To: barebox; +Cc: Alexander Shiyan
common/kallsyms.c falls back to _end as the upper bound when the size of
the last symbol is unknown:
if (!symbol_end)
symbol_end = (unsigned long)_end;
Every other architecture defines _end in its linker script, but the x86
EFI scripts don't, so any x86_64 configuration with CONFIG_KALLSYMS
enabled fails to link:
common/kallsyms.o: in function `get_symbol_pos':
kallsyms.c:(.text+0x207): undefined reference to `_end'
This is reachable with a plain randconfig build on x86_64.
Define _end right after .dynstr, the last section that carries loadable
data. It deliberately is not placed at the very end of the script, as
.comment uses an absolute section address of 0 and would drag the
location counter back to the start of the image.
The same addition is made to the ia32 script for consistency. It is
untested, as 32-bit x86 support is documented as non-compiling and the
toolchain here has no 32-bit libgcc.
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
arch/x86/mach-efi/elf_ia32_efi.lds.S | 7 +++++++
arch/x86/mach-efi/elf_x86_64_efi.lds.S | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/arch/x86/mach-efi/elf_ia32_efi.lds.S b/arch/x86/mach-efi/elf_ia32_efi.lds.S
index 0a3b6ef947..e9b820de00 100644
--- a/arch/x86/mach-efi/elf_ia32_efi.lds.S
+++ b/arch/x86/mach-efi/elf_ia32_efi.lds.S
@@ -80,6 +80,13 @@ SECTIONS
. = ALIGN(4096);
.dynstr : { *(.dynstr) }
. = ALIGN(4096);
+
+ /* kallsyms uses _end as the upper bound when the size of the last
+ * symbol is unknown. Sections below carry no loadable data, so the
+ * location counter here is the end of the image.
+ */
+ _end = .;
+
/DISCARD/ :
{
*(.rel.reloc)
diff --git a/arch/x86/mach-efi/elf_x86_64_efi.lds.S b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
index ed2ddd5248..3b50715c85 100644
--- a/arch/x86/mach-efi/elf_x86_64_efi.lds.S
+++ b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
@@ -75,6 +75,13 @@ SECTIONS
. = ALIGN(4096);
.dynstr : { *(.dynstr) }
. = ALIGN(4096);
+
+ /* kallsyms uses _end as the upper bound when the size of the last
+ * symbol is unknown. Sections below carry no loadable data, so the
+ * location counter here is the end of the image.
+ */
+ _end = .;
+
.ignored.reloc : {
*(.rela.reloc)
*(.eh_frame)
--
2.54.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 11:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 11:50 [PATCH v2] x86: efi: define _end in the linker scripts Alexander Shiyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox