Skip to content

Commit b341b20

Browse files
author
Peter Zijlstra
committed
x86: Add prefix symbols for function padding
When code is compiled with: -fpatchable-function-entry=${PADDING_BYTES},${PADDING_BYTES} functions will have PADDING_BYTES of NOP in front of them. Unwinders and other things that symbolize code locations will typically attribute these bytes to the preceding function. Given that these bytes nominally belong to the following symbol this mis-attribution is confusing. Inspired by the fact that CFI_CLANG emits __cfi_##name symbols to claim these bytes, use objtool to emit __pfx_##name symbols to do the same when CFI_CLANG is not used. This then shows the callthunk for symbol 'name' as: __pfx_##name+0x6/0x10 Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Yujie Liu <yujie.liu@intel.com> Link: https://lkml.kernel.org/r/20221028194453.592512209@infradead.org
1 parent 9f2899f commit b341b20

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

arch/x86/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,6 +2471,10 @@ config CALL_THUNKS
24712471
def_bool n
24722472
select FUNCTION_ALIGNMENT_16B
24732473

2474+
config PREFIX_SYMBOLS
2475+
def_bool y
2476+
depends on CALL_THUNKS && !CFI_CLANG
2477+
24742478
menuconfig SPECULATION_MITIGATIONS
24752479
bool "Mitigations for speculative execution vulnerabilities"
24762480
default y

scripts/Makefile.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ objtool-args-$(CONFIG_STACK_VALIDATION) += --stackval
265265
objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call
266266
objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess
267267
objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable
268+
objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES)
268269

269270
objtool-args = $(objtool-args-y) \
270271
$(if $(delay-objtool), --link) \

0 commit comments

Comments
 (0)