@@ -131,6 +131,9 @@ ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
131131 # using inline retpolines leads to "unannotated intra-function call"
132132 # warnings from objtool without this:
133133 $(WOLFCRYPT_PIE_FILES ) : OBJECT_FILES_NON_STANDARD := y
134+ ifdef FORCE_GLOBAL_OBJTOOL_OFF
135+ undefine CONFIG_OBJTOOL
136+ endif
134137endif
135138
136139ifdef KERNEL_EXTRA_CFLAGS_REMOVE
@@ -176,8 +179,6 @@ ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
176179
177180LDFLAGS_libwolfssl.o += -T $(src ) /wolfcrypt.lds
178181
179- rename-pie-text-and-data-sections : $(WOLFSSL_OBJ_TARGETS )
180-
181182ifndef NM
182183 NM := nm
183184endif
@@ -186,31 +187,30 @@ ifndef OBJCOPY
186187 OBJCOPY := objcopy
187188endif
188189
189- .PHONY : rename-pie-text-and-data-sections
190- rename-pie-text-and-data-sections :
191- ifneq "$(quiet ) " "silent_"
192- @echo -n ' Checking wolfCrypt for unresolved symbols and forbidden relocations... '
193- endif
194- @cd "$(obj)" || exit $$?
195- $(LD) -relocatable -o wolfcrypt_test_link.o $(WOLFCRYPT_PIE_FILES) || exit $$?
196- undefined=$$($(NM) --undefined-only wolfcrypt_test_link.o) || exit $$?
197- GOT_relocs=$$($(READELF) --relocs --wide wolfcrypt_test_link.o | egrep '^[^ ]+ +[^ ]+ +[^ ]*GOT[^ ]* ') || [ $$? = 1 ] || exit 2
198- rm wolfcrypt_test_link.o
199- if [ -n "$$undefined" ]; then
200- echo "wolfCrypt container has unresolved symbols:" 1>&2
201- echo "$$undefined" 1>&2
202- exit 1
203- fi
204- if [ -n "$$GOT_relocs" ]; then
205- echo "wolfCrypt container has GOT relocations (non-local function address used as operand?):" 1>&2
206- echo "$$GOT_relocs" 1>&2
207- exit 1
208- fi
209- ifneq "$(quiet ) " "silent_"
210- echo 'OK.'
211- endif
212- cd "$(obj)" || exit $$?
213- for file in $(WOLFCRYPT_PIE_FILES); do
190+ RENAME_PIE_TEXT_AND_DATA_SECTIONS := \
191+ if [[ "$(quiet ) " != "silent_" ]]; then \
192+ echo -n ' Checking wolfCrypt for unresolved symbols and forbidden relocations... '; \
193+ fi; \
194+ cd "$(obj ) " || exit $$? ; \
195+ $(LD ) -relocatable -o wolfcrypt_test_link.o $(WOLFCRYPT_PIE_FILES ) || exit $$? ; \
196+ undefined=$$($(NM ) --undefined-only wolfcrypt_test_link.o) || exit $$? ; \
197+ GOT_relocs=$$($(READELF ) --relocs --wide wolfcrypt_test_link.o | grep -E '^[^ ]+ +[^ ]+ +[^ ]*GOT[^ ]* ') || [ $$? = 1 ] || exit 2; \
198+ rm wolfcrypt_test_link.o; \
199+ if [ -n "$$undefined" ]; then \
200+ echo "wolfCrypt container has unresolved symbols:" 1>&2; \
201+ echo "$$undefined" 1>&2; \
202+ exit 1; \
203+ fi; \
204+ if [ -n "$$GOT_relocs" ]; then \
205+ echo "wolfCrypt container has GOT relocations (non-local function address used as operand?):" 1>&2; \
206+ echo "$$GOT_relocs" 1>&2; \
207+ exit 1; \
208+ fi; \
209+ if [[ "$(quiet ) " != "silent_" ]]; then \
210+ echo 'OK.'; \
211+ fi; \
212+ cd "$(obj ) " || exit $$? ; \
213+ for file in $(WOLFCRYPT_PIE_FILES ) ; do \
214214 $(OBJCOPY ) --rename-section .text=.text.wolfcrypt \
215215 --rename-section .text.unlikely=.text.wolfcrypt \
216216 --rename-section .rodata=.rodata.wolfcrypt \
@@ -220,8 +220,8 @@ endif
220220 --rename-section .rodata.cst32=.rodata.wolfcrypt \
221221 --rename-section .data=.data.wolfcrypt \
222222 --rename-section .data.rel.local=.data.wolfcrypt \
223- --rename-section .bss=.bss.wolfcrypt "$$file" || exit $$?
224- done
223+ --rename-section .bss=.bss.wolfcrypt "$$file" || exit $$? ; \
224+ done; \
225225 [ "$(KERNEL_ARCH_X86 ) " != "yes" ] || \
226226 { $(READELF ) --sections --syms --wide $(WOLFCRYPT_PIE_FILES ) | \
227227 $(AWK ) -v obj="$(obj ) " ' \
@@ -295,19 +295,16 @@ endif
295295 } else { \
296296 exit(0); \
297297 }}'; } || \
298- { echo 'Error: symbol(s) missed by containerization.' >&2; exit 1; }
299- ifneq "$(quiet ) " "silent_"
300- echo ' wolfCrypt .{text,data,rodata} sections containerized to .{text,data,rodata}.wolfcrypt'
301- endif
302-
303- $(obj ) /linuxkm/module_exports.c : rename-pie-text-and-data-sections
304-
298+ { echo 'Error: symbol(s) missed by containerization.' >&2; exit 1; }; \
299+ if [[ "$(quiet ) " != "silent_" ]]; then \
300+ echo ' wolfCrypt .{text,data,rodata} sections containerized to .{text,data,rodata}.wolfcrypt'; \
301+ fi
305302endif
306303
307-
308304# auto-generate the exported symbol list, leveraging the WOLFSSL_API visibility tags.
309305# exclude symbols that don't match wc_* or wolf*.
310306$(obj ) /linuxkm/module_exports.c : $(src ) /module_exports.c.template $(WOLFSSL_OBJ_TARGETS ) $(obj ) /linuxkm/module_hooks.o
307+ @$(RENAME_PIE_TEXT_AND_DATA_SECTIONS )
311308 @cp $< $@ || exit $$?
312309 if [[ " $$ {VERSION}" -gt 6 || (" $$ {VERSION}" -eq 6 && " $$ {PATCHLEVEL}" -ge 13) ]]; then
313310 # use ASCII octal escape to avoid syntax disruption in the awk script.
0 commit comments