Project

General

Profile

Submit #2854 » pie.patch

shamaz, 11/25/2015 11:03 AM

View differences:

sys/cpu/i386/include/elf.h
#define ELF_TARG_MACH EM_386
#define ELF_TARG_VER 1
/*
* i386 load base for PIE binaries
*/
#define ET_DYN_LOAD_ADDR 0x01001000
#ifdef _KERNEL
/*
sys/cpu/x86_64/include/elf.h
#define ELF_TARG_MACH EM_X86_64
#define ELF_TARG_VER 1
/*
* x86_64 load base for PIE binaries
*/
#define ET_DYN_LOAD_ADDR 0x01021000
#ifdef _KERNEL
/*
* On the i386 we load the dynamic linker where a userland call
sys/kern/imgact_elf.c
u_long text_size = 0, data_size = 0, total_size = 0;
u_long text_addr = 0, data_addr = 0;
u_long seg_size, seg_addr;
u_long addr, baddr, et_dyn_addr, entry = 0, proghdr = 0;
u_long addr, baddr, et_dyn_addr = 0, entry = 0, proghdr = 0;
int32_t osrel = 0;
int error = 0, i, n;
boolean_t failure;
......
* non-zero for some reason.
*/
if (baddr == 0)
et_dyn_addr = ET_DYN_LOAD_ADDR;
else
et_dyn_addr = 0;
} else
et_dyn_addr = 0;
et_dyn_addr = 1;
}
if (interp != NULL && brand_info->interp_newpath != NULL)
newinterp = brand_info->interp_newpath;
......
vsetflags(imgp->vp, VTEXT);
vmspace = imgp->proc->p_vmspace;
if (et_dyn_addr)
et_dyn_addr = vm_map_hint (imgp->proc, 0, VM_PROT_READ | VM_PROT_EXECUTE);
for (i = 0; i < hdr->e_phnum; i++) {
switch (phdr[i].p_type) {
(1-1/4)