diff --git a/meta-oe/recipes-crypto/leancrypto/files/0002-Linker-script-Handle-a-missing-.init-section.patch b/meta-oe/recipes-crypto/leancrypto/files/0002-Linker-script-Handle-a-missing-.init-section.patch new file mode 100644 index 0000000000..364f223a8e --- /dev/null +++ b/meta-oe/recipes-crypto/leancrypto/files/0002-Linker-script-Handle-a-missing-.init-section.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 19 Oct 2026 22:58:25 -0700 +Subject: [PATCH] Linker script: Handle a missing .init section + +Not every C library provides a .init section; musl, for example, has +no crti.o .init/.fini code on riscv64 and only uses .init_array. The +linker script then refers to ADDR(.init) of a section which does not +exist. GNU ld accepts this and yields an empty range, but LLD rejects +it and the link fails: + + ld.lld: error: internal/src/fips_integrity_check.ld:11: undefined section .init + ld.lld: error: internal/src/fips_integrity_check.ld:12: undefined section .init + +Only use ADDR(.init) when the section has a size, and otherwise provide +an empty range at the start of .text, which matches what GNU ld does. +The symbol values are unchanged whenever .init exists. + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + internal/src/fips_integrity_check.ld | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/internal/src/fips_integrity_check.ld b/internal/src/fips_integrity_check.ld +index 61397f5..e803d2f 100644 +--- a/internal/src/fips_integrity_check.ld ++++ b/internal/src/fips_integrity_check.ld +@@ -8,8 +8,8 @@ SECTIONS + .lc_fips_integrity_hash : + { + /* Executable code */ +- PROVIDE(lc_fips_start_init = ADDR(.init)); +- PROVIDE(lc_fips_end_init = ADDR(.init) + SIZEOF(.init)); ++ PROVIDE(lc_fips_start_init = SIZEOF(.init) ? ADDR(.init) : ADDR(.text)); ++ PROVIDE(lc_fips_end_init = SIZEOF(.init) ? ADDR(.init) + SIZEOF(.init) : ADDR(.text)); + + /* Executable code */ + PROVIDE(lc_fips_start_text = ADDR(.text)); diff --git a/meta-oe/recipes-crypto/leancrypto/leancrypto_1.9.1.bb b/meta-oe/recipes-crypto/leancrypto/leancrypto_1.9.1.bb index 083b70fe8c..c5c7bc104a 100644 --- a/meta-oe/recipes-crypto/leancrypto/leancrypto_1.9.1.bb +++ b/meta-oe/recipes-crypto/leancrypto/leancrypto_1.9.1.bb @@ -14,6 +14,7 @@ SECTION = "libs" SRC_URI = "git://github.com/smuellerDD/leancrypto.git;branch=master;protocol=https;tag=v${PV} \ file://leancrypto-tests.sh \ file://0001-secure_execution_linux-drop-redundant-linux-prctl.h-.patch \ + file://0002-Linker-script-Handle-a-missing-.init-section.patch \ " SRCREV = "65eb4e7e84e3a5499460a66b1623ccf6c59628b1"