linuxkm/Kbuild: refactor RENAME_PIE_TEXT_AND_DATA_SECTIONS to automatically derive the list of all ELF sections to rename, rather than enumerating them staticly in the objcopy recipe (motivated by changes expected in kernel 6.19).

This commit is contained in:
Daniel Pouzzner
2025-10-18 12:07:35 -05:00
parent a36dd35e59
commit 9881c95c46

View File

@@ -214,19 +214,16 @@ RENAME_PIE_TEXT_AND_DATA_SECTIONS := \
echo 'OK.'; \
fi; \
cd "$(obj)" || exit $$?; \
for file in $(WOLFCRYPT_PIE_FILES); do \
$(OBJCOPY) --rename-section .text=.text_wolfcrypt \
--rename-section .text.unlikely=.text_wolfcrypt \
--rename-section .rodata=.rodata_wolfcrypt \
--rename-section .rodata.str1.1=.rodata_wolfcrypt \
--rename-section .rodata.str1.8=.rodata_wolfcrypt \
--rename-section .rodata.cst16=.rodata_wolfcrypt \
--rename-section .rodata.cst32=.rodata_wolfcrypt \
--rename-section .data=.data_wolfcrypt \
--rename-section .data.rel.local=.data_wolfcrypt \
--rename-section .bss=.bss_wolfcrypt "$$file" || exit $$?; \
done; \
[ "$(KERNEL_ARCH_X86)" != "yes" ] || \
for file in $(WOLFCRYPT_PIE_FILES); do \
$(OBJCOPY) $$($(READELF) --sections --wide "$$file" | \
$(AWK) ' \
{ \
if (match($$0, "^ *\\[ *[0-9]+\\] +\\.(text|rodata|data|bss)(\\.[^ ]+)? ", a)) { \
printf("--rename-section .%s%s=.%s_wolfcrypt ", a[1], a[2], a[1]); \
} \
}') "$$file" || exit $$?; \
done; \
[ "$(KERNEL_ARCH_X86)" != "yes" ] || \
{ $(READELF) --sections --syms --wide $(WOLFCRYPT_PIE_FILES) | \
$(AWK) -v obj="$(obj)" ' \
/^File:/ { \