diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2025-08-22 13:59:09 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2025-08-22 13:59:09 +0000 |
| commit | e679319b840e7c3298a0b0c4149113d4bbe63110 (patch) | |
| tree | 1970a4f21e6d023164de345d3afc51471bef6f58 /libexec/rtld-elf | |
| parent | 0cd42981dc0a180ced15265aa1658013a3de4dd4 (diff) | |
rtld: Compute obj->maxsize for obj_rtld
Compute this while parsing the program headers in parse_rtld_phdr().
Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: AFRL, DARPA
Differential Revision: https://reviews.freebsd.org/D52033
Diffstat (limited to 'libexec/rtld-elf')
| -rw-r--r-- | libexec/rtld-elf/rtld.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 8977d5947010..a8a2a0fa5a07 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2437,11 +2437,21 @@ parse_rtld_phdr(Obj_Entry *obj) { const Elf_Phdr *ph; Elf_Addr note_start, note_end; + bool first_seg; + first_seg = true; 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_LOAD: + if (first_seg) { + obj->vaddrbase = rtld_trunc_page(ph->p_vaddr); + first_seg = false; + } + obj->mapsize = rtld_round_page(ph->p_vaddr + + ph->p_memsz) - obj->vaddrbase; + break; case PT_GNU_STACK: obj->stack_flags = ph->p_flags; break; |
