Skip to content

Commit

Permalink
sparc64: use bit neutral Elf symbols
Browse files Browse the repository at this point in the history
To prepare for unification use the bit neutral versions of
the Elf types defined by asm/module.h

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sam Ravnborg authored and David S. Miller committed Dec 26, 2008
1 parent e1648a8 commit c45d1c2
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions arch/sparc/kernel/module_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
struct module *mod)
{
unsigned int symidx;
Elf64_Sym *sym;
Elf_Sym *sym;
const char *strtab;
int i;

Expand All @@ -73,18 +73,18 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
return -ENOEXEC;
}
}
sym = (Elf64_Sym *)sechdrs[symidx].sh_addr;
sym = (Elf_Sym *)sechdrs[symidx].sh_addr;
strtab = (char *)sechdrs[sechdrs[symidx].sh_link].sh_addr;

for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
if (sym[i].st_shndx == SHN_UNDEF &&
ELF64_ST_TYPE(sym[i].st_info) == STT_REGISTER)
ELF_ST_TYPE(sym[i].st_info) == STT_REGISTER)
sym[i].st_shndx = SHN_ABS;
}
return 0;
}

int apply_relocate(Elf64_Shdr *sechdrs,
int apply_relocate(Elf_Shdr *sechdrs,
const char *strtab,
unsigned int symindex,
unsigned int relsec,
Expand All @@ -95,20 +95,20 @@ int apply_relocate(Elf64_Shdr *sechdrs,
return -ENOEXEC;
}

int apply_relocate_add(Elf64_Shdr *sechdrs,
int apply_relocate_add(Elf_Shdr *sechdrs,
const char *strtab,
unsigned int symindex,
unsigned int relsec,
struct module *me)
{
unsigned int i;
Elf64_Rela *rel = (void *)sechdrs[relsec].sh_addr;
Elf64_Sym *sym;
Elf_Rela *rel = (void *)sechdrs[relsec].sh_addr;
Elf_Sym *sym;
u8 *location;
u32 *loc32;

for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
Elf64_Addr v;
Elf_Addr v;

/* This is where to make the change */
location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_addr
Expand All @@ -119,11 +119,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,

/* This is the symbol it is referring to. Note that all
undefined symbols have been resolved. */
sym = (Elf64_Sym *)sechdrs[symindex].sh_addr
+ ELF64_R_SYM(rel[i].r_info);
sym = (Elf_Sym *)sechdrs[symindex].sh_addr
+ ELF_R_SYM(rel[i].r_info);
v = sym->st_value + rel[i].r_addend;

switch (ELF64_R_TYPE(rel[i].r_info) & 0xff) {
switch (ELF_R_TYPE(rel[i].r_info) & 0xff) {
case R_SPARC_64:
location[0] = v >> 56;
location[1] = v >> 48;
Expand All @@ -143,24 +143,24 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
break;

case R_SPARC_DISP32:
v -= (Elf64_Addr) location;
v -= (Elf_Addr) location;
*loc32 = v;
break;

case R_SPARC_WDISP30:
v -= (Elf64_Addr) location;
v -= (Elf_Addr) location;
*loc32 = (*loc32 & ~0x3fffffff) |
((v >> 2) & 0x3fffffff);
break;

case R_SPARC_WDISP22:
v -= (Elf64_Addr) location;
v -= (Elf_Addr) location;
*loc32 = (*loc32 & ~0x3fffff) |
((v >> 2) & 0x3fffff);
break;

case R_SPARC_WDISP19:
v -= (Elf64_Addr) location;
v -= (Elf_Addr) location;
*loc32 = (*loc32 & ~0x7ffff) |
((v >> 2) & 0x7ffff);
break;
Expand All @@ -177,14 +177,14 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
case R_SPARC_OLO10:
*loc32 = (*loc32 & ~0x1fff) |
(((v & 0x3ff) +
(ELF64_R_TYPE(rel[i].r_info) >> 8))
(ELF_R_TYPE(rel[i].r_info) >> 8))
& 0x1fff);
break;

default:
printk(KERN_ERR "module %s: Unknown relocation: %x\n",
me->name,
(int) (ELF64_R_TYPE(rel[i].r_info) & 0xff));
(int) (ELF_R_TYPE(rel[i].r_info) & 0xff));
return -ENOEXEC;
};
}
Expand Down

0 comments on commit c45d1c2

Please sign in to comment.