From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH v2] x86: efi: define _end in the linker scripts
Date: Tue, 1 Dec 2026 14:50:22 +0300 [thread overview]
Message-ID: <20261201115022.984672-1-eagle.alexander923@gmail.com> (raw)
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
reply other threads:[~2026-12-01 11:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201115022.984672-1-eagle.alexander923@gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox