summaryrefslogtreecommitdiff
path: root/csu
diff options
context:
space:
mode:
Diffstat (limited to 'csu')
-rw-r--r--csu/Makefile77
-rw-r--r--csu/abi-note.S2
-rw-r--r--csu/check_fds.c23
-rw-r--r--csu/dso_handle.c2
-rw-r--r--csu/elf-init.c2
-rw-r--r--csu/errno-loc.c2
-rw-r--r--csu/errno.c2
-rw-r--r--csu/gmon-start.c2
-rw-r--r--csu/init-first.c12
-rw-r--r--csu/init.c15
-rw-r--r--csu/libc-start.c61
-rw-r--r--csu/libc-tls.c49
-rw-r--r--csu/static-reloc.c (renamed from csu/tst-atomic-long.c)17
-rw-r--r--csu/tst-atomic.c640
-rw-r--r--csu/tst-empty.c9
-rw-r--r--csu/version.c9
16 files changed, 142 insertions, 782 deletions
diff --git a/csu/Makefile b/csu/Makefile
index 31e8bb98a0..88fc77662e 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -1,5 +1,5 @@
# Makefile for csu code for GNU C library.
-# Copyright (C) 1995-2016 Free Software Foundation, Inc.
+# Copyright (C) 1995-2018 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -37,13 +37,34 @@ extra-objs = start.o \
S$(start-installed-name)
omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
b$(start-installed-name) $(csu-dummies) \
- S$(start-installed-name))
+ S$(start-installed-name) \
+ r$(start-installed-name) \
+ gr$(start-installed-name))
install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
-generated += version-info.h
-before-compile += $(objpfx)version-info.h
-tests := tst-empty tst-atomic tst-atomic-long
-tests-static := tst-empty
+# No tests are allowed in the csu/ subdirectory because the startup
+# code is compiled with special flags.
+tests =
+
+CFLAGS-.o += $(no-stack-protector)
+CFLAGS-.op += $(no-stack-protector)
+CFLAGS-.os += $(no-stack-protector)
+
+# Dummy object not actually used for anything. It is linked into
+# crt1.o nevertheless, which in turn is statically linked into
+# applications, so that build flags matter.
+# See <https://sourceware.org/ml/libc-alpha/2018-07/msg00101.html>.
+# NB: Using $(stack-protector) in this way causes a wrong definition
+# STACK_PROTECTOR_LEVEL due to the preceding $(no-stack-protector),
+# but it does not matter for this source file.
+CFLAGS-static-reloc.os += $(stack-protector)
+
+# This file is not actually part of the startup code in the nonshared
+# case and statically linked into applications. See
+# <https://sourceware.org/bugzilla/show_bug.cgi?id=23323>,
+# <https://sourceware.org/ml/libc-alpha/2018-06/msg00717.html>.
+# Also see the note above regarding STACK_PROTECTOR_LEVEL.
+CFLAGS-elf-init.oS += $(stack-protector)
ifeq (yes,$(build-shared))
extra-objs += S$(start-installed-name) gmon-start.os
@@ -57,10 +78,17 @@ extra-objs += gmon-start.o
endif
ifneq ($(start-installed-name),$(static-start-installed-name))
+# FIXME: Only Hurd defines static-start-installed-name. Hurd needs to
+# provide special rules to support static PIE.
extra-objs += $(static-start-installed-name) g$(static-start-installed-name)
omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \
g$(static-start-installed-name))
install-lib += $(static-start-installed-name) g$(static-start-installed-name)
+else
+ifeq (yes,$(enable-static-pie))
+extra-objs += r$(start-installed-name) gr$(start-installed-name)
+install-lib += r$(start-installed-name) gr$(start-installed-name)
+endif
endif
before-compile += $(objpfx)abi-tag.h
@@ -74,9 +102,20 @@ crtstuff = crti crtn
install-lib += $(crtstuff:=.o)
extra-objs += $(crtstuff:=.o)
-extra-objs += abi-note.o init.o
+ifneq ($(multidir),.)
+multilib-extra-objs = $(addprefix $(multidir)/, $(install-lib))
+extra-objs += $(multilib-extra-objs)
+endif
+
+extra-objs += abi-note.o init.o static-reloc.o
+ifeq (yes,$(build-shared))
+extra-objs += static-reloc.os
+endif
asm-CPPFLAGS += -I$(objpfx).
+# Enable unwinding so backtrace unwinds to __libc_start_main
+CFLAGS-libc-start.c += -funwind-tables
+
include ../Rules
# Make these in the lib pass so they're available in time to link things with.
@@ -90,6 +129,9 @@ ifndef start-installed-name-rule
# We link the ELF startfile along with a SHT_NOTE section indicating
# the kernel ABI the binaries linked with this library will require.
$(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
+ $(objpfx)init.o $(objpfx)static-reloc.o
+ $(link-relocatable)
+$(objpfx)r$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
$(objpfx)init.o
$(link-relocatable)
$(objpfx)S$(start-installed-name): $(objpfx)start.os $(objpfx)abi-note.o \
@@ -102,7 +144,10 @@ endif
# to turn on profiling code at startup.
ifeq (yes,$(build-shared))
$(objpfx)g$(start-installed-name): \
- $(objpfx)g%: $(objpfx)S% $(objpfx)gmon-start.os
+ $(objpfx)g%: $(objpfx)S% $(objpfx)gmon-start.os $(objpfx)static-reloc.os
+ $(link-relocatable)
+$(objpfx)gr$(start-installed-name): \
+ $(objpfx)gr%: $(objpfx)r% $(objpfx)gmon-start.o
$(link-relocatable)
ifneq ($(start-installed-name),$(static-start-installed-name))
$(objpfx)g$(static-start-installed-name): \
@@ -142,15 +187,7 @@ $(objpfx)abi-tag.h: $(..)abi-tags
if test -r $@.new; then mv -f $@.new $@; \
else echo >&2 'This configuration not matched in $<'; exit 1; fi
-all-Banner-files = $(wildcard $(addsuffix /Banner,\
- $(sort $(subdir-srcdirs) \
- $(sysdeps-srcdirs))))
-$(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files)
- $(make-target-directory)
- (files="$(all-Banner-files)"; \
- if test -n "$$files"; then \
- printf '"Available extensions:\\n"\n'; \
- sed -e '/^#/d' -e 's/^[[:space:]]*/ /' \
- -e 's/^\(.*\)$$/\"\1\\n\"/' $$files; \
- fi) > $@T
- mv -f $@T $@
+ifneq ($(multidir),.)
+$(addprefix $(objpfx)$(multidir)/, $(install-lib)): $(addprefix $(objpfx), $(install-lib))
+ $(make-link-multidir)
+endif
diff --git a/csu/abi-note.S b/csu/abi-note.S
index eed2ceb718..5d0ca7803d 100644
--- a/csu/abi-note.S
+++ b/csu/abi-note.S
@@ -1,5 +1,5 @@
/* Special .init and .fini section support.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/csu/check_fds.c b/csu/check_fds.c
index baa77a95d7..ad1763b398 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -39,8 +39,7 @@
static void
check_one_fd (int fd, int mode)
{
- /* Note that fcntl() with this parameter is not a cancellation point. */
- if (__builtin_expect (__libc_fcntl (fd, F_GETFD), 0) == -1
+ if (__builtin_expect (__fcntl64_nocancel (fd, F_GETFD), 0) == -1
&& errno == EBADF)
{
const char *name;
@@ -50,18 +49,18 @@ check_one_fd (int fd, int mode)
if ((mode & O_ACCMODE) == O_WRONLY)
{
name = _PATH_DEV "full";
- dev = makedev (DEV_FULL_MAJOR, DEV_FULL_MINOR);
+ dev = __gnu_dev_makedev (DEV_FULL_MAJOR, DEV_FULL_MINOR);
}
else
{
name = _PATH_DEVNULL;
- dev = makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR);
+ dev = __gnu_dev_makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR);
}
/* Something is wrong with this descriptor, it's probably not
opened. Open /dev/null so that the SUID program we are
about to start does not accidentally use this descriptor. */
- int nullfd = open_not_cancel (name, mode, 0);
+ int nullfd = __open_nocancel (name, mode, 0);
/* We are very paranoid here. With all means we try to ensure
that we are actually opening the /dev/null device and nothing
@@ -87,14 +86,10 @@ check_one_fd (int fd, int mode)
void
__libc_check_standard_fds (void)
{
- /* This is really paranoid but some people actually are. If /dev/null
- should happen to be a symlink to somewhere else and not the device
- commonly known as "/dev/null" we bail out. We can detect this with
- the O_NOFOLLOW flag for open() but only on some system. */
-#ifndef O_NOFOLLOW
-# define O_NOFOLLOW 0
-#endif
- /* Check all three standard file descriptors. */
+ /* Check all three standard file descriptors. The O_NOFOLLOW flag
+ is really paranoid but some people actually are. If /dev/null
+ should happen to be a symlink to somewhere else and not the
+ device commonly known as "/dev/null" we bail out. */
check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW);
check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW);
check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW);
diff --git a/csu/dso_handle.c b/csu/dso_handle.c
index 7a614ca3b3..d8e32fe1b1 100644
--- a/csu/dso_handle.c
+++ b/csu/dso_handle.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/csu/elf-init.c b/csu/elf-init.c
index 0fb98f1606..da59b2c77b 100644
--- a/csu/elf-init.c
+++ b/csu/elf-init.c
@@ -1,5 +1,5 @@
/* Startup support for ELF initializers/finalizers in the main executable.
- Copyright (C) 2002-2016 Free Software Foundation, Inc.
+ Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/csu/errno-loc.c b/csu/errno-loc.c
index d8bbb5fd8b..2fe3608d16 100644
--- a/csu/errno-loc.c
+++ b/csu/errno-loc.c
@@ -1,6 +1,6 @@
/* MT support function to get address of `errno' variable, non-threaded
version.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/csu/errno.c b/csu/errno.c
index 778c941edb..e762d02a66 100644
--- a/csu/errno.c
+++ b/csu/errno.c
@@ -1,5 +1,5 @@
/* Definition of `errno' variable. Canonical version.
- Copyright (C) 2002-2016 Free Software Foundation, Inc.
+ Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/csu/gmon-start.c b/csu/gmon-start.c
index 62c123c9a9..6a130890a9 100644
--- a/csu/gmon-start.c
+++ b/csu/gmon-start.c
@@ -1,5 +1,5 @@
/* Code to enable profiling at program startup.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/csu/init-first.c b/csu/init-first.c
index 77c6e1cb9e..289373f9d8 100644
--- a/csu/init-first.c
+++ b/csu/init-first.c
@@ -1,5 +1,5 @@
/* Initialization code run first thing by the ELF startup code. Common version
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -51,9 +51,6 @@ attribute_hidden
_init (int argc, char **argv, char **envp)
{
#endif
-#ifdef USE_NONOPTION_FLAGS
- extern void __getopt_clean_environment (char **);
-#endif
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
@@ -72,8 +69,6 @@ _init (int argc, char **argv, char **envp)
__environ = envp;
#ifndef SHARED
- __libc_init_secure ();
-
/* First the initialization which normally would be done by the
dynamic linker. */
_dl_non_dynamic_init ();
@@ -85,11 +80,6 @@ _init (int argc, char **argv, char **envp)
__init_misc (argc, argv, envp);
-#ifdef USE_NONOPTION_FLAGS
- /* This is a hack to make the special getopt in GNU libc working. */
- __getopt_clean_environment (envp);
-#endif
-
/* Initialize ctype data. */
__ctype_init ();
diff --git a/csu/init.c b/csu/init.c
index 93277268bb..c2f978f3da 100644
--- a/csu/init.c
+++ b/csu/init.c
@@ -1,5 +1,5 @@
/* Special startup support.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,11 +16,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#if defined __GNUC__ && __GNUC__ >= 2
-
-#include <_G_config.h>
-
-/* This records which stdio is linked against in the application. */
-const int _IO_stdin_used = _G_IO_IO_FILE_VERSION;
-
-#endif
+/* Vestigial libio version number. Some code in libio checks whether
+ this symbol exists in the executable, but nothing looks at its
+ value anymore; the value it was historically set to has been
+ preserved out of an abundance of caution. */
+const int _IO_stdin_used = 0x20001;
diff --git a/csu/libc-start.c b/csu/libc-start.c
index f4aa01a988..494132368f 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,18 +21,15 @@
#include <unistd.h>
#include <ldsodefs.h>
#include <exit-thread.h>
+#include <libc-internal.h>
-extern void __libc_init_first (int argc, char **argv, char **envp);
-#ifndef SHARED
-extern void __libc_csu_irel (void);
-#endif
+#include <elf/dl-tunables.h>
-extern int __libc_multiple_libcs;
+extern void __libc_init_first (int argc, char **argv, char **envp);
#include <tls.h>
#ifndef SHARED
# include <dl-osinfo.h>
-extern void __pthread_initialize_minimal (void);
# ifndef THREAD_SET_STACK_GUARD
/* Only exported for architectures that don't store the stack guard canary
in thread local area. */
@@ -105,6 +102,12 @@ apply_irel (void)
# define MAIN_AUXVEC_PARAM
#endif
+#ifndef ARCH_INIT_CPU_FEATURES
+# define ARCH_INIT_CPU_FEATURES()
+#endif
+
+#include <libc-start.h>
+
STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
MAIN_AUXVEC_DECL),
int argc,
@@ -138,6 +141,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
#ifndef SHARED
+ _dl_relocate_static_pie ();
+
char **ev = &argv[argc + 1];
__environ = ev;
@@ -178,22 +183,23 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
}
}
-# ifdef DL_SYSDEP_OSCHECK
- if (!__libc_multiple_libcs)
- {
- /* This needs to run to initiliaze _dl_osversion before TLS
- setup might check it. */
- DL_SYSDEP_OSCHECK (__libc_fatal);
- }
-# endif
+ /* Initialize very early so that tunables can use it. */
+ __libc_init_secure ();
+
+ __tunables_init (__environ);
+
+ ARCH_INIT_CPU_FEATURES ();
/* Perform IREL{,A} relocations. */
- apply_irel ();
+ ARCH_SETUP_IREL ();
+
+ /* The stack guard goes into the TCB, so initialize it early. */
+ ARCH_SETUP_TLS ();
- /* Initialize the thread library at least a bit since the libgcc
- functions are using thread functions if these are available and
- we need to setup errno. */
- __pthread_initialize_minimal ();
+ /* In some architectures, IREL{,A} relocations happen after TLS setup in
+ order to let IFUNC resolvers benefit from TCB information, e.g. powerpc's
+ hwcap and platform fields available in the TCB. */
+ ARCH_APPLY_IREL ();
/* Set up the stack checker's canary. */
uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
@@ -203,6 +209,19 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
__stack_chk_guard = stack_chk_guard;
# endif
+# ifdef DL_SYSDEP_OSCHECK
+ if (!__libc_multiple_libcs)
+ {
+ /* This needs to run to initiliaze _dl_osversion before TLS
+ setup might check it. */
+ DL_SYSDEP_OSCHECK (__libc_fatal);
+ }
+# endif
+
+ /* Initialize libpthread if linked in. */
+ if (__pthread_initialize_minimal != NULL)
+ __pthread_initialize_minimal ();
+
/* Set up the pointer guard value. */
uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
stack_chk_guard);
@@ -212,7 +231,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
__pointer_chk_guard_local = pointer_chk_guard;
# endif
-#endif
+#endif /* !SHARED */
/* Register the destructor of the dynamic linker if there is any. */
if (__glibc_likely (rtld_fini != NULL))
diff --git a/csu/libc-tls.c b/csu/libc-tls.c
index d6425e0189..28a79441cd 100644
--- a/csu/libc-tls.c
+++ b/csu/libc-tls.c
@@ -1,5 +1,5 @@
/* Initialization code for TLS in statically linked application.
- Copyright (C) 2002-2016 Free Software Foundation, Inc.
+ Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <startup.h>
#include <errno.h>
#include <ldsodefs.h>
#include <tls.h>
@@ -102,17 +103,19 @@ init_static_tls (size_t memsz, size_t align)
}
void
-__libc_setup_tls (size_t tcbsize, size_t tcbalign)
+__libc_setup_tls (void)
{
void *tlsblock;
size_t memsz = 0;
size_t filesz = 0;
void *initimage = NULL;
size_t align = 0;
- size_t max_align = tcbalign;
+ size_t max_align = TCB_ALIGNMENT;
size_t tcb_offset;
const ElfW(Phdr) *phdr;
+ struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+
/* Look through the TLS segment if there is any. */
if (_dl_phdr != NULL)
for (phdr = _dl_phdr; phdr < &_dl_phdr[_dl_phnum]; ++phdr)
@@ -121,7 +124,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
/* Remember the values we need. */
memsz = phdr->p_memsz;
filesz = phdr->p_filesz;
- initimage = (void *) phdr->p_vaddr;
+ initimage = (void *) phdr->p_vaddr + main_map->l_addr;
align = phdr->p_align;
if (phdr->p_align > max_align)
max_align = phdr->p_align;
@@ -142,9 +145,9 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
_dl_allocate_tls_storage (in elf/dl-tls.c) does using __libc_memalign
and dl_tls_static_align. */
tcb_offset = roundup (memsz + GL(dl_tls_static_size), max_align);
- tlsblock = __sbrk (tcb_offset + tcbsize + max_align);
+ tlsblock = __sbrk (tcb_offset + TLS_INIT_TCB_SIZE + max_align);
#elif TLS_DTV_AT_TP
- tcb_offset = roundup (tcbsize, align ?: 1);
+ tcb_offset = roundup (TLS_INIT_TCB_SIZE, align ?: 1);
tlsblock = __sbrk (tcb_offset + memsz + max_align
+ TLS_PRE_TCB_SIZE + GL(dl_tls_static_size));
tlsblock += TLS_PRE_TCB_SIZE;
@@ -162,8 +165,6 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
_dl_static_dtv[0].counter = (sizeof (_dl_static_dtv) / sizeof (_dl_static_dtv[0])) - 2;
// _dl_static_dtv[1].counter = 0; would be needed if not already done
- struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
-
/* Initialize the TLS block. */
#if TLS_TCB_AT_TP
_dl_static_dtv[2].pointer.val = ((char *) tlsblock + tcb_offset
@@ -175,7 +176,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
#else
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
#endif
- _dl_static_dtv[2].pointer.is_static = true;
+ _dl_static_dtv[2].pointer.to_free = NULL;
/* sbrk gives us zero'd memory, so we don't need to clear the remainder. */
memcpy (_dl_static_dtv[2].pointer.val, initimage, filesz);
@@ -193,7 +194,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
#endif
if (__builtin_expect (lossage != NULL, 0))
- __libc_fatal (lossage);
+ _startup_fatal (lossage);
/* Update the executable's link map with enough information to make
the TLS routines happy. */
@@ -215,31 +216,3 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
init_static_tls (memsz, MAX (TLS_TCB_ALIGN, max_align));
}
-
-/* This is called only when the data structure setup was skipped at startup,
- when there was no need for it then. Now we have dynamically loaded
- something needing TLS, or libpthread needs it. */
-int
-internal_function
-_dl_tls_setup (void)
-{
- init_slotinfo ();
- init_static_tls (
-#if TLS_TCB_AT_TP
- TLS_TCB_SIZE,
-#else
- 0,
-#endif
- TLS_TCB_ALIGN);
- return 0;
-}
-
-
-/* This is the minimal initialization function used when libpthread is
- not used. */
-void
-__attribute__ ((weak))
-__pthread_initialize_minimal (void)
-{
- __libc_setup_tls (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN);
-}
diff --git a/csu/tst-atomic-long.c b/csu/static-reloc.c
index 6b62299d60..70729fb4dc 100644
--- a/csu/tst-atomic-long.c
+++ b/csu/static-reloc.c
@@ -1,7 +1,6 @@
-/* Tests for atomic.h macros.
- Copyright (C) 2003-2016 Free Software Foundation, Inc.
+/* Special startup support for non-PIE static executables.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,11 +16,11 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <bits/wordsize.h>
+#if ENABLE_STATIC_PIE
+#include <ldsodefs.h>
-#define atomic_t long
-#if __WORDSIZE == 64
-# define TEST_ATOMIC64 1
+void
+_dl_relocate_static_pie (void)
+{
+}
#endif
-
-#include "tst-atomic.c"
diff --git a/csu/tst-atomic.c b/csu/tst-atomic.c
deleted file mode 100644
index f7dcac159d..0000000000
--- a/csu/tst-atomic.c
+++ /dev/null
@@ -1,640 +0,0 @@
-/* Tests for atomic.h macros.
- Copyright (C) 2003-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <stdio.h>
-#include <atomic.h>
-
-#ifndef atomic_t
-# define atomic_t int
-#endif
-
-/* Test various atomic.h macros. */
-static int
-do_test (void)
-{
- atomic_t mem, expected;
- int ret = 0;
-
-#ifdef atomic_compare_and_exchange_val_acq
- mem = 24;
- if (atomic_compare_and_exchange_val_acq (&mem, 35, 24) != 24
- || mem != 35)
- {
- puts ("atomic_compare_and_exchange_val_acq test 1 failed");
- ret = 1;
- }
-
- mem = 12;
- if (atomic_compare_and_exchange_val_acq (&mem, 10, 15) != 12
- || mem != 12)
- {
- puts ("atomic_compare_and_exchange_val_acq test 2 failed");
- ret = 1;
- }
-
- mem = -15;
- if (atomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15
- || mem != -56)
- {
- puts ("atomic_compare_and_exchange_val_acq test 3 failed");
- ret = 1;
- }
-
- mem = -1;
- if (atomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1
- || mem != -1)
- {
- puts ("atomic_compare_and_exchange_val_acq test 4 failed");
- ret = 1;
- }
-#endif
-
- mem = 24;
- if (atomic_compare_and_exchange_bool_acq (&mem, 35, 24)
- || mem != 35)
- {
- puts ("atomic_compare_and_exchange_bool_acq test 1 failed");
- ret = 1;
- }
-
- mem = 12;
- if (! atomic_compare_and_exchange_bool_acq (&mem, 10, 15)
- || mem != 12)
- {
- puts ("atomic_compare_and_exchange_bool_acq test 2 failed");
- ret = 1;
- }
-
- mem = -15;
- if (atomic_compare_and_exchange_bool_acq (&mem, -56, -15)
- || mem != -56)
- {
- puts ("atomic_compare_and_exchange_bool_acq test 3 failed");
- ret = 1;
- }
-
- mem = -1;
- if (! atomic_compare_and_exchange_bool_acq (&mem, 17, 0)
- || mem != -1)
- {
- puts ("atomic_compare_and_exchange_bool_acq test 4 failed");
- ret = 1;
- }
-
- mem = 64;
- if (atomic_exchange_acq (&mem, 31) != 64
- || mem != 31)
- {
- puts ("atomic_exchange_acq test failed");
- ret = 1;
- }
-
- mem = 2;
- if (atomic_exchange_and_add (&mem, 11) != 2
- || mem != 13)
- {
- puts ("atomic_exchange_and_add test failed");
- ret = 1;
- }
-
- mem = 2;
- if (atomic_exchange_and_add_acq (&mem, 11) != 2
- || mem != 13)
- {
- puts ("atomic_exchange_and_add test failed");
- ret = 1;
- }
-
- mem = 2;
- if (atomic_exchange_and_add_rel (&mem, 11) != 2
- || mem != 13)
- {
- puts ("atomic_exchange_and_add test failed");
- ret = 1;
- }
-
- mem = -21;
- atomic_add (&mem, 22);
- if (mem != 1)
- {
- puts ("atomic_add test failed");
- ret = 1;
- }
-
- mem = -1;
- atomic_increment (&mem);
- if (mem != 0)
- {
- puts ("atomic_increment test failed");
- ret = 1;
- }
-
- mem = 2;
- if (atomic_increment_val (&mem) != 3)
- {
- puts ("atomic_increment_val test failed");
- ret = 1;
- }
-
- mem = 0;
- if (atomic_increment_and_test (&mem)
- || mem != 1)
- {
- puts ("atomic_increment_and_test test 1 failed");
- ret = 1;
- }
-
- mem = 35;
- if (atomic_increment_and_test (&mem)
- || mem != 36)
- {
- puts ("atomic_increment_and_test test 2 failed");
- ret = 1;
- }
-
- mem = -1;
- if (! atomic_increment_and_test (&mem)
- || mem != 0)
- {
- puts ("atomic_increment_and_test test 3 failed");
- ret = 1;
- }
-
- mem = 17;
- atomic_decrement (&mem);
- if (mem != 16)
- {
- puts ("atomic_decrement test failed");
- ret = 1;
- }
-
- if (atomic_decrement_val (&mem) != 15)
- {
- puts ("atomic_decrement_val test failed");
- ret = 1;
- }
-
- mem = 0;
- if (atomic_decrement_and_test (&mem)
- || mem != -1)
- {
- puts ("atomic_decrement_and_test test 1 failed");
- ret = 1;
- }
-
- mem = 15;
- if (atomic_decrement_and_test (&mem)
- || mem != 14)
- {
- puts ("atomic_decrement_and_test test 2 failed");
- ret = 1;
- }
-
- mem = 1;
- if (! atomic_decrement_and_test (&mem)
- || mem != 0)
- {
- puts ("atomic_decrement_and_test test 3 failed");
- ret = 1;
- }
-
- mem = 1;
- if (atomic_decrement_if_positive (&mem) != 1
- || mem != 0)
- {
- puts ("atomic_decrement_if_positive test 1 failed");
- ret = 1;
- }
-
- mem = 0;
- if (atomic_decrement_if_positive (&mem) != 0
- || mem != 0)
- {
- puts ("atomic_decrement_if_positive test 2 failed");
- ret = 1;
- }
-
- mem = -1;
- if (atomic_decrement_if_positive (&mem) != -1
- || mem != -1)
- {
- puts ("atomic_decrement_if_positive test 3 failed");
- ret = 1;
- }
-
- mem = -12;
- if (! atomic_add_negative (&mem, 10)
- || mem != -2)
- {
- puts ("atomic_add_negative test 1 failed");
- ret = 1;
- }
-
- mem = 0;
- if (atomic_add_negative (&mem, 100)
- || mem != 100)
- {
- puts ("atomic_add_negative test 2 failed");
- ret = 1;
- }
-
- mem = 15;
- if (atomic_add_negative (&mem, -10)
- || mem != 5)
- {
- puts ("atomic_add_negative test 3 failed");
- ret = 1;
- }
-
- mem = -12;
- if (atomic_add_negative (&mem, 14)
- || mem != 2)
- {
- puts ("atomic_add_negative test 4 failed");
- ret = 1;
- }
-
- mem = 0;
- if (! atomic_add_negative (&mem, -1)
- || mem != -1)
- {
- puts ("atomic_add_negative test 5 failed");
- ret = 1;
- }
-
- mem = -31;
- if (atomic_add_negative (&mem, 31)
- || mem != 0)
- {
- puts ("atomic_add_negative test 6 failed");
- ret = 1;
- }
-
- mem = -34;
- if (atomic_add_zero (&mem, 31)
- || mem != -3)
- {
- puts ("atomic_add_zero test 1 failed");
- ret = 1;
- }
-
- mem = -36;
- if (! atomic_add_zero (&mem, 36)
- || mem != 0)
- {
- puts ("atomic_add_zero test 2 failed");
- ret = 1;
- }
-
- mem = 113;
- if (atomic_add_zero (&mem, -13)
- || mem != 100)
- {
- puts ("atomic_add_zero test 3 failed");
- ret = 1;
- }
-
- mem = -18;
- if (atomic_add_zero (&mem, 20)
- || mem != 2)
- {
- puts ("atomic_add_zero test 4 failed");
- ret = 1;
- }
-
- mem = 10;
- if (atomic_add_zero (&mem, -20)
- || mem != -10)
- {
- puts ("atomic_add_zero test 5 failed");
- ret = 1;
- }
-
- mem = 10;
- if (! atomic_add_zero (&mem, -10)
- || mem != 0)
- {
- puts ("atomic_add_zero test 6 failed");
- ret = 1;
- }
-
- mem = 0;
- atomic_bit_set (&mem, 1);
- if (mem != 2)
- {
- puts ("atomic_bit_set test 1 failed");
- ret = 1;
- }
-
- mem = 8;
- atomic_bit_set (&mem, 3);
- if (mem != 8)
- {
- puts ("atomic_bit_set test 2 failed");
- ret = 1;
- }
-
-#ifdef TEST_ATOMIC64
- mem = 16;
- atomic_bit_set (&mem, 35);
- if (mem != 0x800000010LL)
- {
- puts ("atomic_bit_set test 3 failed");
- ret = 1;
- }
-#endif
-
- mem = 0;
- if (atomic_bit_test_set (&mem, 1)
- || mem != 2)
- {
- puts ("atomic_bit_test_set test 1 failed");
- ret = 1;
- }
-
- mem = 8;
- if (! atomic_bit_test_set (&mem, 3)
- || mem != 8)
- {
- puts ("atomic_bit_test_set test 2 failed");
- ret = 1;
- }
-
-#ifdef TEST_ATOMIC64
- mem = 16;
- if (atomic_bit_test_set (&mem, 35)
- || mem != 0x800000010LL)
- {
- puts ("atomic_bit_test_set test 3 failed");
- ret = 1;
- }
-
- mem = 0x100000000LL;
- if (! atomic_bit_test_set (&mem, 32)
- || mem != 0x100000000LL)
- {
- puts ("atomic_bit_test_set test 4 failed");
- ret = 1;
- }
-#endif
-
-#ifdef catomic_compare_and_exchange_val_acq
- mem = 24;
- if (catomic_compare_and_exchange_val_acq (&mem, 35, 24) != 24
- || mem != 35)
- {
- puts ("catomic_compare_and_exchange_val_acq test 1 failed");
- ret = 1;
- }
-
- mem = 12;
- if (catomic_compare_and_exchange_val_acq (&mem, 10, 15) != 12
- || mem != 12)
- {
- puts ("catomic_compare_and_exchange_val_acq test 2 failed");
- ret = 1;
- }
-
- mem = -15;
- if (catomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15
- || mem != -56)
- {
- puts ("catomic_compare_and_exchange_val_acq test 3 failed");
- ret = 1;
- }
-
- mem = -1;
- if (catomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1
- || mem != -1)
- {
- puts ("catomic_compare_and_exchange_val_acq test 4 failed");
- ret = 1;
- }
-#endif
-
- mem = 24;
- if (catomic_compare_and_exchange_bool_acq (&mem, 35, 24)
- || mem != 35)
- {
- puts ("catomic_compare_and_exchange_bool_acq test 1 failed");
- ret = 1;
- }
-
- mem = 12;
- if (! catomic_compare_and_exchange_bool_acq (&mem, 10, 15)
- || mem != 12)
- {
- puts ("catomic_compare_and_exchange_bool_acq test 2 failed");
- ret = 1;
- }
-
- mem = -15;
- if (catomic_compare_and_exchange_bool_acq (&mem, -56, -15)
- || mem != -56)
- {
- puts ("catomic_compare_and_exchange_bool_acq test 3 failed");
- ret = 1;
- }
-
- mem = -1;
- if (! catomic_compare_and_exchange_bool_acq (&mem, 17, 0)
- || mem != -1)
- {
- puts ("catomic_compare_and_exchange_bool_acq test 4 failed");
- ret = 1;
- }
-
- mem = 2;
- if (catomic_exchange_and_add (&mem, 11) != 2
- || mem != 13)
- {
- puts ("catomic_exchange_and_add test failed");
- ret = 1;
- }
-
- mem = -21;
- catomic_add (&mem, 22);
- if (mem != 1)
- {
- puts ("catomic_add test failed");
- ret = 1;
- }
-
- mem = -1;
- catomic_increment (&mem);
- if (mem != 0)
- {
- puts ("catomic_increment test failed");
- ret = 1;
- }
-
- mem = 2;
- if (catomic_increment_val (&mem) != 3)
- {
- puts ("catomic_increment_val test failed");
- ret = 1;
- }
-
- mem = 17;
- catomic_decrement (&mem);
- if (mem != 16)
- {
- puts ("catomic_decrement test failed");
- ret = 1;
- }
-
- if (catomic_decrement_val (&mem) != 15)
- {
- puts ("catomic_decrement_val test failed");
- ret = 1;
- }
-
- /* Tests for C11-like atomics. */
- mem = 11;
- if (atomic_load_relaxed (&mem) != 11 || atomic_load_acquire (&mem) != 11)
- {
- puts ("atomic_load_{relaxed,acquire} test failed");
- ret = 1;
- }
-
- atomic_store_relaxed (&mem, 12);
- if (mem != 12)
- {
- puts ("atomic_store_relaxed test failed");
- ret = 1;
- }
- atomic_store_release (&mem, 13);
- if (mem != 13)
- {
- puts ("atomic_store_release test failed");
- ret = 1;
- }
-
- mem = 14;
- expected = 14;
- if (!atomic_compare_exchange_weak_relaxed (&mem, &expected, 25)
- || mem != 25 || expected != 14)
- {
- puts ("atomic_compare_exchange_weak_relaxed test 1 failed");
- ret = 1;
- }
- if (atomic_compare_exchange_weak_relaxed (&mem, &expected, 14)
- || mem != 25 || expected != 25)
- {
- puts ("atomic_compare_exchange_weak_relaxed test 2 failed");
- ret = 1;
- }
- mem = 14;
- expected = 14;
- if (!atomic_compare_exchange_weak_acquire (&mem, &expected, 25)
- || mem != 25 || expected != 14)
- {
- puts ("atomic_compare_exchange_weak_acquire test 1 failed");
- ret = 1;
- }
- if (atomic_compare_exchange_weak_acquire (&mem, &expected, 14)
- || mem != 25 || expected != 25)
- {
- puts ("atomic_compare_exchange_weak_acquire test 2 failed");
- ret = 1;
- }
- mem = 14;
- expected = 14;
- if (!atomic_compare_exchange_weak_release (&mem, &expected, 25)
- || mem != 25 || expected != 14)
- {
- puts ("atomic_compare_exchange_weak_release test 1 failed");
- ret = 1;
- }
- if (atomic_compare_exchange_weak_release (&mem, &expected, 14)
- || mem != 25 || expected != 25)
- {
- puts ("atomic_compare_exchange_weak_release test 2 failed");
- ret = 1;
- }
-
- mem = 23;
- if (atomic_exchange_acquire (&mem, 42) != 23 || mem != 42)
- {
- puts ("atomic_exchange_acquire test failed");
- ret = 1;
- }
- mem = 23;
- if (atomic_exchange_release (&mem, 42) != 23 || mem != 42)
- {
- puts ("atomic_exchange_release test failed");
- ret = 1;
- }
-
- mem = 23;
- if (atomic_fetch_add_relaxed (&mem, 1) != 23 || mem != 24)
- {
- puts ("atomic_fetch_add_relaxed test failed");
- ret = 1;
- }
- mem = 23;
- if (atomic_fetch_add_acquire (&mem, 1) != 23 || mem != 24)
- {
- puts ("atomic_fetch_add_acquire test failed");
- ret = 1;
- }
- mem = 23;
- if (atomic_fetch_add_release (&mem, 1) != 23 || mem != 24)
- {
- puts ("atomic_fetch_add_release test failed");
- ret = 1;
- }
- mem = 23;
- if (atomic_fetch_add_acq_rel (&mem, 1) != 23 || mem != 24)
- {
- puts ("atomic_fetch_add_acq_rel test failed");
- ret = 1;
- }
-
- mem = 3;
- if (atomic_fetch_and_acquire (&mem, 2) != 3 || mem != 2)
- {
- puts ("atomic_fetch_and_acquire test failed");
- ret = 1;
- }
-
- mem = 4;
- if (atomic_fetch_or_relaxed (&mem, 2) != 4 || mem != 6)
- {
- puts ("atomic_fetch_or_relaxed test failed");
- ret = 1;
- }
- mem = 4;
- if (atomic_fetch_or_acquire (&mem, 2) != 4 || mem != 6)
- {
- puts ("atomic_fetch_or_acquire test failed");
- ret = 1;
- }
-
- /* This is a single-threaded test, so we can't test the effects of the
- fences. */
- atomic_thread_fence_acquire ();
- atomic_thread_fence_release ();
- atomic_thread_fence_seq_cst ();
-
- return ret;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/csu/tst-empty.c b/csu/tst-empty.c
deleted file mode 100644
index e99468eef9..0000000000
--- a/csu/tst-empty.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/* The most useful C program known to man. */
-static int
-do_test (void)
-{
- return 0;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/csu/version.c b/csu/version.c
index 15aab349ee..287838d065 100644
--- a/csu/version.c
+++ b/csu/version.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,13 +24,12 @@ static const char __libc_release[] = RELEASE;
static const char __libc_version[] = VERSION;
static const char banner[] =
-"GNU C Library "PKGVERSION RELEASE" release version "VERSION", by Roland McGrath et al.\n\
-Copyright (C) 2016 Free Software Foundation, Inc.\n\
+"GNU C Library "PKGVERSION RELEASE" release version "VERSION".\n\
+Copyright (C) 2018 Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
PARTICULAR PURPOSE.\n\
Compiled by GNU CC version "__VERSION__".\n"
-#include "version-info.h"
#ifdef LIBC_ABIS_STRING
LIBC_ABIS_STRING
#endif
@@ -39,7 +38,7 @@ LIBC_ABIS_STRING
#include <unistd.h>
-extern void __libc_print_version (void);
+extern void __libc_print_version (void) attribute_hidden;
void
__libc_print_version (void)
{