diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2003-01-02 06:13:46 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-01-02 06:13:46 -0800 |
| commit | e4d188bb04361ae4c1f2a51db1f76a316ea5b31c (patch) | |
| tree | 2a181795ee8649c938b4d684b07112920916f42d /kernel | |
| parent | 85b09bd807adc566ddff04adcbe2f233c0e5c64e (diff) | |
[PATCH] Use sh_entsize for ELF section offsets
sh_link is a 32-bit field on 64 bit archs, so a bad choice to store
module section offsets, and also INIT_OFFSET_MASK is out of range.
So switch to using sh_entsize instead.
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/module.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/kernel/module.c b/kernel/module.c index 680deb635e30..ff961f21135f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -880,7 +880,7 @@ static long get_offset(unsigned long *size, Elf_Shdr *sechdr) /* 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_link fields: high bit means it + 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, @@ -896,7 +896,7 @@ static void layout_sections(struct module *mod, unsigned int m, i; for (i = 0; i < hdr->e_shnum; i++) - sechdrs[i].sh_link = ~0UL; + sechdrs[i].sh_entsize = ~0UL; DEBUGP("Core section allocation order:\n"); for (m = 0; m < ARRAY_SIZE(masks); ++m) { @@ -905,10 +905,10 @@ static void layout_sections(struct module *mod, if ((s->sh_flags & masks[m][0]) != masks[m][0] || (s->sh_flags & masks[m][1]) - || s->sh_link != ~0UL + || s->sh_entsize != ~0UL || strstr(secstrings + s->sh_name, ".init")) continue; - s->sh_link = get_offset(&mod->core_size, s); + s->sh_entsize = get_offset(&mod->core_size, s); DEBUGP("\t%s\n", name); } } @@ -920,11 +920,11 @@ static void layout_sections(struct module *mod, if ((s->sh_flags & masks[m][0]) != masks[m][0] || (s->sh_flags & masks[m][1]) - || s->sh_link != ~0UL + || s->sh_entsize != ~0UL || !strstr(secstrings + s->sh_name, ".init")) continue; - s->sh_link = (get_offset(&mod->init_size, s) - | INIT_OFFSET_MASK); + s->sh_entsize = (get_offset(&mod->init_size, s) + | INIT_OFFSET_MASK); DEBUGP("\t%s\n", name); } } @@ -1066,7 +1066,7 @@ static struct module *load_module(void *umod, if (err < 0) goto free_mod; - /* Determine total sizes, and put offsets in sh_link. For now + /* Determine total sizes, and put offsets in sh_entsize. For now this is done generically; there doesn't appear to be any special cases for the architectures. */ layout_sections(mod, hdr, sechdrs, secstrings); @@ -1095,11 +1095,11 @@ static struct module *load_module(void *umod, if (!(sechdrs[i].sh_flags & SHF_ALLOC)) continue; - if (sechdrs[i].sh_link & INIT_OFFSET_MASK) + if (sechdrs[i].sh_entsize & INIT_OFFSET_MASK) dest = mod->module_init - + (sechdrs[i].sh_link & ~INIT_OFFSET_MASK); + + (sechdrs[i].sh_entsize & ~INIT_OFFSET_MASK); else - dest = mod->module_core + sechdrs[i].sh_link; + dest = mod->module_core + sechdrs[i].sh_entsize; if (sechdrs[i].sh_type != SHT_NOBITS) memcpy(dest, (void *)sechdrs[i].sh_addr, |
