History

objtool/klp: Add .klp.symid for sympos disambiguation

Livepatch identifies a duplicate-named symbol by its position (sympos) among same-named kallsyms entries, which for vmlinux are counted in ascending address order in the final linked kernel. That order can't be reliably derived from vmlinux.o: the final link reorders sub-sections (.text.unlikely*, .data..*, etc). Bridge the gap with a new .klp.symid section which can be used to correlate symbols between vmlinux.o and vmlinux so that klp-diff can reliably determine the sympos. The table can't survive --gc-sections: keeping it alive would keep every duplicate-named symbol's section alive, so the reference kernel would stop matching the one which ships. klp-build rejects CONFIG_LD_DEAD_CODE_DATA_ELIMINATION instead. Nothing is lost today: x86_64 is the only HAVE_KLP_BUILD arch and doesn't select HAVE_LD_DEAD_CODE_DATA_ELIMINATION, arm64 and s390 have never selected it either, and on powerpc, it's still EXPERIMENTAL and disabled by every distro kernel. This is the build-time half of reliable vmlinux sympos computation; "objtool klp diff" will consume the table in a subsequent commit.

Josh Poimboeuf committed 3 months ago

Commit 029223d1 parent f5f762f10 files · +166 −1Browse files

Showing the changes to scripts/livepatch (1 of 10 files). Show all

Unified · Split

scripts/livepatch/klp-build+5−0
@@ -271,6 +271,9 @@ validate_config() { · 270 unmodified lines
271 [[ -v CONFIG_GCC_PLUGIN_RANDSTRUCT ]] && \271 [[ -v CONFIG_GCC_PLUGIN_RANDSTRUCT ]] && \
272 die "kernel option 'CONFIG_GCC_PLUGIN_RANDSTRUCT' not supported"272 die "kernel option 'CONFIG_GCC_PLUGIN_RANDSTRUCT' not supported"
273 273
274 [[ -v CONFIG_LD_DEAD_CODE_DATA_ELIMINATION ]] && \
275 die "kernel option 'CONFIG_LD_DEAD_CODE_DATA_ELIMINATION' not supported"
276
274 [[ -v CONFIG_AS_IS_LLVM ]] && \277 [[ -v CONFIG_AS_IS_LLVM ]] && \
275 [[ "$CONFIG_AS_VERSION" -lt 200000 ]] && \278 [[ "$CONFIG_AS_VERSION" -lt 200000 ]] && \
276 die "Clang assembler version < 20 not supported"279 die "Clang assembler version < 20 not supported"
@@ -555,6 +558,8 @@ build_kernel() { · 278 unmodified lines
555 #558 #
556 cmd+=("KBUILD_MODPOST_WARN=1")559 cmd+=("KBUILD_MODPOST_WARN=1")
557 560
561 cmd+=("KLP_SYMIDS=1")
562
558 if [[ -v VERBOSE ]]; then563 if [[ -v VERBOSE ]]; then
559 cmd+=("V=1")564 cmd+=("V=1")
560 else565 else

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