Use macro STATIC_LIB_REQUIRE to declare a symbol should be linked into

static binary.
This commit is contained in:
David Xu 2006-01-10 04:53:03 +00:00
parent 174cda8010
commit 9572a73405
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=154160
2 changed files with 74 additions and 95 deletions

View file

@ -33,36 +33,22 @@
* $FreeBSD$
*/
/* Allocate space for global thread variables here: */
#define GLOBAL_PTHREAD_PRIVATE
#include "namespace.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/signalvar.h>
#include <machine/reg.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <sys/event.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/ttycom.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <pthread.h>
#include <pthread_np.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "un-namespace.h"
@ -133,62 +119,59 @@ static void init_main_thread(struct pthread *thread);
* All weak references used within libc should be in this table.
* This is so that static libraries will work.
*/
static void *references[] = {
&_accept,
&_bind,
&_close,
&_connect,
&_dup,
&_dup2,
&_execve,
&_fcntl,
&_flock,
&_flockfile,
&_fstat,
&_fstatfs,
&_fsync,
&_funlockfile,
&_getdirentries,
&_getlogin,
&_getpeername,
&_getsockname,
&_getsockopt,
&_ioctl,
&_kevent,
&_listen,
&_nanosleep,
&_open,
&_pthread_getspecific,
&_pthread_key_create,
&_pthread_key_delete,
&_pthread_mutex_destroy,
&_pthread_mutex_init,
&_pthread_mutex_lock,
&_pthread_mutex_trylock,
&_pthread_mutex_unlock,
&_pthread_mutexattr_init,
&_pthread_mutexattr_destroy,
&_pthread_mutexattr_settype,
&_pthread_once,
&_pthread_setspecific,
&_read,
&_readv,
&_recvfrom,
&_recvmsg,
&_select,
&_sendmsg,
&_sendto,
&_setsockopt,
&_sigaction,
&_sigprocmask,
&_sigsuspend,
&_socket,
&_socketpair,
&_thread_init_hack,
&_wait4,
&_write,
&_writev
};
STATIC_LIB_REQUIRE(_accept);
STATIC_LIB_REQUIRE(_bind);
STATIC_LIB_REQUIRE(_close);
STATIC_LIB_REQUIRE(_connect);
STATIC_LIB_REQUIRE(_dup);
STATIC_LIB_REQUIRE(_dup2);
STATIC_LIB_REQUIRE(_execve);
STATIC_LIB_REQUIRE(_fcntl);
STATIC_LIB_REQUIRE(_flock);
STATIC_LIB_REQUIRE(_flockfile);
STATIC_LIB_REQUIRE(_fstat);
STATIC_LIB_REQUIRE(_fstatfs);
STATIC_LIB_REQUIRE(_fsync);
STATIC_LIB_REQUIRE(_getdirentries);
STATIC_LIB_REQUIRE(_getlogin);
STATIC_LIB_REQUIRE(_getpeername);
STATIC_LIB_REQUIRE(_getsockname);
STATIC_LIB_REQUIRE(_getsockopt);
STATIC_LIB_REQUIRE(_ioctl);
STATIC_LIB_REQUIRE(_kevent);
STATIC_LIB_REQUIRE(_listen);
STATIC_LIB_REQUIRE(_nanosleep);
STATIC_LIB_REQUIRE(_open);
STATIC_LIB_REQUIRE(_pthread_getspecific);
STATIC_LIB_REQUIRE(_pthread_key_create);
STATIC_LIB_REQUIRE(_pthread_key_delete);
STATIC_LIB_REQUIRE(_pthread_mutex_destroy);
STATIC_LIB_REQUIRE(_pthread_mutex_init);
STATIC_LIB_REQUIRE(_pthread_mutex_lock);
STATIC_LIB_REQUIRE(_pthread_mutex_trylock);
STATIC_LIB_REQUIRE(_pthread_mutex_unlock);
STATIC_LIB_REQUIRE(_pthread_mutexattr_init);
STATIC_LIB_REQUIRE(_pthread_mutexattr_destroy);
STATIC_LIB_REQUIRE(_pthread_mutexattr_settype);
STATIC_LIB_REQUIRE(_pthread_once);
STATIC_LIB_REQUIRE(_pthread_setspecific);
STATIC_LIB_REQUIRE(_read);
STATIC_LIB_REQUIRE(_readv);
STATIC_LIB_REQUIRE(_recvfrom);
STATIC_LIB_REQUIRE(_recvmsg);
STATIC_LIB_REQUIRE(_select);
STATIC_LIB_REQUIRE(_sendmsg);
STATIC_LIB_REQUIRE(_sendto);
STATIC_LIB_REQUIRE(_setsockopt);
STATIC_LIB_REQUIRE(_sigaction);
STATIC_LIB_REQUIRE(_sigprocmask);
STATIC_LIB_REQUIRE(_sigsuspend);
STATIC_LIB_REQUIRE(_socket);
STATIC_LIB_REQUIRE(_socketpair);
STATIC_LIB_REQUIRE(_thread_init_hack);
STATIC_LIB_REQUIRE(_wait4);
STATIC_LIB_REQUIRE(_write);
STATIC_LIB_REQUIRE(_writev);
/*
* These are needed when linking statically. All references within
@ -196,19 +179,20 @@ static void *references[] = {
* if they are not (strongly) referenced by the application or other
* libraries, then the actual functions will not be loaded.
*/
static void *libgcc_references[] = {
&_pthread_once,
&_pthread_key_create,
&_pthread_key_delete,
&_pthread_getspecific,
&_pthread_setspecific,
&_pthread_mutex_init,
&_pthread_mutex_destroy,
&_pthread_mutex_lock,
&_pthread_mutex_trylock,
&_pthread_mutex_unlock,
&_pthread_create
};
STATIC_LIB_REQUIRE(_pthread_once);
STATIC_LIB_REQUIRE(_pthread_key_create);
STATIC_LIB_REQUIRE(_pthread_key_delete);
STATIC_LIB_REQUIRE(_pthread_getspecific);
STATIC_LIB_REQUIRE(_pthread_setspecific);
STATIC_LIB_REQUIRE(_pthread_mutex_init);
STATIC_LIB_REQUIRE(_pthread_mutex_destroy);
STATIC_LIB_REQUIRE(_pthread_mutex_lock);
STATIC_LIB_REQUIRE(_pthread_mutex_trylock);
STATIC_LIB_REQUIRE(_pthread_mutex_unlock);
STATIC_LIB_REQUIRE(_pthread_create);
/* Pull in all symbols required by libthread_db */
STATIC_LIB_REQUIRE(_thread_state_running);
#define DUAL_ENTRY(entry) \
(pthread_func_t)entry, (pthread_func_t)entry
@ -247,7 +231,6 @@ static pthread_func_t jmp_table[][2] = {
{DUAL_ENTRY(_pthread_sigmask)} /* PJT_SIGMASK */
};
extern int _thread_state_running;
static int init_once = 0;
/*
@ -293,16 +276,6 @@ _libpthread_init(struct pthread *curthread)
/* Only initialize the threaded application once. */
return;
/*
* Make gcc quiescent about {,libgcc_}references not being
* referenced:
*/
if ((references[0] == NULL) || (libgcc_references[0] == NULL))
PANIC("Failed loading mandatory references in _thread_init");
/* Pull debug symbols in for static binary */
_thread_state_running = PS_RUNNING;
/*
* Check the size of the jump table to make sure it is preset
* with the correct number of entries.

View file

@ -83,6 +83,12 @@ typedef TAILQ_HEAD(atfork_head, pthread_atfork) atfork_head;
#define THR_ASSERT(cond, msg)
#endif
#ifdef PIC
# define STATIC_LIB_REQUIRE(name)
#else
# define STATIC_LIB_REQUIRE(name) __asm (".globl " #name)
#endif
#define TIMESPEC_ADD(dst, src, val) \
do { \
(dst)->tv_sec = (src)->tv_sec + (val)->tv_sec; \