Page MenuHomeFreeBSD

D43985.id134747.diff
No OneTemporary

D43985.id134747.diff

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 \
@@ -46,7 +47,6 @@
erand48.c \
err.c \
errlst.c \
- errno.c \
eventfd.c \
exec.c \
exect.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
deleted file mode 100644
--- a/lib/libc/gen/errno.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2002 Peter Wemm <peter@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-int errno;
diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile
--- a/lib/libsys/Makefile
+++ b/lib/libsys/Makefile
@@ -21,11 +21,15 @@
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
+
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
@@ -33,7 +33,6 @@
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 <errno.h>
#include <link.h>
#include <pthread.h>
+#include <stdbool.h>
#include <string.h>
#include <sys/auxv.h>
#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;
@@ -77,11 +81,19 @@
int _powerpc_elf_aux_info(int, void *, int);
#endif
+/*
+ * This function might be called and actual body executed more than
+ * once in multithreading environment. Due to this, it is and must
+ * continue to be idempotent. All stores are atomic (no store
+ * tearing), because we only assign to int/long/ptr.
+ */
static void
init_aux(void)
{
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 +178,8 @@
if (!powerpc_new_auxv_format)
_init_aux_powerpc_fixup();
#endif
+
+ aux_once = true;
}
#ifdef __powerpc__
@@ -256,10 +270,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

File Metadata

Mime Type
text/plain
Expires
Mon, Jun 29, 8:13 AM (8 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34455424
Default Alt Text
D43985.id134747.diff (5 KB)

Event Timeline