* [PATCH] um: fix CONFIG_GCOV for built-in code
@ 2026-07-27 19:55 Alex Hung
2026-08-10 13:51 ` Alex Hung
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alex Hung @ 2026-07-27 19:55 UTC (permalink / raw)
To: richard, anton.ivanov, johannes, alex.hung, linux-um
From: Johannes Berg <johannes@sipsolutions.net>
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>
---
This is a revived patch. The original can be found at
https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06608.html
arch/um/include/asm/common.lds.S | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S
index fd481ac371de..2ed213913afe 100644
--- a/arch/um/include/asm/common.lds.S
+++ b/arch/um/include/asm/common.lds.S
@@ -91,6 +91,7 @@
.fini_array : {
__fini_array_start = .;
*(.fini_array)
+ *(.fini_array.*)
__fini_array_end = .;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] um: fix CONFIG_GCOV for built-in code
2026-07-27 19:55 [PATCH] um: fix CONFIG_GCOV for built-in code Alex Hung
@ 2026-08-10 13:51 ` Alex Hung
2026-08-21 15:25 ` Alex Hung
2026-09-23 5:05 ` Mariia Nikitash
2026-09-24 3:42 ` Kees Cook
2 siblings, 1 reply; 6+ messages in thread
From: Alex Hung @ 2026-08-10 13:51 UTC (permalink / raw)
To: richard, anton.ivanov, johannes, linux-um; +Cc: alex.hung
Hi,
Any comments or concerns on this patch? Is it ready to be merged?
On 7/27/26 13:55, Alex Hung wrote:
> From: Johannes Berg <johannes@sipsolutions.net>
>
> 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>
> ---
>
> This is a revived patch. The original can be found at
> https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06608.html
>
> arch/um/include/asm/common.lds.S | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S
> index fd481ac371de..2ed213913afe 100644
> --- a/arch/um/include/asm/common.lds.S
> +++ b/arch/um/include/asm/common.lds.S
> @@ -91,6 +91,7 @@
> .fini_array : {
> __fini_array_start = .;
> *(.fini_array)
> + *(.fini_array.*)
> __fini_array_end = .;
> }
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] um: fix CONFIG_GCOV for built-in code
2026-08-10 13:51 ` Alex Hung
@ 2026-08-21 15:25 ` Alex Hung
0 siblings, 0 replies; 6+ messages in thread
From: Alex Hung @ 2026-08-21 15:25 UTC (permalink / raw)
To: richard, anton.ivanov, johannes, linux-um
Ping for comments for this patch. Is it possible to merge for kernel 7.3
if there are no concerns?
On 8/10/26 07:51, Alex Hung wrote:
> Hi,
>
> Any comments or concerns on this patch? Is it ready to be merged?
>
> On 7/27/26 13:55, Alex Hung wrote:
>> From: Johannes Berg <johannes@sipsolutions.net>
>>
>> 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>
>> ---
>>
>> This is a revived patch. The original can be found at
>> https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06608.html
>>
>> arch/um/include/asm/common.lds.S | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/
>> common.lds.S
>> index fd481ac371de..2ed213913afe 100644
>> --- a/arch/um/include/asm/common.lds.S
>> +++ b/arch/um/include/asm/common.lds.S
>> @@ -91,6 +91,7 @@
>> .fini_array : {
>> __fini_array_start = .;
>> *(.fini_array)
>> + *(.fini_array.*)
>> __fini_array_end = .;
>> }
>>
>> --
>> 2.43.0
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] um: fix CONFIG_GCOV for built-in code
2026-07-27 19:55 [PATCH] um: fix CONFIG_GCOV for built-in code Alex Hung
2026-08-10 13:51 ` Alex Hung
@ 2026-09-23 5:05 ` Mariia Nikitash
2026-09-24 3:42 ` Kees Cook
2 siblings, 0 replies; 6+ messages in thread
From: Mariia Nikitash @ 2026-09-23 5:05 UTC (permalink / raw)
To: richard, anton.ivanov, johannes, alex.hung, linux-um; +Cc: Mariia Nikitash
Hi Alex,
I tested this while investigating GCC/GCOV coverage under UML using KUnit.
Tested on:
Architecture: x86_64 UML
Kernel: v7.3-rc3-61-gbc77531b2a6f
KUnit configs: default.config + coverage_uml.config
Compilers: GCC 13.3.0 and GCC 16.2.0
With GCC 13.3, the unpatched tree produced 731 .gcno files and
0 .gcda files after the KUnit run. With the patch applied, the
same run produced 731 .gcno files and 704 .gcda files, and LCOV
was able to generate coverage successfully.
I also reproduced the same result with GCC 16.2:
without patch: 731 .gcno / 0 .gcda
with patch: 731 .gcno / 704 .gcda
LCOV coverage generation also completed successfully with GCC 16.2.
Tested-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
Thanks,
Mariia
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] um: fix CONFIG_GCOV for built-in code
2026-07-27 19:55 [PATCH] um: fix CONFIG_GCOV for built-in code Alex Hung
2026-08-10 13:51 ` Alex Hung
2026-09-23 5:05 ` Mariia Nikitash
@ 2026-09-24 3:42 ` Kees Cook
2026-09-28 18:09 ` Johannes Berg
2 siblings, 1 reply; 6+ messages in thread
From: Kees Cook @ 2026-09-24 3:42 UTC (permalink / raw)
To: richard, anton.ivanov, johannes, linux-um, Alex Hung,
Mariia Nikitash
Cc: Kees Cook
On Mon, 27 Jul 2026 13:55:15 -0600, Alex Hung wrote:
> 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.
>
> [...]
Applied to for-next/hardening, thanks! Only a 5 year delay. :P
What else is needed from the original series to get the full coverage?
https://lore.kernel.org/all/20210312095526.197739-1-johannes@sipsolutions.net/
[1/1] um: fix CONFIG_GCOV for built-in code
https://git.kernel.org/kees/c/760f96b7f54b
Take care,
-Kees
--
Kees Cook
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-28 18:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 19:55 [PATCH] um: fix CONFIG_GCOV for built-in code Alex Hung
2026-08-10 13:51 ` Alex Hung
2026-08-21 15:25 ` Alex Hung
2026-09-23 5:05 ` Mariia Nikitash
2026-09-24 3:42 ` Kees Cook
2026-09-28 18:09 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox