A question about uninitializing static variables
Hi.
One of the tasks at http://janitor.kernelnewbies.org/TODO
is described as
"
uninitialize static variables initialized to 0, to make it go to the .bss, instead of .data.
"
I made two patches for two maintainers which uninitialize some static int used as module parameters and actually initialized to 0.
One maintainer do not have problems with the patches but the maintainer of the file the second patch refers to would like to have some kind of "proof" that "it is still guaranteed that those variables will be initialized to 0". I wrote him something like "this simple hello module shows it is still guaranteed..." but it's not enough for him. I guess he'd like a more formal explanation of the following statement:
An uninitialized static variable of {the kernel, a kernel module} will be compiled to go to the .bss and it is guaranteed that will be "zero-ed" there.
Is there someone with a link or something I could send to this maintainer to show him the reasons why the previous statement is true? Maybe it could be useful to put this reference in the TODO itself.
Thanks.
Signature · 6 lines
Carlo Perassi - http://www.linux.it/~carlo/ _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
Using the symbol table display tools like objcmp or nm on the object file should show what section the symbol is allocated in after a link. By definition .bss is always zero'ed by the implementation. If they can see all of the symbols in this category allocated in .bss, that should be enough.
Thanks,
Dave Howell
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Carlo Perassi
Sent: Tuesday, March 29, 2005 9:31 AM
To: [email protected]
Subject: [KJ] A question about uninitializing static variables
Hi.
One of the tasks at http://janitor.kernelnewbies.org/TODO
is described as
"
uninitialize static variables initialized to 0, to make it go to the .bss, instead of .data.
"
I made two patches for two maintainers which uninitialize some static int used as module parameters and actually initialized to 0.
One maintainer do not have problems with the patches but the maintainer of the file the second patch refers to would like to have some kind of "proof" that "it is still guaranteed that those variables will be initialized to 0". I wrote him something like "this simple hello module shows it is still guaranteed..." but it's not enough for him. I guess he'd like a more formal explanation of the following statement:
An uninitialized static variable of {the kernel, a kernel module} will be compiled to go to the .bss and it is guaranteed that will be "zero-ed" there.
Is there someone with a link or something I could send to this maintainer to show him the reasons why the previous statement is true? Maybe it could be useful to put this reference in the TODO itself.
Thanks.
Signature · 6 lines
Carlo Perassi - http://www.linux.it/~carlo/ _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
the default for gcc is `-fzero-initialized-in-bss', the kernel makefile does not change this therefore bss is zeroed, this is documented in the gcc manpage.
Tom
Quoted 29 lines · Carlo Perassi
Hi.
One of the tasks at http://janitor.kernelnewbies.org/TODO
is described as"
uninitialize static variables initialized to 0, to make it go to the .bss, instead of .data.
"I made two patches for two maintainers which uninitialize some static int used as module parameters and actually initialized to 0.
One maintainer do not have problems with the patches but the maintainer of the file the second patch refers to would like to have some kind of "proof" that "it is still guaranteed that those variables will be initialized to 0". I wrote him something like "this simple hello module shows it is still guaranteed..." but it's not enough for him. I guess he'd like a more formal explanation of the following statement:
An uninitialized static variable of {the kernel, a kernel module} will be compiled to go to the .bss and it is guaranteed that will be "zero-ed" there.
Is there someone with a link or something I could send to this maintainer to show him the reasons why the previous statement is true? Maybe it could be useful to put this reference in the TODO itself.
Thanks.
Quoted 8 lines
--
Carlo Perassi - http://www.linux.it/~carlo/_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 1 line
Hi.
Thank you all for your answers.
The maintainer will integrate the patch.
Signature · 1 line
Carlo Perassi - http://www.linux.it/~carlo/
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors