* [PATCH] Reduce the statically linked startup code [BZ #23323]
@ 2018-06-23 21:45 Florian Weimer
2018-07-01 9:30 ` Florian Weimer
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Florian Weimer @ 2018-06-23 21:45 UTC (permalink / raw)
To: libc-alpha
It turns out the startup code in csu/elf-unit.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, âreturn-to-csu: A
New Method to Bypass 64-bit Linux ASLRâ). These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker. However, the dynamic
linker skipped the main program for some reason. For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.
For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.
A new symbol version __libc_start_main@@GLIBC_2.28 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues. This approach
(multiple symbol versions for the same function symbol) requires a
recent binutils version (later than 2.25 on some architectures) because
earlier versions cannot use a symbol alias to define multiple symbol
versions for the same symbol.
Tested on aarch64, armhfp, i686, mips64, ppc, ppc64, ppc64el, s390,
s390x, x86_64, and built with build-many-glibcs.py. This patch
depends on the earlier patch which introduces ELF_INITFINI.
2018-06-23 Florian Weimer <fweimer@redhat.com>
[BZ #23323]
Reduce statically-linked startup code.
* csu/Makefile (routines): Remove elf-init.
* csu/elf-init.c: Remove file.
* csu/Versions (GLIBC_2.28): Export __libc_start_main from libc.
* csu/libc-start.c: Add note that this is not part of the startup
code for dynamically linked applications.
[SHARED] (call_init): New function, based on call_init from
elf/dl-init.c.
[!SHARED] (call_init, call_fini): New functions, based on
csu/elf-init.c
(LIBC_START_MAIN): Update function comment. Register call_fini
directly for statically linked applications. Call call_init
instead of init (in statically linked applications, and if it is
not NULL).
(DO_DEFINE_LIBC_START_MAIN_VERSION)
(DEFINE_LIBC_START_MAIN_VERSION_1)
(DEFINE_LIBC_START_MAIN_VERSION): Define.
* elf/dl-init.c (init_t): Move to <ldsodefs.h>.
(call_init, _dl_init) Adjust.
* sysdeps/generic/ldsodefs.h (dl_init_t): Moved from
elf/dl-init.c.
(DL_CALL_DT_INIT): Adjust.
* sysdeps/hppa/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
* sysdeps/ia64/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
* sysdeps/aarch64/start.S (_start): Pass zero for init and fini.
* sysdeps/alpha/start.S (_start): Likewise.
* sysdeps/arm/start.S (_start): Likewise. Adjust offset of
pointer to main.
(.L_GOT): Adjust.
* sysdeps/hppa/start.S (.Lp__libc_csu_fini, .Lp__libc_csu_init):
Remove.
(_start): Pass zero for init and fini.
* sysdeps/ia64/start.S (_start): Pass zero for init and fini.
* sysdeps/i386/start.S (_start): Likewise.
* sysdeps/m68k/start.S (_start): Likewise.
* sysdeps/microblaze/start.S (_start): Likewise.
* sysdeps/mips/start.S (ENTRY_POINT): Likewise.
* sysdeps/nios2/start.S (_start): Likewise.
* sydeps/powerpc/powerpc32/start.S (start_addresses): Use zero for
init and fini.
* sysdeps/powerpc/powerpc64/start.S (start_addresses): Likewise.
* sysdeps/unix/sysv/linux/powerpc/libc-start: Use
DEFINE_LIBC_START_MAIN_VERSION.
* sysdeps/riscv/start.S (ENTRY_POINT): Pass zero for init and fini.
* sysdeps/s390/s390-32/start.S (_start): Pass zero for init and
fini.
(.L1, .L2): Remove.
* sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
fini.
* sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
fini.
* sysdeps/sh/start.S (_start): Likewise.
(L_init, L_fini): Remove.
* sysdeps/sparc/sparc32/start.S (_start): Pass zero for init and
fini.
* sysdeps/sparc/sparc64/start.S (_start): Likewise.
* sysdeps/x86_64/start.S (start): Likewise.
* sysdeps/mach/hurd/i386/libc.abilist: Add
__libc_start_main@GLIBC_2.28.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
diff --git a/csu/Makefile b/csu/Makefile
index f3498960f8..4fcdcfbba9 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -27,10 +27,9 @@ subdir := csu
include ../Makeconfig
routines = init-first libc-start $(libc-init) sysdep version check_fds \
- libc-tls elf-init dso_handle
+ libc-tls dso_handle
aux = errno
elide-routines.os = libc-tls
-static-only-routines = elf-init
csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
extra-objs = start.o \
$(start-installed-name) g$(start-installed-name) $(csu-dummies) \
diff --git a/csu/Versions b/csu/Versions
index 43010c3443..8fb2e360a9 100644
--- a/csu/Versions
+++ b/csu/Versions
@@ -7,6 +7,9 @@ libc {
# New special glibc functions.
gnu_get_libc_release; gnu_get_libc_version;
}
+ GLIBC_2.28 {
+ __libc_start_main;
+ }
GLIBC_PRIVATE {
errno;
}
diff --git a/csu/elf-init.c b/csu/elf-init.c
deleted file mode 100644
index 8bde25a340..0000000000
--- a/csu/elf-init.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Startup support for ELF initializers/finalizers in the main executable.
- 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
- 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.
-
- In addition to the permissions in the GNU Lesser General Public
- License, the Free Software Foundation gives you unlimited
- permission to link the compiled version of this file with other
- programs, and to distribute those programs without any restriction
- coming from the use of this file. (The GNU Lesser General Public
- License restrictions do apply in other respects; for example, they
- cover modification of the file, and distribution when not linked
- into another program.)
-
- Note that people who make modified versions of this file are not
- obligated to grant this special exception for their modified
- versions; it is their choice whether to do so. The GNU Lesser
- General Public License gives permission to release a modified
- version without this exception; this exception also makes it
- possible to release a modified version which carries forward this
- exception.
-
- 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 <stddef.h>
-#include <platform-params.h>
-
-
-/* These magic symbols are provided by the linker. */
-extern void (*__preinit_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__preinit_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__fini_array_start []) (void) attribute_hidden;
-extern void (*__fini_array_end []) (void) attribute_hidden;
-
-
-#if ELF_INITFINI
-/* These function symbols are provided for the .init/.fini section entry
- points automagically by the linker. */
-extern void _init (void);
-extern void _fini (void);
-#endif
-
-
-/* These functions are passed to __libc_start_main by the startup code.
- These get statically linked into each program. For dynamically linked
- programs, this module will come from libc_nonshared.a and differs from
- the libc.a module in that it doesn't call the preinit array. */
-
-
-void
-__libc_csu_init (int argc, char **argv, char **envp)
-{
- /* For dynamically linked executables the preinit array is executed by
- the dynamic linker (before initializing any shared object). */
-
-#ifndef LIBC_NONSHARED
- /* For static executables, preinit happens right before init. */
- {
- const size_t size = __preinit_array_end - __preinit_array_start;
- size_t i;
- for (i = 0; i < size; i++)
- (*__preinit_array_start [i]) (argc, argv, envp);
- }
-#endif
-
-#if ELF_INITFINI
- _init ();
-#endif
-
- const size_t size = __init_array_end - __init_array_start;
- for (size_t i = 0; i < size; i++)
- (*__init_array_start [i]) (argc, argv, envp);
-}
-
-/* This function should not be used anymore. We run the executable's
- destructor now just like any other. We cannot remove the function,
- though. */
-void
-__libc_csu_fini (void)
-{
-#ifndef LIBC_NONSHARED
- size_t i = __fini_array_end - __fini_array_start;
- while (i-- > 0)
- (*__fini_array_start [i]) ();
-
-# if ELF_INITFINI
- _fini ();
-# endif
-#endif
-}
diff --git a/csu/libc-start.c b/csu/libc-start.c
index 494132368f..0faa4242d8 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
+/* Perform initialization and invoke main.
+ 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
@@ -15,6 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+/* Note: This code is only part of the startup code proper for
+ statically linked binaries. For dynamically linked binaries, it
+ resides in libc.so. */
+
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
@@ -22,6 +27,8 @@
#include <ldsodefs.h>
#include <exit-thread.h>
#include <libc-internal.h>
+#include <platform-params.h>
+#include <shlib-compat.h>
#include <elf/dl-tunables.h>
@@ -88,9 +95,11 @@ apply_irel (void)
# else
# define STATIC static inline __attribute__ ((always_inline))
# endif
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 0
#else
# define STATIC
# define LIBC_START_MAIN __libc_start_main
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 1
#endif
#ifdef MAIN_AUXVEC_ARG
@@ -106,6 +115,92 @@ apply_irel (void)
# define ARCH_INIT_CPU_FEATURES()
#endif
+#ifdef SHARED
+/* Initialization for dynamic executables. Find the main executable
+ link map and run its init functions. */
+static void
+call_init (int argc, char **argv, char **env)
+{
+ /* Obtain the main map of the executable. */
+ struct link_map *l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+
+ /* DT_PREINIT_ARRAY is not processed here. It is already handled in
+ _dl_init in elf/dl-init.c. Also see the call_init function in
+ the same file. */
+
+ if (ELF_INITFINI && l->l_info[DT_INIT] != NULL)
+ DL_CALL_DT_INIT(l, l->l_addr + l->l_info[DT_INIT]->d_un.d_ptr,
+ argc, argv, env);
+
+ ElfW(Dyn) *init_array = l->l_info[DT_INIT_ARRAY];
+ if (init_array != NULL)
+ {
+ unsigned int jm
+ = l->l_info[DT_INIT_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr));
+ ElfW(Addr) *addrs = (void *) (init_array->d_un.d_ptr + l->l_addr);
+ for (unsigned int j = 0; j < jm; ++j)
+ ((dl_init_t) addrs[j]) (argc, argv, env);
+ }
+}
+
+#else /* !SHARED */
+
+/* These magic symbols are provided by the linker. */
+extern void (*__preinit_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__preinit_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__fini_array_start []) (void) attribute_hidden;
+extern void (*__fini_array_end []) (void) attribute_hidden;
+
+# if ELF_INITFINI
+/* These function symbols are provided for the .init/.fini section entry
+ points automagically by the linker. */
+extern void _init (void);
+extern void _fini (void);
+# endif
+
+/* Initialization for static executables. There is no dynamic
+ segment, so we access the symbols directly. */
+static void
+call_init (int argc, char **argv, char **envp)
+{
+ /* For static executables, preinit happens right before init. */
+ {
+ const size_t size = __preinit_array_end - __preinit_array_start;
+ size_t i;
+ for (i = 0; i < size; i++)
+ (*__preinit_array_start [i]) (argc, argv, envp);
+ }
+
+# if ELF_INITFINI
+ _init ();
+# endif
+
+ const size_t size = __init_array_end - __init_array_start;
+ for (size_t i = 0; i < size; i++)
+ (*__init_array_start [i]) (argc, argv, envp);
+}
+
+/* Likewise for the destructor. */
+static void
+call_fini (void *unused)
+{
+ size_t i = __fini_array_end - __fini_array_start;
+ while (i-- > 0)
+ (*__fini_array_start [i]) ();
+
+# if ELF_INITFINI
+ _fini ();
+# endif
+}
+
+#endif /* !SHARED */
+
#include <libc-start.h>
STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
@@ -122,9 +217,16 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
__attribute__ ((noreturn));
-/* Note: the fini parameter is ignored here for shared library. It
- is registered with __cxa_atexit. This had the disadvantage that
- finalizers were called in more than one place. */
+/* Note: The init and fini parameters are no longer used. fini is
+ completely unused, init is still called if not NULL, but the
+ current startup code always passes NULL. (In the future, it would
+ be possible to use fini to pass a version code if init is NULL, to
+ indicate the link-time glibc without introducing a hard
+ incompatibility for new programs with older glibc versions.)
+
+ For dynamically linked executables, the dynamic segment is used to
+ locate constructors and destructors. For statically linked
+ executables, the relevant symbols are access directly. */
STATIC int
LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
int argc, char **argv,
@@ -243,9 +345,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
run the constructors in `_dl_start_user'. */
__libc_init_first (argc, argv, __environ);
- /* Register the destructor of the program, if any. */
- if (fini)
- __cxa_atexit ((void (*) (void *)) fini, NULL, NULL);
+ /* Register the destructor of the statically-linked program. */
+ __cxa_atexit (call_fini, NULL, NULL);
/* Some security at this point. Prevent starting a SUID binary where
the standard file descriptors are not opened. We have to do this
@@ -253,15 +354,24 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
loader did the work already. */
if (__builtin_expect (__libc_enable_secure, 0))
__libc_check_standard_fds ();
-#endif
+#endif /* !SHARED */
/* Call the initializer of the program, if any. */
#ifdef SHARED
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
-#endif
- if (init)
+
+ if (init != NULL)
+ /* This is a legacy program which supplied its own init
+ routine. */
(*init) (argc, argv, __environ MAIN_AUXVEC_PARAM);
+ else
+ /* This is a current program. Use the dynamic segment to find
+ constructors. */
+ call_init (argc, argv, __environ);
+#else /* !SHARED */
+ call_init (argc, argv, __environ);
+#endif /* SHARED */
#ifdef SHARED
/* Auditing checkpoint: we have a new object. */
@@ -341,3 +451,28 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
exit (result);
}
+
+#ifdef SHARED
+/* Starting with glibc 2.28, the init parameter is always NULL. Older
+ libcs are not prepared to handle that. */
+# define DEFINE_LIBC_START_MAIN_VERSION \
+ DEFINE_LIBC_START_MAIN_VERSION_1 \
+ versioned_symbol (libc, __libc_start_main, __libc_start_main, GLIBC_2_28);
+
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28)
+# define DEFINE_LIBC_START_MAIN_VERSION_1 \
+ strong_alias (__libc_start_main, __libc_start_main_alias) \
+ compat_symbol (libc, __libc_start_main_alias, __libc_start_main, GLIBC_2_0);
+# else
+# define DEFINE_LIBC_START_MAIN_VERSION_1
+# endif
+#else
+# define DEFINE_LIBC_START_MAIN_VERSION
+#endif
+
+/* Only define the version information if LIBC_START_MAIN was not set.
+ If there is a wrapper file, it must expand
+ DEFINE_LIBC_START_MAIN_VERSION on its own. */
+#if DO_DEFINE_LIBC_START_MAIN_VERSION
+DEFINE_LIBC_START_MAIN_VERSION
+#endif
diff --git a/elf/dl-init.c b/elf/dl-init.c
index 31eb12b974..dad3902254 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -21,10 +21,6 @@
#include <platform-params.h>
-/* Type of the initializer. */
-typedef void (*init_t) (int, char **, char **);
-
-
static void
call_init (struct link_map *l, int argc, char **argv, char **env)
{
@@ -71,7 +67,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (init_array->d_un.d_ptr + l->l_addr);
for (j = 0; j < jm; ++j)
- ((init_t) addrs[j]) (argc, argv, env);
+ ((dl_init_t) addrs[j]) (argc, argv, env);
}
}
@@ -103,7 +99,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (preinit_array->d_un.d_ptr + main_map->l_addr);
for (cnt = 0; cnt < i; ++cnt)
- ((init_t) addrs[cnt]) (argc, argv, env);
+ ((dl_init_t) addrs[cnt]) (argc, argv, env);
}
/* Stupid users forced the ELF specification to be changed. It now
diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
index bad000f555..2c22b6ff27 100644
--- a/sysdeps/aarch64/start.S
+++ b/sysdeps/aarch64/start.S
@@ -64,26 +64,16 @@ _start:
# ifdef SHARED
adrp x0, :got:main
ldr PTR_REG (0), [x0, #:got_lo12:main]
-
- adrp x3, :got:__libc_csu_init
- ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
-
- adrp x4, :got:__libc_csu_fini
- ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
# else
adrp x0, __wrap_main
add x0, x0, :lo12:__wrap_main
- adrp x3, __libc_csu_init
- add x3, x3, :lo12:__libc_csu_init
- adrp x4, __libc_csu_fini
- add x4, x4, :lo12:__libc_csu_fini
# endif
#else
/* Set up the other arguments in registers */
MOVL (0, main)
- MOVL (3, __libc_csu_init)
- MOVL (4, __libc_csu_fini)
#endif
+ mov x3, #0 /* Used to be init. */
+ mov x4, #0 /* Used to be fini. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
stack_end) */
diff --git a/sysdeps/alpha/start.S b/sysdeps/alpha/start.S
index 5de8ceeca7..57ea0d67f7 100644
--- a/sysdeps/alpha/start.S
+++ b/sysdeps/alpha/start.S
@@ -55,9 +55,8 @@ _start:
ldl a1, 16(sp) /* get argc */
lda a2, 24(sp) /* get argv */
- /* Load address of our own entry points to .fini and .init. */
- lda a3, __libc_csu_init
- lda a4, __libc_csu_fini
+ mov $r31, a3 /* Used to be init. */
+ mov $r31, a4 /* Used to be init. */
/* Store address of the shared library termination function. */
mov v0, a5
diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S
index adef090717..ad2b25c2e1 100644
--- a/sysdeps/arm/start.S
+++ b/sysdeps/arm/start.S
@@ -94,30 +94,20 @@ _start:
adr a4, .L_GOT
add sl, sl, a4
- ldr ip, .L_GOT+4 /* __libc_csu_fini */
- ldr ip, [sl, ip]
+ mov a4, #0 /* Used to be init. */
+ push { a4 } /* Used to be fini. */
- push { ip } /* Push __libc_csu_fini */
-
- ldr a4, .L_GOT+8 /* __libc_csu_init */
- ldr a4, [sl, a4]
-
- ldr a1, .L_GOT+12 /* main */
+ ldr a1, .L_GOT+4 /* main */
ldr a1, [sl, a1]
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
bl __libc_start_main(PLT)
#else
- /* Fetch address of __libc_csu_fini */
- ldr ip, =__libc_csu_fini
- /* Push __libc_csu_fini */
- push { ip }
-
- /* Set up the other arguments in registers */
+ mov a4, #0 /* Used to init. */
+ push { a4 } /* Used to fini. */
ldr a1, =main
- ldr a4, =__libc_csu_init
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
@@ -131,8 +121,6 @@ _start:
.align 2
.L_GOT:
.word _GLOBAL_OFFSET_TABLE_ - .L_GOT
- .word __libc_csu_fini(GOT)
- .word __libc_csu_init(GOT)
.word main(GOT)
#endif
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 95dc87519b..76a1f0dd56 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -75,6 +75,10 @@ typedef struct link_map *lookup_t;
: (__glibc_unlikely ((ref)->st_shndx == SHN_ABS) ? 0 \
: LOOKUP_VALUE_ADDRESS (map, map_set)) + (ref)->st_value)
+/* Type of a constructor function, in DT_INIT, DT_INIT_ARRAY,
+ DT_PREINIT_ARRAY. */
+typedef void (*dl_init_t) (int, char **, char **);
+
/* On some architectures a pointer to a function is not just a pointer
to the actual code of the function but rather an architecture
specific descriptor. */
@@ -83,7 +87,7 @@ typedef struct link_map *lookup_t;
(void *) SYMBOL_ADDRESS (map, ref, false)
# define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
# define DL_CALL_DT_INIT(map, start, argc, argv, env) \
- ((init_t) (start)) (argc, argv, env)
+ ((dl_init_t) (start)) (argc, argv, env)
# define DL_CALL_DT_FINI(map, start) ((fini_t) (start)) ()
#endif
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
index 38db345936..f9ef78d856 100644
--- a/sysdeps/hppa/dl-lookupcfg.h
+++ b/sysdeps/hppa/dl-lookupcfg.h
@@ -56,7 +56,7 @@ void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S
index c1d2bd4bb7..8ffc247827 100644
--- a/sysdeps/hppa/start.S
+++ b/sysdeps/hppa/start.S
@@ -36,8 +36,6 @@
.import main, code
.import $global$, data
.import __libc_start_main, code
- .import __libc_csu_fini, code
- .import __libc_csu_init, code
/* Have the linker create plabel words so we get PLABEL32
relocs and not 21/14. The use of 21/14 relocs is only
@@ -52,10 +50,6 @@
.word P%main
.Lp__libc_start_main:
.word P%__libc_start_main
-.Lp__libc_csu_fini:
- .word P%__libc_csu_fini
-.Lp__libc_csu_init:
- .word P%__libc_csu_init
.text
.align 4
@@ -77,8 +71,8 @@ _start:
1. r26 - Application main
2. r25 - argc
3. r24 - argv
- 4. r23 - __libc_csu_init
- 5. sp-52 - __libc_csu_fini
+ 4. r23 - init (unused)
+ 5. sp-52 - fini (unused)
6. sp-56 - rtld_fini
7. sp-60 - stackend */
@@ -108,14 +102,6 @@ _start:
addil LT'.Lpmain, %r19
ldw RT'.Lpmain(%r1), %r26
ldw 0(%r26),%r26
- /* void (*init) (void) (4th argument) */
- addil LT'.Lp__libc_csu_init, %r19
- ldw RT'.Lp__libc_csu_init(%r1), %r23
- ldw 0(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- addil LT'.Lp__libc_csu_fini, %r19
- ldw RT'.Lp__libc_csu_fini(%r1), %r22
- ldw 0(%r22), %r22
#else
/* Load $global$ address into %dp */
ldil L%$global$, %dp
@@ -124,13 +110,9 @@ _start:
/* load main (1st argument) */
ldil LR'.Lpmain, %r26
ldw RR'.Lpmain(%r26), %r26
- /* void (*init) (void) (4th argument) */
- ldil LR'.Lp__libc_csu_init, %r23
- ldw RR'.Lp__libc_csu_init(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- ldil LR'.Lp__libc_csu_fini, %r22
- ldw RR'.Lp__libc_csu_fini(%r22), %r22
#endif
+ ldi 0,%r23 /* Used to be init. */
+ ldi 0,%r22 /* Used to be fini. */
/* Store 5th argument */
stw %r22, -52(%sp)
/* void *stack_end (7th argument) */
diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S
index 91035fa83f..92781dc121 100644
--- a/sysdeps/i386/start.S
+++ b/sysdeps/i386/start.S
@@ -86,11 +86,9 @@ _start:
call 1f
addl $_GLOBAL_OFFSET_TABLE_, %ebx
- /* Push address of our own entry points to .fini and .init. */
- leal __libc_csu_fini@GOTOFF(%ebx), %eax
- pushl %eax
- leal __libc_csu_init@GOTOFF(%ebx), %eax
- pushl %eax
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
@@ -111,9 +109,9 @@ _start:
But let the libc call main. */
call __libc_start_main@PLT
#else
- /* Push address of our own entry points to .fini and .init. */
- pushl $__libc_csu_fini
- pushl $__libc_csu_init
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
diff --git a/sysdeps/ia64/dl-lookupcfg.h b/sysdeps/ia64/dl-lookupcfg.h
index 48f91202c4..83734a9562 100644
--- a/sysdeps/ia64/dl-lookupcfg.h
+++ b/sysdeps/ia64/dl-lookupcfg.h
@@ -50,7 +50,7 @@ extern void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/ia64/start.S b/sysdeps/ia64/start.S
index 04205aa94f..6c3e468bcb 100644
--- a/sysdeps/ia64/start.S
+++ b/sysdeps/ia64/start.S
@@ -83,20 +83,15 @@ _start:
{
addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
addl out0 = @ltoff(@fptr(main)), gp
- addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
+ mov out3 = r0 /* Used to be init. */
;;
}
{ .mmi
ld8 r3 = [r11] /* pointer to __libc_ia64_register_backing_store_base */
ld8 out0 = [out0] /* pointer to `main' function descriptor */
- addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
+ mov out4 = r0 /* Used to be fini. */
;;
}
- { .mmi
- ld8 out3 = [out3] /* pointer to `init' function descriptor */
- ld8 out4 = [out4] /* pointer to `fini' function descriptor */
- nop 0
- }
.body
{ .mib
st8 [r3] = r10
diff --git a/sysdeps/m68k/start.S b/sysdeps/m68k/start.S
index 7bab3e1cde..7d151a3205 100644
--- a/sysdeps/m68k/start.S
+++ b/sysdeps/m68k/start.S
@@ -76,15 +76,14 @@ _start:
pea (%a1) /* Push address of the shared library
termination function. */
+ /* These used to be addresses of the .fini and .init entry points. */
+ clr.l -(%sp)
+ clr.l -(%sp)
+
#ifdef PIC
/* Load PIC register. */
LOAD_GOT (%a5)
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- move.l __libc_csu_fini@GOT(%a5), -(%sp)
- move.l __libc_csu_init@GOT(%a5), -(%sp)
-
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
@@ -94,10 +93,6 @@ _start:
let the libc call main. */
jbsr __libc_start_main@PLTPC
#else
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- pea __libc_csu_fini
- pea __libc_csu_init
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 2cb507052b..7bd93814eb 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2033,6 +2033,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S
index cc8dd13fe4..39f858ab71 100644
--- a/sysdeps/microblaze/start.S
+++ b/sysdeps/microblaze/start.S
@@ -63,14 +63,14 @@ _start:
mfs r20,rpc
addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
lwi r5,r20,main@GOT
- lwi r8,r20,__libc_csu_init@GOT
- lwi r9,r20,__libc_csu_fini@GOT
+ addk r8,r0,r0 /* Used to be init. */
+ addk r8,r0,r0 /* Used to be fini. */
brid __libc_start_main@PLT
addk r10,r0,r0
#else
addik r5,r0,main
- addik r8,r0,__libc_csu_init
- addik r9,r0,__libc_csu_fini
+ addk r8,r0,r0 /* Used to be init. */
+ addk r8,r0,r0 /* Used to be fini. */
brid __libc_start_main
addk r10,r0,r0
#endif
diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S
index a4c4ef0fae..f1ba04bc97 100644
--- a/sysdeps/mips/start.S
+++ b/sysdeps/mips/start.S
@@ -96,10 +96,9 @@ ENTRY_POINT:
# if _MIPS_SIM == _ABIO32
PTR_SUBIU $29, 32
# endif
- PTR_LA $7, __libc_csu_init /* init */
- PTR_LA $8, __libc_csu_fini
+ move $7, $0 /* init */
# if _MIPS_SIM == _ABIO32
- PTR_S $8, 16($29) /* fini */
+ PTR_S $0, 16($29) /* fini */
PTR_S $2, 20($29) /* rtld_fini */
PTR_S $29, 24($29) /* stack_end */
# else
@@ -143,19 +142,17 @@ ENTRY_POINT:
/* Lay out last arguments, and call __libc_start_main(). */
# ifdef __PIC__
sw $7, 24($sp) /* stack_end */
- lw $4, %got(__libc_csu_fini)($3)
- lw $7, %got(__libc_csu_init)($3) /* init */
- sw $4, 16($sp) /* fini */
+ move $4, $0 /* Used to be ini. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, %got(main)($3) /* main */
lw $3, %call16(__libc_start_main)($3)
sw $2, 20($sp) /* rtld_fini */
move $25, $3
jalr $3
# else
- lw $4, 1f
sw $7, 24($sp) /* stack_end */
- lw $7, 2f /* init */
- sw $4, 16($sp) /* fini */
+ move $7, $0 /* Used to be init. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, 3f /* main */
sw $2, 20($sp) /* rtld_fini */
/* Load and call __libc_start_main(). */
@@ -165,8 +162,6 @@ ENTRY_POINT:
hlt: b hlt /* Crash if somehow it does return. */
# ifndef __PIC__
.align 2
-1: .word __libc_csu_fini
-2: .word __libc_csu_init
3: .word main
4: .word __libc_start_main
# endif
diff --git a/sysdeps/nios2/start.S b/sysdeps/nios2/start.S
index fa224ef75c..51a0757d78 100644
--- a/sysdeps/nios2/start.S
+++ b/sysdeps/nios2/start.S
@@ -92,18 +92,11 @@ _start:
addi r2, r2, %lo(_gp_got - 1b)
add r22, r22, r2
- /* Push fini */
- movhi r8, %call_hiadj(__libc_csu_fini)
- addi r8, r8, %call_lo(__libc_csu_fini)
- add r8, r8, r22
- ldw r8, 0(r8)
- stw r8, 0(sp)
+ /* Used to be fini. */
+ stw zero, 0(sp)
- /* r7 == init */
- movhi r7, %call_hiadj(__libc_csu_init)
- addi r7, r7, %call_lo(__libc_csu_init)
- add r7, r7, r22
- ldw r7, 0(r7)
+ /* Used to be init. */
+ mov r7, zero
/* r6 == argv */
addi r6, sp, 16
diff --git a/sysdeps/powerpc/powerpc32/start.S b/sysdeps/powerpc/powerpc32/start.S
index 5c10a22f8a..0be6aed543 100644
--- a/sysdeps/powerpc/powerpc32/start.S
+++ b/sysdeps/powerpc/powerpc32/start.S
@@ -52,8 +52,8 @@
L(start_addresses):
.long _SDA_BASE_
.long main
- .long __libc_csu_init
- .long __libc_csu_fini
+ .long 0 /* Used to be init. */
+ .long 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
.section ".text"
diff --git a/sysdeps/powerpc/powerpc64/start.S b/sysdeps/powerpc/powerpc64/start.S
index bd7189310c..149afbeab1 100644
--- a/sysdeps/powerpc/powerpc64/start.S
+++ b/sysdeps/powerpc/powerpc64/start.S
@@ -53,8 +53,8 @@ L(start_addresses):
.quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
/* function descriptors so don't need JUMPTARGET */
.quad main
- .quad __libc_csu_init
- .quad __libc_csu_fini
+ .quad 0 /* Used to be init. */
+ .quad 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S
index 4635ddb5eb..9dd4714910 100644
--- a/sysdeps/riscv/start.S
+++ b/sysdeps/riscv/start.S
@@ -50,8 +50,8 @@ ENTRY (ENTRY_POINT)
REG_L a1, 0(sp) /* argc. */
addi a2, sp, SZREG /* argv. */
andi sp, sp, ALMASK /* Align stack. */
- lla a3, __libc_csu_init
- lla a4, __libc_csu_fini
+ li a3, 0 /* Used to be init. */
+ li a4, 0 /* Used to be fini. */
mv a6, sp /* stack_end. */
tail __libc_start_main@plt
diff --git a/sysdeps/s390/s390-32/start.S b/sysdeps/s390/s390-32/start.S
index 1483642985..4587b2de5e 100644
--- a/sysdeps/s390/s390-32/start.S
+++ b/sysdeps/s390/s390-32/start.S
@@ -175,18 +175,16 @@ _start:
*/
stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
la %r7,96(%r15)
- l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini
- l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init
l %r2,.L3-.Llit(%r13) # load pointer to main
l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main
#ifdef PIC
l %r12,.L5-.Llit(%r13) # load .got pointer
- la %r6,0(%r13,%r6)
- la %r5,0(%r13,%r5)
la %r12,0(%r13,%r12)
l %r2,0(%r12,%r2)
la %r1,0(%r13,%r1)
#endif
+ lhi %r6, 0 # Used to fini.
+ lhi %r5, 0 # Used to init.
/* ok, now branch to the libc main routine */
basr %r14,%r1
@@ -197,13 +195,9 @@ _start:
cfi_endproc
.Llit:
#ifndef PIC
-.L1: .long __libc_csu_init
-.L2: .long __libc_csu_fini
.L3: .long main
.L4: .long __libc_start_main
#else
-.L1: .long __libc_csu_init-.Llit
-.L2: .long __libc_csu_fini-.Llit
.L3: .long main@GOT
.L4: .long __libc_start_main@plt-.Llit
.L5: .long _GLOBAL_OFFSET_TABLE_-.Llit
diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S
index 79e7b69f1d..518dfd989e 100644
--- a/sysdeps/s390/s390-64/start.S
+++ b/sysdeps/s390/s390-64/start.S
@@ -80,8 +80,8 @@ _start:
*/
stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
la %r7,160(%r15)
- larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
- larl %r5,__libc_csu_init # load pointer to __libc_csu_init
+ lghi %r6,0 # Used to be fini.
+ lghi %r5,0 # Used to be init.
/* Ok, now branch to the libc main routine. */
#ifdef PIC
diff --git a/sysdeps/sh/start.S b/sysdeps/sh/start.S
index f52077abca..4b0aad511b 100644
--- a/sysdeps/sh/start.S
+++ b/sysdeps/sh/start.S
@@ -70,12 +70,11 @@ _start:
/* Push the last arguments to main() onto the stack */
mov.l r4,@-r15
- mov.l L_fini,r0
- mov.l r0,@-r15
+ mov.l r14,@-r15 /* Used to be fini. */
/* Set up the other arguments for main() that go in registers */
mov.l L_main,r4
- mov.l L_init,r7
+ mov #0,r7 /* Used to be init. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
@@ -90,10 +89,6 @@ _start:
.align 2
L_main:
.long main
-L_init:
- .long __libc_csu_init
-L_fini:
- .long __libc_csu_fini
L_libc_start_main:
.long __libc_start_main
L_abort:
diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S
index 46ba8b6afa..48b30a3fb5 100644
--- a/sysdeps/sparc/sparc32/start.S
+++ b/sysdeps/sparc/sparc32/start.S
@@ -59,22 +59,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ld [%l7 + %o0], %o0, %gdop(main)
- ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S
index 75ff5093dc..73395df40a 100644
--- a/sysdeps/sparc/sparc64/start.S
+++ b/sysdeps/sparc/sparc64/start.S
@@ -60,22 +60,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ldx [%l7 + %o0], %o0, %gdop(main)
- ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 80cdb98e1c..e5bcea397f 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2131,3 +2131,4 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index c761f61c43..ec3716e631 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2026,6 +2026,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist
index 6aa58c3ca7..59d91ab2f3 100644
--- a/sysdeps/unix/sysv/linux/arm/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libc.abilist
@@ -115,6 +115,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index d10695b7d3..4c468d6eb5 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -1872,6 +1872,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 23092ab6d7..64729ea4ea 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2037,6 +2037,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index 7bf259e86c..909d742540 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1907,6 +1907,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 4673bcd79b..d848fb4f13 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0x98
GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 1f8ac40399..30280266e4 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -1981,6 +1981,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
index 09277f5954..2eb49d6dc1 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
@@ -2122,3 +2122,4 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index f562e20f23..b273754592 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -1959,6 +1959,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index ceb7388829..4a0a6b6545 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -1957,6 +1957,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 5765f487a2..04ef0ea835 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -1965,6 +1965,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index a84bb45a38..df5c75a986 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1961,6 +1961,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index e43295986c..e9bc514407 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2163,3 +2163,4 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
index f2ad0c355d..522926604b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-start.c
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
@@ -103,3 +103,4 @@ __libc_start_main (int argc, char **argv,
stinfo->init, stinfo->fini, rtld_fini,
stack_on_entry);
}
+DEFINE_LIBC_START_MAIN_VERSION
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index a5f2b23068..20ad9f97a1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -1985,6 +1985,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index e4cbe36279..2bb053f087 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -1989,6 +1989,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index 9869feb56b..a9154afddb 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2221,3 +2221,4 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index e526dc4627..cd0afdbd7f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 _Exit F
GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
GLIBC_2.3 _IO_2_1_stdin_ D 0xe0
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index e6319eef8d..8605c56a2c 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2093,3 +2093,4 @@ GLIBC_2.27 xdrstdio_create F
GLIBC_2.27 xencrypt F
GLIBC_2.27 xprt_register F
GLIBC_2.27 xprt_unregister F
+GLIBC_2.28 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 41cdda0c2e..87ca6db77a 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -1994,6 +1994,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 8a756cf287..68789b381a 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1900,6 +1900,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist
index 999bddd1db..7d3c96bb42 100644
--- a/sysdeps/unix/sysv/linux/sh/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libc.abilist
@@ -1876,6 +1876,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 7c4296fc10..4f180a0608 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -1988,6 +1988,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index dafe9d74b7..50b9bf70ca 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1930,6 +1930,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index f72d494920..5648d8ffda 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1888,6 +1888,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 96c9fa050e..ada4314f7c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2139,3 +2139,4 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S
index 354d2e6ec7..8060586b5c 100644
--- a/sysdeps/x86_64/start.S
+++ b/sysdeps/x86_64/start.S
@@ -96,17 +96,13 @@ ENTRY (_start)
which grow downwards). */
pushq %rsp
+ /* These used to be the addresses of .fini and .init. */
+ xor %R8_LP, %R8_LP
+ xor %RCX_LP, %RCX_LP
+
#ifdef PIC
- /* Pass address of our own entry points to .fini and .init. */
- mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
- mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
-
mov main@GOTPCREL(%rip), %RDI_LP
#else
- /* Pass address of our own entry points to .fini and .init. */
- mov $__libc_csu_fini, %R8_LP
- mov $__libc_csu_init, %RCX_LP
-
mov $main, %RDI_LP
#endif
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2018-06-23 21:45 [PATCH] Reduce the statically linked startup code [BZ #23323] Florian Weimer
@ 2018-07-01 9:30 ` Florian Weimer
2018-07-03 10:01 ` Florian Weimer
2018-08-08 14:48 ` Florian Weimer
2 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2018-07-01 9:30 UTC (permalink / raw)
To: libc-alpha
On 06/23/2018 11:45 PM, Florian Weimer wrote:
> 2018-06-23 Florian Weimer<fweimer@redhat.com>
>
> [BZ #23323]
> Reduce statically-linked startup code.
Any chance we can get this reviewed for 2.28?
Thanks,
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2018-06-23 21:45 [PATCH] Reduce the statically linked startup code [BZ #23323] Florian Weimer
2018-07-01 9:30 ` Florian Weimer
@ 2018-07-03 10:01 ` Florian Weimer
2018-08-08 14:48 ` Florian Weimer
2 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2018-07-03 10:01 UTC (permalink / raw)
To: libc-alpha
[-- Attachment #1: Type: text/plain, Size: 50 bytes --]
I rebased the patch onto current master.
Florian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: minimize-csu.patch --]
[-- Type: text/x-patch; name="minimize-csu.patch", Size: 51620 bytes --]
Subject: [PATCH] Reduce the statically linked startup code [BZ #23323]
To: libc-alpha@sourceware.org
It turns out the startup code in csu/elf-unit.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, âreturn-to-csu: A
New Method to Bypass 64-bit Linux ASLRâ). These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker. However, the dynamic
linker skipped the main program for some reason. For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.
For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.
A new symbol version __libc_start_main@@GLIBC_2.28 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues. This approach
(multiple symbol versions for the same function symbol) requires a
recent binutils version (later than 2.25 on some architectures) because
earlier versions cannot use a symbol alias to define multiple symbol
versions for the same symbol.
Tested on aarch64, armhfp, i686, mips64, ppc, ppc64, ppc64el, s390,
s390x, x86_64, and built with build-many-glibcs.py. This patch
depends on the earlier patch which introduces ELF_INITFINI.
2018-06-23 Florian Weimer <fweimer@redhat.com>
[BZ #23323]
Reduce statically-linked startup code.
* csu/Makefile (routines): Remove elf-init.
* csu/elf-init.c: Remove file.
* csu/Versions (GLIBC_2.28): Export __libc_start_main from libc.
* csu/libc-start.c: Add note that this is not part of the startup
code for dynamically linked applications.
[SHARED] (call_init): New function, based on call_init from
elf/dl-init.c.
[!SHARED] (call_init, call_fini): New functions, based on
csu/elf-init.c
(LIBC_START_MAIN): Update function comment. Register call_fini
directly for statically linked applications. Call call_init
instead of init (in statically linked applications, and if it is
not NULL).
(DO_DEFINE_LIBC_START_MAIN_VERSION)
(DEFINE_LIBC_START_MAIN_VERSION_1)
(DEFINE_LIBC_START_MAIN_VERSION): Define.
* elf/dl-init.c (init_t): Move to <ldsodefs.h>.
(call_init, _dl_init) Adjust.
* sysdeps/generic/ldsodefs.h (dl_init_t): Moved from
elf/dl-init.c.
(DL_CALL_DT_INIT): Adjust.
* sysdeps/hppa/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
* sysdeps/ia64/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
* sysdeps/aarch64/start.S (_start): Pass zero for init and fini.
* sysdeps/alpha/start.S (_start): Likewise.
* sysdeps/arm/start.S (_start): Likewise. Adjust offset of
pointer to main.
(.L_GOT): Adjust.
* sysdeps/hppa/start.S (.Lp__libc_csu_fini, .Lp__libc_csu_init):
Remove.
(_start): Pass zero for init and fini.
* sysdeps/ia64/start.S (_start): Pass zero for init and fini.
* sysdeps/i386/start.S (_start): Likewise.
* sysdeps/m68k/start.S (_start): Likewise.
* sysdeps/microblaze/start.S (_start): Likewise.
* sysdeps/mips/start.S (ENTRY_POINT): Likewise.
* sysdeps/nios2/start.S (_start): Likewise.
* sydeps/powerpc/powerpc32/start.S (start_addresses): Use zero for
init and fini.
* sysdeps/powerpc/powerpc64/start.S (start_addresses): Likewise.
* sysdeps/unix/sysv/linux/powerpc/libc-start: Use
DEFINE_LIBC_START_MAIN_VERSION.
* sysdeps/riscv/start.S (ENTRY_POINT): Pass zero for init and fini.
* sysdeps/s390/s390-32/start.S (_start): Pass zero for init and
fini.
(.L1, .L2): Remove.
* sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
fini.
* sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
fini.
* sysdeps/sh/start.S (_start): Likewise.
(L_init, L_fini): Remove.
* sysdeps/sparc/sparc32/start.S (_start): Pass zero for init and
fini.
* sysdeps/sparc/sparc64/start.S (_start): Likewise.
* sysdeps/x86_64/start.S (start): Likewise.
* sysdeps/mach/hurd/i386/libc.abilist: Add
__libc_start_main@GLIBC_2.28.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
diff --git a/csu/Makefile b/csu/Makefile
index f3498960f8..4fcdcfbba9 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -27,10 +27,9 @@ subdir := csu
include ../Makeconfig
routines = init-first libc-start $(libc-init) sysdep version check_fds \
- libc-tls elf-init dso_handle
+ libc-tls dso_handle
aux = errno
elide-routines.os = libc-tls
-static-only-routines = elf-init
csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
extra-objs = start.o \
$(start-installed-name) g$(start-installed-name) $(csu-dummies) \
diff --git a/csu/Versions b/csu/Versions
index 43010c3443..8fb2e360a9 100644
--- a/csu/Versions
+++ b/csu/Versions
@@ -7,6 +7,9 @@ libc {
# New special glibc functions.
gnu_get_libc_release; gnu_get_libc_version;
}
+ GLIBC_2.28 {
+ __libc_start_main;
+ }
GLIBC_PRIVATE {
errno;
}
diff --git a/csu/elf-init.c b/csu/elf-init.c
deleted file mode 100644
index 8bde25a340..0000000000
--- a/csu/elf-init.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Startup support for ELF initializers/finalizers in the main executable.
- 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
- 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.
-
- In addition to the permissions in the GNU Lesser General Public
- License, the Free Software Foundation gives you unlimited
- permission to link the compiled version of this file with other
- programs, and to distribute those programs without any restriction
- coming from the use of this file. (The GNU Lesser General Public
- License restrictions do apply in other respects; for example, they
- cover modification of the file, and distribution when not linked
- into another program.)
-
- Note that people who make modified versions of this file are not
- obligated to grant this special exception for their modified
- versions; it is their choice whether to do so. The GNU Lesser
- General Public License gives permission to release a modified
- version without this exception; this exception also makes it
- possible to release a modified version which carries forward this
- exception.
-
- 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 <stddef.h>
-#include <platform-params.h>
-
-
-/* These magic symbols are provided by the linker. */
-extern void (*__preinit_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__preinit_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__fini_array_start []) (void) attribute_hidden;
-extern void (*__fini_array_end []) (void) attribute_hidden;
-
-
-#if ELF_INITFINI
-/* These function symbols are provided for the .init/.fini section entry
- points automagically by the linker. */
-extern void _init (void);
-extern void _fini (void);
-#endif
-
-
-/* These functions are passed to __libc_start_main by the startup code.
- These get statically linked into each program. For dynamically linked
- programs, this module will come from libc_nonshared.a and differs from
- the libc.a module in that it doesn't call the preinit array. */
-
-
-void
-__libc_csu_init (int argc, char **argv, char **envp)
-{
- /* For dynamically linked executables the preinit array is executed by
- the dynamic linker (before initializing any shared object). */
-
-#ifndef LIBC_NONSHARED
- /* For static executables, preinit happens right before init. */
- {
- const size_t size = __preinit_array_end - __preinit_array_start;
- size_t i;
- for (i = 0; i < size; i++)
- (*__preinit_array_start [i]) (argc, argv, envp);
- }
-#endif
-
-#if ELF_INITFINI
- _init ();
-#endif
-
- const size_t size = __init_array_end - __init_array_start;
- for (size_t i = 0; i < size; i++)
- (*__init_array_start [i]) (argc, argv, envp);
-}
-
-/* This function should not be used anymore. We run the executable's
- destructor now just like any other. We cannot remove the function,
- though. */
-void
-__libc_csu_fini (void)
-{
-#ifndef LIBC_NONSHARED
- size_t i = __fini_array_end - __fini_array_start;
- while (i-- > 0)
- (*__fini_array_start [i]) ();
-
-# if ELF_INITFINI
- _fini ();
-# endif
-#endif
-}
diff --git a/csu/libc-start.c b/csu/libc-start.c
index 494132368f..0faa4242d8 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
+/* Perform initialization and invoke main.
+ 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
@@ -15,6 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+/* Note: This code is only part of the startup code proper for
+ statically linked binaries. For dynamically linked binaries, it
+ resides in libc.so. */
+
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
@@ -22,6 +27,8 @@
#include <ldsodefs.h>
#include <exit-thread.h>
#include <libc-internal.h>
+#include <platform-params.h>
+#include <shlib-compat.h>
#include <elf/dl-tunables.h>
@@ -88,9 +95,11 @@ apply_irel (void)
# else
# define STATIC static inline __attribute__ ((always_inline))
# endif
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 0
#else
# define STATIC
# define LIBC_START_MAIN __libc_start_main
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 1
#endif
#ifdef MAIN_AUXVEC_ARG
@@ -106,6 +115,92 @@ apply_irel (void)
# define ARCH_INIT_CPU_FEATURES()
#endif
+#ifdef SHARED
+/* Initialization for dynamic executables. Find the main executable
+ link map and run its init functions. */
+static void
+call_init (int argc, char **argv, char **env)
+{
+ /* Obtain the main map of the executable. */
+ struct link_map *l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+
+ /* DT_PREINIT_ARRAY is not processed here. It is already handled in
+ _dl_init in elf/dl-init.c. Also see the call_init function in
+ the same file. */
+
+ if (ELF_INITFINI && l->l_info[DT_INIT] != NULL)
+ DL_CALL_DT_INIT(l, l->l_addr + l->l_info[DT_INIT]->d_un.d_ptr,
+ argc, argv, env);
+
+ ElfW(Dyn) *init_array = l->l_info[DT_INIT_ARRAY];
+ if (init_array != NULL)
+ {
+ unsigned int jm
+ = l->l_info[DT_INIT_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr));
+ ElfW(Addr) *addrs = (void *) (init_array->d_un.d_ptr + l->l_addr);
+ for (unsigned int j = 0; j < jm; ++j)
+ ((dl_init_t) addrs[j]) (argc, argv, env);
+ }
+}
+
+#else /* !SHARED */
+
+/* These magic symbols are provided by the linker. */
+extern void (*__preinit_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__preinit_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__fini_array_start []) (void) attribute_hidden;
+extern void (*__fini_array_end []) (void) attribute_hidden;
+
+# if ELF_INITFINI
+/* These function symbols are provided for the .init/.fini section entry
+ points automagically by the linker. */
+extern void _init (void);
+extern void _fini (void);
+# endif
+
+/* Initialization for static executables. There is no dynamic
+ segment, so we access the symbols directly. */
+static void
+call_init (int argc, char **argv, char **envp)
+{
+ /* For static executables, preinit happens right before init. */
+ {
+ const size_t size = __preinit_array_end - __preinit_array_start;
+ size_t i;
+ for (i = 0; i < size; i++)
+ (*__preinit_array_start [i]) (argc, argv, envp);
+ }
+
+# if ELF_INITFINI
+ _init ();
+# endif
+
+ const size_t size = __init_array_end - __init_array_start;
+ for (size_t i = 0; i < size; i++)
+ (*__init_array_start [i]) (argc, argv, envp);
+}
+
+/* Likewise for the destructor. */
+static void
+call_fini (void *unused)
+{
+ size_t i = __fini_array_end - __fini_array_start;
+ while (i-- > 0)
+ (*__fini_array_start [i]) ();
+
+# if ELF_INITFINI
+ _fini ();
+# endif
+}
+
+#endif /* !SHARED */
+
#include <libc-start.h>
STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
@@ -122,9 +217,16 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
__attribute__ ((noreturn));
-/* Note: the fini parameter is ignored here for shared library. It
- is registered with __cxa_atexit. This had the disadvantage that
- finalizers were called in more than one place. */
+/* Note: The init and fini parameters are no longer used. fini is
+ completely unused, init is still called if not NULL, but the
+ current startup code always passes NULL. (In the future, it would
+ be possible to use fini to pass a version code if init is NULL, to
+ indicate the link-time glibc without introducing a hard
+ incompatibility for new programs with older glibc versions.)
+
+ For dynamically linked executables, the dynamic segment is used to
+ locate constructors and destructors. For statically linked
+ executables, the relevant symbols are access directly. */
STATIC int
LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
int argc, char **argv,
@@ -243,9 +345,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
run the constructors in `_dl_start_user'. */
__libc_init_first (argc, argv, __environ);
- /* Register the destructor of the program, if any. */
- if (fini)
- __cxa_atexit ((void (*) (void *)) fini, NULL, NULL);
+ /* Register the destructor of the statically-linked program. */
+ __cxa_atexit (call_fini, NULL, NULL);
/* Some security at this point. Prevent starting a SUID binary where
the standard file descriptors are not opened. We have to do this
@@ -253,15 +354,24 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
loader did the work already. */
if (__builtin_expect (__libc_enable_secure, 0))
__libc_check_standard_fds ();
-#endif
+#endif /* !SHARED */
/* Call the initializer of the program, if any. */
#ifdef SHARED
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
-#endif
- if (init)
+
+ if (init != NULL)
+ /* This is a legacy program which supplied its own init
+ routine. */
(*init) (argc, argv, __environ MAIN_AUXVEC_PARAM);
+ else
+ /* This is a current program. Use the dynamic segment to find
+ constructors. */
+ call_init (argc, argv, __environ);
+#else /* !SHARED */
+ call_init (argc, argv, __environ);
+#endif /* SHARED */
#ifdef SHARED
/* Auditing checkpoint: we have a new object. */
@@ -341,3 +451,28 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
exit (result);
}
+
+#ifdef SHARED
+/* Starting with glibc 2.28, the init parameter is always NULL. Older
+ libcs are not prepared to handle that. */
+# define DEFINE_LIBC_START_MAIN_VERSION \
+ DEFINE_LIBC_START_MAIN_VERSION_1 \
+ versioned_symbol (libc, __libc_start_main, __libc_start_main, GLIBC_2_28);
+
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28)
+# define DEFINE_LIBC_START_MAIN_VERSION_1 \
+ strong_alias (__libc_start_main, __libc_start_main_alias) \
+ compat_symbol (libc, __libc_start_main_alias, __libc_start_main, GLIBC_2_0);
+# else
+# define DEFINE_LIBC_START_MAIN_VERSION_1
+# endif
+#else
+# define DEFINE_LIBC_START_MAIN_VERSION
+#endif
+
+/* Only define the version information if LIBC_START_MAIN was not set.
+ If there is a wrapper file, it must expand
+ DEFINE_LIBC_START_MAIN_VERSION on its own. */
+#if DO_DEFINE_LIBC_START_MAIN_VERSION
+DEFINE_LIBC_START_MAIN_VERSION
+#endif
diff --git a/elf/dl-init.c b/elf/dl-init.c
index 31eb12b974..dad3902254 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -21,10 +21,6 @@
#include <platform-params.h>
-/* Type of the initializer. */
-typedef void (*init_t) (int, char **, char **);
-
-
static void
call_init (struct link_map *l, int argc, char **argv, char **env)
{
@@ -71,7 +67,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (init_array->d_un.d_ptr + l->l_addr);
for (j = 0; j < jm; ++j)
- ((init_t) addrs[j]) (argc, argv, env);
+ ((dl_init_t) addrs[j]) (argc, argv, env);
}
}
@@ -103,7 +99,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (preinit_array->d_un.d_ptr + main_map->l_addr);
for (cnt = 0; cnt < i; ++cnt)
- ((init_t) addrs[cnt]) (argc, argv, env);
+ ((dl_init_t) addrs[cnt]) (argc, argv, env);
}
/* Stupid users forced the ELF specification to be changed. It now
diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
index bad000f555..2c22b6ff27 100644
--- a/sysdeps/aarch64/start.S
+++ b/sysdeps/aarch64/start.S
@@ -64,26 +64,16 @@ _start:
# ifdef SHARED
adrp x0, :got:main
ldr PTR_REG (0), [x0, #:got_lo12:main]
-
- adrp x3, :got:__libc_csu_init
- ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
-
- adrp x4, :got:__libc_csu_fini
- ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
# else
adrp x0, __wrap_main
add x0, x0, :lo12:__wrap_main
- adrp x3, __libc_csu_init
- add x3, x3, :lo12:__libc_csu_init
- adrp x4, __libc_csu_fini
- add x4, x4, :lo12:__libc_csu_fini
# endif
#else
/* Set up the other arguments in registers */
MOVL (0, main)
- MOVL (3, __libc_csu_init)
- MOVL (4, __libc_csu_fini)
#endif
+ mov x3, #0 /* Used to be init. */
+ mov x4, #0 /* Used to be fini. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
stack_end) */
diff --git a/sysdeps/alpha/start.S b/sysdeps/alpha/start.S
index 5de8ceeca7..57ea0d67f7 100644
--- a/sysdeps/alpha/start.S
+++ b/sysdeps/alpha/start.S
@@ -55,9 +55,8 @@ _start:
ldl a1, 16(sp) /* get argc */
lda a2, 24(sp) /* get argv */
- /* Load address of our own entry points to .fini and .init. */
- lda a3, __libc_csu_init
- lda a4, __libc_csu_fini
+ mov $r31, a3 /* Used to be init. */
+ mov $r31, a4 /* Used to be init. */
/* Store address of the shared library termination function. */
mov v0, a5
diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S
index adef090717..ad2b25c2e1 100644
--- a/sysdeps/arm/start.S
+++ b/sysdeps/arm/start.S
@@ -94,30 +94,20 @@ _start:
adr a4, .L_GOT
add sl, sl, a4
- ldr ip, .L_GOT+4 /* __libc_csu_fini */
- ldr ip, [sl, ip]
+ mov a4, #0 /* Used to be init. */
+ push { a4 } /* Used to be fini. */
- push { ip } /* Push __libc_csu_fini */
-
- ldr a4, .L_GOT+8 /* __libc_csu_init */
- ldr a4, [sl, a4]
-
- ldr a1, .L_GOT+12 /* main */
+ ldr a1, .L_GOT+4 /* main */
ldr a1, [sl, a1]
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
bl __libc_start_main(PLT)
#else
- /* Fetch address of __libc_csu_fini */
- ldr ip, =__libc_csu_fini
- /* Push __libc_csu_fini */
- push { ip }
-
- /* Set up the other arguments in registers */
+ mov a4, #0 /* Used to init. */
+ push { a4 } /* Used to fini. */
ldr a1, =main
- ldr a4, =__libc_csu_init
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
@@ -131,8 +121,6 @@ _start:
.align 2
.L_GOT:
.word _GLOBAL_OFFSET_TABLE_ - .L_GOT
- .word __libc_csu_fini(GOT)
- .word __libc_csu_init(GOT)
.word main(GOT)
#endif
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 95dc87519b..76a1f0dd56 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -75,6 +75,10 @@ typedef struct link_map *lookup_t;
: (__glibc_unlikely ((ref)->st_shndx == SHN_ABS) ? 0 \
: LOOKUP_VALUE_ADDRESS (map, map_set)) + (ref)->st_value)
+/* Type of a constructor function, in DT_INIT, DT_INIT_ARRAY,
+ DT_PREINIT_ARRAY. */
+typedef void (*dl_init_t) (int, char **, char **);
+
/* On some architectures a pointer to a function is not just a pointer
to the actual code of the function but rather an architecture
specific descriptor. */
@@ -83,7 +87,7 @@ typedef struct link_map *lookup_t;
(void *) SYMBOL_ADDRESS (map, ref, false)
# define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
# define DL_CALL_DT_INIT(map, start, argc, argv, env) \
- ((init_t) (start)) (argc, argv, env)
+ ((dl_init_t) (start)) (argc, argv, env)
# define DL_CALL_DT_FINI(map, start) ((fini_t) (start)) ()
#endif
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
index 38db345936..f9ef78d856 100644
--- a/sysdeps/hppa/dl-lookupcfg.h
+++ b/sysdeps/hppa/dl-lookupcfg.h
@@ -56,7 +56,7 @@ void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S
index c1d2bd4bb7..8ffc247827 100644
--- a/sysdeps/hppa/start.S
+++ b/sysdeps/hppa/start.S
@@ -36,8 +36,6 @@
.import main, code
.import $global$, data
.import __libc_start_main, code
- .import __libc_csu_fini, code
- .import __libc_csu_init, code
/* Have the linker create plabel words so we get PLABEL32
relocs and not 21/14. The use of 21/14 relocs is only
@@ -52,10 +50,6 @@
.word P%main
.Lp__libc_start_main:
.word P%__libc_start_main
-.Lp__libc_csu_fini:
- .word P%__libc_csu_fini
-.Lp__libc_csu_init:
- .word P%__libc_csu_init
.text
.align 4
@@ -77,8 +71,8 @@ _start:
1. r26 - Application main
2. r25 - argc
3. r24 - argv
- 4. r23 - __libc_csu_init
- 5. sp-52 - __libc_csu_fini
+ 4. r23 - init (unused)
+ 5. sp-52 - fini (unused)
6. sp-56 - rtld_fini
7. sp-60 - stackend */
@@ -108,14 +102,6 @@ _start:
addil LT'.Lpmain, %r19
ldw RT'.Lpmain(%r1), %r26
ldw 0(%r26),%r26
- /* void (*init) (void) (4th argument) */
- addil LT'.Lp__libc_csu_init, %r19
- ldw RT'.Lp__libc_csu_init(%r1), %r23
- ldw 0(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- addil LT'.Lp__libc_csu_fini, %r19
- ldw RT'.Lp__libc_csu_fini(%r1), %r22
- ldw 0(%r22), %r22
#else
/* Load $global$ address into %dp */
ldil L%$global$, %dp
@@ -124,13 +110,9 @@ _start:
/* load main (1st argument) */
ldil LR'.Lpmain, %r26
ldw RR'.Lpmain(%r26), %r26
- /* void (*init) (void) (4th argument) */
- ldil LR'.Lp__libc_csu_init, %r23
- ldw RR'.Lp__libc_csu_init(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- ldil LR'.Lp__libc_csu_fini, %r22
- ldw RR'.Lp__libc_csu_fini(%r22), %r22
#endif
+ ldi 0,%r23 /* Used to be init. */
+ ldi 0,%r22 /* Used to be fini. */
/* Store 5th argument */
stw %r22, -52(%sp)
/* void *stack_end (7th argument) */
diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S
index 91035fa83f..92781dc121 100644
--- a/sysdeps/i386/start.S
+++ b/sysdeps/i386/start.S
@@ -86,11 +86,9 @@ _start:
call 1f
addl $_GLOBAL_OFFSET_TABLE_, %ebx
- /* Push address of our own entry points to .fini and .init. */
- leal __libc_csu_fini@GOTOFF(%ebx), %eax
- pushl %eax
- leal __libc_csu_init@GOTOFF(%ebx), %eax
- pushl %eax
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
@@ -111,9 +109,9 @@ _start:
But let the libc call main. */
call __libc_start_main@PLT
#else
- /* Push address of our own entry points to .fini and .init. */
- pushl $__libc_csu_fini
- pushl $__libc_csu_init
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
diff --git a/sysdeps/ia64/dl-lookupcfg.h b/sysdeps/ia64/dl-lookupcfg.h
index 48f91202c4..83734a9562 100644
--- a/sysdeps/ia64/dl-lookupcfg.h
+++ b/sysdeps/ia64/dl-lookupcfg.h
@@ -50,7 +50,7 @@ extern void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/ia64/start.S b/sysdeps/ia64/start.S
index 04205aa94f..6c3e468bcb 100644
--- a/sysdeps/ia64/start.S
+++ b/sysdeps/ia64/start.S
@@ -83,20 +83,15 @@ _start:
{
addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
addl out0 = @ltoff(@fptr(main)), gp
- addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
+ mov out3 = r0 /* Used to be init. */
;;
}
{ .mmi
ld8 r3 = [r11] /* pointer to __libc_ia64_register_backing_store_base */
ld8 out0 = [out0] /* pointer to `main' function descriptor */
- addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
+ mov out4 = r0 /* Used to be fini. */
;;
}
- { .mmi
- ld8 out3 = [out3] /* pointer to `init' function descriptor */
- ld8 out4 = [out4] /* pointer to `fini' function descriptor */
- nop 0
- }
.body
{ .mib
st8 [r3] = r10
diff --git a/sysdeps/m68k/start.S b/sysdeps/m68k/start.S
index 7bab3e1cde..7d151a3205 100644
--- a/sysdeps/m68k/start.S
+++ b/sysdeps/m68k/start.S
@@ -76,15 +76,14 @@ _start:
pea (%a1) /* Push address of the shared library
termination function. */
+ /* These used to be addresses of the .fini and .init entry points. */
+ clr.l -(%sp)
+ clr.l -(%sp)
+
#ifdef PIC
/* Load PIC register. */
LOAD_GOT (%a5)
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- move.l __libc_csu_fini@GOT(%a5), -(%sp)
- move.l __libc_csu_init@GOT(%a5), -(%sp)
-
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
@@ -94,10 +93,6 @@ _start:
let the libc call main. */
jbsr __libc_start_main@PLTPC
#else
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- pea __libc_csu_fini
- pea __libc_csu_init
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 3d46de795d..bc1b2c0658 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2033,6 +2033,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S
index cc8dd13fe4..39f858ab71 100644
--- a/sysdeps/microblaze/start.S
+++ b/sysdeps/microblaze/start.S
@@ -63,14 +63,14 @@ _start:
mfs r20,rpc
addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
lwi r5,r20,main@GOT
- lwi r8,r20,__libc_csu_init@GOT
- lwi r9,r20,__libc_csu_fini@GOT
+ addk r8,r0,r0 /* Used to be init. */
+ addk r8,r0,r0 /* Used to be fini. */
brid __libc_start_main@PLT
addk r10,r0,r0
#else
addik r5,r0,main
- addik r8,r0,__libc_csu_init
- addik r9,r0,__libc_csu_fini
+ addk r8,r0,r0 /* Used to be init. */
+ addk r8,r0,r0 /* Used to be fini. */
brid __libc_start_main
addk r10,r0,r0
#endif
diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S
index a4c4ef0fae..f1ba04bc97 100644
--- a/sysdeps/mips/start.S
+++ b/sysdeps/mips/start.S
@@ -96,10 +96,9 @@ ENTRY_POINT:
# if _MIPS_SIM == _ABIO32
PTR_SUBIU $29, 32
# endif
- PTR_LA $7, __libc_csu_init /* init */
- PTR_LA $8, __libc_csu_fini
+ move $7, $0 /* init */
# if _MIPS_SIM == _ABIO32
- PTR_S $8, 16($29) /* fini */
+ PTR_S $0, 16($29) /* fini */
PTR_S $2, 20($29) /* rtld_fini */
PTR_S $29, 24($29) /* stack_end */
# else
@@ -143,19 +142,17 @@ ENTRY_POINT:
/* Lay out last arguments, and call __libc_start_main(). */
# ifdef __PIC__
sw $7, 24($sp) /* stack_end */
- lw $4, %got(__libc_csu_fini)($3)
- lw $7, %got(__libc_csu_init)($3) /* init */
- sw $4, 16($sp) /* fini */
+ move $4, $0 /* Used to be ini. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, %got(main)($3) /* main */
lw $3, %call16(__libc_start_main)($3)
sw $2, 20($sp) /* rtld_fini */
move $25, $3
jalr $3
# else
- lw $4, 1f
sw $7, 24($sp) /* stack_end */
- lw $7, 2f /* init */
- sw $4, 16($sp) /* fini */
+ move $7, $0 /* Used to be init. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, 3f /* main */
sw $2, 20($sp) /* rtld_fini */
/* Load and call __libc_start_main(). */
@@ -165,8 +162,6 @@ ENTRY_POINT:
hlt: b hlt /* Crash if somehow it does return. */
# ifndef __PIC__
.align 2
-1: .word __libc_csu_fini
-2: .word __libc_csu_init
3: .word main
4: .word __libc_start_main
# endif
diff --git a/sysdeps/nios2/start.S b/sysdeps/nios2/start.S
index fa224ef75c..51a0757d78 100644
--- a/sysdeps/nios2/start.S
+++ b/sysdeps/nios2/start.S
@@ -92,18 +92,11 @@ _start:
addi r2, r2, %lo(_gp_got - 1b)
add r22, r22, r2
- /* Push fini */
- movhi r8, %call_hiadj(__libc_csu_fini)
- addi r8, r8, %call_lo(__libc_csu_fini)
- add r8, r8, r22
- ldw r8, 0(r8)
- stw r8, 0(sp)
+ /* Used to be fini. */
+ stw zero, 0(sp)
- /* r7 == init */
- movhi r7, %call_hiadj(__libc_csu_init)
- addi r7, r7, %call_lo(__libc_csu_init)
- add r7, r7, r22
- ldw r7, 0(r7)
+ /* Used to be init. */
+ mov r7, zero
/* r6 == argv */
addi r6, sp, 16
diff --git a/sysdeps/powerpc/powerpc32/start.S b/sysdeps/powerpc/powerpc32/start.S
index 5c10a22f8a..0be6aed543 100644
--- a/sysdeps/powerpc/powerpc32/start.S
+++ b/sysdeps/powerpc/powerpc32/start.S
@@ -52,8 +52,8 @@
L(start_addresses):
.long _SDA_BASE_
.long main
- .long __libc_csu_init
- .long __libc_csu_fini
+ .long 0 /* Used to be init. */
+ .long 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
.section ".text"
diff --git a/sysdeps/powerpc/powerpc64/start.S b/sysdeps/powerpc/powerpc64/start.S
index bd7189310c..149afbeab1 100644
--- a/sysdeps/powerpc/powerpc64/start.S
+++ b/sysdeps/powerpc/powerpc64/start.S
@@ -53,8 +53,8 @@ L(start_addresses):
.quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
/* function descriptors so don't need JUMPTARGET */
.quad main
- .quad __libc_csu_init
- .quad __libc_csu_fini
+ .quad 0 /* Used to be init. */
+ .quad 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S
index 4635ddb5eb..9dd4714910 100644
--- a/sysdeps/riscv/start.S
+++ b/sysdeps/riscv/start.S
@@ -50,8 +50,8 @@ ENTRY (ENTRY_POINT)
REG_L a1, 0(sp) /* argc. */
addi a2, sp, SZREG /* argv. */
andi sp, sp, ALMASK /* Align stack. */
- lla a3, __libc_csu_init
- lla a4, __libc_csu_fini
+ li a3, 0 /* Used to be init. */
+ li a4, 0 /* Used to be fini. */
mv a6, sp /* stack_end. */
tail __libc_start_main@plt
diff --git a/sysdeps/s390/s390-32/start.S b/sysdeps/s390/s390-32/start.S
index 1483642985..4587b2de5e 100644
--- a/sysdeps/s390/s390-32/start.S
+++ b/sysdeps/s390/s390-32/start.S
@@ -175,18 +175,16 @@ _start:
*/
stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
la %r7,96(%r15)
- l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini
- l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init
l %r2,.L3-.Llit(%r13) # load pointer to main
l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main
#ifdef PIC
l %r12,.L5-.Llit(%r13) # load .got pointer
- la %r6,0(%r13,%r6)
- la %r5,0(%r13,%r5)
la %r12,0(%r13,%r12)
l %r2,0(%r12,%r2)
la %r1,0(%r13,%r1)
#endif
+ lhi %r6, 0 # Used to fini.
+ lhi %r5, 0 # Used to init.
/* ok, now branch to the libc main routine */
basr %r14,%r1
@@ -197,13 +195,9 @@ _start:
cfi_endproc
.Llit:
#ifndef PIC
-.L1: .long __libc_csu_init
-.L2: .long __libc_csu_fini
.L3: .long main
.L4: .long __libc_start_main
#else
-.L1: .long __libc_csu_init-.Llit
-.L2: .long __libc_csu_fini-.Llit
.L3: .long main@GOT
.L4: .long __libc_start_main@plt-.Llit
.L5: .long _GLOBAL_OFFSET_TABLE_-.Llit
diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S
index 79e7b69f1d..518dfd989e 100644
--- a/sysdeps/s390/s390-64/start.S
+++ b/sysdeps/s390/s390-64/start.S
@@ -80,8 +80,8 @@ _start:
*/
stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
la %r7,160(%r15)
- larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
- larl %r5,__libc_csu_init # load pointer to __libc_csu_init
+ lghi %r6,0 # Used to be fini.
+ lghi %r5,0 # Used to be init.
/* Ok, now branch to the libc main routine. */
#ifdef PIC
diff --git a/sysdeps/sh/start.S b/sysdeps/sh/start.S
index f52077abca..4b0aad511b 100644
--- a/sysdeps/sh/start.S
+++ b/sysdeps/sh/start.S
@@ -70,12 +70,11 @@ _start:
/* Push the last arguments to main() onto the stack */
mov.l r4,@-r15
- mov.l L_fini,r0
- mov.l r0,@-r15
+ mov.l r14,@-r15 /* Used to be fini. */
/* Set up the other arguments for main() that go in registers */
mov.l L_main,r4
- mov.l L_init,r7
+ mov #0,r7 /* Used to be init. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
@@ -90,10 +89,6 @@ _start:
.align 2
L_main:
.long main
-L_init:
- .long __libc_csu_init
-L_fini:
- .long __libc_csu_fini
L_libc_start_main:
.long __libc_start_main
L_abort:
diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S
index 46ba8b6afa..48b30a3fb5 100644
--- a/sysdeps/sparc/sparc32/start.S
+++ b/sysdeps/sparc/sparc32/start.S
@@ -59,22 +59,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ld [%l7 + %o0], %o0, %gdop(main)
- ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S
index 75ff5093dc..73395df40a 100644
--- a/sysdeps/sparc/sparc64/start.S
+++ b/sysdeps/sparc/sparc64/start.S
@@ -60,22 +60,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ldx [%l7 + %o0], %o0, %gdop(main)
- ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 884d0dfa95..55381e98a8 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2131,4 +2131,5 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 28d54b9794..066c0dedba 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2026,6 +2026,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist
index dfde3bd725..bb6ea42885 100644
--- a/sysdeps/unix/sysv/linux/arm/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libc.abilist
@@ -115,6 +115,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.4 _Exit F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 06b00f730a..df2fd63659 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -1872,6 +1872,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 1c1cc00d40..818988243e 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2037,6 +2037,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index f6e17a005f..914b85c09c 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1907,6 +1907,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index ee054a618d..653977528d 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.4 _Exit F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 227a0581cb..272ec82747 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -1981,6 +1981,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
index 18781b3017..eebe614306 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
@@ -2122,5 +2122,6 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 2d86989cf2..4b5729c284 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -1959,6 +1959,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index b8b113e1a5..fba08ce853 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -1957,6 +1957,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 6a3cd13e2d..b6c94e202a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -1965,6 +1965,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 596ec05379..24fcefb660 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1961,6 +1961,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 8da18eed57..bb64e4b43d 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2163,5 +2163,6 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
index f2ad0c355d..522926604b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-start.c
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
@@ -103,3 +103,4 @@ __libc_start_main (int argc, char **argv,
stinfo->init, stinfo->fini, rtld_fini,
stack_on_entry);
}
+DEFINE_LIBC_START_MAIN_VERSION
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 555751eb12..997210f64c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -1985,6 +1985,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 80324e41aa..1b54e27556 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -1989,6 +1989,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index 97b1d354af..d124c12eab 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2221,4 +2221,5 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 15be314921..87e0baf761 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 _Exit F
GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 436b992251..8b5a2302ee 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2093,4 +2093,5 @@ GLIBC_2.27 xdrstdio_create F
GLIBC_2.27 xencrypt F
GLIBC_2.27 xprt_register F
GLIBC_2.27 xprt_unregister F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index f66715f0c9..838fc5e1dc 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -1994,6 +1994,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index bd6242861b..d738bf3659 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1900,6 +1900,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist
index f2f070fbce..c04c3bae24 100644
--- a/sysdeps/unix/sysv/linux/sh/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libc.abilist
@@ -1876,6 +1876,7 @@ GLIBC_2.27 wcstof32x F
GLIBC_2.27 wcstof32x_l F
GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 265087f6a8..5f865dad28 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -1988,6 +1988,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 16a69812cb..5caf4992d8 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1930,6 +1930,7 @@ GLIBC_2.27 wcstof64 F
GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.28 fcntl64 F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index fa8c198d13..950208aee8 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1889,6 +1889,7 @@ GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
GLIBC_2.28 fcntl64 F
+GLIBC_2.28 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 2536971682..ed5762bba2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2140,3 +2140,4 @@ GLIBC_2.27 wcstof64_l F
GLIBC_2.27 wcstof64x F
GLIBC_2.27 wcstof64x_l F
GLIBC_2.28 fcntl64 F
+GLIBC_2.28 __libc_start_main F
diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S
index 354d2e6ec7..8060586b5c 100644
--- a/sysdeps/x86_64/start.S
+++ b/sysdeps/x86_64/start.S
@@ -96,17 +96,13 @@ ENTRY (_start)
which grow downwards). */
pushq %rsp
+ /* These used to be the addresses of .fini and .init. */
+ xor %R8_LP, %R8_LP
+ xor %RCX_LP, %RCX_LP
+
#ifdef PIC
- /* Pass address of our own entry points to .fini and .init. */
- mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
- mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
-
mov main@GOTPCREL(%rip), %RDI_LP
#else
- /* Pass address of our own entry points to .fini and .init. */
- mov $__libc_csu_fini, %R8_LP
- mov $__libc_csu_init, %RCX_LP
-
mov $main, %RDI_LP
#endif
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2018-06-23 21:45 [PATCH] Reduce the statically linked startup code [BZ #23323] Florian Weimer
2018-07-01 9:30 ` Florian Weimer
2018-07-03 10:01 ` Florian Weimer
@ 2018-08-08 14:48 ` Florian Weimer
2018-08-08 15:10 ` H.J. Lu
2018-08-08 15:56 ` Szabolcs Nagy
2 siblings, 2 replies; 15+ messages in thread
From: Florian Weimer @ 2018-08-08 14:48 UTC (permalink / raw)
To: libc-alpha
[-- Attachment #1: Type: text/plain, Size: 147 bytes --]
This is the patch rebased for glibc 2.29.
Should we make more far-reaching changes and remove the arguments which
are now zero?
Thanks,
Florian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: csu.patch --]
[-- Type: text/x-patch; name="csu.patch", Size: 51961 bytes --]
Subject: [PATCH] Reduce the statically linked startup code [BZ #23323]
To: libc-alpha@sourceware.org
It turns out the startup code in csu/elf-unit.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, âreturn-to-csu: A
New Method to Bypass 64-bit Linux ASLRâ). These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker. However, the dynamic
linker skipped the main program for some reason. For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.
For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.
A new symbol version __libc_start_main@@GLIBC_2.29 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues. This approach
(multiple symbol versions for the same function symbol) requires a
recent binutils version (later than 2.25 on some architectures) because
earlier versions cannot use a symbol alias to define multiple symbol
versions for the same symbol.
Tested on aarch64, armhfp, i686, mips64, ppc, ppc64, ppc64el, s390,
s390x, x86_64, and built with build-many-glibcs.py. This patch
depends on the earlier patch which introduces ELF_INITFINI.
2018-06-23 Florian Weimer <fweimer@redhat.com>
[BZ #23323]
Reduce statically-linked startup code.
* csu/Makefile (routines): Remove elf-init.
* csu/elf-init.c: Remove file.
* csu/Versions (GLIBC_2.29): Export __libc_start_main from libc.
* csu/libc-start.c: Add note that this is not part of the startup
code for dynamically linked applications.
[SHARED] (call_init): New function, based on call_init from
elf/dl-init.c.
[!SHARED] (call_init, call_fini): New functions, based on
csu/elf-init.c
(LIBC_START_MAIN): Update function comment. Register call_fini
directly for statically linked applications. Call call_init
instead of init (in statically linked applications, and if it is
not NULL).
(DO_DEFINE_LIBC_START_MAIN_VERSION)
(DEFINE_LIBC_START_MAIN_VERSION_1)
(DEFINE_LIBC_START_MAIN_VERSION): Define.
* elf/dl-init.c (init_t): Move to <ldsodefs.h>.
(call_init, _dl_init) Adjust.
* sysdeps/generic/ldsodefs.h (dl_init_t): Moved from
elf/dl-init.c.
(DL_CALL_DT_INIT): Adjust.
* sysdeps/hppa/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
* sysdeps/ia64/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
* sysdeps/aarch64/start.S (_start): Pass zero for init and fini.
* sysdeps/alpha/start.S (_start): Likewise.
* sysdeps/arm/start.S (_start): Likewise. Adjust offset of
pointer to main.
(.L_GOT): Adjust.
* sysdeps/hppa/start.S (.Lp__libc_csu_fini, .Lp__libc_csu_init):
Remove.
(_start): Pass zero for init and fini.
* sysdeps/ia64/start.S (_start): Pass zero for init and fini.
* sysdeps/i386/start.S (_start): Likewise.
* sysdeps/m68k/start.S (_start): Likewise.
* sysdeps/microblaze/start.S (_start): Likewise.
* sysdeps/mips/start.S (ENTRY_POINT): Likewise.
* sysdeps/nios2/start.S (_start): Likewise.
* sydeps/powerpc/powerpc32/start.S (start_addresses): Use zero for
init and fini.
* sysdeps/powerpc/powerpc64/start.S (start_addresses): Likewise.
* sysdeps/unix/sysv/linux/powerpc/libc-start: Use
DEFINE_LIBC_START_MAIN_VERSION.
* sysdeps/riscv/start.S (ENTRY_POINT): Pass zero for init and fini.
* sysdeps/s390/s390-32/start.S (_start): Pass zero for init and
fini.
(.L1, .L2): Remove.
* sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
fini.
* sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
fini.
* sysdeps/sh/start.S (_start): Likewise.
(L_init, L_fini): Remove.
* sysdeps/sparc/sparc32/start.S (_start): Pass zero for init and
fini.
* sysdeps/sparc/sparc64/start.S (_start): Likewise.
* sysdeps/x86_64/start.S (start): Likewise.
* sysdeps/mach/hurd/i386/libc.abilist: Add
__libc_start_main@GLIBC_2.29.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
diff --git a/csu/Makefile b/csu/Makefile
index 88fc77662e..50d291ce72 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -27,10 +27,9 @@ subdir := csu
include ../Makeconfig
routines = init-first libc-start $(libc-init) sysdep version check_fds \
- libc-tls elf-init dso_handle
+ libc-tls dso_handle
aux = errno
elide-routines.os = libc-tls
-static-only-routines = elf-init
csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
extra-objs = start.o \
$(start-installed-name) g$(start-installed-name) $(csu-dummies) \
diff --git a/csu/Versions b/csu/Versions
index 43010c3443..136e8155d5 100644
--- a/csu/Versions
+++ b/csu/Versions
@@ -7,6 +7,9 @@ libc {
# New special glibc functions.
gnu_get_libc_release; gnu_get_libc_version;
}
+ GLIBC_2.29 {
+ __libc_start_main;
+ }
GLIBC_PRIVATE {
errno;
}
diff --git a/csu/elf-init.c b/csu/elf-init.c
deleted file mode 100644
index 8bde25a340..0000000000
--- a/csu/elf-init.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Startup support for ELF initializers/finalizers in the main executable.
- 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
- 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.
-
- In addition to the permissions in the GNU Lesser General Public
- License, the Free Software Foundation gives you unlimited
- permission to link the compiled version of this file with other
- programs, and to distribute those programs without any restriction
- coming from the use of this file. (The GNU Lesser General Public
- License restrictions do apply in other respects; for example, they
- cover modification of the file, and distribution when not linked
- into another program.)
-
- Note that people who make modified versions of this file are not
- obligated to grant this special exception for their modified
- versions; it is their choice whether to do so. The GNU Lesser
- General Public License gives permission to release a modified
- version without this exception; this exception also makes it
- possible to release a modified version which carries forward this
- exception.
-
- 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 <stddef.h>
-#include <platform-params.h>
-
-
-/* These magic symbols are provided by the linker. */
-extern void (*__preinit_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__preinit_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__fini_array_start []) (void) attribute_hidden;
-extern void (*__fini_array_end []) (void) attribute_hidden;
-
-
-#if ELF_INITFINI
-/* These function symbols are provided for the .init/.fini section entry
- points automagically by the linker. */
-extern void _init (void);
-extern void _fini (void);
-#endif
-
-
-/* These functions are passed to __libc_start_main by the startup code.
- These get statically linked into each program. For dynamically linked
- programs, this module will come from libc_nonshared.a and differs from
- the libc.a module in that it doesn't call the preinit array. */
-
-
-void
-__libc_csu_init (int argc, char **argv, char **envp)
-{
- /* For dynamically linked executables the preinit array is executed by
- the dynamic linker (before initializing any shared object). */
-
-#ifndef LIBC_NONSHARED
- /* For static executables, preinit happens right before init. */
- {
- const size_t size = __preinit_array_end - __preinit_array_start;
- size_t i;
- for (i = 0; i < size; i++)
- (*__preinit_array_start [i]) (argc, argv, envp);
- }
-#endif
-
-#if ELF_INITFINI
- _init ();
-#endif
-
- const size_t size = __init_array_end - __init_array_start;
- for (size_t i = 0; i < size; i++)
- (*__init_array_start [i]) (argc, argv, envp);
-}
-
-/* This function should not be used anymore. We run the executable's
- destructor now just like any other. We cannot remove the function,
- though. */
-void
-__libc_csu_fini (void)
-{
-#ifndef LIBC_NONSHARED
- size_t i = __fini_array_end - __fini_array_start;
- while (i-- > 0)
- (*__fini_array_start [i]) ();
-
-# if ELF_INITFINI
- _fini ();
-# endif
-#endif
-}
diff --git a/csu/libc-start.c b/csu/libc-start.c
index 494132368f..eccc42a70c 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
+/* Perform initialization and invoke main.
+ 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
@@ -15,6 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+/* Note: This code is only part of the startup code proper for
+ statically linked binaries. For dynamically linked binaries, it
+ resides in libc.so. */
+
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
@@ -22,6 +27,8 @@
#include <ldsodefs.h>
#include <exit-thread.h>
#include <libc-internal.h>
+#include <platform-params.h>
+#include <shlib-compat.h>
#include <elf/dl-tunables.h>
@@ -88,9 +95,11 @@ apply_irel (void)
# else
# define STATIC static inline __attribute__ ((always_inline))
# endif
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 0
#else
# define STATIC
# define LIBC_START_MAIN __libc_start_main
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 1
#endif
#ifdef MAIN_AUXVEC_ARG
@@ -106,6 +115,92 @@ apply_irel (void)
# define ARCH_INIT_CPU_FEATURES()
#endif
+#ifdef SHARED
+/* Initialization for dynamic executables. Find the main executable
+ link map and run its init functions. */
+static void
+call_init (int argc, char **argv, char **env)
+{
+ /* Obtain the main map of the executable. */
+ struct link_map *l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+
+ /* DT_PREINIT_ARRAY is not processed here. It is already handled in
+ _dl_init in elf/dl-init.c. Also see the call_init function in
+ the same file. */
+
+ if (ELF_INITFINI && l->l_info[DT_INIT] != NULL)
+ DL_CALL_DT_INIT(l, l->l_addr + l->l_info[DT_INIT]->d_un.d_ptr,
+ argc, argv, env);
+
+ ElfW(Dyn) *init_array = l->l_info[DT_INIT_ARRAY];
+ if (init_array != NULL)
+ {
+ unsigned int jm
+ = l->l_info[DT_INIT_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr));
+ ElfW(Addr) *addrs = (void *) (init_array->d_un.d_ptr + l->l_addr);
+ for (unsigned int j = 0; j < jm; ++j)
+ ((dl_init_t) addrs[j]) (argc, argv, env);
+ }
+}
+
+#else /* !SHARED */
+
+/* These magic symbols are provided by the linker. */
+extern void (*__preinit_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__preinit_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__fini_array_start []) (void) attribute_hidden;
+extern void (*__fini_array_end []) (void) attribute_hidden;
+
+# if ELF_INITFINI
+/* These function symbols are provided for the .init/.fini section entry
+ points automagically by the linker. */
+extern void _init (void);
+extern void _fini (void);
+# endif
+
+/* Initialization for static executables. There is no dynamic
+ segment, so we access the symbols directly. */
+static void
+call_init (int argc, char **argv, char **envp)
+{
+ /* For static executables, preinit happens right before init. */
+ {
+ const size_t size = __preinit_array_end - __preinit_array_start;
+ size_t i;
+ for (i = 0; i < size; i++)
+ (*__preinit_array_start [i]) (argc, argv, envp);
+ }
+
+# if ELF_INITFINI
+ _init ();
+# endif
+
+ const size_t size = __init_array_end - __init_array_start;
+ for (size_t i = 0; i < size; i++)
+ (*__init_array_start [i]) (argc, argv, envp);
+}
+
+/* Likewise for the destructor. */
+static void
+call_fini (void *unused)
+{
+ size_t i = __fini_array_end - __fini_array_start;
+ while (i-- > 0)
+ (*__fini_array_start [i]) ();
+
+# if ELF_INITFINI
+ _fini ();
+# endif
+}
+
+#endif /* !SHARED */
+
#include <libc-start.h>
STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
@@ -122,9 +217,16 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
__attribute__ ((noreturn));
-/* Note: the fini parameter is ignored here for shared library. It
- is registered with __cxa_atexit. This had the disadvantage that
- finalizers were called in more than one place. */
+/* Note: The init and fini parameters are no longer used. fini is
+ completely unused, init is still called if not NULL, but the
+ current startup code always passes NULL. (In the future, it would
+ be possible to use fini to pass a version code if init is NULL, to
+ indicate the link-time glibc without introducing a hard
+ incompatibility for new programs with older glibc versions.)
+
+ For dynamically linked executables, the dynamic segment is used to
+ locate constructors and destructors. For statically linked
+ executables, the relevant symbols are access directly. */
STATIC int
LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
int argc, char **argv,
@@ -243,9 +345,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
run the constructors in `_dl_start_user'. */
__libc_init_first (argc, argv, __environ);
- /* Register the destructor of the program, if any. */
- if (fini)
- __cxa_atexit ((void (*) (void *)) fini, NULL, NULL);
+ /* Register the destructor of the statically-linked program. */
+ __cxa_atexit (call_fini, NULL, NULL);
/* Some security at this point. Prevent starting a SUID binary where
the standard file descriptors are not opened. We have to do this
@@ -253,15 +354,24 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
loader did the work already. */
if (__builtin_expect (__libc_enable_secure, 0))
__libc_check_standard_fds ();
-#endif
+#endif /* !SHARED */
/* Call the initializer of the program, if any. */
#ifdef SHARED
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
-#endif
- if (init)
+
+ if (init != NULL)
+ /* This is a legacy program which supplied its own init
+ routine. */
(*init) (argc, argv, __environ MAIN_AUXVEC_PARAM);
+ else
+ /* This is a current program. Use the dynamic segment to find
+ constructors. */
+ call_init (argc, argv, __environ);
+#else /* !SHARED */
+ call_init (argc, argv, __environ);
+#endif /* SHARED */
#ifdef SHARED
/* Auditing checkpoint: we have a new object. */
@@ -341,3 +451,28 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
exit (result);
}
+
+#ifdef SHARED
+/* Starting with glibc 2.29, the init parameter is always NULL. Older
+ libcs are not prepared to handle that. */
+# define DEFINE_LIBC_START_MAIN_VERSION \
+ DEFINE_LIBC_START_MAIN_VERSION_1 \
+ versioned_symbol (libc, __libc_start_main, __libc_start_main, GLIBC_2_29);
+
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_29)
+# define DEFINE_LIBC_START_MAIN_VERSION_1 \
+ strong_alias (__libc_start_main, __libc_start_main_alias) \
+ compat_symbol (libc, __libc_start_main_alias, __libc_start_main, GLIBC_2_0);
+# else
+# define DEFINE_LIBC_START_MAIN_VERSION_1
+# endif
+#else
+# define DEFINE_LIBC_START_MAIN_VERSION
+#endif
+
+/* Only define the version information if LIBC_START_MAIN was not set.
+ If there is a wrapper file, it must expand
+ DEFINE_LIBC_START_MAIN_VERSION on its own. */
+#if DO_DEFINE_LIBC_START_MAIN_VERSION
+DEFINE_LIBC_START_MAIN_VERSION
+#endif
diff --git a/elf/dl-init.c b/elf/dl-init.c
index 31eb12b974..dad3902254 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -21,10 +21,6 @@
#include <platform-params.h>
-/* Type of the initializer. */
-typedef void (*init_t) (int, char **, char **);
-
-
static void
call_init (struct link_map *l, int argc, char **argv, char **env)
{
@@ -71,7 +67,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (init_array->d_un.d_ptr + l->l_addr);
for (j = 0; j < jm; ++j)
- ((init_t) addrs[j]) (argc, argv, env);
+ ((dl_init_t) addrs[j]) (argc, argv, env);
}
}
@@ -103,7 +99,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (preinit_array->d_un.d_ptr + main_map->l_addr);
for (cnt = 0; cnt < i; ++cnt)
- ((init_t) addrs[cnt]) (argc, argv, env);
+ ((dl_init_t) addrs[cnt]) (argc, argv, env);
}
/* Stupid users forced the ELF specification to be changed. It now
diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
index bad000f555..2c22b6ff27 100644
--- a/sysdeps/aarch64/start.S
+++ b/sysdeps/aarch64/start.S
@@ -64,26 +64,16 @@ _start:
# ifdef SHARED
adrp x0, :got:main
ldr PTR_REG (0), [x0, #:got_lo12:main]
-
- adrp x3, :got:__libc_csu_init
- ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
-
- adrp x4, :got:__libc_csu_fini
- ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
# else
adrp x0, __wrap_main
add x0, x0, :lo12:__wrap_main
- adrp x3, __libc_csu_init
- add x3, x3, :lo12:__libc_csu_init
- adrp x4, __libc_csu_fini
- add x4, x4, :lo12:__libc_csu_fini
# endif
#else
/* Set up the other arguments in registers */
MOVL (0, main)
- MOVL (3, __libc_csu_init)
- MOVL (4, __libc_csu_fini)
#endif
+ mov x3, #0 /* Used to be init. */
+ mov x4, #0 /* Used to be fini. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
stack_end) */
diff --git a/sysdeps/alpha/start.S b/sysdeps/alpha/start.S
index 5de8ceeca7..57ea0d67f7 100644
--- a/sysdeps/alpha/start.S
+++ b/sysdeps/alpha/start.S
@@ -55,9 +55,8 @@ _start:
ldl a1, 16(sp) /* get argc */
lda a2, 24(sp) /* get argv */
- /* Load address of our own entry points to .fini and .init. */
- lda a3, __libc_csu_init
- lda a4, __libc_csu_fini
+ mov $r31, a3 /* Used to be init. */
+ mov $r31, a4 /* Used to be init. */
/* Store address of the shared library termination function. */
mov v0, a5
diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S
index adef090717..ad2b25c2e1 100644
--- a/sysdeps/arm/start.S
+++ b/sysdeps/arm/start.S
@@ -94,30 +94,20 @@ _start:
adr a4, .L_GOT
add sl, sl, a4
- ldr ip, .L_GOT+4 /* __libc_csu_fini */
- ldr ip, [sl, ip]
+ mov a4, #0 /* Used to be init. */
+ push { a4 } /* Used to be fini. */
- push { ip } /* Push __libc_csu_fini */
-
- ldr a4, .L_GOT+8 /* __libc_csu_init */
- ldr a4, [sl, a4]
-
- ldr a1, .L_GOT+12 /* main */
+ ldr a1, .L_GOT+4 /* main */
ldr a1, [sl, a1]
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
bl __libc_start_main(PLT)
#else
- /* Fetch address of __libc_csu_fini */
- ldr ip, =__libc_csu_fini
- /* Push __libc_csu_fini */
- push { ip }
-
- /* Set up the other arguments in registers */
+ mov a4, #0 /* Used to init. */
+ push { a4 } /* Used to fini. */
ldr a1, =main
- ldr a4, =__libc_csu_init
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
@@ -131,8 +121,6 @@ _start:
.align 2
.L_GOT:
.word _GLOBAL_OFFSET_TABLE_ - .L_GOT
- .word __libc_csu_fini(GOT)
- .word __libc_csu_init(GOT)
.word main(GOT)
#endif
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 95dc87519b..76a1f0dd56 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -75,6 +75,10 @@ typedef struct link_map *lookup_t;
: (__glibc_unlikely ((ref)->st_shndx == SHN_ABS) ? 0 \
: LOOKUP_VALUE_ADDRESS (map, map_set)) + (ref)->st_value)
+/* Type of a constructor function, in DT_INIT, DT_INIT_ARRAY,
+ DT_PREINIT_ARRAY. */
+typedef void (*dl_init_t) (int, char **, char **);
+
/* On some architectures a pointer to a function is not just a pointer
to the actual code of the function but rather an architecture
specific descriptor. */
@@ -83,7 +87,7 @@ typedef struct link_map *lookup_t;
(void *) SYMBOL_ADDRESS (map, ref, false)
# define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
# define DL_CALL_DT_INIT(map, start, argc, argv, env) \
- ((init_t) (start)) (argc, argv, env)
+ ((dl_init_t) (start)) (argc, argv, env)
# define DL_CALL_DT_FINI(map, start) ((fini_t) (start)) ()
#endif
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
index 38db345936..f9ef78d856 100644
--- a/sysdeps/hppa/dl-lookupcfg.h
+++ b/sysdeps/hppa/dl-lookupcfg.h
@@ -56,7 +56,7 @@ void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S
index c1d2bd4bb7..8ffc247827 100644
--- a/sysdeps/hppa/start.S
+++ b/sysdeps/hppa/start.S
@@ -36,8 +36,6 @@
.import main, code
.import $global$, data
.import __libc_start_main, code
- .import __libc_csu_fini, code
- .import __libc_csu_init, code
/* Have the linker create plabel words so we get PLABEL32
relocs and not 21/14. The use of 21/14 relocs is only
@@ -52,10 +50,6 @@
.word P%main
.Lp__libc_start_main:
.word P%__libc_start_main
-.Lp__libc_csu_fini:
- .word P%__libc_csu_fini
-.Lp__libc_csu_init:
- .word P%__libc_csu_init
.text
.align 4
@@ -77,8 +71,8 @@ _start:
1. r26 - Application main
2. r25 - argc
3. r24 - argv
- 4. r23 - __libc_csu_init
- 5. sp-52 - __libc_csu_fini
+ 4. r23 - init (unused)
+ 5. sp-52 - fini (unused)
6. sp-56 - rtld_fini
7. sp-60 - stackend */
@@ -108,14 +102,6 @@ _start:
addil LT'.Lpmain, %r19
ldw RT'.Lpmain(%r1), %r26
ldw 0(%r26),%r26
- /* void (*init) (void) (4th argument) */
- addil LT'.Lp__libc_csu_init, %r19
- ldw RT'.Lp__libc_csu_init(%r1), %r23
- ldw 0(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- addil LT'.Lp__libc_csu_fini, %r19
- ldw RT'.Lp__libc_csu_fini(%r1), %r22
- ldw 0(%r22), %r22
#else
/* Load $global$ address into %dp */
ldil L%$global$, %dp
@@ -124,13 +110,9 @@ _start:
/* load main (1st argument) */
ldil LR'.Lpmain, %r26
ldw RR'.Lpmain(%r26), %r26
- /* void (*init) (void) (4th argument) */
- ldil LR'.Lp__libc_csu_init, %r23
- ldw RR'.Lp__libc_csu_init(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- ldil LR'.Lp__libc_csu_fini, %r22
- ldw RR'.Lp__libc_csu_fini(%r22), %r22
#endif
+ ldi 0,%r23 /* Used to be init. */
+ ldi 0,%r22 /* Used to be fini. */
/* Store 5th argument */
stw %r22, -52(%sp)
/* void *stack_end (7th argument) */
diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S
index 91035fa83f..92781dc121 100644
--- a/sysdeps/i386/start.S
+++ b/sysdeps/i386/start.S
@@ -86,11 +86,9 @@ _start:
call 1f
addl $_GLOBAL_OFFSET_TABLE_, %ebx
- /* Push address of our own entry points to .fini and .init. */
- leal __libc_csu_fini@GOTOFF(%ebx), %eax
- pushl %eax
- leal __libc_csu_init@GOTOFF(%ebx), %eax
- pushl %eax
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
@@ -111,9 +109,9 @@ _start:
But let the libc call main. */
call __libc_start_main@PLT
#else
- /* Push address of our own entry points to .fini and .init. */
- pushl $__libc_csu_fini
- pushl $__libc_csu_init
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
diff --git a/sysdeps/ia64/dl-lookupcfg.h b/sysdeps/ia64/dl-lookupcfg.h
index 48f91202c4..83734a9562 100644
--- a/sysdeps/ia64/dl-lookupcfg.h
+++ b/sysdeps/ia64/dl-lookupcfg.h
@@ -50,7 +50,7 @@ extern void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/ia64/start.S b/sysdeps/ia64/start.S
index 04205aa94f..6c3e468bcb 100644
--- a/sysdeps/ia64/start.S
+++ b/sysdeps/ia64/start.S
@@ -83,20 +83,15 @@ _start:
{
addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
addl out0 = @ltoff(@fptr(main)), gp
- addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
+ mov out3 = r0 /* Used to be init. */
;;
}
{ .mmi
ld8 r3 = [r11] /* pointer to __libc_ia64_register_backing_store_base */
ld8 out0 = [out0] /* pointer to `main' function descriptor */
- addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
+ mov out4 = r0 /* Used to be fini. */
;;
}
- { .mmi
- ld8 out3 = [out3] /* pointer to `init' function descriptor */
- ld8 out4 = [out4] /* pointer to `fini' function descriptor */
- nop 0
- }
.body
{ .mib
st8 [r3] = r10
diff --git a/sysdeps/m68k/start.S b/sysdeps/m68k/start.S
index 7bab3e1cde..7d151a3205 100644
--- a/sysdeps/m68k/start.S
+++ b/sysdeps/m68k/start.S
@@ -76,15 +76,14 @@ _start:
pea (%a1) /* Push address of the shared library
termination function. */
+ /* These used to be addresses of the .fini and .init entry points. */
+ clr.l -(%sp)
+ clr.l -(%sp)
+
#ifdef PIC
/* Load PIC register. */
LOAD_GOT (%a5)
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- move.l __libc_csu_fini@GOT(%a5), -(%sp)
- move.l __libc_csu_init@GOT(%a5), -(%sp)
-
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
@@ -94,10 +93,6 @@ _start:
let the libc call main. */
jbsr __libc_start_main@PLTPC
#else
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- pea __libc_csu_fini
- pea __libc_csu_init
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index e3fc05137b..0705f9e129 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2038,6 +2038,7 @@ GLIBC_2.27 wcstof64x_l F
GLIBC_2.28 fcntl64 F
GLIBC_2.28 renameat2 F
GLIBC_2.28 statx F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S
index cc8dd13fe4..39f858ab71 100644
--- a/sysdeps/microblaze/start.S
+++ b/sysdeps/microblaze/start.S
@@ -63,14 +63,14 @@ _start:
mfs r20,rpc
addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
lwi r5,r20,main@GOT
- lwi r8,r20,__libc_csu_init@GOT
- lwi r9,r20,__libc_csu_fini@GOT
+ addk r8,r0,r0 /* Used to be init. */
+ addk r8,r0,r0 /* Used to be fini. */
brid __libc_start_main@PLT
addk r10,r0,r0
#else
addik r5,r0,main
- addik r8,r0,__libc_csu_init
- addik r9,r0,__libc_csu_fini
+ addk r8,r0,r0 /* Used to be init. */
+ addk r8,r0,r0 /* Used to be fini. */
brid __libc_start_main
addk r10,r0,r0
#endif
diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S
index a4c4ef0fae..f1ba04bc97 100644
--- a/sysdeps/mips/start.S
+++ b/sysdeps/mips/start.S
@@ -96,10 +96,9 @@ ENTRY_POINT:
# if _MIPS_SIM == _ABIO32
PTR_SUBIU $29, 32
# endif
- PTR_LA $7, __libc_csu_init /* init */
- PTR_LA $8, __libc_csu_fini
+ move $7, $0 /* init */
# if _MIPS_SIM == _ABIO32
- PTR_S $8, 16($29) /* fini */
+ PTR_S $0, 16($29) /* fini */
PTR_S $2, 20($29) /* rtld_fini */
PTR_S $29, 24($29) /* stack_end */
# else
@@ -143,19 +142,17 @@ ENTRY_POINT:
/* Lay out last arguments, and call __libc_start_main(). */
# ifdef __PIC__
sw $7, 24($sp) /* stack_end */
- lw $4, %got(__libc_csu_fini)($3)
- lw $7, %got(__libc_csu_init)($3) /* init */
- sw $4, 16($sp) /* fini */
+ move $4, $0 /* Used to be ini. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, %got(main)($3) /* main */
lw $3, %call16(__libc_start_main)($3)
sw $2, 20($sp) /* rtld_fini */
move $25, $3
jalr $3
# else
- lw $4, 1f
sw $7, 24($sp) /* stack_end */
- lw $7, 2f /* init */
- sw $4, 16($sp) /* fini */
+ move $7, $0 /* Used to be init. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, 3f /* main */
sw $2, 20($sp) /* rtld_fini */
/* Load and call __libc_start_main(). */
@@ -165,8 +162,6 @@ ENTRY_POINT:
hlt: b hlt /* Crash if somehow it does return. */
# ifndef __PIC__
.align 2
-1: .word __libc_csu_fini
-2: .word __libc_csu_init
3: .word main
4: .word __libc_start_main
# endif
diff --git a/sysdeps/nios2/start.S b/sysdeps/nios2/start.S
index fa224ef75c..51a0757d78 100644
--- a/sysdeps/nios2/start.S
+++ b/sysdeps/nios2/start.S
@@ -92,18 +92,11 @@ _start:
addi r2, r2, %lo(_gp_got - 1b)
add r22, r22, r2
- /* Push fini */
- movhi r8, %call_hiadj(__libc_csu_fini)
- addi r8, r8, %call_lo(__libc_csu_fini)
- add r8, r8, r22
- ldw r8, 0(r8)
- stw r8, 0(sp)
+ /* Used to be fini. */
+ stw zero, 0(sp)
- /* r7 == init */
- movhi r7, %call_hiadj(__libc_csu_init)
- addi r7, r7, %call_lo(__libc_csu_init)
- add r7, r7, r22
- ldw r7, 0(r7)
+ /* Used to be init. */
+ mov r7, zero
/* r6 == argv */
addi r6, sp, 16
diff --git a/sysdeps/powerpc/powerpc32/start.S b/sysdeps/powerpc/powerpc32/start.S
index 5c10a22f8a..0be6aed543 100644
--- a/sysdeps/powerpc/powerpc32/start.S
+++ b/sysdeps/powerpc/powerpc32/start.S
@@ -52,8 +52,8 @@
L(start_addresses):
.long _SDA_BASE_
.long main
- .long __libc_csu_init
- .long __libc_csu_fini
+ .long 0 /* Used to be init. */
+ .long 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
.section ".text"
diff --git a/sysdeps/powerpc/powerpc64/start.S b/sysdeps/powerpc/powerpc64/start.S
index bd7189310c..149afbeab1 100644
--- a/sysdeps/powerpc/powerpc64/start.S
+++ b/sysdeps/powerpc/powerpc64/start.S
@@ -53,8 +53,8 @@ L(start_addresses):
.quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
/* function descriptors so don't need JUMPTARGET */
.quad main
- .quad __libc_csu_init
- .quad __libc_csu_fini
+ .quad 0 /* Used to be init. */
+ .quad 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S
index 4635ddb5eb..9dd4714910 100644
--- a/sysdeps/riscv/start.S
+++ b/sysdeps/riscv/start.S
@@ -50,8 +50,8 @@ ENTRY (ENTRY_POINT)
REG_L a1, 0(sp) /* argc. */
addi a2, sp, SZREG /* argv. */
andi sp, sp, ALMASK /* Align stack. */
- lla a3, __libc_csu_init
- lla a4, __libc_csu_fini
+ li a3, 0 /* Used to be init. */
+ li a4, 0 /* Used to be fini. */
mv a6, sp /* stack_end. */
tail __libc_start_main@plt
diff --git a/sysdeps/s390/s390-32/start.S b/sysdeps/s390/s390-32/start.S
index 1483642985..4587b2de5e 100644
--- a/sysdeps/s390/s390-32/start.S
+++ b/sysdeps/s390/s390-32/start.S
@@ -175,18 +175,16 @@ _start:
*/
stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
la %r7,96(%r15)
- l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini
- l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init
l %r2,.L3-.Llit(%r13) # load pointer to main
l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main
#ifdef PIC
l %r12,.L5-.Llit(%r13) # load .got pointer
- la %r6,0(%r13,%r6)
- la %r5,0(%r13,%r5)
la %r12,0(%r13,%r12)
l %r2,0(%r12,%r2)
la %r1,0(%r13,%r1)
#endif
+ lhi %r6, 0 # Used to fini.
+ lhi %r5, 0 # Used to init.
/* ok, now branch to the libc main routine */
basr %r14,%r1
@@ -197,13 +195,9 @@ _start:
cfi_endproc
.Llit:
#ifndef PIC
-.L1: .long __libc_csu_init
-.L2: .long __libc_csu_fini
.L3: .long main
.L4: .long __libc_start_main
#else
-.L1: .long __libc_csu_init-.Llit
-.L2: .long __libc_csu_fini-.Llit
.L3: .long main@GOT
.L4: .long __libc_start_main@plt-.Llit
.L5: .long _GLOBAL_OFFSET_TABLE_-.Llit
diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S
index 79e7b69f1d..518dfd989e 100644
--- a/sysdeps/s390/s390-64/start.S
+++ b/sysdeps/s390/s390-64/start.S
@@ -80,8 +80,8 @@ _start:
*/
stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
la %r7,160(%r15)
- larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
- larl %r5,__libc_csu_init # load pointer to __libc_csu_init
+ lghi %r6,0 # Used to be fini.
+ lghi %r5,0 # Used to be init.
/* Ok, now branch to the libc main routine. */
#ifdef PIC
diff --git a/sysdeps/sh/start.S b/sysdeps/sh/start.S
index f52077abca..4b0aad511b 100644
--- a/sysdeps/sh/start.S
+++ b/sysdeps/sh/start.S
@@ -70,12 +70,11 @@ _start:
/* Push the last arguments to main() onto the stack */
mov.l r4,@-r15
- mov.l L_fini,r0
- mov.l r0,@-r15
+ mov.l r14,@-r15 /* Used to be fini. */
/* Set up the other arguments for main() that go in registers */
mov.l L_main,r4
- mov.l L_init,r7
+ mov #0,r7 /* Used to be init. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
@@ -90,10 +89,6 @@ _start:
.align 2
L_main:
.long main
-L_init:
- .long __libc_csu_init
-L_fini:
- .long __libc_csu_fini
L_libc_start_main:
.long __libc_start_main
L_abort:
diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S
index 46ba8b6afa..48b30a3fb5 100644
--- a/sysdeps/sparc/sparc32/start.S
+++ b/sysdeps/sparc/sparc32/start.S
@@ -59,22 +59,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ld [%l7 + %o0], %o0, %gdop(main)
- ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S
index 75ff5093dc..73395df40a 100644
--- a/sysdeps/sparc/sparc64/start.S
+++ b/sysdeps/sparc/sparc64/start.S
@@ -60,22 +60,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ldx [%l7 + %o0], %o0, %gdop(main)
- ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 15f966f841..1bee009bd5 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2138,3 +2138,4 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index e22b91655d..4985abf3ff 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2033,6 +2033,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist
index a231812eea..828d53d583 100644
--- a/sysdeps/unix/sysv/linux/arm/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libc.abilist
@@ -123,6 +123,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 24b11b15c0..d3d3c7d821 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -1880,6 +1880,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 9762c81365..a4be302340 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2045,6 +2045,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index 50c94adff9..a35aac00e6 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1914,6 +1914,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index f57be98e49..09837b79bf 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -124,6 +124,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0x98
GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index ddc7ebca67..ff86eada39 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -1989,6 +1989,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
index daed511f00..63008d937e 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
@@ -2130,3 +2130,4 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index dda9797e0e..6ed8e7fe97 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -1967,6 +1967,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 42e930d565..792876692a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -1965,6 +1965,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index f89b44f3a1..f39bfd392f 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -1973,6 +1973,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 1486af11d7..c71f720538 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1968,6 +1968,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index aab1c44e46..6d1a92ca9f 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2171,3 +2171,4 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
index f2ad0c355d..522926604b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-start.c
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
@@ -103,3 +103,4 @@ __libc_start_main (int argc, char **argv,
stinfo->init, stinfo->fini, rtld_fini,
stack_on_entry);
}
+DEFINE_LIBC_START_MAIN_VERSION
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 45839ed25b..7d06166905 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -1993,6 +1993,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 344e5ae87c..5b079783cc 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -1997,6 +1997,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index e26930e728..d0ee5d21ed 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2228,3 +2228,4 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 8c1781adf4..01a394146e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -123,6 +123,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 _Exit F
GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
GLIBC_2.3 _IO_2_1_stdin_ D 0xe0
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index daacceebd6..a1f19becf9 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2100,3 +2100,4 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 3a5ec2a1e4..3d4adb5018 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2002,6 +2002,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 3b5465558b..9d6d587a2b 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1907,6 +1907,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist
index 1f4e648baa..1d2a8f5759 100644
--- a/sysdeps/unix/sysv/linux/sh/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libc.abilist
@@ -1884,6 +1884,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index d308ac8b05..f041d824e6 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -1996,6 +1996,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 6731ebfc28..d709b89be4 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1937,6 +1937,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 816e4a7426..73fcf0e0d0 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1895,6 +1895,7 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 6fee16a850..4be56f140d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2146,3 +2146,4 @@ GLIBC_2.28 thrd_current F
GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
+GLIBC_2.29 __libc_start_main F
diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S
index 354d2e6ec7..8060586b5c 100644
--- a/sysdeps/x86_64/start.S
+++ b/sysdeps/x86_64/start.S
@@ -96,17 +96,13 @@ ENTRY (_start)
which grow downwards). */
pushq %rsp
+ /* These used to be the addresses of .fini and .init. */
+ xor %R8_LP, %R8_LP
+ xor %RCX_LP, %RCX_LP
+
#ifdef PIC
- /* Pass address of our own entry points to .fini and .init. */
- mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
- mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
-
mov main@GOTPCREL(%rip), %RDI_LP
#else
- /* Pass address of our own entry points to .fini and .init. */
- mov $__libc_csu_fini, %R8_LP
- mov $__libc_csu_init, %RCX_LP
-
mov $main, %RDI_LP
#endif
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2018-08-08 14:48 ` Florian Weimer
@ 2018-08-08 15:10 ` H.J. Lu
2018-08-08 15:17 ` Florian Weimer
2018-08-08 15:56 ` Szabolcs Nagy
1 sibling, 1 reply; 15+ messages in thread
From: H.J. Lu @ 2018-08-08 15:10 UTC (permalink / raw)
To: Florian Weimer; +Cc: GNU C Library
On Wed, Aug 8, 2018 at 7:48 AM, Florian Weimer <fweimer@redhat.com> wrote:
> This is the patch rebased for glibc 2.29.
>
> Should we make more far-reaching changes and remove the arguments which are
> now zero?
>
i386 and x86-64 parts look good, except for
+ /* These used to be the addresses of .fini and .init. */
+ xor %R8_LP, %R8_LP
+ xor %RCX_LP, %RCX_LP
Please use
xorl %r8d, %r8d
xorl %ecx, %ecx
They will zero-extend to 64 bits.
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2018-08-08 15:10 ` H.J. Lu
@ 2018-08-08 15:17 ` Florian Weimer
0 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2018-08-08 15:17 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library
On 08/08/2018 05:10 PM, H.J. Lu wrote:
> On Wed, Aug 8, 2018 at 7:48 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> This is the patch rebased for glibc 2.29.
>>
>> Should we make more far-reaching changes and remove the arguments which are
>> now zero?
>>
>
> i386 and x86-64 parts look good, except for
>
> + /* These used to be the addresses of .fini and .init. */
> + xor %R8_LP, %R8_LP
> + xor %RCX_LP, %RCX_LP
>
> Please use
>
> xorl %r8d, %r8d
> xorl %ecx, %ecx
>
> They will zero-extend to 64 bits.
Thanks, I've made the change locally. xorl %ecx, %ecx is indeed one
byte shorter.
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2018-08-08 14:48 ` Florian Weimer
2018-08-08 15:10 ` H.J. Lu
@ 2018-08-08 15:56 ` Szabolcs Nagy
2018-08-08 16:11 ` Florian Weimer
1 sibling, 1 reply; 15+ messages in thread
From: Szabolcs Nagy @ 2018-08-08 15:56 UTC (permalink / raw)
To: Florian Weimer, libc-alpha; +Cc: nd
On 08/08/18 15:48, Florian Weimer wrote:
> This is the patch rebased for glibc 2.29.
>
> Should we make more far-reaching changes and remove the arguments which are now zero?
>
there might be code that calls __libc_start_main directly
(e.g. the cgo runtime ?), if removing args breaks something
then i'd keep them (i don't know if it does).
the aarch64 changes look good.
> Subject: [PATCH] Reduce the statically linked startup code [BZ #23323]
> To:libc-alpha@sourceware.org
>
> It turns out the startup code in csu/elf-unit.c has a perfect pair of
i think you mean csu/elf-init.c
> ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, ââ¬Åreturn-to-csu: A
> New Method to Bypass 64-bit Linux ASLRââ¬Â). These functions are not
> needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
> are already processed by the dynamic linker. However, the dynamic
> linker skipped the main program for some reason. For maximum
> backwards compatibility, this is not changed, and instead, the main
> map is consulted from __libc_start_main if the init function argument
> is a NULL pointer.
>
> For statically linked binaries, the old approach based on linker
> symbols is still used because there is nothing else available.
>
> A new symbol version __libc_start_main@@GLIBC_2.29 is introduced because
> new binaries running on an old libc would not run their ELF
> constructors, leading to difficult-to-debug issues. This approach
> (multiple symbol versions for the same function symbol) requires a
> recent binutils version (later than 2.25 on some architectures) because
> earlier versions cannot use a symbol alias to define multiple symbol
> versions for the same symbol.
>
> Tested on aarch64, armhfp, i686, mips64, ppc, ppc64, ppc64el, s390,
> s390x, x86_64, and built with build-many-glibcs.py. This patch
> depends on the earlier patch which introduces ELF_INITFINI.
>
> 2018-06-23 Florian Weimer<fweimer@redhat.com>
>
> [BZ #23323]
> Reduce statically-linked startup code.
> * csu/Makefile (routines): Remove elf-init.
> * csu/elf-init.c: Remove file.
> * csu/Versions (GLIBC_2.29): Export __libc_start_main from libc.
> * csu/libc-start.c: Add note that this is not part of the startup
> code for dynamically linked applications.
> [SHARED] (call_init): New function, based on call_init from
> elf/dl-init.c.
> [!SHARED] (call_init, call_fini): New functions, based on
> csu/elf-init.c
> (LIBC_START_MAIN): Update function comment. Register call_fini
> directly for statically linked applications. Call call_init
> instead of init (in statically linked applications, and if it is
> not NULL).
> (DO_DEFINE_LIBC_START_MAIN_VERSION)
> (DEFINE_LIBC_START_MAIN_VERSION_1)
> (DEFINE_LIBC_START_MAIN_VERSION): Define.
> * elf/dl-init.c (init_t): Move to <ldsodefs.h>.
> (call_init, _dl_init) Adjust.
> * sysdeps/generic/ldsodefs.h (dl_init_t): Moved from
> elf/dl-init.c.
> (DL_CALL_DT_INIT): Adjust.
> * sysdeps/hppa/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
> * sysdeps/ia64/dl-lookupcfg.h (DL_CALL_DT_INIT): Likewise.
> * sysdeps/aarch64/start.S (_start): Pass zero for init and fini.
> * sysdeps/alpha/start.S (_start): Likewise.
> * sysdeps/arm/start.S (_start): Likewise. Adjust offset of
> pointer to main.
> (.L_GOT): Adjust.
> * sysdeps/hppa/start.S (.Lp__libc_csu_fini, .Lp__libc_csu_init):
> Remove.
> (_start): Pass zero for init and fini.
> * sysdeps/ia64/start.S (_start): Pass zero for init and fini.
> * sysdeps/i386/start.S (_start): Likewise.
> * sysdeps/m68k/start.S (_start): Likewise.
> * sysdeps/microblaze/start.S (_start): Likewise.
> * sysdeps/mips/start.S (ENTRY_POINT): Likewise.
> * sysdeps/nios2/start.S (_start): Likewise.
> * sydeps/powerpc/powerpc32/start.S (start_addresses): Use zero for
> init and fini.
> * sysdeps/powerpc/powerpc64/start.S (start_addresses): Likewise.
> * sysdeps/unix/sysv/linux/powerpc/libc-start: Use
> DEFINE_LIBC_START_MAIN_VERSION.
> * sysdeps/riscv/start.S (ENTRY_POINT): Pass zero for init and fini.
> * sysdeps/s390/s390-32/start.S (_start): Pass zero for init and
> fini.
> (.L1, .L2): Remove.
> * sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
> fini.
> * sysdeps/s390/s390-64/start.S (_start): Pass zero for init and
> fini.
> * sysdeps/sh/start.S (_start): Likewise.
> (L_init, L_fini): Remove.
> * sysdeps/sparc/sparc32/start.S (_start): Pass zero for init and
> fini.
> * sysdeps/sparc/sparc64/start.S (_start): Likewise.
> * sysdeps/x86_64/start.S (start): Likewise.
> * sysdeps/mach/hurd/i386/libc.abilist: Add
> __libc_start_main@GLIBC_2.29.
> * sysdeps/unix/sysv/linux/aarch64/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
> Likewise.
> * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
> Likewise.
> * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
> Likewise.
> * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
> Likewise.
> * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
> Likewise.
> * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
> * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2018-08-08 15:56 ` Szabolcs Nagy
@ 2018-08-08 16:11 ` Florian Weimer
0 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2018-08-08 16:11 UTC (permalink / raw)
To: Szabolcs Nagy, libc-alpha; +Cc: nd
On 08/08/2018 05:56 PM, Szabolcs Nagy wrote:
> On 08/08/18 15:48, Florian Weimer wrote:
>> This is the patch rebased for glibc 2.29.
>>
>> Should we make more far-reaching changes and remove the arguments
>> which are now zero?
>>
>
> there might be code that calls __libc_start_main directly
> (e.g. the cgo runtime ?), if removing args breaks something
> then i'd keep them (i don't know if it does).
If that's a concern, we should rename the symbol as well.
I think cgo mentions it only in the documentation, quoting Go code which
has been auto-generated from the underlying executable link.
Thanks,
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2021-03-01 9:43 ` Florian Weimer
@ 2021-03-07 16:39 ` Mike Frysinger
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger @ 2021-03-07 16:39 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 01 Mar 2021 10:43, Florian Weimer via Libc-alpha wrote:
> * Mike Frysinger:
> >> What about this?
> >>
> >> /* Note: This file is part of the startup code in statically linked
> >> programs. From the statically linked startup code, dynamically
> >> linked programs call __libc_start_main in libc.so, which is compiled
> >> from this file as well, but not part of the statically linked startup
> >> code due to this separation. */
> >
> > iiuc, libc-start ends up in libc.a & libc.so. in both cases, it provides
> > the __libc_start_main symbol, and in both cases, the crt object calls it.
> >
> > when you say "statically linked startup code", i'm guessing you're referring
> > to the crt objects.
> >
> > so when you say "part of the startup code in statically linked programs", it
> > makes it sound like this file is not used in shared programs which is not the
> > case at all.
> >
> > how about:
> > /* This file provides __libc_start_main which is responsible for initializing
> > the glibc runtime before transferring execution to the main function. It is
> > called from the startup code statically linked into all programs (e.g. the
> > crt1.o object that provides the _start symbol).
> >
> > In a statically linked program, it is linked directly into the image via the
> > libc.a archive. In a dynamically linked program, it is part of libc.so. */
>
> By being part of the startup code, I meant code that runs very early,
> before full platform initialization (like the TCB). In the statically
> linked base, __libc_start_main is in that category. But in the
> dynamically linked case, it runs very late (after ELF constructors for
> the initially loaded DSOs, for example). This is an important
> distinction, I think.
adding that bit of detail would be helpful.
> We can argue about this some more, or split the file in two. 8-)
my concern is that the extensive use of "statically linked" in your comments
can be easily confused between statically linked programs and dynamically
linked programs (with the little bit of statically linked code) to the point
that i'm not sure it adds clarity for the reader.
-mie
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2021-02-28 6:02 ` Mike Frysinger
@ 2021-03-01 9:43 ` Florian Weimer
2021-03-07 16:39 ` Mike Frysinger
0 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-03-01 9:43 UTC (permalink / raw)
To: libc-alpha
* Mike Frysinger:
>> What about this?
>>
>> /* Note: This file is part of the startup code in statically linked
>> programs. From the statically linked startup code, dynamically
>> linked programs call __libc_start_main in libc.so, which is compiled
>> from this file as well, but not part of the statically linked startup
>> code due to this separation. */
>
> iiuc, libc-start ends up in libc.a & libc.so. in both cases, it provides
> the __libc_start_main symbol, and in both cases, the crt object calls it.
>
> when you say "statically linked startup code", i'm guessing you're referring
> to the crt objects.
>
> so when you say "part of the startup code in statically linked programs", it
> makes it sound like this file is not used in shared programs which is not the
> case at all.
>
> how about:
> /* This file provides __libc_start_main which is responsible for initializing
> the glibc runtime before transferring execution to the main function. It is
> called from the startup code statically linked into all programs (e.g. the
> crt1.o object that provides the _start symbol).
>
> In a statically linked program, it is linked directly into the image via the
> libc.a archive. In a dynamically linked program, it is part of libc.so. */
> -mike
By being part of the startup code, I meant code that runs very early,
before full platform initialization (like the TCB). In the statically
linked base, __libc_start_main is in that category. But in the
dynamically linked case, it runs very late (after ELF constructors for
the initially loaded DSOs, for example). This is an important
distinction, I think.
We can argue about this some more, or split the file in two. 8-)
Thanks,
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2021-02-25 18:52 ` Florian Weimer
@ 2021-02-28 6:02 ` Mike Frysinger
2021-03-01 9:43 ` Florian Weimer
0 siblings, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2021-02-28 6:02 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 25 Feb 2021 19:52, Florian Weimer via Libc-alpha wrote:
> * Mike Frysinger:
> > On 18 Feb 2021 14:12, Florian Weimer via Libc-alpha wrote:
> >> --- a/csu/libc-start.c
> >> +++ b/csu/libc-start.c
> >>
> >> +/* Note: This code is only part of the startup code proper for
> >> + statically linked binaries. For dynamically linked binaries, it
> >> + resides in libc.so. */
> >
> > i'm having a hard time reconciling this comment. it makes it sound like
> > the code in this file is only used in static binaries. at which point,
> > what is the reference to libc.so for, and why is SHARED check ?
> >
> > i'm guessing you're trying to clarify the linkage behavior for readers.
> > maybe use that phrasing/framing instead ?
>
> What about this?
>
> /* Note: This file is part of the startup code in statically linked
> programs. From the statically linked startup code, dynamically
> linked programs call __libc_start_main in libc.so, which is compiled
> from this file as well, but not part of the statically linked startup
> code due to this separation. */
iiuc, libc-start ends up in libc.a & libc.so. in both cases, it provides
the __libc_start_main symbol, and in both cases, the crt object calls it.
when you say "statically linked startup code", i'm guessing you're referring
to the crt objects.
so when you say "part of the startup code in statically linked programs", it
makes it sound like this file is not used in shared programs which is not the
case at all.
how about:
/* This file provides __libc_start_main which is responsible for initializing
the glibc runtime before transferring execution to the main function. It is
called from the startup code statically linked into all programs (e.g. the
crt1.o object that provides the _start symbol).
In a statically linked program, it is linked directly into the image via the
libc.a archive. In a dynamically linked program, it is part of libc.so. */
-mike
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2021-02-25 18:43 ` Mike Frysinger
@ 2021-02-25 18:52 ` Florian Weimer
2021-02-28 6:02 ` Mike Frysinger
0 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-02-25 18:52 UTC (permalink / raw)
To: libc-alpha
* Mike Frysinger:
> On 18 Feb 2021 14:12, Florian Weimer via Libc-alpha wrote:
>> --- a/csu/libc-start.c
>> +++ b/csu/libc-start.c
>>
>> +/* Note: This code is only part of the startup code proper for
>> + statically linked binaries. For dynamically linked binaries, it
>> + resides in libc.so. */
>
> i'm having a hard time reconciling this comment. it makes it sound like
> the code in this file is only used in static binaries. at which point,
> what is the reference to libc.so for, and why is SHARED check ?
>
> i'm guessing you're trying to clarify the linkage behavior for readers.
> maybe use that phrasing/framing instead ?
What about this?
/* Note: This file is part of the startup code in statically linked
programs. From the statically linked startup code, dynamically
linked programs call __libc_start_main in libc.so, which is compiled
from this file as well, but not part of the statically linked startup
code due to this separation. */
I hope this explains what is going on.
Thanks,
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2021-02-18 13:12 Florian Weimer
2021-02-25 11:00 ` Siddhesh Poyarekar
@ 2021-02-25 18:43 ` Mike Frysinger
2021-02-25 18:52 ` Florian Weimer
1 sibling, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2021-02-25 18:43 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 18 Feb 2021 14:12, Florian Weimer via Libc-alpha wrote:
> --- a/csu/libc-start.c
> +++ b/csu/libc-start.c
>
> +/* Note: This code is only part of the startup code proper for
> + statically linked binaries. For dynamically linked binaries, it
> + resides in libc.so. */
i'm having a hard time reconciling this comment. it makes it sound like
the code in this file is only used in static binaries. at which point,
what is the reference to libc.so for, and why is SHARED check ?
i'm guessing you're trying to clarify the linkage behavior for readers.
maybe use that phrasing/framing instead ?
-mike
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Reduce the statically linked startup code [BZ #23323]
2021-02-18 13:12 Florian Weimer
@ 2021-02-25 11:00 ` Siddhesh Poyarekar
2021-02-25 18:43 ` Mike Frysinger
1 sibling, 0 replies; 15+ messages in thread
From: Siddhesh Poyarekar @ 2021-02-25 11:00 UTC (permalink / raw)
To: Florian Weimer, libc-alpha
On 2/18/21 6:42 PM, Florian Weimer via Libc-alpha wrote:
> It turns out the startup code in csu/elf-init.c has a perfect pair of
> ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, “return-to-csu: A
> New Method to Bypass 64-bit Linux ASLR”). These functions are not
> needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
> are already processed by the dynamic linker. However, the dynamic
> linker skipped the main program for some reason. For maximum
> backwards compatibility, this is not changed, and instead, the main
> map is consulted from __libc_start_main if the init function argument
> is a NULL pointer.
>
> For statically linked binaries, the old approach based on linker
> symbols is still used because there is nothing else available.
>
> A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because
> new binaries running on an old libc would not run their ELF
> constructors, leading to difficult-to-debug issues.
Looks OK to me.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
> ---
> This version incorporates the x86_64 fix suggested by H.J.
>
> I found a typos in the microblaze changes and fixed them. I added the
> ARC and C-SKY ports.
>
> I tweaked the MIPS start.S changes to be more clear, I hope.
>
> It was necessary to change the __libc_start_main symbol management to
> use more aliases, so that recent binutils linkers do not complain about
> multiple symbol definitions.
>
> Tested on aarch64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
> powerpc64-linux-gnu, powerpc64le-linux-gnu, x86_64-linux-gnu. Built
> with build-many-glibcs.py.
>
>
> csu/Makefile | 10 +-
> csu/Versions | 3 +
> csu/elf-init.c | 107 -------------
> csu/libc-start.c | 166 +++++++++++++++++++--
> elf/dl-init.c | 8 +-
> sysdeps/aarch64/start.S | 14 +-
> sysdeps/alpha/start.S | 5 +-
> sysdeps/arc/start.S | 7 +-
> sysdeps/arm/start.S | 22 +--
> sysdeps/csky/abiv2/start.S | 17 +--
> sysdeps/generic/ldsodefs.h | 6 +-
> sysdeps/hppa/dl-lookupcfg.h | 2 +-
> sysdeps/hppa/start.S | 26 +---
> sysdeps/i386/start.S | 14 +-
> sysdeps/ia64/dl-lookupcfg.h | 2 +-
> sysdeps/ia64/start.S | 9 +-
> sysdeps/m68k/start.S | 13 +-
> sysdeps/mach/hurd/i386/libc.abilist | 1 +
> sysdeps/microblaze/start.S | 8 +-
> sysdeps/mips/start.S | 18 +--
> sysdeps/nios2/start.S | 15 +-
> sysdeps/powerpc/powerpc32/start.S | 4 +-
> sysdeps/powerpc/powerpc64/start.S | 4 +-
> sysdeps/riscv/start.S | 4 +-
> sysdeps/s390/s390-32/start.S | 10 +-
> sysdeps/s390/s390-64/start.S | 4 +-
> sysdeps/sh/start.S | 9 +-
> sysdeps/sparc/sparc32/start.S | 12 +-
> sysdeps/sparc/sparc64/start.S | 12 +-
> sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/arc/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/csky/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/i386/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/microblaze/be/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/microblaze/le/libc.abilist | 1 +
> .../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 1 +
> .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 1 +
> .../unix/sysv/linux/mips/mips64/n32/libc.abilist | 1 +
> .../unix/sysv/linux/mips/mips64/n64/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/nios2/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/powerpc/libc-start.c | 13 +-
> .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 1 +
> .../linux/powerpc/powerpc32/nofpu/libc.abilist | 1 +
> .../sysv/linux/powerpc/powerpc64/be/libc.abilist | 1 +
> .../sysv/linux/powerpc/powerpc64/le/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/sh/be/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/sh/le/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 1 +
> sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 1 +
> sysdeps/x86_64/start.S | 12 +-
> 63 files changed, 275 insertions(+), 314 deletions(-)
>
> diff --git a/csu/Makefile b/csu/Makefile
> index c9385df2e9..e587434be8 100644
> --- a/csu/Makefile
> +++ b/csu/Makefile
> @@ -27,10 +27,9 @@ subdir := csu
> include ../Makeconfig
>
> routines = init-first libc-start $(libc-init) sysdep version check_fds \
> - libc-tls elf-init dso_handle
> + libc-tls dso_handle
> aux = errno
> elide-routines.os = libc-tls
> -static-only-routines = elf-init
> csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
> extra-objs = start.o \
> $(start-installed-name) g$(start-installed-name) $(csu-dummies) \
> @@ -59,13 +58,6 @@ CFLAGS-.os += $(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
> ifneq ($(start-installed-name),$(static-start-installed-name))
> diff --git a/csu/Versions b/csu/Versions
> index 43010c3443..8e1b21948e 100644
> --- a/csu/Versions
> +++ b/csu/Versions
> @@ -7,6 +7,9 @@ libc {
> # New special glibc functions.
> gnu_get_libc_release; gnu_get_libc_version;
> }
> + GLIBC_2.34 {
> + __libc_start_main;
> + }
New symbol. OK.
> GLIBC_PRIVATE {
> errno;
> }
> diff --git a/csu/elf-init.c b/csu/elf-init.c
> deleted file mode 100644
> index 6e96ab7fce..0000000000
> --- a/csu/elf-init.c
> +++ /dev/null
Removed elf-init.c. OK.
> @@ -1,107 +0,0 @@
> -/* Startup support for ELF initializers/finalizers in the main executable.
> - Copyright (C) 2002-2021 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
> - 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.
> -
> - In addition to the permissions in the GNU Lesser General Public
> - License, the Free Software Foundation gives you unlimited
> - permission to link the compiled version of this file with other
> - programs, and to distribute those programs without any restriction
> - coming from the use of this file. (The GNU Lesser General Public
> - License restrictions do apply in other respects; for example, they
> - cover modification of the file, and distribution when not linked
> - into another program.)
> -
> - Note that people who make modified versions of this file are not
> - obligated to grant this special exception for their modified
> - versions; it is their choice whether to do so. The GNU Lesser
> - General Public License gives permission to release a modified
> - version without this exception; this exception also makes it
> - possible to release a modified version which carries forward this
> - exception.
> -
> - 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <stddef.h>
> -#include <elf-initfini.h>
> -
> -
> -/* These magic symbols are provided by the linker. */
> -extern void (*__preinit_array_start []) (int, char **, char **)
> - attribute_hidden;
> -extern void (*__preinit_array_end []) (int, char **, char **)
> - attribute_hidden;
> -extern void (*__init_array_start []) (int, char **, char **)
> - attribute_hidden;
> -extern void (*__init_array_end []) (int, char **, char **)
> - attribute_hidden;
> -extern void (*__fini_array_start []) (void) attribute_hidden;
> -extern void (*__fini_array_end []) (void) attribute_hidden;
> -
> -
> -#if ELF_INITFINI
> -/* These function symbols are provided for the .init/.fini section entry
> - points automagically by the linker. */
> -extern void _init (void);
> -extern void _fini (void);
> -#endif
> -
> -
> -/* These functions are passed to __libc_start_main by the startup code.
> - These get statically linked into each program. For dynamically linked
> - programs, this module will come from libc_nonshared.a and differs from
> - the libc.a module in that it doesn't call the preinit array. */
> -
> -
> -void
> -__libc_csu_init (int argc, char **argv, char **envp)
> -{
> - /* For dynamically linked executables the preinit array is executed by
> - the dynamic linker (before initializing any shared object). */
> -
> -#ifndef LIBC_NONSHARED
> - /* For static executables, preinit happens right before init. */
> - {
> - const size_t size = __preinit_array_end - __preinit_array_start;
> - size_t i;
> - for (i = 0; i < size; i++)
> - (*__preinit_array_start [i]) (argc, argv, envp);
> - }
> -#endif
> -
> -#if ELF_INITFINI
> - _init ();
> -#endif
> -
> - const size_t size = __init_array_end - __init_array_start;
> - for (size_t i = 0; i < size; i++)
> - (*__init_array_start [i]) (argc, argv, envp);
> -}
> -
> -/* This function should not be used anymore. We run the executable's
> - destructor now just like any other. We cannot remove the function,
> - though. */
> -void
> -__libc_csu_fini (void)
> -{
> -#ifndef LIBC_NONSHARED
> - size_t i = __fini_array_end - __fini_array_start;
> - while (i-- > 0)
> - (*__fini_array_start [i]) ();
> -
> -# if ELF_INITFINI
> - _fini ();
> -# endif
> -#endif
> -}
> diff --git a/csu/libc-start.c b/csu/libc-start.c
> index feb0d7ce11..05ff7afddf 100644
> --- a/csu/libc-start.c
> +++ b/csu/libc-start.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1998-2021 Free Software Foundation, Inc.
> +/* Perform initialization and invoke main.
> + Copyright (C) 1998-2021 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
> @@ -15,10 +16,15 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> +/* Note: This code is only part of the startup code proper for
> + statically linked binaries. For dynamically linked binaries, it
> + resides in libc.so. */
> +
> /* Mark symbols hidden in static PIE for early self relocation to work. */
> #if BUILD_PIE_DEFAULT
> # pragma GCC visibility push(hidden)
> #endif
> +
> #include <assert.h>
> #include <stdlib.h>
> #include <stdio.h>
> @@ -29,6 +35,8 @@
> #include <libc-internal.h>
> #include <elf/libc-early-init.h>
> #include <stdbool.h>
> +#include <elf-initfini.h>
> +#include <shlib-compat.h>
>
> #include <elf/dl-tunables.h>
>
> @@ -95,9 +103,11 @@ apply_irel (void)
> # else
> # define STATIC static inline __attribute__ ((always_inline))
> # endif
> +# define DO_DEFINE_LIBC_START_MAIN_VERSION 0
> #else
> # define STATIC
> -# define LIBC_START_MAIN __libc_start_main
> +# define LIBC_START_MAIN __libc_start_main_impl
> +# define DO_DEFINE_LIBC_START_MAIN_VERSION 1
> #endif
>
> #ifdef MAIN_AUXVEC_ARG
> @@ -113,6 +123,92 @@ apply_irel (void)
> # define ARCH_INIT_CPU_FEATURES()
> #endif
>
> +#ifdef SHARED
> +/* Initialization for dynamic executables. Find the main executable
> + link map and run its init functions. */
> +static void
> +call_init (int argc, char **argv, char **env)
> +{
> + /* Obtain the main map of the executable. */
> + struct link_map *l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
> +
> + /* DT_PREINIT_ARRAY is not processed here. It is already handled in
> + _dl_init in elf/dl-init.c. Also see the call_init function in
> + the same file. */
> +
> + if (ELF_INITFINI && l->l_info[DT_INIT] != NULL)
> + DL_CALL_DT_INIT(l, l->l_addr + l->l_info[DT_INIT]->d_un.d_ptr,
> + argc, argv, env);
> +
> + ElfW(Dyn) *init_array = l->l_info[DT_INIT_ARRAY];
> + if (init_array != NULL)
> + {
> + unsigned int jm
> + = l->l_info[DT_INIT_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr));
> + ElfW(Addr) *addrs = (void *) (init_array->d_un.d_ptr + l->l_addr);
> + for (unsigned int j = 0; j < jm; ++j)
> + ((dl_init_t) addrs[j]) (argc, argv, env);
> + }
> +}
init function is now in libc.so, so we won't miss __libc_csu_init.
> +
> +#else /* !SHARED */
> +
> +/* These magic symbols are provided by the linker. */
> +extern void (*__preinit_array_start []) (int, char **, char **)
> + attribute_hidden;
> +extern void (*__preinit_array_end []) (int, char **, char **)
> + attribute_hidden;
> +extern void (*__init_array_start []) (int, char **, char **)
> + attribute_hidden;
> +extern void (*__init_array_end []) (int, char **, char **)
> + attribute_hidden;
> +extern void (*__fini_array_start []) (void) attribute_hidden;
> +extern void (*__fini_array_end []) (void) attribute_hidden;
> +
> +# if ELF_INITFINI
> +/* These function symbols are provided for the .init/.fini section entry
> + points automagically by the linker. */
> +extern void _init (void);
> +extern void _fini (void);
> +# endif
> +
> +/* Initialization for static executables. There is no dynamic
> + segment, so we access the symbols directly. */
> +static void
> +call_init (int argc, char **argv, char **envp)
> +{
> + /* For static executables, preinit happens right before init. */
> + {
> + const size_t size = __preinit_array_end - __preinit_array_start;
> + size_t i;
> + for (i = 0; i < size; i++)
> + (*__preinit_array_start [i]) (argc, argv, envp);
> + }
> +
> +# if ELF_INITFINI
> + _init ();
> +# endif
> +
> + const size_t size = __init_array_end - __init_array_start;
> + for (size_t i = 0; i < size; i++)
> + (*__init_array_start [i]) (argc, argv, envp);
> +}
The static bits. OK.
> +
> +/* Likewise for the destructor. */
> +static void
> +call_fini (void *unused)
> +{
> + size_t i = __fini_array_end - __fini_array_start;
> + while (i-- > 0)
> + (*__fini_array_start [i]) ();
> +
> +# if ELF_INITFINI
> + _fini ();
> +# endif
> +}
> +
> +#endif /* !SHARED */
> +
> #include <libc-start.h>
>
> STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
> @@ -129,9 +225,16 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
> __attribute__ ((noreturn));
>
>
> -/* Note: the fini parameter is ignored here for shared library. It
> - is registered with __cxa_atexit. This had the disadvantage that
> - finalizers were called in more than one place. */
> +/* Note: The init and fini parameters are no longer used. fini is
> + completely unused, init is still called if not NULL, but the
> + current startup code always passes NULL. (In the future, it would
> + be possible to use fini to pass a version code if init is NULL, to
> + indicate the link-time glibc without introducing a hard
> + incompatibility for new programs with older glibc versions.)
> +
> + For dynamically linked executables, the dynamic segment is used to
> + locate constructors and destructors. For statically linked
> + executables, the relevant symbols are access directly. */
> STATIC int
> LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
> int argc, char **argv,
> @@ -258,9 +361,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
> run the constructors in `_dl_start_user'. */
> __libc_init_first (argc, argv, __environ);
>
> - /* Register the destructor of the program, if any. */
> - if (fini)
> - __cxa_atexit ((void (*) (void *)) fini, NULL, NULL);
> + /* Register the destructor of the statically-linked program. */
> + __cxa_atexit (call_fini, NULL, NULL);
call_fini for static bins.
>
> /* Some security at this point. Prevent starting a SUID binary where
> the standard file descriptors are not opened. We have to do this
> @@ -268,15 +370,24 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
> loader did the work already. */
> if (__builtin_expect (__libc_enable_secure, 0))
> __libc_check_standard_fds ();
> -#endif
> +#endif /* !SHARED */
>
> /* Call the initializer of the program, if any. */
> #ifdef SHARED
> if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
> GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
> -#endif
> - if (init)
> +
> + if (init != NULL)
> + /* This is a legacy program which supplied its own init
> + routine. */
> (*init) (argc, argv, __environ MAIN_AUXVEC_PARAM);
> + else
> + /* This is a current program. Use the dynamic segment to find
> + constructors. */
> + call_init (argc, argv, __environ);
> +#else /* !SHARED */
> + call_init (argc, argv, __environ);
> +#endif /* SHARED */
Call the passed init if it exists (for backward compatibility), or
call_init.
>
> #ifdef SHARED
> /* Auditing checkpoint: we have a new object. */
> @@ -365,3 +476,36 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
>
> exit (result);
> }
> +
> +/* Starting with glibc 2.34, the init parameter is always NULL. Older
> + libcs are not prepared to handle that. The macro
> + DEFINE_LIBC_START_MAIN_VERSION creates GLIBC_2.34 alias, so that
> + newly linked binaries reflect that dependency. The macros below
> + expect that the exported function is called
> + __libc_start_main_impl. */
> +#ifdef SHARED
> +# define DEFINE_LIBC_START_MAIN_VERSION \
> + DEFINE_LIBC_START_MAIN_VERSION_1 \
> + strong_alias (__libc_start_main_impl, __libc_start_main_alias_2) \
> + versioned_symbol (libc, __libc_start_main_alias_2, __libc_start_main, \
> + GLIBC_2_34);
> +
> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_34)
> +# define DEFINE_LIBC_START_MAIN_VERSION_1 \
> + strong_alias (__libc_start_main_impl, __libc_start_main_alias_1) \
> + compat_symbol (libc, __libc_start_main_alias_1, __libc_start_main, GLIBC_2_0);
> +# else
> +# define DEFINE_LIBC_START_MAIN_VERSION_1
> +# endif
> +#else /* !SHARED */
> +/* Enable calling the function under its exported name. */
> +# define DEFINE_LIBC_START_MAIN_VERSION \
> + strong_alias (__libc_start_main_impl, __libc_start_main)
> +#endif
> +
> +/* Only define the version information if LIBC_START_MAIN was not set.
> + If there is a wrapper file, it must expand
> + DEFINE_LIBC_START_MAIN_VERSION on its own. */
> +#if DO_DEFINE_LIBC_START_MAIN_VERSION
> +DEFINE_LIBC_START_MAIN_VERSION
> +#endif
symver bump.
> diff --git a/elf/dl-init.c b/elf/dl-init.c
> index b7e4b8a3af..f924d26642 100644
> --- a/elf/dl-init.c
> +++ b/elf/dl-init.c
> @@ -22,10 +22,6 @@
> #include <elf-initfini.h>
>
>
> -/* Type of the initializer. */
> -typedef void (*init_t) (int, char **, char **);
> -
> -
Move to ldsodefs so that libc-start can use it.
> static void
> call_init (struct link_map *l, int argc, char **argv, char **env)
> {
> @@ -71,7 +67,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
>
> addrs = (ElfW(Addr) *) (init_array->d_un.d_ptr + l->l_addr);
> for (j = 0; j < jm; ++j)
> - ((init_t) addrs[j]) (argc, argv, env);
> + ((dl_init_t) addrs[j]) (argc, argv, env);
> }
> }
>
> @@ -103,7 +99,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
>
> addrs = (ElfW(Addr) *) (preinit_array->d_un.d_ptr + main_map->l_addr);
> for (cnt = 0; cnt < i; ++cnt)
> - ((init_t) addrs[cnt]) (argc, argv, env);
> + ((dl_init_t) addrs[cnt]) (argc, argv, env);
> }
>
> /* Stupid users forced the ELF specification to be changed. It now
[unrelated] That reminds me; somebody needs to push an obvious commit to
change that rant comment.
... and we update all callers to pass init and fini as NULL so that
newer binaries don't need elf-init.oS anymore. OK.
> diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
> index 3761cbd7ee..417da8802b 100644
> --- a/sysdeps/aarch64/start.S
> +++ b/sysdeps/aarch64/start.S
> @@ -63,26 +63,16 @@ ENTRY(_start)
> # ifdef SHARED
> adrp x0, :got:main
> ldr PTR_REG (0), [x0, #:got_lo12:main]
> -
> - adrp x3, :got:__libc_csu_init
> - ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
> -
> - adrp x4, :got:__libc_csu_fini
> - ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
> # else
> adrp x0, __wrap_main
> add x0, x0, :lo12:__wrap_main
> - adrp x3, __libc_csu_init
> - add x3, x3, :lo12:__libc_csu_init
> - adrp x4, __libc_csu_fini
> - add x4, x4, :lo12:__libc_csu_fini
> # endif
> #else
> /* Set up the other arguments in registers */
> MOVL (0, main)
> - MOVL (3, __libc_csu_init)
> - MOVL (4, __libc_csu_fini)
> #endif
> + mov x3, #0 /* Used to be init. */
> + mov x4, #0 /* Used to be fini. */
>
> /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
> stack_end) */
> diff --git a/sysdeps/alpha/start.S b/sysdeps/alpha/start.S
> index f3eb2029e1..65dcd4d392 100644
> --- a/sysdeps/alpha/start.S
> +++ b/sysdeps/alpha/start.S
> @@ -55,9 +55,8 @@ _start:
> ldl a1, 16(sp) /* get argc */
> lda a2, 24(sp) /* get argv */
>
> - /* Load address of our own entry points to .fini and .init. */
> - lda a3, __libc_csu_init
> - lda a4, __libc_csu_fini
> + mov $r31, a3 /* Used to be init. */
> + mov $r31, a4 /* Used to be fini. */
>
> /* Store address of the shared library termination function. */
> mov v0, a5
> diff --git a/sysdeps/arc/start.S b/sysdeps/arc/start.S
> index dbec87e6bb..5302a57cab 100644
> --- a/sysdeps/arc/start.S
> +++ b/sysdeps/arc/start.S
> @@ -49,15 +49,14 @@ ENTRY (ENTRY_POINT)
>
> /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end). */
>
> + mov_s r3, 0 /* Used to be init. */
> + mov r4, 0 /* Used to be fini. */
> +
> #ifdef SHARED
> ld r0, [pcl, @main@gotpc]
> - ld r3, [pcl, @__libc_csu_init@gotpc]
> - ld r4, [pcl, @__libc_csu_fini@gotpc]
> bl __libc_start_main@plt
> #else
> mov_s r0, main
> - mov_s r3, __libc_csu_init
> - mov r4, __libc_csu_fini
> bl __libc_start_main
> #endif
>
> diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S
> index 30f69e1b07..9b56bc0cca 100644
> --- a/sysdeps/arm/start.S
> +++ b/sysdeps/arm/start.S
> @@ -94,30 +94,20 @@ _start:
> adr a4, .L_GOT
> add sl, sl, a4
>
> - ldr ip, .L_GOT+4 /* __libc_csu_fini */
> - ldr ip, [sl, ip]
> + mov a4, #0 /* Used to be init. */
> + push { a4 } /* Used to be fini. */
>
> - push { ip } /* Push __libc_csu_fini */
> -
> - ldr a4, .L_GOT+8 /* __libc_csu_init */
> - ldr a4, [sl, a4]
> -
> - ldr a1, .L_GOT+12 /* main */
> + ldr a1, .L_GOT+4 /* main */
> ldr a1, [sl, a1]
>
> /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
> /* Let the libc call main and exit with its return code. */
> bl __libc_start_main(PLT)
> #else
> - /* Fetch address of __libc_csu_fini */
> - ldr ip, =__libc_csu_fini
>
> - /* Push __libc_csu_fini */
> - push { ip }
> -
> - /* Set up the other arguments in registers */
> + mov a4, #0 /* Used to init. */
> + push { a4 } /* Used to fini. */
> ldr a1, =main
> - ldr a4, =__libc_csu_init
>
> /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
> /* Let the libc call main and exit with its return code. */
> @@ -131,8 +121,6 @@ _start:
> .align 2
> .L_GOT:
> .word _GLOBAL_OFFSET_TABLE_ - .L_GOT
> - .word __libc_csu_fini(GOT)
> - .word __libc_csu_init(GOT)
> .word main(GOT)
> #endif
>
> diff --git a/sysdeps/csky/abiv2/start.S b/sysdeps/csky/abiv2/start.S
> index d65e37e61b..a565cfa87b 100644
> --- a/sysdeps/csky/abiv2/start.S
> +++ b/sysdeps/csky/abiv2/start.S
> @@ -66,13 +66,9 @@ _start:
> .Lgetpc:
> lrw gb, .Lgetpc@GOTPC
> addu gb, t0
> - lrw a3, __libc_csu_fini@GOT
> - ldr.w a3, (gb, a3 << 0)
> - stw a3, (sp, 0)
>
> - lrw a3, __libc_csu_init@GOT
> - addu a3, gb
> - ldw a3, (a3, 0)
> + movi a3, 0 /* Used to be init. */
> + stw a3, (sp, 0) /* Used to be fini. */
>
> lrw t0, main@GOT
> addu t0, gb
> @@ -85,14 +81,9 @@ _start:
> ldr.w t1, (gb, t1 << 0)
> jsr t1
> #else
> - /* Fetch address of __libc_csu_fini. */
> - lrw a0, __libc_csu_fini
> - /* Push __libc_csu_fini */
> - stw a0, (sp, 0)
> -
> - /* Set up the other arguments in registers. */
> + movi a3, 0 /* Used to be init. */
> + stw a3, (sp, 0) /* Used to be fini. */
> lrw a0, main
> - lrw a3, __libc_csu_init
> /* Let the libc call main and exit with its return code. */
> jsri __libc_start_main
>
> diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
> index 9720a4e446..ea3f7a69d0 100644
> --- a/sysdeps/generic/ldsodefs.h
> +++ b/sysdeps/generic/ldsodefs.h
> @@ -93,6 +93,10 @@ typedef struct link_map *lookup_t;
> : (__glibc_unlikely ((ref)->st_shndx == SHN_ABS) ? 0 \
> : LOOKUP_VALUE_ADDRESS (map, map_set)) + (ref)->st_value)
>
> +/* Type of a constructor function, in DT_INIT, DT_INIT_ARRAY,
> + DT_PREINIT_ARRAY. */
> +typedef void (*dl_init_t) (int, char **, char **);
> +
> /* On some architectures a pointer to a function is not just a pointer
> to the actual code of the function but rather an architecture
> specific descriptor. */
> @@ -101,7 +105,7 @@ typedef struct link_map *lookup_t;
> (void *) SYMBOL_ADDRESS (map, ref, false)
> # define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
> # define DL_CALL_DT_INIT(map, start, argc, argv, env) \
> - ((init_t) (start)) (argc, argv, env)
> + ((dl_init_t) (start)) (argc, argv, env)
> # define DL_CALL_DT_FINI(map, start) ((fini_t) (start)) ()
> #endif
>
> diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
> index 29d994bfc2..a9a927f26c 100644
> --- a/sysdeps/hppa/dl-lookupcfg.h
> +++ b/sysdeps/hppa/dl-lookupcfg.h
> @@ -56,7 +56,7 @@ void attribute_hidden _dl_unmap (struct link_map *map);
> { \
> ElfW(Addr) addr; \
> DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
> - init_t init = (init_t) addr; \
> + dl_init_t init = (dl_init_t) addr; \
> init (argc, argv, env); \
> }
>
> diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S
> index 2fe73c9aae..4a1877f8e8 100644
> --- a/sysdeps/hppa/start.S
> +++ b/sysdeps/hppa/start.S
> @@ -36,8 +36,6 @@
> .import main, code
> .import $global$, data
> .import __libc_start_main, code
> - .import __libc_csu_fini, code
> - .import __libc_csu_init, code
>
> /* Have the linker create plabel words so we get PLABEL32
> relocs and not 21/14. The use of 21/14 relocs is only
> @@ -52,10 +50,6 @@
> .word P%main
> .Lp__libc_start_main:
> .word P%__libc_start_main
> -.Lp__libc_csu_fini:
> - .word P%__libc_csu_fini
> -.Lp__libc_csu_init:
> - .word P%__libc_csu_init
>
> .text
> .align 4
> @@ -77,8 +71,8 @@ _start:
> 1. r26 - Application main
> 2. r25 - argc
> 3. r24 - argv
> - 4. r23 - __libc_csu_init
> - 5. sp-52 - __libc_csu_fini
> + 4. r23 - init (unused)
> + 5. sp-52 - fini (unused)
> 6. sp-56 - rtld_fini
> 7. sp-60 - stackend */
>
> @@ -108,14 +102,6 @@ _start:
> addil LT'.Lpmain, %r19
> ldw RT'.Lpmain(%r1), %r26
> ldw 0(%r26),%r26
> - /* void (*init) (void) (4th argument) */
> - addil LT'.Lp__libc_csu_init, %r19
> - ldw RT'.Lp__libc_csu_init(%r1), %r23
> - ldw 0(%r23), %r23
> - /* void (*fini) (void) (5th argument) */
> - addil LT'.Lp__libc_csu_fini, %r19
> - ldw RT'.Lp__libc_csu_fini(%r1), %r22
> - ldw 0(%r22), %r22
> #else
> /* Load $global$ address into %dp */
> ldil L%$global$, %dp
> @@ -124,13 +110,9 @@ _start:
> /* load main (1st argument) */
> ldil LR'.Lpmain, %r26
> ldw RR'.Lpmain(%r26), %r26
> - /* void (*init) (void) (4th argument) */
> - ldil LR'.Lp__libc_csu_init, %r23
> - ldw RR'.Lp__libc_csu_init(%r23), %r23
> - /* void (*fini) (void) (5th argument) */
> - ldil LR'.Lp__libc_csu_fini, %r22
> - ldw RR'.Lp__libc_csu_fini(%r22), %r22
> #endif
> + ldi 0,%r23 /* Used to be init. */
> + ldi 0,%r22 /* Used to be fini. */
> /* Store 5th argument */
> stw %r22, -52(%sp)
> /* void *stack_end (7th argument) */
> diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S
> index 24c806cfec..5296b27e65 100644
> --- a/sysdeps/i386/start.S
> +++ b/sysdeps/i386/start.S
> @@ -87,11 +87,9 @@ ENTRY (_start)
> call 1f
> addl $_GLOBAL_OFFSET_TABLE_, %ebx
>
> - /* Push address of our own entry points to .fini and .init. */
> - leal __libc_csu_fini@GOTOFF(%ebx), %eax
> - pushl %eax
> - leal __libc_csu_init@GOTOFF(%ebx), %eax
> - pushl %eax
> + /* This used to be the addresses of .fini and .init. */
> + pushl $0
> + pushl $0
>
> pushl %ecx /* Push second argument: argv. */
> pushl %esi /* Push first argument: argc. */
> @@ -112,9 +110,9 @@ ENTRY (_start)
> But let the libc call main. */
> call __libc_start_main@PLT
> #else
> - /* Push address of our own entry points to .fini and .init. */
> - pushl $__libc_csu_fini
> - pushl $__libc_csu_init
> + /* This used to be the addresses of .fini and .init. */
> + pushl $0
> + pushl $0
>
> pushl %ecx /* Push second argument: argv. */
> pushl %esi /* Push first argument: argc. */
> diff --git a/sysdeps/ia64/dl-lookupcfg.h b/sysdeps/ia64/dl-lookupcfg.h
> index 209d926bad..58ca32424b 100644
> --- a/sysdeps/ia64/dl-lookupcfg.h
> +++ b/sysdeps/ia64/dl-lookupcfg.h
> @@ -50,7 +50,7 @@ extern void attribute_hidden _dl_unmap (struct link_map *map);
> { \
> ElfW(Addr) addr; \
> DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
> - init_t init = (init_t) addr; \
> + dl_init_t init = (dl_init_t) addr; \
> init (argc, argv, env); \
> }
>
> diff --git a/sysdeps/ia64/start.S b/sysdeps/ia64/start.S
> index 0018acc821..b28f8cb429 100644
> --- a/sysdeps/ia64/start.S
> +++ b/sysdeps/ia64/start.S
> @@ -82,20 +82,15 @@ _start:
> {
> addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
> addl out0 = @ltoff(@fptr(main)), gp
> - addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
> + mov out3 = r0 /* Used to be init. */
> ;;
> }
> { .mmi
> ld8 r3 = [r11] /* pointer to __libc_ia64_register_backing_store_base */
> ld8 out0 = [out0] /* pointer to `main' function descriptor */
> - addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
> + mov out4 = r0 /* Used to be fini. */
> ;;
> }
> - { .mmi
> - ld8 out3 = [out3] /* pointer to `init' function descriptor */
> - ld8 out4 = [out4] /* pointer to `fini' function descriptor */
> - nop 0
> - }
> .body
> { .mib
> st8 [r3] = r10
> diff --git a/sysdeps/m68k/start.S b/sysdeps/m68k/start.S
> index c36b34f8d9..98da4db9f3 100644
> --- a/sysdeps/m68k/start.S
> +++ b/sysdeps/m68k/start.S
> @@ -76,15 +76,14 @@ _start:
> pea (%a1) /* Push address of the shared library
> termination function. */
>
> + /* These used to be addresses of the .fini and .init entry points. */
> + clr.l -(%sp)
> + clr.l -(%sp)
> +
> #ifdef PIC
> /* Load PIC register. */
> LOAD_GOT (%a5)
>
> - /* Push the address of our own entry points to `.fini' and
> - `.init'. */
> - move.l __libc_csu_fini@GOT(%a5), -(%sp)
> - move.l __libc_csu_init@GOT(%a5), -(%sp)
> -
> pea (%a0) /* Push second argument: argv. */
> move.l %d0, -(%sp) /* Push first argument: argc. */
>
> @@ -94,10 +93,6 @@ _start:
> let the libc call main. */
> jbsr __libc_start_main@PLTPC
> #else
> - /* Push the address of our own entry points to `.fini' and
> - `.init'. */
> - pea __libc_csu_fini
> - pea __libc_csu_init
>
> pea (%a0) /* Push second argument: argv. */
> move.l %d0, -(%sp) /* Push first argument: argc. */
> diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
> index 509e9b7cb0..e10a286d2e 100644
> --- a/sysdeps/mach/hurd/i386/libc.abilist
> +++ b/sysdeps/mach/hurd/i386/libc.abilist
> @@ -2203,6 +2203,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S
> index dcb202a63b..6589bd4dc7 100644
> --- a/sysdeps/microblaze/start.S
> +++ b/sysdeps/microblaze/start.S
> @@ -63,14 +63,14 @@ _start:
> mfs r20,rpc
> addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
> lwi r5,r20,main@GOT
> - lwi r8,r20,__libc_csu_init@GOT
> - lwi r9,r20,__libc_csu_fini@GOT
> + addk r8,r0,r0 /* Used to be init. */
> + addk r9,r0,r0 /* Used to be fini. */
> brid __libc_start_main@PLT
> addk r10,r0,r0
> #else
> addik r5,r0,main
> - addik r8,r0,__libc_csu_init
> - addik r9,r0,__libc_csu_fini
> + addk r8,r0,r0 /* Used to be init. */
> + addk r9,r0,r0 /* Used to be fini. */
> brid __libc_start_main
> addk r10,r0,r0
> #endif
> diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S
> index 28e2ed17ad..4ec42a2a7f 100644
> --- a/sysdeps/mips/start.S
> +++ b/sysdeps/mips/start.S
> @@ -96,13 +96,13 @@ ENTRY_POINT:
> # if _MIPS_SIM == _ABIO32
> PTR_SUBIU $29, 32
> # endif
> - PTR_LA $7, __libc_csu_init /* init */
> - PTR_LA $8, __libc_csu_fini
> + move $7, $0 /* Used to be init. */
> # if _MIPS_SIM == _ABIO32
> - PTR_S $8, 16($29) /* fini */
> + PTR_S $0, 16($29) /* Used to be fini. */
> PTR_S $2, 20($29) /* rtld_fini */
> PTR_S $29, 24($29) /* stack_end */
> # else
> + move $8, $0 /* Used to be fini. */
> move $9, $2 /* rtld_fini */
> move $10, $29 /* stack_end */
> # endif
> @@ -143,19 +143,17 @@ ENTRY_POINT:
> /* Lay out last arguments, and call __libc_start_main(). */
> # ifdef __PIC__
> sw $7, 24($sp) /* stack_end */
> - lw $4, %got(__libc_csu_fini)($3)
> - lw $7, %got(__libc_csu_init)($3) /* init */
> - sw $4, 16($sp) /* fini */
> + move $4, $0 /* Used to be ini. */
> + sw $0, 16($sp) /* Used to be fini. */
> lw $4, %got(main)($3) /* main */
> lw $3, %call16(__libc_start_main)($3)
> sw $2, 20($sp) /* rtld_fini */
> move $25, $3
> jalr $3
> # else
> - lw $4, 1f
> sw $7, 24($sp) /* stack_end */
> - lw $7, 2f /* init */
> - sw $4, 16($sp) /* fini */
> + move $7, $0 /* Used to be init. */
> + sw $0, 16($sp) /* Used to be fini. */
> lw $4, 3f /* main */
> sw $2, 20($sp) /* rtld_fini */
> /* Load and call __libc_start_main(). */
> @@ -165,8 +163,6 @@ ENTRY_POINT:
> hlt: b hlt /* Crash if somehow it does return. */
> # ifndef __PIC__
> .align 2
> -1: .word __libc_csu_fini
> -2: .word __libc_csu_init
> 3: .word main
> 4: .word __libc_start_main
> # endif
> diff --git a/sysdeps/nios2/start.S b/sysdeps/nios2/start.S
> index 0a6c587de3..7c9696977f 100644
> --- a/sysdeps/nios2/start.S
> +++ b/sysdeps/nios2/start.S
> @@ -92,18 +92,11 @@ _start:
> addi r2, r2, %lo(_gp_got - 1b)
> add r22, r22, r2
>
> - /* Push fini */
> - movhi r8, %call_hiadj(__libc_csu_fini)
> - addi r8, r8, %call_lo(__libc_csu_fini)
> - add r8, r8, r22
> - ldw r8, 0(r8)
> - stw r8, 0(sp)
> + /* Used to be fini. */
> + stw zero, 0(sp)
>
> - /* r7 == init */
> - movhi r7, %call_hiadj(__libc_csu_init)
> - addi r7, r7, %call_lo(__libc_csu_init)
> - add r7, r7, r22
> - ldw r7, 0(r7)
> + /* Used to be init. */
> + mov r7, zero
>
> /* r6 == argv */
> addi r6, sp, 16
> diff --git a/sysdeps/powerpc/powerpc32/start.S b/sysdeps/powerpc/powerpc32/start.S
> index a721a18775..39ce1a18ff 100644
> --- a/sysdeps/powerpc/powerpc32/start.S
> +++ b/sysdeps/powerpc/powerpc32/start.S
> @@ -52,8 +52,8 @@
> L(start_addresses):
> .long _SDA_BASE_
> .long main
> - .long __libc_csu_init
> - .long __libc_csu_fini
> + .long 0 /* Used to be init. */
> + .long 0 /* Used to be fini. */
> ASM_SIZE_DIRECTIVE(L(start_addresses))
>
> .section ".text"
> diff --git a/sysdeps/powerpc/powerpc64/start.S b/sysdeps/powerpc/powerpc64/start.S
> index 612c846632..71c0c67926 100644
> --- a/sysdeps/powerpc/powerpc64/start.S
> +++ b/sysdeps/powerpc/powerpc64/start.S
> @@ -53,8 +53,8 @@ L(start_addresses):
> .quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
> /* function descriptors so don't need JUMPTARGET */
> .quad main
> - .quad __libc_csu_init
> - .quad __libc_csu_fini
> + .quad 0 /* Used to be init. */
> + .quad 0 /* Used to be fini. */
>
> ASM_SIZE_DIRECTIVE(L(start_addresses))
>
> diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S
> index 9c94035015..806f6aacd6 100644
> --- a/sysdeps/riscv/start.S
> +++ b/sysdeps/riscv/start.S
> @@ -54,8 +54,8 @@ ENTRY (ENTRY_POINT)
> REG_L a1, 0(sp) /* argc. */
> addi a2, sp, SZREG /* argv. */
> andi sp, sp, ALMASK /* Align stack. */
> - lla a3, __libc_csu_init
> - lla a4, __libc_csu_fini
> + li a3, 0 /* Used to be init. */
> + li a4, 0 /* Used to be fini. */
> mv a6, sp /* stack_end. */
>
> call __libc_start_main@plt
> diff --git a/sysdeps/s390/s390-32/start.S b/sysdeps/s390/s390-32/start.S
> index aba90739c1..b6cfa4caf3 100644
> --- a/sysdeps/s390/s390-32/start.S
> +++ b/sysdeps/s390/s390-32/start.S
> @@ -175,18 +175,16 @@ _start:
> */
> stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
> la %r7,96(%r15)
> - l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini
> - l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init
> l %r2,.L3-.Llit(%r13) # load pointer to main
> l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main
> #ifdef PIC
> l %r12,.L5-.Llit(%r13) # load .got pointer
> - la %r6,0(%r13,%r6)
> - la %r5,0(%r13,%r5)
> la %r12,0(%r13,%r12)
> l %r2,0(%r12,%r2)
> la %r1,0(%r13,%r1)
> #endif
> + lhi %r6, 0 # Used to fini.
> + lhi %r5, 0 # Used to init.
>
> /* ok, now branch to the libc main routine */
> basr %r14,%r1
> @@ -197,13 +195,9 @@ _start:
> cfi_endproc
> .Llit:
> #ifndef PIC
> -.L1: .long __libc_csu_init
> -.L2: .long __libc_csu_fini
> .L3: .long main
> .L4: .long __libc_start_main
> #else
> -.L1: .long __libc_csu_init-.Llit
> -.L2: .long __libc_csu_fini-.Llit
> .L3: .long main@GOT
> .L4: .long __libc_start_main@plt-.Llit
> .L5: .long _GLOBAL_OFFSET_TABLE_-.Llit
> diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S
> index 0d9d30916d..4e6526308a 100644
> --- a/sysdeps/s390/s390-64/start.S
> +++ b/sysdeps/s390/s390-64/start.S
> @@ -80,8 +80,8 @@ _start:
> */
> stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
> la %r7,160(%r15)
> - larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
> - larl %r5,__libc_csu_init # load pointer to __libc_csu_init
> + lghi %r6,0 # Used to be fini.
> + lghi %r5,0 # Used to be init.
>
> /* Ok, now branch to the libc main routine. */
> #ifdef PIC
> diff --git a/sysdeps/sh/start.S b/sysdeps/sh/start.S
> index ab29f194f7..606ee59222 100644
> --- a/sysdeps/sh/start.S
> +++ b/sysdeps/sh/start.S
> @@ -70,12 +70,11 @@ _start:
>
> /* Push the last arguments to main() onto the stack */
> mov.l r4,@-r15
> - mov.l L_fini,r0
> - mov.l r0,@-r15
> + mov.l r14,@-r15 /* Used to be fini. */
>
> /* Set up the other arguments for main() that go in registers */
> mov.l L_main,r4
> - mov.l L_init,r7
> + mov #0,r7 /* Used to be init. */
>
> /* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
>
> @@ -90,10 +89,6 @@ _start:
> .align 2
> L_main:
> .long main
> -L_init:
> - .long __libc_csu_init
> -L_fini:
> - .long __libc_csu_fini
> L_libc_start_main:
> .long __libc_start_main
> L_abort:
> diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S
> index 45ca77da3e..00bf898fb9 100644
> --- a/sysdeps/sparc/sparc32/start.S
> +++ b/sysdeps/sparc/sparc32/start.S
> @@ -59,22 +59,14 @@ _start:
> /* Load the addresses of the user entry points. */
> #ifndef PIC
> sethi %hi(main), %o0
> - sethi %hi(__libc_csu_init), %o3
> - sethi %hi(__libc_csu_fini), %o4
> or %o0, %lo(main), %o0
> - or %o3, %lo(__libc_csu_init), %o3
> - or %o4, %lo(__libc_csu_fini), %o4
> #else
> sethi %gdop_hix22(main), %o0
> - sethi %gdop_hix22(__libc_csu_init), %o3
> - sethi %gdop_hix22(__libc_csu_fini), %o4
> xor %o0, %gdop_lox10(main), %o0
> - xor %o3, %gdop_lox10(__libc_csu_init), %o3
> - xor %o4, %gdop_lox10(__libc_csu_fini), %o4
> ld [%l7 + %o0], %o0, %gdop(main)
> - ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
> - ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
> #endif
> + mov 0, %o3 /* Used to be init. */
> + mov 0, %o4 /* Used to be fini. */
>
> /* When starting a binary via the dynamic linker, %g1 contains the
> address of the shared library termination function, which will be
> diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S
> index 210fbaff90..8520717eba 100644
> --- a/sysdeps/sparc/sparc64/start.S
> +++ b/sysdeps/sparc/sparc64/start.S
> @@ -60,22 +60,14 @@ _start:
> /* Load the addresses of the user entry points. */
> #ifndef PIC
> sethi %hi(main), %o0
> - sethi %hi(__libc_csu_init), %o3
> - sethi %hi(__libc_csu_fini), %o4
> or %o0, %lo(main), %o0
> - or %o3, %lo(__libc_csu_init), %o3
> - or %o4, %lo(__libc_csu_fini), %o4
> #else
> sethi %gdop_hix22(main), %o0
> - sethi %gdop_hix22(__libc_csu_init), %o3
> - sethi %gdop_hix22(__libc_csu_fini), %o4
> xor %o0, %gdop_lox10(main), %o0
> - xor %o3, %gdop_lox10(__libc_csu_init), %o3
> - xor %o4, %gdop_lox10(__libc_csu_fini), %o4
> ldx [%l7 + %o0], %o0, %gdop(main)
> - ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
> - ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
> #endif
> + mov 0, %o3 /* Used to be init. */
> + mov 0, %o4 /* Used to be fini. */
>
> /* When starting a binary via the dynamic linker, %g1 contains the
> address of the shared library termination function, which will be
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> index 4cc1c6a591..bac795262d 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> @@ -2171,3 +2171,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> index 26ad9845e4..897f70db22 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> @@ -2253,6 +2253,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
> index bb9dfd4daf..604d259ad6 100644
> --- a/sysdeps/unix/sysv/linux/arc/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
> @@ -1931,3 +1931,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> index 3b0a47e967..094236f713 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -155,6 +155,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _Exit F
> GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
> GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> index 9ab3924888..2bb4d31e81 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -152,6 +152,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _Exit F
> GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
> GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
> index 14a84dac8f..d4291fecfb 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2115,3 +2115,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index 5c8502f3d3..1fd2a862f6 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2074,6 +2074,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
> index ddc5837059..943331f01e 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2241,6 +2241,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> index e3b345b803..f530151bde 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> @@ -2106,6 +2106,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> index 25f2d1c08f..6e76b6dcaa 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -156,6 +156,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _Exit F
> GLIBC_2.4 _IO_2_1_stderr_ D 0x98
> GLIBC_2.4 _IO_2_1_stdin_ D 0x98
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index c4891479d3..7541b8289f 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2186,6 +2186,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> index 143b0163b4..6cf1936c42 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2166,3 +2166,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> index 13d374a031..98730ebcda 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2163,3 +2163,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> index b2295f1937..92fa6cbc73 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2157,6 +2157,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> index 4c786070d0..265a49e74e 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2155,6 +2155,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> index aa9c6a4dca..cfa5e1111b 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2163,6 +2163,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> index 5939588ad5..8c03ac52cd 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> @@ -2157,6 +2157,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> index 92556c4237..17f5609e06 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2204,3 +2204,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
> index 66f5effe8a..4d681dad06 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/libc-start.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
> @@ -41,12 +41,12 @@ struct startup_info
> };
>
> int
> -__libc_start_main (int argc, char **argv,
> - char **ev,
> - ElfW (auxv_t) * auxvec,
> - void (*rtld_fini) (void),
> - struct startup_info *stinfo,
> - char **stack_on_entry)
> +__libc_start_main_impl (int argc, char **argv,
> + char **ev,
> + ElfW (auxv_t) * auxvec,
> + void (*rtld_fini) (void),
> + struct startup_info *stinfo,
> + char **stack_on_entry)
> {
> /* the PPC SVR4 ABI says that the top thing on the stack will
> be a NULL pointer, so if not we assume that we're being called
> @@ -99,3 +99,4 @@ __libc_start_main (int argc, char **argv,
> stinfo->init, stinfo->fini, rtld_fini,
> stack_on_entry);
> }
> +DEFINE_LIBC_START_MAIN_VERSION
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> index 26c93dff05..76a16e2a6d 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2213,6 +2213,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> index f04b167788..697f072fd4 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2246,6 +2246,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> index c2ca00709e..2647bb51f1 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> @@ -2076,6 +2076,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> index 0ea50dc851..036b1c8345 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> @@ -2366,3 +2366,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> index 0263e284d4..ff3225e16f 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> @@ -1933,3 +1933,4 @@ GLIBC_2.33 wprintf F
> GLIBC_2.33 write F
> GLIBC_2.33 writev F
> GLIBC_2.33 wscanf F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> index 1626c5351f..fb5ad9909f 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> @@ -2133,3 +2133,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> index a66426eb4d..cead75acc5 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2211,6 +2211,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> index ab351873ae..31366dd7e6 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> @@ -2112,6 +2112,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> index 22ceaa3d87..a3a8be8910 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2081,6 +2081,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> index d36f228192..8f505c5045 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2078,6 +2078,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> index 59b4313280..53ef6304f1 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2202,6 +2202,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> index 266dcdfa08..eba0cb156d 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> @@ -2129,6 +2129,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> index 2744bba4af..17ce5dfd58 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> @@ -2088,6 +2088,7 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> index ce2f4fb72b..17a1c83903 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> @@ -2185,3 +2185,4 @@ GLIBC_2.33 mknod F
> GLIBC_2.33 mknodat F
> GLIBC_2.33 stat F
> GLIBC_2.33 stat64 F
> +GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S
> index 30fc9007c9..1b3e36826b 100644
> --- a/sysdeps/x86_64/start.S
> +++ b/sysdeps/x86_64/start.S
> @@ -96,17 +96,13 @@ ENTRY (_start)
> which grow downwards). */
> pushq %rsp
>
> + /* These used to be the addresses of .fini and .init. */
> + xorl %r8d, %r8d
> + xorl %ecx, %ecx
> +
> #ifdef PIC
> - /* Pass address of our own entry points to .fini and .init. */
> - mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
> - mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
> -
> mov main@GOTPCREL(%rip), %RDI_LP
> #else
> - /* Pass address of our own entry points to .fini and .init. */
> - mov $__libc_csu_fini, %R8_LP
> - mov $__libc_csu_init, %RCX_LP
> -
> mov $main, %RDI_LP
> #endif
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH] Reduce the statically linked startup code [BZ #23323]
@ 2021-02-18 13:12 Florian Weimer
2021-02-25 11:00 ` Siddhesh Poyarekar
2021-02-25 18:43 ` Mike Frysinger
0 siblings, 2 replies; 15+ messages in thread
From: Florian Weimer @ 2021-02-18 13:12 UTC (permalink / raw)
To: libc-alpha
It turns out the startup code in csu/elf-init.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, “return-to-csu: A
New Method to Bypass 64-bit Linux ASLR”). These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker. However, the dynamic
linker skipped the main program for some reason. For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.
For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.
A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues.
---
This version incorporates the x86_64 fix suggested by H.J.
I found a typos in the microblaze changes and fixed them. I added the
ARC and C-SKY ports.
I tweaked the MIPS start.S changes to be more clear, I hope.
It was necessary to change the __libc_start_main symbol management to
use more aliases, so that recent binutils linkers do not complain about
multiple symbol definitions.
Tested on aarch64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, powerpc64le-linux-gnu, x86_64-linux-gnu. Built
with build-many-glibcs.py.
csu/Makefile | 10 +-
csu/Versions | 3 +
csu/elf-init.c | 107 -------------
csu/libc-start.c | 166 +++++++++++++++++++--
elf/dl-init.c | 8 +-
sysdeps/aarch64/start.S | 14 +-
sysdeps/alpha/start.S | 5 +-
sysdeps/arc/start.S | 7 +-
sysdeps/arm/start.S | 22 +--
sysdeps/csky/abiv2/start.S | 17 +--
sysdeps/generic/ldsodefs.h | 6 +-
sysdeps/hppa/dl-lookupcfg.h | 2 +-
sysdeps/hppa/start.S | 26 +---
sysdeps/i386/start.S | 14 +-
sysdeps/ia64/dl-lookupcfg.h | 2 +-
sysdeps/ia64/start.S | 9 +-
sysdeps/m68k/start.S | 13 +-
sysdeps/mach/hurd/i386/libc.abilist | 1 +
sysdeps/microblaze/start.S | 8 +-
sysdeps/mips/start.S | 18 +--
sysdeps/nios2/start.S | 15 +-
sysdeps/powerpc/powerpc32/start.S | 4 +-
sysdeps/powerpc/powerpc64/start.S | 4 +-
sysdeps/riscv/start.S | 4 +-
sysdeps/s390/s390-32/start.S | 10 +-
sysdeps/s390/s390-64/start.S | 4 +-
sysdeps/sh/start.S | 9 +-
sysdeps/sparc/sparc32/start.S | 12 +-
sysdeps/sparc/sparc64/start.S | 12 +-
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 +
sysdeps/unix/sysv/linux/arc/libc.abilist | 1 +
sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 +
sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 +
sysdeps/unix/sysv/linux/csky/libc.abilist | 1 +
sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 +
sysdeps/unix/sysv/linux/i386/libc.abilist | 1 +
sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 +
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 1 +
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 1 +
sysdeps/unix/sysv/linux/microblaze/be/libc.abilist | 1 +
sysdeps/unix/sysv/linux/microblaze/le/libc.abilist | 1 +
.../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 1 +
.../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 1 +
.../unix/sysv/linux/mips/mips64/n32/libc.abilist | 1 +
.../unix/sysv/linux/mips/mips64/n64/libc.abilist | 1 +
sysdeps/unix/sysv/linux/nios2/libc.abilist | 1 +
sysdeps/unix/sysv/linux/powerpc/libc-start.c | 13 +-
.../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 1 +
.../linux/powerpc/powerpc32/nofpu/libc.abilist | 1 +
.../sysv/linux/powerpc/powerpc64/be/libc.abilist | 1 +
.../sysv/linux/powerpc/powerpc64/le/libc.abilist | 1 +
sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist | 1 +
sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 1 +
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 1 +
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 1 +
sysdeps/unix/sysv/linux/sh/be/libc.abilist | 1 +
sysdeps/unix/sysv/linux/sh/le/libc.abilist | 1 +
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 1 +
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 1 +
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 1 +
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 1 +
sysdeps/x86_64/start.S | 12 +-
63 files changed, 275 insertions(+), 314 deletions(-)
diff --git a/csu/Makefile b/csu/Makefile
index c9385df2e9..e587434be8 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -27,10 +27,9 @@ subdir := csu
include ../Makeconfig
routines = init-first libc-start $(libc-init) sysdep version check_fds \
- libc-tls elf-init dso_handle
+ libc-tls dso_handle
aux = errno
elide-routines.os = libc-tls
-static-only-routines = elf-init
csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
extra-objs = start.o \
$(start-installed-name) g$(start-installed-name) $(csu-dummies) \
@@ -59,13 +58,6 @@ CFLAGS-.os += $(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
ifneq ($(start-installed-name),$(static-start-installed-name))
diff --git a/csu/Versions b/csu/Versions
index 43010c3443..8e1b21948e 100644
--- a/csu/Versions
+++ b/csu/Versions
@@ -7,6 +7,9 @@ libc {
# New special glibc functions.
gnu_get_libc_release; gnu_get_libc_version;
}
+ GLIBC_2.34 {
+ __libc_start_main;
+ }
GLIBC_PRIVATE {
errno;
}
diff --git a/csu/elf-init.c b/csu/elf-init.c
deleted file mode 100644
index 6e96ab7fce..0000000000
--- a/csu/elf-init.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Startup support for ELF initializers/finalizers in the main executable.
- Copyright (C) 2002-2021 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
- 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.
-
- In addition to the permissions in the GNU Lesser General Public
- License, the Free Software Foundation gives you unlimited
- permission to link the compiled version of this file with other
- programs, and to distribute those programs without any restriction
- coming from the use of this file. (The GNU Lesser General Public
- License restrictions do apply in other respects; for example, they
- cover modification of the file, and distribution when not linked
- into another program.)
-
- Note that people who make modified versions of this file are not
- obligated to grant this special exception for their modified
- versions; it is their choice whether to do so. The GNU Lesser
- General Public License gives permission to release a modified
- version without this exception; this exception also makes it
- possible to release a modified version which carries forward this
- exception.
-
- 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
- <https://www.gnu.org/licenses/>. */
-
-#include <stddef.h>
-#include <elf-initfini.h>
-
-
-/* These magic symbols are provided by the linker. */
-extern void (*__preinit_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__preinit_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_start []) (int, char **, char **)
- attribute_hidden;
-extern void (*__init_array_end []) (int, char **, char **)
- attribute_hidden;
-extern void (*__fini_array_start []) (void) attribute_hidden;
-extern void (*__fini_array_end []) (void) attribute_hidden;
-
-
-#if ELF_INITFINI
-/* These function symbols are provided for the .init/.fini section entry
- points automagically by the linker. */
-extern void _init (void);
-extern void _fini (void);
-#endif
-
-
-/* These functions are passed to __libc_start_main by the startup code.
- These get statically linked into each program. For dynamically linked
- programs, this module will come from libc_nonshared.a and differs from
- the libc.a module in that it doesn't call the preinit array. */
-
-
-void
-__libc_csu_init (int argc, char **argv, char **envp)
-{
- /* For dynamically linked executables the preinit array is executed by
- the dynamic linker (before initializing any shared object). */
-
-#ifndef LIBC_NONSHARED
- /* For static executables, preinit happens right before init. */
- {
- const size_t size = __preinit_array_end - __preinit_array_start;
- size_t i;
- for (i = 0; i < size; i++)
- (*__preinit_array_start [i]) (argc, argv, envp);
- }
-#endif
-
-#if ELF_INITFINI
- _init ();
-#endif
-
- const size_t size = __init_array_end - __init_array_start;
- for (size_t i = 0; i < size; i++)
- (*__init_array_start [i]) (argc, argv, envp);
-}
-
-/* This function should not be used anymore. We run the executable's
- destructor now just like any other. We cannot remove the function,
- though. */
-void
-__libc_csu_fini (void)
-{
-#ifndef LIBC_NONSHARED
- size_t i = __fini_array_end - __fini_array_start;
- while (i-- > 0)
- (*__fini_array_start [i]) ();
-
-# if ELF_INITFINI
- _fini ();
-# endif
-#endif
-}
diff --git a/csu/libc-start.c b/csu/libc-start.c
index feb0d7ce11..05ff7afddf 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1998-2021 Free Software Foundation, Inc.
+/* Perform initialization and invoke main.
+ Copyright (C) 1998-2021 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
@@ -15,10 +16,15 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+/* Note: This code is only part of the startup code proper for
+ statically linked binaries. For dynamically linked binaries, it
+ resides in libc.so. */
+
/* Mark symbols hidden in static PIE for early self relocation to work. */
#if BUILD_PIE_DEFAULT
# pragma GCC visibility push(hidden)
#endif
+
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
@@ -29,6 +35,8 @@
#include <libc-internal.h>
#include <elf/libc-early-init.h>
#include <stdbool.h>
+#include <elf-initfini.h>
+#include <shlib-compat.h>
#include <elf/dl-tunables.h>
@@ -95,9 +103,11 @@ apply_irel (void)
# else
# define STATIC static inline __attribute__ ((always_inline))
# endif
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 0
#else
# define STATIC
-# define LIBC_START_MAIN __libc_start_main
+# define LIBC_START_MAIN __libc_start_main_impl
+# define DO_DEFINE_LIBC_START_MAIN_VERSION 1
#endif
#ifdef MAIN_AUXVEC_ARG
@@ -113,6 +123,92 @@ apply_irel (void)
# define ARCH_INIT_CPU_FEATURES()
#endif
+#ifdef SHARED
+/* Initialization for dynamic executables. Find the main executable
+ link map and run its init functions. */
+static void
+call_init (int argc, char **argv, char **env)
+{
+ /* Obtain the main map of the executable. */
+ struct link_map *l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+
+ /* DT_PREINIT_ARRAY is not processed here. It is already handled in
+ _dl_init in elf/dl-init.c. Also see the call_init function in
+ the same file. */
+
+ if (ELF_INITFINI && l->l_info[DT_INIT] != NULL)
+ DL_CALL_DT_INIT(l, l->l_addr + l->l_info[DT_INIT]->d_un.d_ptr,
+ argc, argv, env);
+
+ ElfW(Dyn) *init_array = l->l_info[DT_INIT_ARRAY];
+ if (init_array != NULL)
+ {
+ unsigned int jm
+ = l->l_info[DT_INIT_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr));
+ ElfW(Addr) *addrs = (void *) (init_array->d_un.d_ptr + l->l_addr);
+ for (unsigned int j = 0; j < jm; ++j)
+ ((dl_init_t) addrs[j]) (argc, argv, env);
+ }
+}
+
+#else /* !SHARED */
+
+/* These magic symbols are provided by the linker. */
+extern void (*__preinit_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__preinit_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_start []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__init_array_end []) (int, char **, char **)
+ attribute_hidden;
+extern void (*__fini_array_start []) (void) attribute_hidden;
+extern void (*__fini_array_end []) (void) attribute_hidden;
+
+# if ELF_INITFINI
+/* These function symbols are provided for the .init/.fini section entry
+ points automagically by the linker. */
+extern void _init (void);
+extern void _fini (void);
+# endif
+
+/* Initialization for static executables. There is no dynamic
+ segment, so we access the symbols directly. */
+static void
+call_init (int argc, char **argv, char **envp)
+{
+ /* For static executables, preinit happens right before init. */
+ {
+ const size_t size = __preinit_array_end - __preinit_array_start;
+ size_t i;
+ for (i = 0; i < size; i++)
+ (*__preinit_array_start [i]) (argc, argv, envp);
+ }
+
+# if ELF_INITFINI
+ _init ();
+# endif
+
+ const size_t size = __init_array_end - __init_array_start;
+ for (size_t i = 0; i < size; i++)
+ (*__init_array_start [i]) (argc, argv, envp);
+}
+
+/* Likewise for the destructor. */
+static void
+call_fini (void *unused)
+{
+ size_t i = __fini_array_end - __fini_array_start;
+ while (i-- > 0)
+ (*__fini_array_start [i]) ();
+
+# if ELF_INITFINI
+ _fini ();
+# endif
+}
+
+#endif /* !SHARED */
+
#include <libc-start.h>
STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
@@ -129,9 +225,16 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
__attribute__ ((noreturn));
-/* Note: the fini parameter is ignored here for shared library. It
- is registered with __cxa_atexit. This had the disadvantage that
- finalizers were called in more than one place. */
+/* Note: The init and fini parameters are no longer used. fini is
+ completely unused, init is still called if not NULL, but the
+ current startup code always passes NULL. (In the future, it would
+ be possible to use fini to pass a version code if init is NULL, to
+ indicate the link-time glibc without introducing a hard
+ incompatibility for new programs with older glibc versions.)
+
+ For dynamically linked executables, the dynamic segment is used to
+ locate constructors and destructors. For statically linked
+ executables, the relevant symbols are access directly. */
STATIC int
LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
int argc, char **argv,
@@ -258,9 +361,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
run the constructors in `_dl_start_user'. */
__libc_init_first (argc, argv, __environ);
- /* Register the destructor of the program, if any. */
- if (fini)
- __cxa_atexit ((void (*) (void *)) fini, NULL, NULL);
+ /* Register the destructor of the statically-linked program. */
+ __cxa_atexit (call_fini, NULL, NULL);
/* Some security at this point. Prevent starting a SUID binary where
the standard file descriptors are not opened. We have to do this
@@ -268,15 +370,24 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
loader did the work already. */
if (__builtin_expect (__libc_enable_secure, 0))
__libc_check_standard_fds ();
-#endif
+#endif /* !SHARED */
/* Call the initializer of the program, if any. */
#ifdef SHARED
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
-#endif
- if (init)
+
+ if (init != NULL)
+ /* This is a legacy program which supplied its own init
+ routine. */
(*init) (argc, argv, __environ MAIN_AUXVEC_PARAM);
+ else
+ /* This is a current program. Use the dynamic segment to find
+ constructors. */
+ call_init (argc, argv, __environ);
+#else /* !SHARED */
+ call_init (argc, argv, __environ);
+#endif /* SHARED */
#ifdef SHARED
/* Auditing checkpoint: we have a new object. */
@@ -365,3 +476,36 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
exit (result);
}
+
+/* Starting with glibc 2.34, the init parameter is always NULL. Older
+ libcs are not prepared to handle that. The macro
+ DEFINE_LIBC_START_MAIN_VERSION creates GLIBC_2.34 alias, so that
+ newly linked binaries reflect that dependency. The macros below
+ expect that the exported function is called
+ __libc_start_main_impl. */
+#ifdef SHARED
+# define DEFINE_LIBC_START_MAIN_VERSION \
+ DEFINE_LIBC_START_MAIN_VERSION_1 \
+ strong_alias (__libc_start_main_impl, __libc_start_main_alias_2) \
+ versioned_symbol (libc, __libc_start_main_alias_2, __libc_start_main, \
+ GLIBC_2_34);
+
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_34)
+# define DEFINE_LIBC_START_MAIN_VERSION_1 \
+ strong_alias (__libc_start_main_impl, __libc_start_main_alias_1) \
+ compat_symbol (libc, __libc_start_main_alias_1, __libc_start_main, GLIBC_2_0);
+# else
+# define DEFINE_LIBC_START_MAIN_VERSION_1
+# endif
+#else /* !SHARED */
+/* Enable calling the function under its exported name. */
+# define DEFINE_LIBC_START_MAIN_VERSION \
+ strong_alias (__libc_start_main_impl, __libc_start_main)
+#endif
+
+/* Only define the version information if LIBC_START_MAIN was not set.
+ If there is a wrapper file, it must expand
+ DEFINE_LIBC_START_MAIN_VERSION on its own. */
+#if DO_DEFINE_LIBC_START_MAIN_VERSION
+DEFINE_LIBC_START_MAIN_VERSION
+#endif
diff --git a/elf/dl-init.c b/elf/dl-init.c
index b7e4b8a3af..f924d26642 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -22,10 +22,6 @@
#include <elf-initfini.h>
-/* Type of the initializer. */
-typedef void (*init_t) (int, char **, char **);
-
-
static void
call_init (struct link_map *l, int argc, char **argv, char **env)
{
@@ -71,7 +67,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (init_array->d_un.d_ptr + l->l_addr);
for (j = 0; j < jm; ++j)
- ((init_t) addrs[j]) (argc, argv, env);
+ ((dl_init_t) addrs[j]) (argc, argv, env);
}
}
@@ -103,7 +99,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
addrs = (ElfW(Addr) *) (preinit_array->d_un.d_ptr + main_map->l_addr);
for (cnt = 0; cnt < i; ++cnt)
- ((init_t) addrs[cnt]) (argc, argv, env);
+ ((dl_init_t) addrs[cnt]) (argc, argv, env);
}
/* Stupid users forced the ELF specification to be changed. It now
diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
index 3761cbd7ee..417da8802b 100644
--- a/sysdeps/aarch64/start.S
+++ b/sysdeps/aarch64/start.S
@@ -63,26 +63,16 @@ ENTRY(_start)
# ifdef SHARED
adrp x0, :got:main
ldr PTR_REG (0), [x0, #:got_lo12:main]
-
- adrp x3, :got:__libc_csu_init
- ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
-
- adrp x4, :got:__libc_csu_fini
- ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
# else
adrp x0, __wrap_main
add x0, x0, :lo12:__wrap_main
- adrp x3, __libc_csu_init
- add x3, x3, :lo12:__libc_csu_init
- adrp x4, __libc_csu_fini
- add x4, x4, :lo12:__libc_csu_fini
# endif
#else
/* Set up the other arguments in registers */
MOVL (0, main)
- MOVL (3, __libc_csu_init)
- MOVL (4, __libc_csu_fini)
#endif
+ mov x3, #0 /* Used to be init. */
+ mov x4, #0 /* Used to be fini. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
stack_end) */
diff --git a/sysdeps/alpha/start.S b/sysdeps/alpha/start.S
index f3eb2029e1..65dcd4d392 100644
--- a/sysdeps/alpha/start.S
+++ b/sysdeps/alpha/start.S
@@ -55,9 +55,8 @@ _start:
ldl a1, 16(sp) /* get argc */
lda a2, 24(sp) /* get argv */
- /* Load address of our own entry points to .fini and .init. */
- lda a3, __libc_csu_init
- lda a4, __libc_csu_fini
+ mov $r31, a3 /* Used to be init. */
+ mov $r31, a4 /* Used to be fini. */
/* Store address of the shared library termination function. */
mov v0, a5
diff --git a/sysdeps/arc/start.S b/sysdeps/arc/start.S
index dbec87e6bb..5302a57cab 100644
--- a/sysdeps/arc/start.S
+++ b/sysdeps/arc/start.S
@@ -49,15 +49,14 @@ ENTRY (ENTRY_POINT)
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end). */
+ mov_s r3, 0 /* Used to be init. */
+ mov r4, 0 /* Used to be fini. */
+
#ifdef SHARED
ld r0, [pcl, @main@gotpc]
- ld r3, [pcl, @__libc_csu_init@gotpc]
- ld r4, [pcl, @__libc_csu_fini@gotpc]
bl __libc_start_main@plt
#else
mov_s r0, main
- mov_s r3, __libc_csu_init
- mov r4, __libc_csu_fini
bl __libc_start_main
#endif
diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S
index 30f69e1b07..9b56bc0cca 100644
--- a/sysdeps/arm/start.S
+++ b/sysdeps/arm/start.S
@@ -94,30 +94,20 @@ _start:
adr a4, .L_GOT
add sl, sl, a4
- ldr ip, .L_GOT+4 /* __libc_csu_fini */
- ldr ip, [sl, ip]
+ mov a4, #0 /* Used to be init. */
+ push { a4 } /* Used to be fini. */
- push { ip } /* Push __libc_csu_fini */
-
- ldr a4, .L_GOT+8 /* __libc_csu_init */
- ldr a4, [sl, a4]
-
- ldr a1, .L_GOT+12 /* main */
+ ldr a1, .L_GOT+4 /* main */
ldr a1, [sl, a1]
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
bl __libc_start_main(PLT)
#else
- /* Fetch address of __libc_csu_fini */
- ldr ip, =__libc_csu_fini
- /* Push __libc_csu_fini */
- push { ip }
-
- /* Set up the other arguments in registers */
+ mov a4, #0 /* Used to init. */
+ push { a4 } /* Used to fini. */
ldr a1, =main
- ldr a4, =__libc_csu_init
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
/* Let the libc call main and exit with its return code. */
@@ -131,8 +121,6 @@ _start:
.align 2
.L_GOT:
.word _GLOBAL_OFFSET_TABLE_ - .L_GOT
- .word __libc_csu_fini(GOT)
- .word __libc_csu_init(GOT)
.word main(GOT)
#endif
diff --git a/sysdeps/csky/abiv2/start.S b/sysdeps/csky/abiv2/start.S
index d65e37e61b..a565cfa87b 100644
--- a/sysdeps/csky/abiv2/start.S
+++ b/sysdeps/csky/abiv2/start.S
@@ -66,13 +66,9 @@ _start:
.Lgetpc:
lrw gb, .Lgetpc@GOTPC
addu gb, t0
- lrw a3, __libc_csu_fini@GOT
- ldr.w a3, (gb, a3 << 0)
- stw a3, (sp, 0)
- lrw a3, __libc_csu_init@GOT
- addu a3, gb
- ldw a3, (a3, 0)
+ movi a3, 0 /* Used to be init. */
+ stw a3, (sp, 0) /* Used to be fini. */
lrw t0, main@GOT
addu t0, gb
@@ -85,14 +81,9 @@ _start:
ldr.w t1, (gb, t1 << 0)
jsr t1
#else
- /* Fetch address of __libc_csu_fini. */
- lrw a0, __libc_csu_fini
- /* Push __libc_csu_fini */
- stw a0, (sp, 0)
-
- /* Set up the other arguments in registers. */
+ movi a3, 0 /* Used to be init. */
+ stw a3, (sp, 0) /* Used to be fini. */
lrw a0, main
- lrw a3, __libc_csu_init
/* Let the libc call main and exit with its return code. */
jsri __libc_start_main
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 9720a4e446..ea3f7a69d0 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -93,6 +93,10 @@ typedef struct link_map *lookup_t;
: (__glibc_unlikely ((ref)->st_shndx == SHN_ABS) ? 0 \
: LOOKUP_VALUE_ADDRESS (map, map_set)) + (ref)->st_value)
+/* Type of a constructor function, in DT_INIT, DT_INIT_ARRAY,
+ DT_PREINIT_ARRAY. */
+typedef void (*dl_init_t) (int, char **, char **);
+
/* On some architectures a pointer to a function is not just a pointer
to the actual code of the function but rather an architecture
specific descriptor. */
@@ -101,7 +105,7 @@ typedef struct link_map *lookup_t;
(void *) SYMBOL_ADDRESS (map, ref, false)
# define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
# define DL_CALL_DT_INIT(map, start, argc, argv, env) \
- ((init_t) (start)) (argc, argv, env)
+ ((dl_init_t) (start)) (argc, argv, env)
# define DL_CALL_DT_FINI(map, start) ((fini_t) (start)) ()
#endif
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
index 29d994bfc2..a9a927f26c 100644
--- a/sysdeps/hppa/dl-lookupcfg.h
+++ b/sysdeps/hppa/dl-lookupcfg.h
@@ -56,7 +56,7 @@ void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S
index 2fe73c9aae..4a1877f8e8 100644
--- a/sysdeps/hppa/start.S
+++ b/sysdeps/hppa/start.S
@@ -36,8 +36,6 @@
.import main, code
.import $global$, data
.import __libc_start_main, code
- .import __libc_csu_fini, code
- .import __libc_csu_init, code
/* Have the linker create plabel words so we get PLABEL32
relocs and not 21/14. The use of 21/14 relocs is only
@@ -52,10 +50,6 @@
.word P%main
.Lp__libc_start_main:
.word P%__libc_start_main
-.Lp__libc_csu_fini:
- .word P%__libc_csu_fini
-.Lp__libc_csu_init:
- .word P%__libc_csu_init
.text
.align 4
@@ -77,8 +71,8 @@ _start:
1. r26 - Application main
2. r25 - argc
3. r24 - argv
- 4. r23 - __libc_csu_init
- 5. sp-52 - __libc_csu_fini
+ 4. r23 - init (unused)
+ 5. sp-52 - fini (unused)
6. sp-56 - rtld_fini
7. sp-60 - stackend */
@@ -108,14 +102,6 @@ _start:
addil LT'.Lpmain, %r19
ldw RT'.Lpmain(%r1), %r26
ldw 0(%r26),%r26
- /* void (*init) (void) (4th argument) */
- addil LT'.Lp__libc_csu_init, %r19
- ldw RT'.Lp__libc_csu_init(%r1), %r23
- ldw 0(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- addil LT'.Lp__libc_csu_fini, %r19
- ldw RT'.Lp__libc_csu_fini(%r1), %r22
- ldw 0(%r22), %r22
#else
/* Load $global$ address into %dp */
ldil L%$global$, %dp
@@ -124,13 +110,9 @@ _start:
/* load main (1st argument) */
ldil LR'.Lpmain, %r26
ldw RR'.Lpmain(%r26), %r26
- /* void (*init) (void) (4th argument) */
- ldil LR'.Lp__libc_csu_init, %r23
- ldw RR'.Lp__libc_csu_init(%r23), %r23
- /* void (*fini) (void) (5th argument) */
- ldil LR'.Lp__libc_csu_fini, %r22
- ldw RR'.Lp__libc_csu_fini(%r22), %r22
#endif
+ ldi 0,%r23 /* Used to be init. */
+ ldi 0,%r22 /* Used to be fini. */
/* Store 5th argument */
stw %r22, -52(%sp)
/* void *stack_end (7th argument) */
diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S
index 24c806cfec..5296b27e65 100644
--- a/sysdeps/i386/start.S
+++ b/sysdeps/i386/start.S
@@ -87,11 +87,9 @@ ENTRY (_start)
call 1f
addl $_GLOBAL_OFFSET_TABLE_, %ebx
- /* Push address of our own entry points to .fini and .init. */
- leal __libc_csu_fini@GOTOFF(%ebx), %eax
- pushl %eax
- leal __libc_csu_init@GOTOFF(%ebx), %eax
- pushl %eax
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
@@ -112,9 +110,9 @@ ENTRY (_start)
But let the libc call main. */
call __libc_start_main@PLT
#else
- /* Push address of our own entry points to .fini and .init. */
- pushl $__libc_csu_fini
- pushl $__libc_csu_init
+ /* This used to be the addresses of .fini and .init. */
+ pushl $0
+ pushl $0
pushl %ecx /* Push second argument: argv. */
pushl %esi /* Push first argument: argc. */
diff --git a/sysdeps/ia64/dl-lookupcfg.h b/sysdeps/ia64/dl-lookupcfg.h
index 209d926bad..58ca32424b 100644
--- a/sysdeps/ia64/dl-lookupcfg.h
+++ b/sysdeps/ia64/dl-lookupcfg.h
@@ -50,7 +50,7 @@ extern void attribute_hidden _dl_unmap (struct link_map *map);
{ \
ElfW(Addr) addr; \
DL_DT_FUNCTION_ADDRESS(map, start, , addr) \
- init_t init = (init_t) addr; \
+ dl_init_t init = (dl_init_t) addr; \
init (argc, argv, env); \
}
diff --git a/sysdeps/ia64/start.S b/sysdeps/ia64/start.S
index 0018acc821..b28f8cb429 100644
--- a/sysdeps/ia64/start.S
+++ b/sysdeps/ia64/start.S
@@ -82,20 +82,15 @@ _start:
{
addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
addl out0 = @ltoff(@fptr(main)), gp
- addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
+ mov out3 = r0 /* Used to be init. */
;;
}
{ .mmi
ld8 r3 = [r11] /* pointer to __libc_ia64_register_backing_store_base */
ld8 out0 = [out0] /* pointer to `main' function descriptor */
- addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
+ mov out4 = r0 /* Used to be fini. */
;;
}
- { .mmi
- ld8 out3 = [out3] /* pointer to `init' function descriptor */
- ld8 out4 = [out4] /* pointer to `fini' function descriptor */
- nop 0
- }
.body
{ .mib
st8 [r3] = r10
diff --git a/sysdeps/m68k/start.S b/sysdeps/m68k/start.S
index c36b34f8d9..98da4db9f3 100644
--- a/sysdeps/m68k/start.S
+++ b/sysdeps/m68k/start.S
@@ -76,15 +76,14 @@ _start:
pea (%a1) /* Push address of the shared library
termination function. */
+ /* These used to be addresses of the .fini and .init entry points. */
+ clr.l -(%sp)
+ clr.l -(%sp)
+
#ifdef PIC
/* Load PIC register. */
LOAD_GOT (%a5)
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- move.l __libc_csu_fini@GOT(%a5), -(%sp)
- move.l __libc_csu_init@GOT(%a5), -(%sp)
-
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
@@ -94,10 +93,6 @@ _start:
let the libc call main. */
jbsr __libc_start_main@PLTPC
#else
- /* Push the address of our own entry points to `.fini' and
- `.init'. */
- pea __libc_csu_fini
- pea __libc_csu_init
pea (%a0) /* Push second argument: argv. */
move.l %d0, -(%sp) /* Push first argument: argc. */
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 509e9b7cb0..e10a286d2e 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2203,6 +2203,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S
index dcb202a63b..6589bd4dc7 100644
--- a/sysdeps/microblaze/start.S
+++ b/sysdeps/microblaze/start.S
@@ -63,14 +63,14 @@ _start:
mfs r20,rpc
addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
lwi r5,r20,main@GOT
- lwi r8,r20,__libc_csu_init@GOT
- lwi r9,r20,__libc_csu_fini@GOT
+ addk r8,r0,r0 /* Used to be init. */
+ addk r9,r0,r0 /* Used to be fini. */
brid __libc_start_main@PLT
addk r10,r0,r0
#else
addik r5,r0,main
- addik r8,r0,__libc_csu_init
- addik r9,r0,__libc_csu_fini
+ addk r8,r0,r0 /* Used to be init. */
+ addk r9,r0,r0 /* Used to be fini. */
brid __libc_start_main
addk r10,r0,r0
#endif
diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S
index 28e2ed17ad..4ec42a2a7f 100644
--- a/sysdeps/mips/start.S
+++ b/sysdeps/mips/start.S
@@ -96,13 +96,13 @@ ENTRY_POINT:
# if _MIPS_SIM == _ABIO32
PTR_SUBIU $29, 32
# endif
- PTR_LA $7, __libc_csu_init /* init */
- PTR_LA $8, __libc_csu_fini
+ move $7, $0 /* Used to be init. */
# if _MIPS_SIM == _ABIO32
- PTR_S $8, 16($29) /* fini */
+ PTR_S $0, 16($29) /* Used to be fini. */
PTR_S $2, 20($29) /* rtld_fini */
PTR_S $29, 24($29) /* stack_end */
# else
+ move $8, $0 /* Used to be fini. */
move $9, $2 /* rtld_fini */
move $10, $29 /* stack_end */
# endif
@@ -143,19 +143,17 @@ ENTRY_POINT:
/* Lay out last arguments, and call __libc_start_main(). */
# ifdef __PIC__
sw $7, 24($sp) /* stack_end */
- lw $4, %got(__libc_csu_fini)($3)
- lw $7, %got(__libc_csu_init)($3) /* init */
- sw $4, 16($sp) /* fini */
+ move $4, $0 /* Used to be ini. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, %got(main)($3) /* main */
lw $3, %call16(__libc_start_main)($3)
sw $2, 20($sp) /* rtld_fini */
move $25, $3
jalr $3
# else
- lw $4, 1f
sw $7, 24($sp) /* stack_end */
- lw $7, 2f /* init */
- sw $4, 16($sp) /* fini */
+ move $7, $0 /* Used to be init. */
+ sw $0, 16($sp) /* Used to be fini. */
lw $4, 3f /* main */
sw $2, 20($sp) /* rtld_fini */
/* Load and call __libc_start_main(). */
@@ -165,8 +163,6 @@ ENTRY_POINT:
hlt: b hlt /* Crash if somehow it does return. */
# ifndef __PIC__
.align 2
-1: .word __libc_csu_fini
-2: .word __libc_csu_init
3: .word main
4: .word __libc_start_main
# endif
diff --git a/sysdeps/nios2/start.S b/sysdeps/nios2/start.S
index 0a6c587de3..7c9696977f 100644
--- a/sysdeps/nios2/start.S
+++ b/sysdeps/nios2/start.S
@@ -92,18 +92,11 @@ _start:
addi r2, r2, %lo(_gp_got - 1b)
add r22, r22, r2
- /* Push fini */
- movhi r8, %call_hiadj(__libc_csu_fini)
- addi r8, r8, %call_lo(__libc_csu_fini)
- add r8, r8, r22
- ldw r8, 0(r8)
- stw r8, 0(sp)
+ /* Used to be fini. */
+ stw zero, 0(sp)
- /* r7 == init */
- movhi r7, %call_hiadj(__libc_csu_init)
- addi r7, r7, %call_lo(__libc_csu_init)
- add r7, r7, r22
- ldw r7, 0(r7)
+ /* Used to be init. */
+ mov r7, zero
/* r6 == argv */
addi r6, sp, 16
diff --git a/sysdeps/powerpc/powerpc32/start.S b/sysdeps/powerpc/powerpc32/start.S
index a721a18775..39ce1a18ff 100644
--- a/sysdeps/powerpc/powerpc32/start.S
+++ b/sysdeps/powerpc/powerpc32/start.S
@@ -52,8 +52,8 @@
L(start_addresses):
.long _SDA_BASE_
.long main
- .long __libc_csu_init
- .long __libc_csu_fini
+ .long 0 /* Used to be init. */
+ .long 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
.section ".text"
diff --git a/sysdeps/powerpc/powerpc64/start.S b/sysdeps/powerpc/powerpc64/start.S
index 612c846632..71c0c67926 100644
--- a/sysdeps/powerpc/powerpc64/start.S
+++ b/sysdeps/powerpc/powerpc64/start.S
@@ -53,8 +53,8 @@ L(start_addresses):
.quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
/* function descriptors so don't need JUMPTARGET */
.quad main
- .quad __libc_csu_init
- .quad __libc_csu_fini
+ .quad 0 /* Used to be init. */
+ .quad 0 /* Used to be fini. */
ASM_SIZE_DIRECTIVE(L(start_addresses))
diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S
index 9c94035015..806f6aacd6 100644
--- a/sysdeps/riscv/start.S
+++ b/sysdeps/riscv/start.S
@@ -54,8 +54,8 @@ ENTRY (ENTRY_POINT)
REG_L a1, 0(sp) /* argc. */
addi a2, sp, SZREG /* argv. */
andi sp, sp, ALMASK /* Align stack. */
- lla a3, __libc_csu_init
- lla a4, __libc_csu_fini
+ li a3, 0 /* Used to be init. */
+ li a4, 0 /* Used to be fini. */
mv a6, sp /* stack_end. */
call __libc_start_main@plt
diff --git a/sysdeps/s390/s390-32/start.S b/sysdeps/s390/s390-32/start.S
index aba90739c1..b6cfa4caf3 100644
--- a/sysdeps/s390/s390-32/start.S
+++ b/sysdeps/s390/s390-32/start.S
@@ -175,18 +175,16 @@ _start:
*/
stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
la %r7,96(%r15)
- l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini
- l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init
l %r2,.L3-.Llit(%r13) # load pointer to main
l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main
#ifdef PIC
l %r12,.L5-.Llit(%r13) # load .got pointer
- la %r6,0(%r13,%r6)
- la %r5,0(%r13,%r5)
la %r12,0(%r13,%r12)
l %r2,0(%r12,%r2)
la %r1,0(%r13,%r1)
#endif
+ lhi %r6, 0 # Used to fini.
+ lhi %r5, 0 # Used to init.
/* ok, now branch to the libc main routine */
basr %r14,%r1
@@ -197,13 +195,9 @@ _start:
cfi_endproc
.Llit:
#ifndef PIC
-.L1: .long __libc_csu_init
-.L2: .long __libc_csu_fini
.L3: .long main
.L4: .long __libc_start_main
#else
-.L1: .long __libc_csu_init-.Llit
-.L2: .long __libc_csu_fini-.Llit
.L3: .long main@GOT
.L4: .long __libc_start_main@plt-.Llit
.L5: .long _GLOBAL_OFFSET_TABLE_-.Llit
diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S
index 0d9d30916d..4e6526308a 100644
--- a/sysdeps/s390/s390-64/start.S
+++ b/sysdeps/s390/s390-64/start.S
@@ -80,8 +80,8 @@ _start:
*/
stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
la %r7,160(%r15)
- larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
- larl %r5,__libc_csu_init # load pointer to __libc_csu_init
+ lghi %r6,0 # Used to be fini.
+ lghi %r5,0 # Used to be init.
/* Ok, now branch to the libc main routine. */
#ifdef PIC
diff --git a/sysdeps/sh/start.S b/sysdeps/sh/start.S
index ab29f194f7..606ee59222 100644
--- a/sysdeps/sh/start.S
+++ b/sysdeps/sh/start.S
@@ -70,12 +70,11 @@ _start:
/* Push the last arguments to main() onto the stack */
mov.l r4,@-r15
- mov.l L_fini,r0
- mov.l r0,@-r15
+ mov.l r14,@-r15 /* Used to be fini. */
/* Set up the other arguments for main() that go in registers */
mov.l L_main,r4
- mov.l L_init,r7
+ mov #0,r7 /* Used to be init. */
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
@@ -90,10 +89,6 @@ _start:
.align 2
L_main:
.long main
-L_init:
- .long __libc_csu_init
-L_fini:
- .long __libc_csu_fini
L_libc_start_main:
.long __libc_start_main
L_abort:
diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S
index 45ca77da3e..00bf898fb9 100644
--- a/sysdeps/sparc/sparc32/start.S
+++ b/sysdeps/sparc/sparc32/start.S
@@ -59,22 +59,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ld [%l7 + %o0], %o0, %gdop(main)
- ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S
index 210fbaff90..8520717eba 100644
--- a/sysdeps/sparc/sparc64/start.S
+++ b/sysdeps/sparc/sparc64/start.S
@@ -60,22 +60,14 @@ _start:
/* Load the addresses of the user entry points. */
#ifndef PIC
sethi %hi(main), %o0
- sethi %hi(__libc_csu_init), %o3
- sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
- or %o3, %lo(__libc_csu_init), %o3
- or %o4, %lo(__libc_csu_fini), %o4
#else
sethi %gdop_hix22(main), %o0
- sethi %gdop_hix22(__libc_csu_init), %o3
- sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
- xor %o3, %gdop_lox10(__libc_csu_init), %o3
- xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ldx [%l7 + %o0], %o0, %gdop(main)
- ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
- ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#endif
+ mov 0, %o3 /* Used to be init. */
+ mov 0, %o4 /* Used to be fini. */
/* When starting a binary via the dynamic linker, %g1 contains the
address of the shared library termination function, which will be
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 4cc1c6a591..bac795262d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2171,3 +2171,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 26ad9845e4..897f70db22 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2253,6 +2253,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index bb9dfd4daf..604d259ad6 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -1931,3 +1931,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 3b0a47e967..094236f713 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -155,6 +155,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index 9ab3924888..2bb4d31e81 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -152,6 +152,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 14a84dac8f..d4291fecfb 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2115,3 +2115,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 5c8502f3d3..1fd2a862f6 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2074,6 +2074,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index ddc5837059..943331f01e 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2241,6 +2241,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index e3b345b803..f530151bde 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2106,6 +2106,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 25f2d1c08f..6e76b6dcaa 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -156,6 +156,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0x98
GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index c4891479d3..7541b8289f 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2186,6 +2186,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 143b0163b4..6cf1936c42 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2166,3 +2166,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index 13d374a031..98730ebcda 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2163,3 +2163,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index b2295f1937..92fa6cbc73 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2157,6 +2157,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 4c786070d0..265a49e74e 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2155,6 +2155,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index aa9c6a4dca..cfa5e1111b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2163,6 +2163,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 5939588ad5..8c03ac52cd 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2157,6 +2157,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 92556c4237..17f5609e06 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2204,3 +2204,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
index 66f5effe8a..4d681dad06 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-start.c
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c
@@ -41,12 +41,12 @@ struct startup_info
};
int
-__libc_start_main (int argc, char **argv,
- char **ev,
- ElfW (auxv_t) * auxvec,
- void (*rtld_fini) (void),
- struct startup_info *stinfo,
- char **stack_on_entry)
+__libc_start_main_impl (int argc, char **argv,
+ char **ev,
+ ElfW (auxv_t) * auxvec,
+ void (*rtld_fini) (void),
+ struct startup_info *stinfo,
+ char **stack_on_entry)
{
/* the PPC SVR4 ABI says that the top thing on the stack will
be a NULL pointer, so if not we assume that we're being called
@@ -99,3 +99,4 @@ __libc_start_main (int argc, char **argv,
stinfo->init, stinfo->fini, rtld_fini,
stack_on_entry);
}
+DEFINE_LIBC_START_MAIN_VERSION
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 26c93dff05..76a16e2a6d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2213,6 +2213,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index f04b167788..697f072fd4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2246,6 +2246,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index c2ca00709e..2647bb51f1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2076,6 +2076,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index 0ea50dc851..036b1c8345 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2366,3 +2366,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index 0263e284d4..ff3225e16f 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -1933,3 +1933,4 @@ GLIBC_2.33 wprintf F
GLIBC_2.33 write F
GLIBC_2.33 writev F
GLIBC_2.33 wscanf F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 1626c5351f..fb5ad9909f 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2133,3 +2133,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index a66426eb4d..cead75acc5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2211,6 +2211,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index ab351873ae..31366dd7e6 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2112,6 +2112,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 22ceaa3d87..a3a8be8910 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2081,6 +2081,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index d36f228192..8f505c5045 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2078,6 +2078,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 59b4313280..53ef6304f1 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2202,6 +2202,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 266dcdfa08..eba0cb156d 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2129,6 +2129,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 2744bba4af..17ce5dfd58 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2088,6 +2088,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index ce2f4fb72b..17a1c83903 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2185,3 +2185,4 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
+GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S
index 30fc9007c9..1b3e36826b 100644
--- a/sysdeps/x86_64/start.S
+++ b/sysdeps/x86_64/start.S
@@ -96,17 +96,13 @@ ENTRY (_start)
which grow downwards). */
pushq %rsp
+ /* These used to be the addresses of .fini and .init. */
+ xorl %r8d, %r8d
+ xorl %ecx, %ecx
+
#ifdef PIC
- /* Pass address of our own entry points to .fini and .init. */
- mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
- mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
-
mov main@GOTPCREL(%rip), %RDI_LP
#else
- /* Pass address of our own entry points to .fini and .init. */
- mov $__libc_csu_fini, %R8_LP
- mov $__libc_csu_init, %RCX_LP
-
mov $main, %RDI_LP
#endif
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2021-03-07 16:39 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-23 21:45 [PATCH] Reduce the statically linked startup code [BZ #23323] Florian Weimer
2018-07-01 9:30 ` Florian Weimer
2018-07-03 10:01 ` Florian Weimer
2018-08-08 14:48 ` Florian Weimer
2018-08-08 15:10 ` H.J. Lu
2018-08-08 15:17 ` Florian Weimer
2018-08-08 15:56 ` Szabolcs Nagy
2018-08-08 16:11 ` Florian Weimer
2021-02-18 13:12 Florian Weimer
2021-02-25 11:00 ` Siddhesh Poyarekar
2021-02-25 18:43 ` Mike Frysinger
2021-02-25 18:52 ` Florian Weimer
2021-02-28 6:02 ` Mike Frysinger
2021-03-01 9:43 ` Florian Weimer
2021-03-07 16:39 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).