struct load_info 中的字段 strmap 的含义是什么?

发布于 2024-11-14 07:17:26 字数 394 浏览 2 评论 0原文

我正在研究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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌伤ぢ 2024-11-21 07:17:26

(我在 LWN 上找不到任何内容。这是代码的部分分析。请注意,在引入 struct load_info 之前,strmap 作为单独的变量存在。 )

strtab 包含一堆连接在一起的以 null 结尾的字符串。例如,它可能包含此内容,其中 . 代表空字符:

foo.bar.quux.corge.
0123456789012345678

layout_symtabstrmap用于判断strtab中哪些块对应于核心符号循环设置的第j位strtab 每当第 j 个字符是核心符号名称的一部分时。例如,根据上表,如果 barcorge 是核心符号,则位 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 before struct 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:

foo.bar.quux.corge.
0123456789012345678

In layout_symtab, strmap is used to determine which chunks of strtab correspond to core symbols. The loop sets the jth bit of strtab whenever the jth character is part of the name of a core symbol. For example, given the table above, if bar and corge 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 table mod->symtab by copying only the bytes of strtab for which the corresponding bit in strmap is set. In the example above, the new table would contain bar.corge..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文