Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/kldxref/ef_powerpc.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
* target relocation address of the section, and `dataoff/len' is the region | * target relocation address of the section, and `dataoff/len' is the region | ||||
* that is to be relocated, and has been copied to *dest | * that is to be relocated, and has been copied to *dest | ||||
*/ | */ | ||||
int | int | ||||
ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase, | ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase, | ||||
Elf_Off dataoff, size_t len, void *dest) | Elf_Off dataoff, size_t len, void *dest) | ||||
{ | { | ||||
Elf_Addr *where, addend; | Elf_Addr *where, addend; | ||||
Elf32_Addr *where32; | |||||
Elf_Size rtype, symidx; | Elf_Size rtype, symidx; | ||||
const Elf_Rela *rela; | const Elf_Rela *rela; | ||||
if (reltype != EF_RELOC_RELA) | if (reltype != EF_RELOC_RELA) | ||||
return (EINVAL); | return (EINVAL); | ||||
rela = (const Elf_Rela *)reldata; | rela = (const Elf_Rela *)reldata; | ||||
where = (Elf_Addr *) ((Elf_Off)dest - dataoff + rela->r_offset); | where = (Elf_Addr *) ((Elf_Off)dest - dataoff + rela->r_offset); | ||||
where32 = (Elf32_Addr *) ((Elf_Off)dest - dataoff + rela->r_offset); | |||||
luporl: No change is really needed here, but maybe just cast 'where' to (Elf32_Addr *)? | |||||
alfredoAuthorUnsubmitted Done Inline Actionsyes but the cast need to be later since at this point we don't know what data size is going to be used. alfredo: yes but the cast need to be later since at this point we don't know what data size is going to… | |||||
addend = rela->r_addend; | addend = rela->r_addend; | ||||
rtype = ELF_R_TYPE(rela->r_info); | rtype = ELF_R_TYPE(rela->r_info); | ||||
symidx = ELF_R_SYM(rela->r_info); | symidx = ELF_R_SYM(rela->r_info); | ||||
if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len) | if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len) | ||||
return (0); | return (0); | ||||
switch (rtype) { | switch (rtype) { | ||||
case R_PPC_RELATIVE: /* word32|doubleword64 B + A */ | case R_PPC_RELATIVE: /* word32|doubleword64 B + A */ | ||||
*where = relbase + addend; | *where = relbase + addend; | ||||
break; | break; | ||||
case R_PPC64_ADDR64: /* S + A */ | case R_PPC_ADDR32: /* word32 S + A */ | ||||
*where32 = EF_SYMADDR(ef, symidx) + addend; | |||||
break; | |||||
#ifdef __powerpc64__ | |||||
case R_PPC64_ADDR64: /* doubleword64 S + A */ | |||||
*where = EF_SYMADDR(ef, symidx) + addend; | *where = EF_SYMADDR(ef, symidx) + addend; | ||||
break; | break; | ||||
#endif | |||||
default: | default: | ||||
warnx("unhandled relocation type %" PRI_ELF_SIZE, rtype); | warnx("unhandled relocation type %" PRI_ELF_SIZE, rtype); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } |
No change is really needed here, but maybe just cast 'where' to (Elf32_Addr *)?