Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Remove old assert that only two segments e...
details: https://anonhg.NetBSD.org/src/rev/7304a97fbb71
branches: trunk
changeset: 354648:7304a97fbb71
user: joerg <joerg%NetBSD.org@localhost>
date: Fri Jun 23 15:29:21 2017 +0000
description:
Remove old assert that only two segments exist. The rest of the code has
been changed to cope with more and at least Go actively creates them.
Adjust the mapping size computation to use the maximum and not depend on
PT_LOAD segments to be in order.
diffstat:
libexec/ld.elf_so/headers.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diffs (62 lines):
diff -r 5e0868dae6f2 -r 7304a97fbb71 libexec/ld.elf_so/headers.c
--- a/libexec/ld.elf_so/headers.c Fri Jun 23 15:24:35 2017 +0000
+++ b/libexec/ld.elf_so/headers.c Fri Jun 23 15:29:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: headers.c,v 1.61 2016/06/14 13:06:41 christos Exp $ */
+/* $NetBSD: headers.c,v 1.62 2017/06/23 15:29:21 joerg Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: headers.c,v 1.61 2016/06/14 13:06:41 christos Exp $");
+__RCSID("$NetBSD: headers.c,v 1.62 2017/06/23 15:29:21 joerg Exp $");
#endif /* not lint */
#include <err.h>
@@ -380,8 +380,9 @@
Obj_Entry *obj;
const Elf_Phdr *phlimit = phdr + phnum;
const Elf_Phdr *ph;
- int nsegs = 0;
- Elf_Addr vaddr;
+ bool first_seg = true;
+ Elf_Addr vaddr;
+ size_t size;
obj = _rtld_obj_new();
@@ -409,17 +410,16 @@
break;
case PT_LOAD:
- assert(nsegs < 2);
- if (nsegs == 0) { /* First load segment */
+ size = round_up(vaddr + ph->p_memsz) - obj->vaddrbase;
+ if (first_seg) { /* First load segment */
obj->vaddrbase = round_down(vaddr);
obj->mapbase = (caddr_t)(uintptr_t)obj->vaddrbase;
- obj->textsize = round_up(vaddr + ph->p_memsz) -
- obj->vaddrbase;
+ obj->textsize = size;
+ obj->mapsize = size;
+ first_seg = false;
} else { /* Last load segment */
- obj->mapsize = round_up(vaddr + ph->p_memsz) -
- obj->vaddrbase;
+ obj->mapsize = MAX(obj->mapsize, size);
}
- ++nsegs;
dbg(("headers: %s %p phsize %" PRImemsz,
"PT_LOAD", (void *)(uintptr_t)vaddr,
ph->p_memsz));
@@ -466,7 +466,6 @@
#endif
}
}
- assert(nsegs == 2);
obj->entry = entry;
return obj;
Home |
Main Index |
Thread Index |
Old Index