diff options
author | 2012-08-13 04:52:42 +0000 | |
---|---|---|
committer | 2012-08-13 04:52:42 +0000 | |
commit | 5c815786232601794b9612d2c3b2be977d06bb2a (patch) | |
tree | 81032aa30bebaa8b8ce34a84d5c29be4c3b678f3 | |
parent | replace uint32_ts for hi and lo addresses in the mfi_init_ hardware (diff) | |
download | wireguard-openbsd-5c815786232601794b9612d2c3b2be977d06bb2a.tar.xz wireguard-openbsd-5c815786232601794b9612d2c3b2be977d06bb2a.zip |
Add explicit references from rthread.o to all of the weak symbol
overrides provided by libpthread.a. This ensures that statically
linked threaded programs use (e.g.) __cerror() from libpthread.a
instead of libc.a. (Same idea previously used by libuthread.)
Thanks to fgsch@ for pointing out libuthread's solution to the static
linking problem.
ok guenther@, tedu@;
-rw-r--r-- | lib/librthread/rthread.c | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index 27a9b6dbf72..ccc42898524 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.62 2012/06/21 00:56:59 guenther Exp $ */ +/* $OpenBSD: rthread.c,v 1.63 2012/08/13 04:52:42 matthew Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -21,6 +21,11 @@ */ #include <sys/types.h> +#include <sys/uio.h> +#include <sys/wait.h> +#include <sys/socket.h> +#include <sys/mman.h> +#include <sys/msg.h> #include <stdlib.h> #include <unistd.h> @@ -29,6 +34,8 @@ #include <string.h> #include <errno.h> #include <dlfcn.h> +#include <fcntl.h> +#include <poll.h> #include <pthread.h> @@ -638,3 +645,66 @@ _rthread_bind_lock(int what) _spinunlock(&lock); } #endif + +/* + * XXX: Bogus type signature, but we only need to be able to emit a + * reference to it below. + */ +extern void __cerror(void); + +/* + * All weak references used within libc that are redefined in libpthread + * MUST be in this table. This is necessary to force the proper version to + * be used when linking -static. + */ +static void *__libc_overrides[] __used = { + &__cerror, + &__errno, + &_thread_arc4_lock, + &_thread_arc4_unlock, + &_thread_atexit_lock, + &_thread_atexit_unlock, + &_thread_malloc_lock, + &_thread_malloc_unlock, + &_thread_mutex_destroy, + &_thread_mutex_lock, + &_thread_mutex_unlock, + &_thread_tag_lock, + &_thread_tag_storage, + &_thread_tag_unlock, + &accept, + &close, + &closefrom, + &connect, + &fcntl, + &flockfile, + &fork, + &fsync, + &ftrylockfile, + &funlockfile, + &msgrcv, + &msgsnd, + &msync, + &nanosleep, + &open, + &openat, + &poll, + &pread, + &preadv, + &pwrite, + &pwritev, + &read, + &readv, + &recvfrom, + &recvmsg, + &select, + &sendmsg, + &sendto, + &sigaction, + &sigprocmask, + &sigsuspend, + &vfork, + &wait4, + &write, + &writev, +}; |