summaryrefslogtreecommitdiffstats
path: root/libexec/ld.so/resolve.h
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2019-05-10 13:29:21 +0000
committerguenther <guenther@openbsd.org>2019-05-10 13:29:21 +0000
commitc0197e40dd4094880fe205f9c12d3e12e14e7ff3 (patch)
tree6882480a3d40ae2f97a06566d8fe24fcd28a10f0 /libexec/ld.so/resolve.h
parentAdd some more edge case tests. (diff)
downloadwireguard-openbsd-c0197e40dd4094880fe205f9c12d3e12e14e7ff3.tar.xz
wireguard-openbsd-c0197e40dd4094880fe205f9c12d3e12e14e7ff3.zip
ld.so boot cleanup support:
- put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later ok kettenis@
Diffstat (limited to 'libexec/ld.so/resolve.h')
-rw-r--r--libexec/ld.so/resolve.h38
1 files changed, 26 insertions, 12 deletions
diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h
index 6a87eb538cd..1f313788a5b 100644
--- a/libexec/ld.so/resolve.h
+++ b/libexec/ld.so/resolve.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.h,v 1.90 2019/04/21 04:11:42 deraadt Exp $ */
+/* $OpenBSD: resolve.h,v 1.91 2019/05/10 13:29:21 guenther Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -30,11 +30,22 @@
#define _RESOLVE_H_
#include <sys/queue.h>
-#include <link.h>
#include <dlfcn.h>
+#include <link.h>
+#include <tib.h>
#define __relro __attribute__((section(".data.rel.ro")))
+#ifndef __boot
+# if DO_CLEAN_BOOT
+# define __boot __attribute__((section(".boot.text")))
+# define __boot_data __attribute__((section(".boot.data")))
+# else
+# define __boot
+# define __boot_data
+# endif
+#endif
+
/* Number of low tags that are used saved internally (0 .. DT_NUM-1) */
#define DT_NUM (DT_PREINIT_ARRAYSZ + 1)
@@ -47,6 +58,9 @@ struct load_list {
long foff;
};
+typedef void initarrayfunc(int, const char **, char **, dl_cb_cb *);
+typedef void initfunc(void); /* also fini and fini_array functions */
+
/* Alpha uses 8byte entries for DT_HASH */
#ifdef __alpha__
typedef uint64_t Elf_Hash_Word;
@@ -88,8 +102,8 @@ struct elf_object {
Elf_Addr relaent;
Elf_Addr strsz;
Elf_Addr syment;
- void (*init)(void);
- void (*fini)(void);
+ initfunc *init;
+ initfunc *fini;
const char *soname;
const char *rpath;
Elf_Addr symbolic;
@@ -101,14 +115,14 @@ struct elf_object {
Elf_Addr textrel;
Elf_Addr jmprel;
Elf_Addr bind_now;
- void (**init_array)(void);
- void (**fini_array)(void);
+ initarrayfunc **init_array;
+ initfunc **fini_array;
Elf_Addr init_arraysz;
Elf_Addr fini_arraysz;
const char *runpath;
Elf_Addr flags;
Elf_Addr encoding;
- void (**preinit_array)(void);
+ initarrayfunc **preinit_array;
Elf_Addr preinit_arraysz;
} u;
} Dyn;
@@ -291,16 +305,16 @@ typedef void lock_cb(int);
void _dl_thread_kern_go(lock_cb *);
lock_cb *_dl_thread_kern_stop(void);
-char *_dl_getenv(const char *, char **);
-void _dl_unsetenv(const char *, char **);
+char *_dl_getenv(const char *, char **) __boot;
+void _dl_unsetenv(const char *, char **) __boot;
-void _dl_trace_setup(char **);
+void _dl_trace_setup(char **) __boot;
void _dl_trace_object_setup(elf_object_t *);
int _dl_trace_plt(const elf_object_t *, const char *);
/* tib.c */
-void _dl_allocate_tls_offsets(void);
-void _dl_allocate_first_tib(void);
+void _dl_allocate_tls_offsets(void) __boot;
+void _dl_allocate_first_tib(void) __boot;
void _dl_set_tls(elf_object_t *_object, Elf_Phdr *_ptls, Elf_Addr _libaddr,
const char *_libname);
extern int _dl_tib_static_done;