diff --git a/linuxkm/Kbuild b/linuxkm/Kbuild index 2b47bcf81..54986a6ab 100644 --- a/linuxkm/Kbuild +++ b/linuxkm/Kbuild @@ -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:/ { \