U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Edwards <cfsworks@gmail.com>
To: Tom Rini <trini@konsulko.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Simon Glass <sjg@chromium.org>, Bin Meng <bmeng.cn@gmail.com>,
	Rick Chen <rick@andestech.com>, Leo <ycliang@andestech.com>
Cc: Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Sumit Garg <sumit.garg@linaro.org>,
	Peter Robinson <pbrobinson@gmail.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	u-boot@lists.denx.de, Sam Edwards <CFSworks@gmail.com>,
	Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Subject: [PATCH v2 12/15] efi_loader: Move .dynamic out of .text in EFI
Date: Sat, 15 Mar 2025 15:18:10 -0700	[thread overview]
Message-ID: <20250315221813.1265193-13-CFSworks@gmail.com> (raw)
In-Reply-To: <20250315221813.1265193-1-CFSworks@gmail.com>

EFI applications need to be relocatable. Ordinarily, this is achieved
through a PE-format .reloc section, but since that requires toolchain
tricks to achieve, U-Boot's EFI applications instead embed ELF-flavored
relocation information and use it for self-relocation; thus, the
.dynamic section needs to be preserved.

Before this patch, it was tacked on to the end of .text, but this was
not proper: A .text section is SHT_PROGBITS, while the .dynamic section
is SHT_DYNAMIC. Attempting to combine them like this creates a section
type mismatch. While GNU ld doesn't seem to complain, LLVM's lld
considers this a fatal linking error.

This patch moves .dynamic out to its own section, so that the output ELF
has the correct types. (They're all mashed together when converting to
binary anyway, so this patch causes no change in the final .efi output.)

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 lib/efi_loader/elf_efi.ldsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/elf_efi.ldsi b/lib/efi_loader/elf_efi.ldsi
index 190a88fb69e..4fa5ca43872 100644
--- a/lib/efi_loader/elf_efi.ldsi
+++ b/lib/efi_loader/elf_efi.ldsi
@@ -21,10 +21,10 @@ SECTIONS
 		*(.gnu.linkonce.t.*)
 		*(.srodata)
 		*(.rodata*)
-		. = ALIGN(16);
-		*(.dynamic);
-		. = ALIGN(512);
 	}
+	. = ALIGN(16);
+	.dynamic : { *(.dynamic) }
+	. = ALIGN(512);
 	.rela.dyn : { *(.rela.dyn) }
 	.rela.plt : { *(.rela.plt) }
 	.rela.got : { *(.rela.got) }
-- 
2.48.1


  parent reply	other threads:[~2025-03-15 22:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-15 22:17 [PATCH v2 00/15] Various toolchain compatibility fixes/improvements Sam Edwards
2025-03-15 22:17 ` [PATCH v2 01/15] arm: Remove stray .mmutable reference in linker script Sam Edwards
2025-03-15 22:18 ` [PATCH v2 02/15] arm: Exclude eabi_compat from LTO Sam Edwards
2025-03-15 22:18 ` [PATCH v2 03/15] arm: Add __aeabi_memclr in eabi_compat Sam Edwards
2025-03-15 22:18 ` [PATCH v2 04/15] arm: Add aligned-memory aliases to eabi_compat Sam Edwards
2025-03-15 22:18 ` [PATCH v2 05/15] arm: Discard unwanted sections in linker script Sam Edwards
2025-03-30  6:47   ` Ilias Apalodimas
2025-03-15 22:18 ` [PATCH v2 06/15] arm: Replace 'adrl' in EFI crt0 Sam Edwards
2025-03-30  6:46   ` Ilias Apalodimas
2025-03-15 22:18 ` [PATCH v2 07/15] x86: Fix call64's section flags Sam Edwards
2025-03-15 22:18 ` [PATCH v2 08/15] makefile: Avoid objcopy --gap-fill for .hex/.srec Sam Edwards
2025-03-30  6:47   ` Ilias Apalodimas
2025-03-15 22:18 ` [PATCH v2 09/15] makefile: Add `norelro` linker option Sam Edwards
2025-03-15 22:18 ` [PATCH v2 10/15] makefile: Add READELF command variable Sam Edwards
2025-03-15 22:18 ` [PATCH v2 11/15] arm: riscv: efi: Export _start symbol from crt0_*_efi stubs Sam Edwards
2025-03-17  8:43   ` Heinrich Schuchardt
2025-03-15 22:18 ` Sam Edwards [this message]
2025-03-17  8:34   ` [PATCH v2 12/15] efi_loader: Move .dynamic out of .text in EFI Heinrich Schuchardt
2025-03-15 22:18 ` [PATCH v2 13/15] scripts/Makefile.lib: efi: Preserve the .dynstr section as well Sam Edwards
2025-03-15 22:18 ` [PATCH v2 14/15] spl: riscv: opensbi: Error on misaligned FDT Sam Edwards
2025-03-15 22:18 ` [PATCH v2 15/15] spl: Align FDT load address Sam Edwards
2025-03-16  5:27 ` [PATCH v2 00/15] Various toolchain compatibility fixes/improvements Heinrich Schuchardt
2025-03-16 19:31   ` Sam Edwards
2025-04-03  1:59 ` Tom Rini

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=20250315221813.1265193-13-CFSworks@gmail.com \
    --to=cfsworks@gmail.com \
    --cc=bmeng.cn@gmail.com \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=pbrobinson@gmail.com \
    --cc=richard.henderson@linaro.org \
    --cc=rick@andestech.com \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    /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