diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2020-06-18 23:06:05 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2020-06-18 23:06:05 +0000 |
| commit | e0b322ae78f270fea23d361eab5387a9a3d65213 (patch) | |
| tree | 7ac46785f52b0c706689fa95b2933140f6f25358 /libexec | |
| parent | 049264c5cce03cdd1a93965acacd377492dabcb3 (diff) | |
Notes
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/rtld-elf/rtld.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 4f24e0564a549..f999bf2bd07fb 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -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; } |
