struct load_info 中的字段 strmap 的含义是什么?
我正在研究linux内核内部模块加载的机制,并且我被struct load_info
内部字段strmap
的含义所困扰。
该结构体在在kernel/module.c
并且该字段填充
kernel/module.c
。我知道这是一个位图,但我无法弄清楚各个位的含义。
I'm studying the mechanism of module loading inside the linux kernel, and I'm stuck at the meaning of the field strmap
inside the struct load_info
.
The struct is defined in kernel/module.c
and the field is filled in kernel/module.c
. I know it is a bitmap, but I can't figure out the meaning of the individual bits.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(我在 LWN 上找不到任何内容。这是代码的部分分析。请注意,在引入
struct load_info
之前,strmap
作为单独的变量存在。 )strtab
包含一堆连接在一起的以 null 结尾的字符串。例如,它可能包含此内容,其中.
代表空字符:在
layout_symtab
,strmap
用于判断strtab
中哪些块对应于核心符号。 循环设置的第j位strtab 每当第 j 个字符是核心符号名称的一部分时。例如,根据上表,如果
bar
和corge
是核心符号,则位 4-7 和 13-18 将设置为 1。在
add_kallsyms
,第二个循环计算内核名称的总长度符号,第三个循环复制核心通过仅复制在strmap
中设置了相应位的strtab
字节,将符号复制到新表mod->symtab
中。在上面的示例中,新表将包含bar.corge.
。(I couldn't find anything on LWN. This is a partial analysis of the code. Note that
strmap
existed as a separate variable beforestruct load_info
was introduced.)strtab
contains a bunch of null-terminated strings concatenated together. E.g. it might contain this, where.
stands for a null character:In
layout_symtab
,strmap
is used to determine which chunks ofstrtab
correspond to core symbols. The loop sets the jth bit ofstrtab
whenever the jth character is part of the name of a core symbol. For example, given the table above, ifbar
andcorge
are core symbols then bits 4–7 and 13–18 are set to 1.In
add_kallsyms
, the second loop computes the total length of the names of the core symbols, and the third loop copies the core symbols into a new tablemod->symtab
by copying only the bytes ofstrtab
for which the corresponding bit instrmap
is set. In the example above, the new table would containbar.corge.
.