Commit 18f7a1ae authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] Modules 2/3: Use sh_addr instead of sh_offset

From: Richard Henderson <rth@twiddle.net>

Richard points out that we should be using sh_addr to hold the address,

The original patch used to overload sh_offset to a pointer to the
location of the section.  This uses sh_addr, which is more correct
and less surprising.
parent dfe2cbd1
...@@ -88,7 +88,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, ...@@ -88,7 +88,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
Elf32_Shdr *symsec = sechdrs + symindex; Elf32_Shdr *symsec = sechdrs + symindex;
Elf32_Shdr *relsec = sechdrs + relindex; Elf32_Shdr *relsec = sechdrs + relindex;
Elf32_Shdr *dstsec = sechdrs + relsec->sh_info; Elf32_Shdr *dstsec = sechdrs + relsec->sh_info;
Elf32_Rel *rel = (void *)relsec->sh_offset; Elf32_Rel *rel = (void *)relsec->sh_addr;
unsigned int i; unsigned int i;
for (i = 0; i < relsec->sh_size / sizeof(Elf32_Rel); i++, rel++) { for (i = 0; i < relsec->sh_size / sizeof(Elf32_Rel); i++, rel++) {
...@@ -103,7 +103,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, ...@@ -103,7 +103,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
return -ENOEXEC; return -ENOEXEC;
} }
sym = ((Elf32_Sym *)symsec->sh_offset) + offset; sym = ((Elf32_Sym *)symsec->sh_addr) + offset;
if (!sym->st_value) { if (!sym->st_value) {
printk(KERN_WARNING "%s: unknown symbol %s\n", printk(KERN_WARNING "%s: unknown symbol %s\n",
module->name, strtab + sym->st_name); module->name, strtab + sym->st_name);
...@@ -118,7 +118,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, ...@@ -118,7 +118,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
return -ENOEXEC; return -ENOEXEC;
} }
loc = dstsec->sh_offset + rel->r_offset; loc = dstsec->sh_addr + rel->r_offset;
switch (ELF32_R_TYPE(rel->r_info)) { switch (ELF32_R_TYPE(rel->r_info)) {
case R_ARM_ABS32: case R_ARM_ABS32:
......
...@@ -68,7 +68,7 @@ int apply_relocate(Elf32_Shdr *sechdrs, ...@@ -68,7 +68,7 @@ int apply_relocate(Elf32_Shdr *sechdrs,
struct module *me) struct module *me)
{ {
unsigned int i; unsigned int i;
Elf32_Rel *rel = (void *)sechdrs[relsec].sh_offset; Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
Elf32_Sym *sym; Elf32_Sym *sym;
uint32_t *location; uint32_t *location;
...@@ -76,10 +76,10 @@ int apply_relocate(Elf32_Shdr *sechdrs, ...@@ -76,10 +76,10 @@ int apply_relocate(Elf32_Shdr *sechdrs,
sechdrs[relsec].sh_info); sechdrs[relsec].sh_info);
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
/* This is where to make the change */ /* This is where to make the change */
location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_offset location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rel[i].r_offset; + rel[i].r_offset;
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (Elf32_Sym *)sechdrs[symindex].sh_offset sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
+ ELF32_R_SYM(rel[i].r_info); + ELF32_R_SYM(rel[i].r_info);
if (!sym->st_value) { if (!sym->st_value) {
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
......
...@@ -176,7 +176,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -176,7 +176,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
struct module *module) struct module *module)
{ {
unsigned int i; unsigned int i;
Elf32_Rela *rela = (void *)sechdrs[relsec].sh_offset; Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;
Elf32_Sym *sym; Elf32_Sym *sym;
uint32_t *location; uint32_t *location;
uint32_t value; uint32_t value;
...@@ -185,10 +185,10 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -185,10 +185,10 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
sechdrs[relsec].sh_info); sechdrs[relsec].sh_info);
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rela); i++) { for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rela); i++) {
/* This is where to make the change */ /* This is where to make the change */
location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_offset location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rela[i].r_offset; + rela[i].r_offset;
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (Elf32_Sym *)sechdrs[symindex].sh_offset sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
+ ELF32_R_SYM(rela[i].r_info); + ELF32_R_SYM(rela[i].r_info);
if (!sym->st_value) { if (!sym->st_value) {
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
......
...@@ -78,7 +78,7 @@ int apply_relocate(Elf_Shdr *sechdrs, ...@@ -78,7 +78,7 @@ int apply_relocate(Elf_Shdr *sechdrs,
struct module *me) struct module *me)
{ {
unsigned int i; unsigned int i;
ElfW(Rel) *rel = (void *)sechdrs[relsec].sh_offset; ElfW(Rel) *rel = (void *)sechdrs[relsec].sh_addr;
ElfW(Sym) *sym; ElfW(Sym) *sym;
ElfW(Addr) *location; ElfW(Addr) *location;
...@@ -86,10 +86,10 @@ int apply_relocate(Elf_Shdr *sechdrs, ...@@ -86,10 +86,10 @@ int apply_relocate(Elf_Shdr *sechdrs,
sechdrs[relsec].sh_info); sechdrs[relsec].sh_info);
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
/* This is where to make the change */ /* This is where to make the change */
location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_offset location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rel[i].r_offset; + rel[i].r_offset;
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (ElfW(Sym) *)sechdrs[symindex].sh_offset sym = (ElfW(Sym) *)sechdrs[symindex].sh_addr
+ ELFW(R_SYM)(rel[i].r_info); + ELFW(R_SYM)(rel[i].r_info);
if (!sym->st_value) { if (!sym->st_value) {
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
......
...@@ -78,7 +78,7 @@ int apply_relocate(Elf_Shdr *sechdrs, ...@@ -78,7 +78,7 @@ int apply_relocate(Elf_Shdr *sechdrs,
struct module *me) struct module *me)
{ {
unsigned int i; unsigned int i;
ElfW(Rel) *rel = (void *)sechdrs[relsec].sh_offset; ElfW(Rel) *rel = (void *)sechdrs[relsec].sh_addr;
ElfW(Sym) *sym; ElfW(Sym) *sym;
ElfW(Addr) *location; ElfW(Addr) *location;
...@@ -86,10 +86,10 @@ int apply_relocate(Elf_Shdr *sechdrs, ...@@ -86,10 +86,10 @@ int apply_relocate(Elf_Shdr *sechdrs,
sechdrs[relsec].sh_info); sechdrs[relsec].sh_info);
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
/* This is where to make the change */ /* This is where to make the change */
location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_offset location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rel[i].r_offset; + rel[i].r_offset;
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (ElfW(Sym) *)sechdrs[symindex].sh_offset sym = (ElfW(Sym) *)sechdrs[symindex].sh_addr
+ ELFW(R_SYM)(rel[i].r_info); + ELFW(R_SYM)(rel[i].r_info);
if (!sym->st_value) { if (!sym->st_value) {
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
......
...@@ -71,7 +71,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -71,7 +71,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
struct module *me) struct module *me)
{ {
unsigned int i; unsigned int i;
Elf32_Rela *rel = (void *)sechdrs[relsec].sh_offset; Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr;
Elf32_Sym *sym; Elf32_Sym *sym;
u8 *location; u8 *location;
u32 *loc32; u32 *loc32;
...@@ -80,11 +80,11 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -80,11 +80,11 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
Elf32_Addr v; Elf32_Addr v;
/* This is where to make the change */ /* This is where to make the change */
location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_offset location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rel[i].r_offset; + rel[i].r_offset;
loc32 = (u32 *) location; loc32 = (u32 *) location;
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (Elf32_Sym *)sechdrs[symindex].sh_offset sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
+ ELF32_R_SYM(rel[i].r_info); + ELF32_R_SYM(rel[i].r_info);
if (!(v = sym->st_value)) { if (!(v = sym->st_value)) {
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
......
...@@ -178,7 +178,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -178,7 +178,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
struct module *me) struct module *me)
{ {
unsigned int i; unsigned int i;
Elf64_Rela *rel = (void *)sechdrs[relsec].sh_offset; Elf64_Rela *rel = (void *)sechdrs[relsec].sh_addr;
Elf64_Sym *sym; Elf64_Sym *sym;
u8 *location; u8 *location;
u32 *loc32; u32 *loc32;
...@@ -187,14 +187,14 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -187,14 +187,14 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
Elf64_Addr v; Elf64_Addr v;
/* This is where to make the change */ /* This is where to make the change */
location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_offset location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rel[i].r_offset; + rel[i].r_offset;
loc32 = (u32 *) location; loc32 = (u32 *) location;
BUG_ON(((u64)location >> (u64)32) != (u64)0); BUG_ON(((u64)location >> (u64)32) != (u64)0);
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (Elf64_Sym *)sechdrs[symindex].sh_offset sym = (Elf64_Sym *)sechdrs[symindex].sh_addr
+ ELF64_R_SYM(rel[i].r_info); + ELF64_R_SYM(rel[i].r_info);
if (!(v = sym->st_value)) { if (!(v = sym->st_value)) {
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
......
...@@ -160,7 +160,7 @@ int apply_relocate_add (Elf32_Shdr *sechdrs, const char *strtab, ...@@ -160,7 +160,7 @@ int apply_relocate_add (Elf32_Shdr *sechdrs, const char *strtab,
struct module *mod) struct module *mod)
{ {
unsigned int i; unsigned int i;
Elf32_Rela *rela = (void *)sechdrs[relsec].sh_offset; Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;
DEBUGP ("Applying relocate section %u to %u\n", relsec, DEBUGP ("Applying relocate section %u to %u\n", relsec,
sechdrs[relsec].sh_info); sechdrs[relsec].sh_info);
...@@ -168,11 +168,11 @@ int apply_relocate_add (Elf32_Shdr *sechdrs, const char *strtab, ...@@ -168,11 +168,11 @@ int apply_relocate_add (Elf32_Shdr *sechdrs, const char *strtab,
for (i = 0; i < sechdrs[relsec].sh_size / sizeof (*rela); i++) { for (i = 0; i < sechdrs[relsec].sh_size / sizeof (*rela); i++) {
/* This is where to make the change */ /* This is where to make the change */
uint32_t *loc uint32_t *loc
= ((void *)sechdrs[sechdrs[relsec].sh_info].sh_offset = ((void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rela[i].r_offset); + rela[i].r_offset);
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
Elf32_Sym *sym Elf32_Sym *sym
= ((Elf32_Sym *)sechdrs[symindex].sh_offset = ((Elf32_Sym *)sechdrs[symindex].sh_addr
+ ELF32_R_SYM (rela[i].r_info)); + ELF32_R_SYM (rela[i].r_info));
uint32_t val = sym->st_value; uint32_t val = sym->st_value;
......
...@@ -49,7 +49,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -49,7 +49,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
struct module *me) struct module *me)
{ {
unsigned int i; unsigned int i;
Elf64_Rela *rel = (void *)sechdrs[relsec].sh_offset; Elf64_Rela *rel = (void *)sechdrs[relsec].sh_addr;
Elf64_Sym *sym; Elf64_Sym *sym;
void *loc; void *loc;
u64 val; u64 val;
...@@ -58,11 +58,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -58,11 +58,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
sechdrs[relsec].sh_info); sechdrs[relsec].sh_info);
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
/* This is where to make the change */ /* This is where to make the change */
loc = (void *)sechdrs[sechdrs[relsec].sh_info].sh_offset loc = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ rel[i].r_offset; + rel[i].r_offset;
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (Elf64_Sym *)sechdrs[symindex].sh_offset sym = (Elf64_Sym *)sechdrs[symindex].sh_addr
+ ELF64_R_SYM(rel[i].r_info); + ELF64_R_SYM(rel[i].r_info);
if (!sym->st_value) { if (!sym->st_value) {
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
......
...@@ -94,7 +94,7 @@ static unsigned long find_local_symbol(Elf_Shdr *sechdrs, ...@@ -94,7 +94,7 @@ static unsigned long find_local_symbol(Elf_Shdr *sechdrs,
const char *name) const char *name)
{ {
unsigned int i; unsigned int i;
Elf_Sym *sym = (void *)sechdrs[symindex].sh_offset; Elf_Sym *sym = (void *)sechdrs[symindex].sh_addr;
/* Search (defined) internal symbols first. */ /* Search (defined) internal symbols first. */
for (i = 1; i < sechdrs[symindex].sh_size/sizeof(*sym); i++) { for (i = 1; i < sechdrs[symindex].sh_size/sizeof(*sym); i++) {
...@@ -810,7 +810,7 @@ static int handle_section(const char *name, ...@@ -810,7 +810,7 @@ static int handle_section(const char *name,
struct module *mod) struct module *mod)
{ {
int ret; int ret;
const char *strtab = (char *)sechdrs[strindex].sh_offset; const char *strtab = (char *)sechdrs[strindex].sh_addr;
switch (sechdrs[i].sh_type) { switch (sechdrs[i].sh_type) {
case SHT_REL: case SHT_REL:
...@@ -852,7 +852,7 @@ static int simplify_symbols(Elf_Shdr *sechdrs, ...@@ -852,7 +852,7 @@ static int simplify_symbols(Elf_Shdr *sechdrs,
/* First simplify defined symbols, so if they become the /* First simplify defined symbols, so if they become the
"answer" to undefined symbols, copying their st_value us "answer" to undefined symbols, copying their st_value us
correct. */ correct. */
for (sym = (void *)sechdrs[symindex].sh_offset, i = 0; for (sym = (void *)sechdrs[symindex].sh_addr, i = 0;
i < sechdrs[symindex].sh_size / sizeof(Elf_Sym); i < sechdrs[symindex].sh_size / sizeof(Elf_Sym);
i++) { i++) {
switch (sym[i].st_shndx) { switch (sym[i].st_shndx) {
...@@ -874,20 +874,20 @@ static int simplify_symbols(Elf_Shdr *sechdrs, ...@@ -874,20 +874,20 @@ static int simplify_symbols(Elf_Shdr *sechdrs,
default: default:
sym[i].st_value sym[i].st_value
= (unsigned long) = (unsigned long)
(sechdrs[sym[i].st_shndx].sh_offset (sechdrs[sym[i].st_shndx].sh_addr
+ sym[i].st_value); + sym[i].st_value);
} }
} }
/* Now try to resolve undefined symbols */ /* Now try to resolve undefined symbols */
for (sym = (void *)sechdrs[symindex].sh_offset, i = 0; for (sym = (void *)sechdrs[symindex].sh_addr, i = 0;
i < sechdrs[symindex].sh_size / sizeof(Elf_Sym); i < sechdrs[symindex].sh_size / sizeof(Elf_Sym);
i++) { i++) {
if (sym[i].st_shndx == SHN_UNDEF) { if (sym[i].st_shndx == SHN_UNDEF) {
/* Look for symbol */ /* Look for symbol */
struct kernel_symbol_group *ksg = NULL; struct kernel_symbol_group *ksg = NULL;
const char *strtab const char *strtab
= (char *)sechdrs[strindex].sh_offset; = (char *)sechdrs[strindex].sh_addr;
sym[i].st_value sym[i].st_value
= find_symbol_internal(sechdrs, = find_symbol_internal(sechdrs,
...@@ -984,6 +984,10 @@ static struct module *load_module(void *umod, ...@@ -984,6 +984,10 @@ static struct module *load_module(void *umod,
/* Find where important sections are */ /* Find where important sections are */
for (i = 1; i < hdr->e_shnum; i++) { for (i = 1; i < hdr->e_shnum; i++) {
/* Mark all sections sh_addr with their address in the
temporary image. */
sechdrs[i].sh_addr = (size_t)hdr + sechdrs[i].sh_offset;
if (sechdrs[i].sh_type == SHT_SYMTAB) { if (sechdrs[i].sh_type == SHT_SYMTAB) {
/* Internal symbols */ /* Internal symbols */
DEBUGP("Symbol table in section %u\n", i); DEBUGP("Symbol table in section %u\n", i);
...@@ -1034,7 +1038,7 @@ static struct module *load_module(void *umod, ...@@ -1034,7 +1038,7 @@ static struct module *load_module(void *umod,
err = -ENOEXEC; err = -ENOEXEC;
goto free_hdr; goto free_hdr;
} }
mod = (void *)hdr + sechdrs[modindex].sh_offset; mod = (void *)sechdrs[modindex].sh_addr;
/* Now copy in args */ /* Now copy in args */
err = strlen_user(uargs); err = strlen_user(uargs);
...@@ -1094,7 +1098,7 @@ static struct module *load_module(void *umod, ...@@ -1094,7 +1098,7 @@ static struct module *load_module(void *umod,
memset(ptr, 0, mod->init_size); memset(ptr, 0, mod->init_size);
mod->module_init = ptr; mod->module_init = ptr;
/* Transfer each section which requires ALLOC, and set sh_offset /* Transfer each section which requires ALLOC, and set sh_addr
fields to absolute addresses. */ fields to absolute addresses. */
used.core_size = 0; used.core_size = 0;
used.init_size = 0; used.init_size = 0;
...@@ -1104,12 +1108,10 @@ static struct module *load_module(void *umod, ...@@ -1104,12 +1108,10 @@ static struct module *load_module(void *umod,
hdr, &sechdrs[i], mod, &used); hdr, &sechdrs[i], mod, &used);
if (IS_ERR(ptr)) if (IS_ERR(ptr))
goto cleanup; goto cleanup;
sechdrs[i].sh_offset = (unsigned long)ptr; sechdrs[i].sh_addr = (unsigned long)ptr;
/* Have we just copied __this_module across? */ /* Have we just copied __this_module across? */
if (i == modindex) if (i == modindex)
mod = ptr; mod = ptr;
} else {
sechdrs[i].sh_offset += (unsigned long)hdr;
} }
} }
/* Don't use more than we allocated! */ /* Don't use more than we allocated! */
...@@ -1128,7 +1130,7 @@ static struct module *load_module(void *umod, ...@@ -1128,7 +1130,7 @@ static struct module *load_module(void *umod,
if (exportindex) { if (exportindex) {
mod->symbols.num_syms = (sechdrs[exportindex].sh_size mod->symbols.num_syms = (sechdrs[exportindex].sh_size
/ sizeof(*mod->symbols.syms)); / sizeof(*mod->symbols.syms));
mod->symbols.syms = (void *)sechdrs[exportindex].sh_offset; mod->symbols.syms = (void *)sechdrs[exportindex].sh_addr;
} }
/* Set up exception table */ /* Set up exception table */
...@@ -1137,7 +1139,7 @@ static struct module *load_module(void *umod, ...@@ -1137,7 +1139,7 @@ static struct module *load_module(void *umod,
mod->extable.num_entries = (sechdrs[exindex].sh_size mod->extable.num_entries = (sechdrs[exindex].sh_size
/ sizeof(struct / sizeof(struct
exception_table_entry)); exception_table_entry));
mod->extable.entry = (void *)sechdrs[exindex].sh_offset; mod->extable.entry = (void *)sechdrs[exindex].sh_addr;
} }
/* Now handle each section. */ /* Now handle each section. */
...@@ -1149,9 +1151,9 @@ static struct module *load_module(void *umod, ...@@ -1149,9 +1151,9 @@ static struct module *load_module(void *umod,
} }
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
mod->symtab = (void *)sechdrs[symindex].sh_offset; mod->symtab = (void *)sechdrs[symindex].sh_addr;
mod->num_syms = sechdrs[symindex].sh_size / sizeof(Elf_Sym); mod->num_syms = sechdrs[symindex].sh_size / sizeof(Elf_Sym);
mod->strtab = (void *)sechdrs[strindex].sh_offset; mod->strtab = (void *)sechdrs[strindex].sh_addr;
#endif #endif
err = module_finalize(hdr, sechdrs, mod); err = module_finalize(hdr, sechdrs, mod);
if (err < 0) if (err < 0)
...@@ -1161,16 +1163,16 @@ static struct module *load_module(void *umod, ...@@ -1161,16 +1163,16 @@ static struct module *load_module(void *umod,
if (obsparmindex) { if (obsparmindex) {
err = obsolete_params(mod->name, mod->args, err = obsolete_params(mod->name, mod->args,
(struct obsolete_modparm *) (struct obsolete_modparm *)
sechdrs[obsparmindex].sh_offset, sechdrs[obsparmindex].sh_addr,
sechdrs[obsparmindex].sh_size sechdrs[obsparmindex].sh_size
/ sizeof(struct obsolete_modparm), / sizeof(struct obsolete_modparm),
sechdrs, symindex, sechdrs, symindex,
(char *)sechdrs[strindex].sh_offset); (char *)sechdrs[strindex].sh_addr);
} else { } else {
/* Size of section 0 is 0, so this works well if no params */ /* Size of section 0 is 0, so this works well if no params */
err = parse_args(mod->name, mod->args, err = parse_args(mod->name, mod->args,
(struct kernel_param *) (struct kernel_param *)
sechdrs[setupindex].sh_offset, sechdrs[setupindex].sh_addr,
sechdrs[setupindex].sh_size sechdrs[setupindex].sh_size
/ sizeof(struct kernel_param), / sizeof(struct kernel_param),
NULL); NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment