Subject: Re: sh_link
In-reply-to: Your message of "Thu, 02 Jan 2003 20:40:23 -0800."
<[email protected]>
In message <[email protected]> you write:
Quoted 5 lines · Rusty Russell
Quoted 1 line
F... bugger. Hmm...
sh_entsize? orsh_addralign?*shrug* Prolly nothing uses
sh_entsize, and you don't have the ordering issues you'd have with addralgin.
Ack. Linus, please apply (sh_link is a 32-bit field on 64 bit archs, so a bad choice to store offsets, and also INIT_OFFSET_MASK is out of range).
Andi, you'll want this most.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
kernel/module.c +11 -11
@@ -880,7 +880,7 @@ static long get_offset(unsigned long *si/* 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 modulunsigned 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 modulif ((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 modulif ((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 *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 *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,