summaryrefslogtreecommitdiff
path: root/src/dl/dl_gnu.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/dl/dl_gnu.go')
-rw-r--r--src/dl/dl_gnu.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/dl/dl_gnu.go b/src/dl/dl_gnu.go
new file mode 100644
index 0000000..c7c409b
--- /dev/null
+++ b/src/dl/dl_gnu.go
@@ -0,0 +1,58 @@
+package dl
+
+import "unsafe"
+
+//#define _GNU_SOURCE
+//#include <stdlib.h>
+//#include <stdint.h>
+//#include <dlfcn.h>
+//const uintptr_t rtld_next = (uintptr_t)RTLD_NEXT;
+//const uintptr_t rtld_default = (uintptr_t)RTLD_DEFAULT;
+import "C"
+
+const (
+ RTLD_NOLOAD Flag = C.RTLD_NOLOAD
+ RTLD_NODELETE Flag = C.RTLD_NODELETE
+ RTLD_DEEPBIND Flag = C.RTLD_DEEPBIND
+)
+
+// These are kinda weird in that they aren't required by the standard,
+// but they are reserved by the standard (see the documentation for
+// `dlsym(3)`). On glibc, it takes _GNU_SOURCE to get them.
+//
+// There are two special pseudo-handles that may be specified
+// in handle:
+var (
+ RTLD_DEFAULT Handle = Handle{unsafe.Pointer(uintptr(C.rtld_default))}
+ // Find the first occurrence of the desired symbol using
+ // the default shared object search order. The search will
+ // include global symbols in the executable and its
+ // dependencies, as well as symbols in shared objects that
+ // were dynamically loaded with the RTLD_GLOBAL flag.
+ RTLD_NEXT Handle = Handle{unsafe.Pointer(uintptr(C.rtld_next))}
+ // Find the next occurrence of the desired symbol in the
+ // search order after the current object. This allows one
+ // to provide a wrapper around a function in another shared
+ // object, so that, for example, the definition of a
+ // function in a preloaded shared object (see LD_PRELOAD in
+ // ld.so(8)) can find and invoke the "real" function
+ // provided in another shared object (or for that matter,
+ // the "next" definition of the function in cases where
+ // there are multiple layers of preloading).
+)
+
+// TODO: dlmopen
+// TODO: dlvsym
+// TODO: dladdr
+// - dladdr1
+// TODO: dlinfo
+// - RTLD_DI_LMID
+// - RTLD_DI_LINKMAP
+// - RTLD_DI_ORIGIN
+// - RTLD_DI_SERINFO
+// - RTLD_DI_SERINFOSIZE
+// - RTLD_DI_MODID
+// - RTLD_DI_DATA
+// TODO: dl_iterate_phdr
+// TODO: rtld-audit(7)
+