Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/powerpc/elf32_machdep.c
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#ifdef __powerpc64__ | #ifdef __powerpc64__ | ||||
#include <compat/freebsd32/freebsd32_proto.h> | #include <compat/freebsd32/freebsd32_proto.h> | ||||
#include <compat/freebsd32/freebsd32_util.h> | #include <compat/freebsd32/freebsd32_util.h> | ||||
extern const char *freebsd32_syscallnames[]; | extern const char *freebsd32_syscallnames[]; | ||||
static void ppc32_fixlimit(struct rlimit *rl, int which); | static void ppc32_fixlimit(struct rlimit *rl, int which); | ||||
static void ppc32_runtime_resolve(void); | |||||
static SYSCTL_NODE(_compat, OID_AUTO, ppc32, CTLFLAG_RW, 0, "32-bit mode"); | static SYSCTL_NODE(_compat, OID_AUTO, ppc32, CTLFLAG_RW, 0, "32-bit mode"); | ||||
#define PPC32_MAXDSIZ (1024*1024*1024) | #define PPC32_MAXDSIZ (1024*1024*1024) | ||||
static u_long ppc32_maxdsiz = PPC32_MAXDSIZ; | static u_long ppc32_maxdsiz = PPC32_MAXDSIZ; | ||||
SYSCTL_ULONG(_compat_ppc32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, &ppc32_maxdsiz, | SYSCTL_ULONG(_compat_ppc32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, &ppc32_maxdsiz, | ||||
0, ""); | 0, ""); | ||||
#define PPC32_MAXSSIZ (64*1024*1024) | #define PPC32_MAXSSIZ (64*1024*1024) | ||||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | case R_PPC_ADDR16_HA: /* #ha(S) */ | ||||
*hwhere = ((addr >> 16) + ((addr & 0x8000) ? 1 : 0)) | *hwhere = ((addr >> 16) + ((addr & 0x8000) ? 1 : 0)) | ||||
& 0xffff; | & 0xffff; | ||||
break; | break; | ||||
case R_PPC_RELATIVE: /* word32 B + A */ | case R_PPC_RELATIVE: /* word32 B + A */ | ||||
*where = elf_relocaddr(lf, relocbase + addend); | *where = elf_relocaddr(lf, relocbase + addend); | ||||
break; | break; | ||||
case R_PPC_JMP_SLOT: /* PLT jump slot entry */ | |||||
/* | |||||
* We currently only support Secure-PLT jump slots. | |||||
* Given that we reject BSS-PLT modules during load, we | |||||
* don't need to check again. | |||||
* The method we are using here is equivilent to | |||||
* LD_BIND_NOW. | |||||
*/ | |||||
error = lookup(lf, symidx, 1, &addr); | |||||
if (error != 0) | |||||
return -1; | |||||
*where = elf_relocaddr(lf, addr + addend); | |||||
break; | |||||
default: | default: | ||||
printf("kldload: unexpected relocation type %d\n", | printf("kldload: unexpected relocation type %d\n", | ||||
(int) rtype); | (int) rtype); | ||||
return -1; | return -1; | ||||
} | } | ||||
return(0); | return(0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return (elf_reloc_internal(lf, relocbase, data, type, 1, lookup)); | return (elf_reloc_internal(lf, relocbase, data, type, 1, lookup)); | ||||
} | } | ||||
int | int | ||||
elf_cpu_load_file(linker_file_t lf) | elf_cpu_load_file(linker_file_t lf) | ||||
{ | { | ||||
/* Only sync the cache for non-kernel modules */ | /* Only sync the cache for non-kernel modules */ | ||||
if (lf->id != 1) | if (lf->id != 1) | ||||
__syncicache(lf->address, lf->size); | __syncicache(lf->address, lf->size); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
elf_cpu_unload_file(linker_file_t lf __unused) | elf_cpu_unload_file(linker_file_t lf __unused) | ||||
{ | { | ||||
return (0); | |||||
} | |||||
static void | |||||
ppc32_runtime_resolve() | |||||
{ | |||||
/* | |||||
* Since we don't support lazy binding, panic immediately if anyone | |||||
* manages to call the runtime resolver. | |||||
*/ | |||||
panic("kldload: Runtime resolver was called unexpectedly!"); | |||||
} | |||||
int | |||||
elf_cpu_parse_dynamic(linker_file_t lf, Elf_Dyn *dynamic) | |||||
{ | |||||
Elf_Dyn *dp; | |||||
bool has_plt = false; | |||||
bool secure_plt = false; | |||||
Elf_Addr *got; | |||||
for (dp = dynamic; dp->d_tag != DT_NULL; dp++) { | |||||
switch (dp->d_tag) { | |||||
case DT_PPC_GOT: | |||||
secure_plt = true; | |||||
got = (Elf_Addr *)(lf->address + dp->d_un.d_ptr); | |||||
/* Install runtime resolver canary. */ | |||||
got[1] = (Elf_Addr)ppc32_runtime_resolve; | |||||
got[2] = (Elf_Addr)0; | |||||
break; | |||||
case DT_PLTGOT: | |||||
has_plt = true; | |||||
break; | |||||
} | |||||
} | |||||
if (has_plt && !secure_plt) { | |||||
printf("kldload: BSS-PLT modules are not supported.\n"); | |||||
luporl: The return style is not very consistent on this file, but I think that on new functions at… | |||||
return (-1); | |||||
} | |||||
return (0); | return (0); | ||||
} | } | ||||
#endif | #endif | ||||
#ifdef __powerpc64__ | #ifdef __powerpc64__ | ||||
static void | static void | ||||
ppc32_fixlimit(struct rlimit *rl, int which) | ppc32_fixlimit(struct rlimit *rl, int which) | ||||
{ | { | ||||
Show All 20 Lines |
The return style is not very consistent on this file, but I think that on new functions at least it is better to always enclose return values in parentheses, as documented in style(9).