um: fix CONFIG_GCOV for built-in code

With contemporary toolchains, CONFIG_GCOV doesn't work because
gcov now relies on both init and exit handlers, but those are
discarded from the binary. Fix the linker scripts to keep them
instead, so that CONFIG_GCOV can work again.

Note that this does not make it work in modules yet, since we
don't call their exit handlers.

Note: the .init_array.* wildcard and the RUNTIME_DISCARD_EXIT
define are already present in this tree; only the matching
.fini_array.* wildcard remained to be added.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
Link: https://patch.msgid.link/20260727195515.2306731-1-alex.hung@amd.com
Signed-off-by: Kees Cook <kees@kernel.org>
This commit is contained in:
Johannes Berg 2026-07-27 13:55:15 -06:00 committed by Kees Cook
parent 6e72cefa7a
commit 760f96b7f5

View File

@ -91,6 +91,7 @@
.fini_array : {
__fini_array_start = .;
*(.fini_array)
*(.fini_array.*)
__fini_array_end = .;
}