diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -9,6 +9,7 @@ SRCS+= \ __pthread_mutex_init_calloc_cb_stub.c \ __xuname.c \ + _once_stub.c \ _pthread_stubs.c \ _rand48.c \ _spinlock_stub.c \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -99,7 +99,6 @@ vwarnx; sys_errlist; sys_nerr; - errno; exect; execl; execle; diff --git a/lib/libsys/_once_stub.c b/lib/libc/gen/_once_stub.c rename from lib/libsys/_once_stub.c rename to lib/libc/gen/_once_stub.c diff --git a/lib/libc/gen/errno.c b/lib/libc/gen/errno.c --- a/lib/libc/gen/errno.c +++ b/lib/libc/gen/errno.c @@ -26,4 +26,22 @@ * SUCH DAMAGE. */ +#include + +/* + * Symbols are only used for filtering. + */ +#ifndef PIC int errno; + +void +__set_error_selector(int *(*arg)(void)) +{ +} + +int * +__error(void) +{ + return (NULL); +} +#endif diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -21,11 +21,17 @@ LIB=sys SHLIB_MAJOR= 7 WARNS?= 2 +MK_SSP= no CFLAGS+=-I${LIBSYS_SRCTOP}/include -I${LIBC_SRCTOP}/include CFLAGS+=-I${LIBSYS_SRCTOP}/${LIBC_ARCH} CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH} +.PATH: ${LIBC_SRCTOP}/string +SRCS+= memcpy.c memset.c strlcpy.c + +SRCS+= __error.c + CLEANFILES+=tags INSTALL_PIC_ARCHIVE= #XXX? BUILD_NOSSP_PIC_ARCHIVE= diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -31,9 +31,7 @@ # Sources common to both syscall interfaces: SRCS+= \ - __error.c \ __getosreldate.c \ - _once_stub.c \ getpagesize.c \ getpagesizes.c \ interposing_table.c diff --git a/lib/libsys/Symbol.sys.map b/lib/libsys/Symbol.sys.map --- a/lib/libsys/Symbol.sys.map +++ b/lib/libsys/Symbol.sys.map @@ -76,6 +76,7 @@ extattr_set_file; extattr_set_link; extattrctl; + errno; fchdir; fchflags; fchmod; diff --git a/lib/libsys/__error.c b/lib/libsys/__error.c --- a/lib/libsys/__error.c +++ b/lib/libsys/__error.c @@ -31,7 +31,7 @@ #include "libc_private.h" -extern int errno; +int errno; static int * __error_unthreaded(void) diff --git a/lib/libsys/auxv.c b/lib/libsys/auxv.c --- a/lib/libsys/auxv.c +++ b/lib/libsys/auxv.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include "un-namespace.h" @@ -40,6 +41,8 @@ #pragma weak _DYNAMIC void *__elf_aux_vector; + +#ifndef PIC static pthread_once_t aux_vector_once = PTHREAD_ONCE_INIT; static void @@ -61,8 +64,9 @@ return; _once(&aux_vector_once, init_aux_vector_once); } +#endif -static pthread_once_t aux_once = PTHREAD_ONCE_INIT; +static bool aux_once = false; static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags; static int hwcap_present, hwcap2_present; static char *canary, *pagesizes, *execpath; @@ -82,6 +86,8 @@ { Elf_Auxinfo *aux; + if (aux_once) + return; for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) { switch (aux->a_type) { case AT_BSDFLAGS: @@ -166,6 +172,8 @@ if (!powerpc_new_auxv_format) _init_aux_powerpc_fixup(); #endif + + aux_once = true; } #ifdef __powerpc__ @@ -256,10 +264,12 @@ { int res; +#ifndef PIC __init_elf_aux_vector(); +#endif if (__elf_aux_vector == NULL) return (ENOSYS); - _once(&aux_once, init_aux); + init_aux(); /* idempotent */ if (buflen < 0) return (EINVAL); diff --git a/libexec/rtld-elf/rtld-libc/rtld_libc.c b/libexec/rtld-elf/rtld-libc/rtld_libc.c --- a/libexec/rtld-elf/rtld-libc/rtld_libc.c +++ b/libexec/rtld-elf/rtld-libc/rtld_libc.c @@ -105,7 +105,7 @@ return (page_size); } -extern int __sys___sysctl(const int *name, u_int namelen, void *oldp, +int __sys___sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, const void *newp, size_t newlen); int