diff options
| author | Khem Raj <raj.khem@gmail.com> | 2025-09-08 14:06:57 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-09-11 11:31:57 +0100 |
| commit | 86970c73bf99789b114a78702b9a0629a4583b1d (patch) | |
| tree | 8635c091b382e816b13d35701f5b56a87b531274 | |
| parent | 0f288ce34e5737fdb97a766d10a9d9d8e5b6f9b0 (diff) | |
| download | poky-86970c73bf99789b114a78702b9a0629a4583b1d.tar.gz | |
kexec-tools: Fix build with LLD linker
With hardcoded -Ttext,0x10000 and newer toolchains emitting
.note.gnu.property before .text, the link can fail with an overlap.
Provide a minimal linker script that:
- sets the image base to 0x10000,
- places .text first at exactly 0x10000,
- moves .note.gnu.property after .text,
- optionally fixes .bss at 0x12000.
Works with both ld.bfd and LLD 21+.
(From OE-Core rev: 049ce8ad241bae31c22b83788e732080f7d04526)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-kernel/kexec/kexec-tools/0001-Make-the-segment-base-match-pinned-section-address.patch | 62 | ||||
| -rw-r--r-- | meta/recipes-kernel/kexec/kexec-tools_2.0.31.bb | 1 |
2 files changed, 63 insertions, 0 deletions
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0001-Make-the-segment-base-match-pinned-section-address.patch b/meta/recipes-kernel/kexec/kexec-tools/0001-Make-the-segment-base-match-pinned-section-address.patch new file mode 100644 index 0000000000..6babf16e6e --- /dev/null +++ b/meta/recipes-kernel/kexec/kexec-tools/0001-Make-the-segment-base-match-pinned-section-address.patch | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | From 0d8a9e12b6509cb2a79818f5f4062a0bee33edfc Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Wed, 3 Sep 2025 13:28:32 -0700 | ||
| 4 | Subject: [PATCH] Make the segment base match pinned section address | ||
| 5 | |||
| 6 | ET_EXEC uses image base of 0x400000, but the build forces | ||
| 7 | section VMAs like .text = 0x10000. LLD now errors when any | ||
| 8 | section address is below the image base unless you explicitly | ||
| 9 | set the base. (Older LLD tolerated it.) | ||
| 10 | |||
| 11 | To fix this, set the image base to match forced section addresses | ||
| 12 | |||
| 13 | Fixes | ||
| 14 | | x86_64-yoe-linux-ld.lld: error: section '.text' address (0x10000) is smaller than image base (0x400000); specify --image-base | ||
| 15 | | x86_64-yoe-linux-ld.lld: error: section '.bss' address (0x12000) is smaller than image base (0x400000); specify --image-base | ||
| 16 | |||
| 17 | Upstream-Status: Submitted [https://lists.infradead.org/pipermail/kexec/2025-September/033493.html] | ||
| 18 | |||
| 19 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 20 | --- | ||
| 21 | kexec_test/Makefile | 2 +- | ||
| 22 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 23 | |||
| 24 | --- a/kexec_test/Makefile | ||
| 25 | +++ b/kexec_test/Makefile | ||
| 26 | @@ -5,7 +5,7 @@ RELOC:=0x10000 | ||
| 27 | KEXEC_TEST_SRCS:= kexec_test/kexec_test16.S kexec_test/kexec_test.S | ||
| 28 | |||
| 29 | dist += kexec_test/Makefile $(KEXEC_TEST_SRCS) \ | ||
| 30 | - kexec_test/x86-setup-legacy-pic.S | ||
| 31 | + kexec_test/x86-setup-legacy-pic.S kexec_test/kexec_test.ld | ||
| 32 | |||
| 33 | BUILD_KEXEC_TEST = no | ||
| 34 | ifeq ($(ARCH),i386) | ||
| 35 | @@ -31,7 +31,7 @@ $(KEXEC_TEST): CPPFLAGS+=-DRELOC=$(RELOC | ||
| 36 | $(KEXEC_TEST): ASFLAGS+=-m32 | ||
| 37 | #$(KEXEC_TEST): LDFLAGS=-m32 -Wl,-e -Wl,_start -Wl,-Ttext -Wl,$(RELOC) \ | ||
| 38 | # -nostartfiles | ||
| 39 | -$(KEXEC_TEST): LDFLAGS=-melf_i386 -e _start -Ttext $(RELOC) | ||
| 40 | +$(KEXEC_TEST): LDFLAGS=-melf_i386 -e _start -T $(srcdir)/kexec_test/kexec_test.ld | ||
| 41 | |||
| 42 | $(KEXEC_TEST): $(KEXEC_TEST_OBJS) | ||
| 43 | mkdir -p $(@D) | ||
| 44 | --- /dev/null | ||
| 45 | +++ b/kexec_test/kexec_test.ld | ||
| 46 | @@ -0,0 +1,16 @@ | ||
| 47 | +ENTRY(_start) | ||
| 48 | +SECTIONS | ||
| 49 | +{ | ||
| 50 | + . = 0x10000; | ||
| 51 | + .text : { *(.text .text.*) } | ||
| 52 | + | ||
| 53 | + /* Place the note after .text to avoid overlap */ | ||
| 54 | + . = ALIGN(16); | ||
| 55 | + .note.gnu.property : { *(.note.gnu.property) } | ||
| 56 | + | ||
| 57 | + .rodata : { *(.rodata .rodata.*) } | ||
| 58 | + | ||
| 59 | + /* If you need bss fixed: */ | ||
| 60 | + . = 0x12000; | ||
| 61 | + .bss : { *(.bss .bss.* COMMON) } | ||
| 62 | +} | ||
diff --git a/meta/recipes-kernel/kexec/kexec-tools_2.0.31.bb b/meta/recipes-kernel/kexec/kexec-tools_2.0.31.bb index 7333aa73c1..b12f76a0bf 100644 --- a/meta/recipes-kernel/kexec/kexec-tools_2.0.31.bb +++ b/meta/recipes-kernel/kexec/kexec-tools_2.0.31.bb | |||
| @@ -19,6 +19,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/kernel/kexec/kexec-tools-${PV}.tar.gz | |||
| 19 | file://0001-arm64-kexec-disabled-check-if-kaslr-seed-dtb-propert.patch \ | 19 | file://0001-arm64-kexec-disabled-check-if-kaslr-seed-dtb-propert.patch \ |
| 20 | file://0001-kexec.c-add-MFD_NOEXEC_SEAL-flag-explicitly.patch \ | 20 | file://0001-kexec.c-add-MFD_NOEXEC_SEAL-flag-explicitly.patch \ |
| 21 | file://0001-ppc-fs2dt-Match-function-signatures.patch \ | 21 | file://0001-ppc-fs2dt-Match-function-signatures.patch \ |
| 22 | file://0001-Make-the-segment-base-match-pinned-section-address.patch \ | ||
| 22 | " | 23 | " |
| 23 | 24 | ||
| 24 | SRC_URI[sha256sum] = "ddaaa65b02b4f8aa9222586b1f26565b93a4baeffd35bcbd523f15fae7aa4897" | 25 | SRC_URI[sha256sum] = "ddaaa65b02b4f8aa9222586b1f26565b93a4baeffd35bcbd523f15fae7aa4897" |
