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
This commit is contained in:
John Baldwin
2025-08-22 09:59:09 -04:00
parent 0cd42981dc
commit e679319b84
+10
View File
@@ -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;