summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/debug.h
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>1999-12-27 04:44:04 +0000
committerjdp <jdp@FreeBSD.org>1999-12-27 04:44:04 +0000
commit52ec4df9e85a6ae74cd9f5cf905ae35c0c1a6670 (patch)
treee4e05bba4c3de19150902d099920062a8bdb21ab /libexec/rtld-elf/debug.h
parentefacb21bbc4c5e4ae5ef661233ee6249ee8a0e7f (diff)
downloadFreeBSD-src-52ec4df9e85a6ae74cd9f5cf905ae35c0c1a6670.zip
FreeBSD-src-52ec4df9e85a6ae74cd9f5cf905ae35c0c1a6670.tar.gz
Add a new function dllockinit() for registering thread locking
functions to be used by the dynamic linker. This can be called by threads packages at start-up time. I will add the call to libc_r soon. Also add a default locking method that is used up until dllockinit() is called. The default method works by blocking SIGVTALRM, SIGPROF, and SIGALRM in critical sections. It is based on the observation that most user-space threads packages implement thread preemption with one of these signals (usually SIGVTALRM). The dynamic linker has never been reentrant, but it became less reentrant in revision 1.34 of "src/libexec/rtld-elf/rtld.c". Starting with that revision, multiple threads each doing lazy binding could interfere with each other. The usual symptom was that a symbol was falsely reported as undefined at start-up time. It was rare but not unseen. This commit fixes it.
Diffstat (limited to 'libexec/rtld-elf/debug.h')
-rw-r--r--libexec/rtld-elf/debug.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/libexec/rtld-elf/debug.h b/libexec/rtld-elf/debug.h
index b356338..2600651 100644
--- a/libexec/rtld-elf/debug.h
+++ b/libexec/rtld-elf/debug.h
@@ -38,6 +38,9 @@
#include <sys/cdefs.h>
+#include <string.h>
+#include <unistd.h>
+
extern void debug_printf(const char *, ...) __printflike(1, 2);
extern int debug;
@@ -47,4 +50,10 @@ extern int debug;
#define dbg(format, args...) ((void) 0)
#endif
+#define assert(cond) ((cond) ? (void) 0 : \
+ (msg("ld-elf.so.1: assert failed: " __FILE__ ":" \
+ __XSTRING(__LINE__) "\n"), abort()))
+#define msg(s) write(1, s, strlen(s))
+#define trace() msg("ld-elf.so.1: " __XSTRING(__LINE__) "\n")
+
#endif /* DEBUG_H */
OpenPOWER on IntegriCloud