@@ -151,6 +151,8 @@ endif
151151
152152ifeq "$(ENABLED_LINUXKM_PIE ) " "yes"
153153
154+ LDFLAGS_libwolfssl.o += -T $(src ) /wolfcrypt.lds
155+
154156rename-pie-text-and-data-sections : $(WOLFSSL_OBJ_TARGETS )
155157
156158ifndef NM
@@ -186,8 +188,40 @@ ifneq "$(quiet)" "silent_"
186188endif
187189 cd "$(obj)" || exit $$?
188190 for file in $(WOLFCRYPT_PIE_FILES); do
189- $(OBJCOPY) --rename-section .text=.text.wolfcrypt --rename-section .data=.data.wolfcrypt --rename-section .rodata=.rodata.wolfcrypt "$$file" || exit $$?
191+ $(OBJCOPY) --rename-section .text=.text.wolfcrypt \
192+ --rename-section .text.unlikely=.text.wolfcrypt \
193+ --rename-section .rodata=.rodata.wolfcrypt \
194+ --rename-section .rodata.str1.1=.rodata.wolfcrypt \
195+ --rename-section .rodata.str1.8=.rodata.wolfcrypt \
196+ --rename-section .data=.data.wolfcrypt \
197+ --rename-section .data.rel.local=.data.wolfcrypt \
198+ --rename-section .bss=.bss.wolfcrypt "$$file" || exit $$?
190199 done
200+ [ "$(KERNEL_ARCH_X86)" != "yes" ] || \
201+ { $(READELF) --syms $(WOLFCRYPT_PIE_FILES) | \
202+ $(AWK) -v obj="$(obj)" ' \
203+ /File:/ { \
204+ if (substr($$2, 1, length(obj)) == obj) { \
205+ curfile = substr($$2, length(obj) + 2); \
206+ } else { \
207+ curfile=$$2; \
208+ } \
209+ next; \
210+ } \
211+ { \
212+ if (($$4 == "SECTION") && ($$8 !~ "wolfcrypt")) {\
213+ if (! ((curfile ";" $$8) in warned_on)) { \
214+ print curfile ": " $$8 >"/dev/stderr"; \
215+ warned_on[curfile ": " $$8] = 1; \
216+ ++warnings; \
217+ }}} \
218+ END { \
219+ if (warnings) { \
220+ exit(1); \
221+ } else { \
222+ exit(0); \
223+ }}'; } || \
224+ { echo 'Error: section(s) missed by containerization.' >&2; exit 1; }
191225ifneq "$(quiet ) " "silent_"
192226 echo ' wolfCrypt .{text,data,rodata} sections containerized to .{text,data,rodata}.wolfcrypt'
193227endif
0 commit comments