good explanation of __read_mostly, __init, __exit macros,
Mulyadi Santosa
mulyadi.santosa at gmail.com
Mon Jul 16 15:03:22 EDT 2012
Hi :)
On Tue, Jul 17, 2012 at 1:49 AM, Aft nix <aftnix at gmail.com> wrote:
> This special section, "data..read_mostly" , is it maintained by
> kernel?
by maintained, you mean allocated? then yes....
> then Linker has to know this information. How that is done?
it is provided by the linker script.... the fastest I can find is in
directory include/asm-generic/vmlinux.lds.h. This file is not final
linker script, it's kinda a "template" that will be further modified
by Kbuild (I guess)
> I mean lets say a.c is compiled into a.o. a.o already has the offsets
> for its data. Linker resolves the final address. So how the linker is
> invoked
> in a way so that this data flagged with __read__mostly will end up in
> the special section?
it's actually the same like putting your initialized variable in .data
section, your code in .text and so on. I just get the big picture that
it is done by creating section in the object file. By section, I think
it's simply done by creating a mark to denote the section.
please kindly study ELF documentation for further info
> Thing is, i'm getting the idea what these macros mean, but not
> understanding the mechanisms behind them.
the whole chain is complex actually, but try to get the simple view
first. it's a grouping, read mostly data into a section/group in a
file (in this case, kernel image), kernel loaded.....kernel arrange
itself..put appropriate section into related addresses....done
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
More information about the Kernelnewbies
mailing list