mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-23 21:31:07 +01:00
rtld: Parse own phdr and notes.
Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D25319
This commit is contained in:
parent
049264c5cc
commit
e0b322ae78
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362346
@ -2182,6 +2182,34 @@ process_z(Obj_Entry *root)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parse_rtld_phdr(Obj_Entry *obj)
|
||||
{
|
||||
const Elf_Phdr *ph;
|
||||
Elf_Addr note_start, note_end;
|
||||
|
||||
obj->stack_flags = PF_X | PF_R | PF_W;
|
||||
for (ph = obj->phdr; (const char *)ph < (const char *)obj->phdr +
|
||||
obj->phsize; ph++) {
|
||||
switch (ph->p_type) {
|
||||
case PT_GNU_STACK:
|
||||
obj->stack_flags = ph->p_flags;
|
||||
break;
|
||||
case PT_GNU_RELRO:
|
||||
obj->relro_page = obj->relocbase +
|
||||
trunc_page(ph->p_vaddr);
|
||||
obj->relro_size = round_page(ph->p_memsz);
|
||||
break;
|
||||
case PT_NOTE:
|
||||
note_start = (Elf_Addr)obj->relocbase + ph->p_vaddr;
|
||||
note_end = note_start + ph->p_filesz;
|
||||
digest_notes(obj, note_start, note_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the dynamic linker. The argument is the address at which
|
||||
* the dynamic linker has been mapped into memory. The primary task of
|
||||
@ -2251,6 +2279,8 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo **aux_info)
|
||||
/* Replace the path with a dynamically allocated copy. */
|
||||
obj_rtld.path = xstrdup(ld_path_rtld);
|
||||
|
||||
parse_rtld_phdr(&obj_rtld);
|
||||
|
||||
r_debug.r_brk = r_debug_state;
|
||||
r_debug.r_state = RT_CONSISTENT;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user