sparc64: use bit neutral Elf symbols
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>
This commit is contained in:
parent
e1648a8194
commit
c45d1c209f
|
@ -63,7 +63,7 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
|
||||||
struct module *mod)
|
struct module *mod)
|
||||||
{
|
{
|
||||||
unsigned int symidx;
|
unsigned int symidx;
|
||||||
Elf64_Sym *sym;
|
Elf_Sym *sym;
|
||||||
const char *strtab;
|
const char *strtab;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -73,18 +73,18 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
|
||||||
return -ENOEXEC;
|
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;
|
strtab = (char *)sechdrs[sechdrs[symidx].sh_link].sh_addr;
|
||||||
|
|
||||||
for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
|
for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
|
||||||
if (sym[i].st_shndx == SHN_UNDEF &&
|
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;
|
sym[i].st_shndx = SHN_ABS;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int apply_relocate(Elf64_Shdr *sechdrs,
|
int apply_relocate(Elf_Shdr *sechdrs,
|
||||||
const char *strtab,
|
const char *strtab,
|
||||||
unsigned int symindex,
|
unsigned int symindex,
|
||||||
unsigned int relsec,
|
unsigned int relsec,
|
||||||
|
@ -95,20 +95,20 @@ int apply_relocate(Elf64_Shdr *sechdrs,
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
int apply_relocate_add(Elf64_Shdr *sechdrs,
|
int apply_relocate_add(Elf_Shdr *sechdrs,
|
||||||
const char *strtab,
|
const char *strtab,
|
||||||
unsigned int symindex,
|
unsigned int symindex,
|
||||||
unsigned int relsec,
|
unsigned int relsec,
|
||||||
struct module *me)
|
struct module *me)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
Elf64_Rela *rel = (void *)sechdrs[relsec].sh_addr;
|
Elf_Rela *rel = (void *)sechdrs[relsec].sh_addr;
|
||||||
Elf64_Sym *sym;
|
Elf_Sym *sym;
|
||||||
u8 *location;
|
u8 *location;
|
||||||
u32 *loc32;
|
u32 *loc32;
|
||||||
|
|
||||||
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
|
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
|
||||||
Elf64_Addr v;
|
Elf_Addr v;
|
||||||
|
|
||||||
/* This is where to make the change */
|
/* This is where to make the change */
|
||||||
location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_addr
|
location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_addr
|
||||||
|
@ -119,11 +119,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
|
||||||
|
|
||||||
/* This is the symbol it is referring to. Note that all
|
/* This is the symbol it is referring to. Note that all
|
||||||
undefined symbols have been resolved. */
|
undefined symbols have been resolved. */
|
||||||
sym = (Elf64_Sym *)sechdrs[symindex].sh_addr
|
sym = (Elf_Sym *)sechdrs[symindex].sh_addr
|
||||||
+ ELF64_R_SYM(rel[i].r_info);
|
+ ELF_R_SYM(rel[i].r_info);
|
||||||
v = sym->st_value + rel[i].r_addend;
|
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:
|
case R_SPARC_64:
|
||||||
location[0] = v >> 56;
|
location[0] = v >> 56;
|
||||||
location[1] = v >> 48;
|
location[1] = v >> 48;
|
||||||
|
@ -143,24 +143,24 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_SPARC_DISP32:
|
case R_SPARC_DISP32:
|
||||||
v -= (Elf64_Addr) location;
|
v -= (Elf_Addr) location;
|
||||||
*loc32 = v;
|
*loc32 = v;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_SPARC_WDISP30:
|
case R_SPARC_WDISP30:
|
||||||
v -= (Elf64_Addr) location;
|
v -= (Elf_Addr) location;
|
||||||
*loc32 = (*loc32 & ~0x3fffffff) |
|
*loc32 = (*loc32 & ~0x3fffffff) |
|
||||||
((v >> 2) & 0x3fffffff);
|
((v >> 2) & 0x3fffffff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_SPARC_WDISP22:
|
case R_SPARC_WDISP22:
|
||||||
v -= (Elf64_Addr) location;
|
v -= (Elf_Addr) location;
|
||||||
*loc32 = (*loc32 & ~0x3fffff) |
|
*loc32 = (*loc32 & ~0x3fffff) |
|
||||||
((v >> 2) & 0x3fffff);
|
((v >> 2) & 0x3fffff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_SPARC_WDISP19:
|
case R_SPARC_WDISP19:
|
||||||
v -= (Elf64_Addr) location;
|
v -= (Elf_Addr) location;
|
||||||
*loc32 = (*loc32 & ~0x7ffff) |
|
*loc32 = (*loc32 & ~0x7ffff) |
|
||||||
((v >> 2) & 0x7ffff);
|
((v >> 2) & 0x7ffff);
|
||||||
break;
|
break;
|
||||||
|
@ -177,14 +177,14 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
|
||||||
case R_SPARC_OLO10:
|
case R_SPARC_OLO10:
|
||||||
*loc32 = (*loc32 & ~0x1fff) |
|
*loc32 = (*loc32 & ~0x1fff) |
|
||||||
(((v & 0x3ff) +
|
(((v & 0x3ff) +
|
||||||
(ELF64_R_TYPE(rel[i].r_info) >> 8))
|
(ELF_R_TYPE(rel[i].r_info) >> 8))
|
||||||
& 0x1fff);
|
& 0x1fff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR "module %s: Unknown relocation: %x\n",
|
printk(KERN_ERR "module %s: Unknown relocation: %x\n",
|
||||||
me->name,
|
me->name,
|
||||||
(int) (ELF64_R_TYPE(rel[i].r_info) & 0xff));
|
(int) (ELF_R_TYPE(rel[i].r_info) & 0xff));
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue