Skip to content

Commit 9881c95

Browse files
committed
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).
1 parent a36dd35 commit 9881c95

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

linuxkm/Kbuild

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,16 @@ RENAME_PIE_TEXT_AND_DATA_SECTIONS := \
214214
echo 'OK.'; \
215215
fi; \
216216
cd "$(obj)" || exit $$?; \
217-
for file in $(WOLFCRYPT_PIE_FILES); do \
218-
$(OBJCOPY) --rename-section .text=.text_wolfcrypt \
219-
--rename-section .text.unlikely=.text_wolfcrypt \
220-
--rename-section .rodata=.rodata_wolfcrypt \
221-
--rename-section .rodata.str1.1=.rodata_wolfcrypt \
222-
--rename-section .rodata.str1.8=.rodata_wolfcrypt \
223-
--rename-section .rodata.cst16=.rodata_wolfcrypt \
224-
--rename-section .rodata.cst32=.rodata_wolfcrypt \
225-
--rename-section .data=.data_wolfcrypt \
226-
--rename-section .data.rel.local=.data_wolfcrypt \
227-
--rename-section .bss=.bss_wolfcrypt "$$file" || exit $$?; \
228-
done; \
229-
[ "$(KERNEL_ARCH_X86)" != "yes" ] || \
217+
for file in $(WOLFCRYPT_PIE_FILES); do \
218+
$(OBJCOPY) $$($(READELF) --sections --wide "$$file" | \
219+
$(AWK) ' \
220+
{ \
221+
if (match($$0, "^ *\\[ *[0-9]+\\] +\\.(text|rodata|data|bss)(\\.[^ ]+)? ", a)) { \
222+
printf("--rename-section .%s%s=.%s_wolfcrypt ", a[1], a[2], a[1]); \
223+
} \
224+
}') "$$file" || exit $$?; \
225+
done; \
226+
[ "$(KERNEL_ARCH_X86)" != "yes" ] || \
230227
{ $(READELF) --sections --syms --wide $(WOLFCRYPT_PIE_FILES) | \
231228
$(AWK) -v obj="$(obj)" ' \
232229
/^File:/ { \

0 commit comments

Comments
 (0)