Thread (11 messages) 11 messages, 6 authors, 2012-07-17

good explanation of __read_mostly, __init, __exit macros,

From: Mulyadi Santosa <hidden>
Date: 2012-07-16 19:03:22

Hi :)

On Tue, Jul 17, 2012 at 1:49 AM, Aft nix [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help