Re: Re: [PATCH v2] init/gcov: allow CONFIG_CONSTRUCTORS on UML to fix module gcov

From: lambertdev@xxxxxxxxx
Date: Mon May 10 2021 - 09:56:37 EST


Hi Johannes,

My original Email address is blocked by the server of kernel.org,
so I have to change an Email address. Please see my reply inline.

>Hi,


>



>> Hi Johannes and Peter, sorry to bother but I have one question



>> on this change. The do_ctors() won’t be executed for UML



>> because  *the constructors have already been called for ELF*.



>>



>> *__ctors_start*  and  *__ctors_end* symbols. See link:



>> https://elixir.bootlin.com/linux/v5.12.2/source/include/asm-generic/vmlinux.lds.h#L676



>>



>> In my environment, UML+GCC 10, I can't find __gcov_init executed



>> before kernel starts. So I did some trace and found glibc



>> __libc_csu_init



>> will only execute constructors between *__init_array_start*and



>> *__init_array_end*. 



>> Which means if do_ctors() is not executed for UML, no elsewhere will



>> the constructors be executed.



>>



>> Shall we remove the *!defined(CONFIG_UML)* for GCC, or I just missed



>> some steps to make the GCOV work for UML?



>



>No, that doesn't seem like the right solution.


>



>Perhaps then with that toolchain (or configuration thereof) we need to



>provide __init_array_start/end labels?


Yes, that's how I worked around in my local environment
(change linker script to add _init_array_start/end labels).
So the __gcov_init is called before start_kernel.


>



>Or ... maybe that actually just needs to be removed, so that the



>toolchain gets to choose?



>



>Hmm. Pretty sure it worked for me, I think also with gcc 10, but not



>sure exactly where I tested.


I will make sure my environment is clean and try again.
Could you please use gdb to check when __gcov_init is called in your setup?
e.g.
(1) gdb *your uml elf*
(2) b __gcov_init
(3) r
(4) when the execution is breaked, use 'bt' to check the call stack
Thanks

Lambert

>



>johannes



>



>



>