-/* $OpenBSD: library_mquery.c,v 1.64 2019/12/09 23:15:03 bluhm Exp $ */
+/* $OpenBSD: library_mquery.c,v 1.65 2021/03/16 18:03:06 kurt Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
* EXEC region unless it is writable.
*/
int exec = (ld->prot & PROT_WRITE) ? 0 : PROT_EXEC;
+ if (exec && lowld->start == NULL)
+ lowld->start = _dl_exec_hint;
res = _dl_mquery((void *)(LOFF + ld->moff),
ROUND_PG(ld->size), ld->prot | exec, flags,
fd, foff);
-/* $OpenBSD: loader.c,v 1.190 2019/12/17 03:16:07 guenther Exp $ */
+/* $OpenBSD: loader.c,v 1.191 2021/03/16 18:03:06 kurt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
#include <sys/mman.h>
#include <sys/exec.h>
#include <sys/sysctl.h>
+#include <machine/vmparam.h>
#include <nlist.h>
#include <string.h>
#include <link.h>
char *_dl_tracefmt1 __boot_data = NULL;
char *_dl_tracefmt2 __boot_data = NULL;
char *_dl_traceprog __boot_data = NULL;
+void *_dl_exec_hint __boot_data = NULL;
char **environ = NULL;
char *__progname = NULL;
unsigned int loop;
int failed;
struct dep_node *n;
- Elf_Addr minva, maxva, exe_loff;
+ Elf_Addr minva, maxva, exe_loff, exec_end, cur_exec_end;
Elf_Phdr *ptls = NULL;
int align;
_dl_loading_object = NULL;
minva = ELF_NO_ADDR;
- maxva = exe_loff = 0;
+ maxva = exe_loff = exec_end = 0;
/*
* Examine the user application and set up object information.
next_load->start = (char *)TRUNC_PG(phdp->p_vaddr) + exe_loff;
next_load->size = (phdp->p_vaddr & align) + phdp->p_filesz;
next_load->prot = PFLAGS(phdp->p_flags);
+ cur_exec_end = (Elf_Addr)next_load->start + next_load->size;
+ if ((next_load->prot & PROT_EXEC) != 0 &&
+ cur_exec_end > exec_end)
+ exec_end = cur_exec_end;
break;
case PT_TLS:
if (phdp->p_filesz > phdp->p_memsz)
exe_obj->load_size = maxva - minva;
_dl_set_sod(exe_obj->load_name, &exe_obj->sod);
+#ifdef __i386__
+ if (exec_end > I386_MAX_EXE_ADDR)
+ _dl_exec_hint = (void *)ROUND_PG(exec_end-I386_MAX_EXE_ADDR);
+ DL_DEB(("_dl_exec_hint: 0x%lx\n", _dl_exec_hint));
+#endif
+
/* TLS bits in the base executable */
if (ptls != NULL && ptls->p_memsz)
_dl_set_tls(exe_obj, ptls, exe_loff, NULL);
-/* $OpenBSD: resolve.h,v 1.96 2019/10/04 17:42:16 guenther Exp $ */
+/* $OpenBSD: resolve.h,v 1.97 2021/03/16 18:03:06 kurt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
extern char *_dl_tracefmt2;
extern char *_dl_traceprog;
+extern void *_dl_exec_hint;
+
extern int _dl_trust;
#define DL_DEB(P) do { if (_dl_debug) _dl_printf P ; } while (0)