mirror-linux/kernel/livepatch
Petr Pavlu ab10815472 livepatch: Fix having __klp_objects relics in non-livepatch modules
The linker script scripts/module.lds.S specifies that all input
__klp_objects sections should be consolidated into an output section of
the same name, and start/stop symbols should be created to enable
scripts/livepatch/init.c to locate this data.

This start/stop pattern is not ideal for modules because the symbols are
created even if no __klp_objects input sections are present.
Consequently, a dummy __klp_objects section also appears in the
resulting module. This unnecessarily pollutes non-livepatch modules.

Instead, since modules are relocatable files, the usual method for
locating consolidated data in a module is to read its section table.
This approach avoids the aforementioned problem.

The klp_modinfo already stores a copy of the entire section table with
the final addresses. Introduce a helper function that
scripts/livepatch/init.c can call to obtain the location of the
__klp_objects section from this data.

Fixes: dd590d4d57 ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Reviewed-by: Aaron Tomlin <atomlin@atomlin.com>
Link: https://patch.msgid.link/20260123102825.3521961-2-petr.pavlu@suse.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
2026-02-05 08:00:44 -08:00
..
Kconfig livepatch: Add CONFIG_KLP_BUILD 2025-10-14 14:50:18 -07:00
Makefile livepatch: Basic API to track system state changes 2019-11-01 13:08:14 +01:00
core.c livepatch: Fix having __klp_objects relics in non-livepatch modules 2026-02-05 08:00:44 -08:00
core.h livepatch: Keep replaced patches until post_patch callback is called 2019-11-01 13:08:08 +01:00
patch.c livepatch: Rename KLP_* to KLP_TRANSITION_* 2024-05-09 15:48:01 +02:00
patch.h livepatch: Remove Nop structures when unused 2019-01-11 20:51:24 +01:00
shadow.c Documentation: livepatch: Add livepatch API page 2021-12-23 11:35:53 +01:00
state.c kernel/: fix repeated words in comments 2020-10-16 11:11:19 -07:00
state.h livepatch: Allow to distinguish different version of system state changes 2019-11-01 13:08:19 +01:00
transition.c sched,livepatch: Untangle cond_resched() and live-patching 2025-05-14 13:16:24 +02:00
transition.h livepatch: Remove signal sysfs attribute 2019-01-16 22:09:33 +01:00