- 论坛徽章:
- 4
|
5可用积分
本帖最后由 chishanmingshen 于 2014-03-22 19:24 编辑
公认:"sh_entsize: 有些section包含的是一组固定大小表项的表,例如符号表,对于这样的section,该成员给出了每个表项的尺寸大小。如果section不包括这样的内容,则该值为0 。"
可是看代码,这个字段一直表示的都是该section相对于CORE/INIT section的偏移啊。。。难道只是临时的?
求指点,谢谢!
from 3.12.14- /* Lay out the SHF_ALLOC sections in a way not dissimilar to how ld
- might -- code, read-only data, read-write data, small data. Tally
- sizes, and place the offsets into sh_entsize fields: high bit means it
- belongs in init. */
- static void layout_sections(struct module *mod, const Elf_Ehdr * hdr,
- Elf_Shdr * sechdrs, const char *secstrings)
- {
- static unsigned long const masks[][2] = {
- /* NOTE: all executable code must be the first section
- * in this array; otherwise modify the text_size
- * finder in the two loops below */
- {SHF_EXECINSTR | SHF_ALLOC, ARCH_SHF_SMALL},
- {SHF_ALLOC, SHF_WRITE | ARCH_SHF_SMALL},
- {SHF_WRITE | SHF_ALLOC, ARCH_SHF_SMALL},
- {ARCH_SHF_SMALL | SHF_ALLOC, 0}
- };
- unsigned int m, i;
- for (i = 0; i < hdr->e_shnum; i++)
- sechdrs[i].sh_entsize = ~0UL;
- for (m = 0; m < ARRAY_SIZE(masks); ++m) {
- for (i = 0; i < hdr->e_shnum; ++i) {
- Elf_Shdr *s = &sechdrs[i];
- // || strncmp(secstrings + s->sh_name, ".init", 5) == 0)
- if ((s->sh_flags & masks[m][0]) != masks[m][0]
- || (s->sh_flags & masks[m][1])
- || s->sh_entsize != ~0UL)
- continue;
- s->sh_entsize =《----------------------------------------------------------
- get_offset((unsigned long *)&mod->core_size, s);
- }
- if (m == 0)
- mod->core_text_size = mod->core_size;
- }
- }
复制代码 求解,谢谢! |
最佳答案
查看完整内容
这个很明显是挪用,因为这个字段作为标准是有意义的,但对内核来说没有意义。对于特性的程序,各个段的数据项大小早已是固定的大小的了,没必要从sh_entsize读回来,你想想,如果真读出来的值和内核对应的结构体长度不一样,内核情何以堪,接下去该如何处理??这是不可能的,因此sh_entsize这个值对内核没有意义。因此挪用来存在这个段在CORE里头的偏移量。CORE这个空间是内核自己弄出来的,得找个地方存着它和每个需要分配内存( ...
|