- 论坛徽章:
- 9
|
这个很明显是挪用,因为这个字段作为标准是有意义的,但对内核来说没有意义。对于特性的程序,各个段的数据项大小早已是固定的大小的了,没必要从sh_entsize读回来,你想想,如果真读出来的值和内核对应的结构体长度不一样,内核情何以堪,接下去该如何处理??这是不可能的,因此sh_entsize这个值对内核没有意义。
因此挪用来存在这个段在CORE里头的偏移量。CORE这个空间是内核自己弄出来的,得找个地方存着它和每个需要分配内存(SHF_ALLOC)的段的关系。
从下面代码段可以看到,无论是数据项的个数或是数据项的大小,都没有从ELF上去获取。
static unsigned long layout_symtab(struct module *mod,
Elf_Shdr *sechdrs,
unsigned int symindex,
unsigned int strindex,
const Elf_Ehdr *hdr,
const char *secstrings,
unsigned long *pstroffs,
unsigned long *strmap)
{
unsigned long symoffs;
Elf_Shdr *symsect = sechdrs + symindex;
Elf_Shdr *strsect = sechdrs + strindex;
const Elf_Sym *src;
const char *strtab;
unsigned int i, nsrc, ndst;
/* Put symbol section at end of init part of module. */
symsect->sh_flags |= SHF_ALLOC;
symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
symindex) | INIT_OFFSET_MASK;
DEBUGP("\t%s\n", secstrings + symsect->sh_name);
src = (void *)hdr + symsect->sh_offset;
nsrc = symsect->sh_size / sizeof(*src); 《——————————————————————————
这种不按标准的小窍门是容把人给弄昏。
你也可以搜一下代码,sh_entsize这个值,内核重来就没有当过是每项大小用过。
|
|