History

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

Peter Zijlstra committed 4 years ago

Commit b341b201 parent 9f2899f2 files · +5 −0Browse files

Unified · Split

2 files
  1. arch/x86/Kconfig +4 −0
  2. scripts/Makefile.lib +1 −0
arch/x86/Kconfig+4−0
@@ -2471,6 +2471,10 @@ config CALL_THUNKS · 2470 unmodified lines
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+1−0
@@ -265,6 +265,7 @@ objtool-args-$(CONFIG_STACK_VALIDATION) += --stackval · 264 unmodified lines
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) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t