git: e679319b840e - main - rtld: Compute obj->maxsize for obj_rtld
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 22 Aug 2025 14:35:28 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=e679319b840e7c3298a0b0c4149113d4bbe63110
commit e679319b840e7c3298a0b0c4149113d4bbe63110
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-08-22 13:59:09 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-08-22 13:59:09 +0000
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
---
libexec/rtld-elf/rtld.c | 10 ++++++++++
1 file changed, 10 insertions(+)
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;