glibc/csu/libc-start.c

416 lines
13 KiB
C
Raw Permalink Normal View History

/* Perform initialization and invoke main.
Copyright (C) 1998-2022 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.
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
Prefer https to http for gnu.org and fsf.org URLs Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 07:40:42 +02:00
<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>
#include <unistd.h>
Update. 2000-03-23 Andreas Jaeger <aj@suse.de> * elf/dl-addr.c: Adjust include paths for ldsodefs location change. * elf/dl-debug.c: Likewise. * elf/dl-deps.c: Likewise. * elf/dl-error.c: Likewise. * elf/dl-fini.c: Likewise. * elf/dl-init.c: Likewise. * elf/dl-load.c: Likewise. * elf/dl-lookup.c: Likewise. * elf/dl-minimal.c: Likewise. * elf/dl-object.c: Likewise. * elf/dl-open.c: Likewise. * elf/dl-preinit.c: Likewise. * elf/dl-profile.c: Likewise. * elf/dl-profstub.c: Likewise. * elf/dl-reloc.c: Likewise. * elf/dl-runtime.c: Likewise. * elf/dl-support.c: Likewise. * elf/dl-symbol.c: Likewise. * elf/dl-version.c: Likewise. * elf/rtld.c: Likewise. * elf/sprof.c: Likewise. * sysdeps/generic/dl-cache.c: Likewise. * sysdeps/generic/dl-origin.c: Likewise. * sysdeps/generic/dl-sysdep.c: Likewise. * sysdeps/generic/elf/backtracesyms.c: Likewise. * sysdeps/generic/elf/backtracesymsfd.c: Likewise. * sysdeps/generic/libc-start.c: Likewise. * sysdeps/mach/hurd/dl-sysdep.c: Likewise. * sysdeps/powerpc/dl-machine.c: Likewise. * sysdeps/powerpc/elf/libc-start.c: Likewise. * sysdeps/sparc/sparc32/dl-machine.h: Likewise. * sysdeps/sparc/sparc64/dl-machine.h: Likewise. * sysdeps/unix/sysv/linux/dl-origin.c: Likewise. * elf/ldsodefs.h: Move file to ... * sysdeps/generic/ldsodefs.h: ... here. * sysdeps/generic/ldsodefs.h: Add definition for D_PTR. * sysdeps/mips/elf/ldsodefs.h: New file. * elf/dl-version.c (match_symbol): Use D_PTR to access relocated entries in l_info. (_dl_check_map_versions): Likewise. * elf/dl-reloc.c (_dl_relocate_object): Likewise. * elf/dl-load.c (_dl_init_paths): Likewise. (_dl_map_object): Likewise. * elf/dynamic-link.h (_ELF_DYNAMIC_DO_RELOC): Likewise. (elf_get_dynamic_info): Likewise. * elf/do-lookup.h (FCT): Likewise. * elf/do-rel.h (elf_dynamic_do_rel): Likewise. * elf/dl-deps.c (_dl_map_object_deps): Likewise. * elf/dl-addr.c (_dl_addr): Likewise. * elf/dl-runtime.c (profile_fixup): Likewise. (fixup): Likewise. * elf/dl-init.c (_dl_init_next): Likewise. * sysdeps/generic/dl-machine.h (elf_machine_runtime_setup): Likewise. * sysdeps/unix/sysv/linux/i386/dl-librecon.h (DISTINGUISH_LIB_VERSIONS): Likewise. * sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Likewise. (elf_machine_rel): Likewise. * elf/dynamic-link.h (elf_get_dynamic_info): Only change l_info for writable dynamic section.
2000-03-23 21:31:46 +01:00
#include <ldsodefs.h>
#include <libc-diag.h>
Add framework for tunables The tunables framework allows us to uniformly manage and expose global variables inside glibc as switches to users. tunables/README has instructions for glibc developers to add new tunables. Tunables support can be enabled by passing the --enable-tunables configure flag to the configure script. This patch only adds a framework and does not pose any limitations on how tunable values are read from the user. It also adds environment variables used in malloc behaviour tweaking to the tunables framework as a PoC of the compatibility interface. * manual/install.texi: Add --enable-tunables option. * INSTALL: Regenerate. * README.tunables: New file. * Makeconfig (CPPFLAGS): Define TOP_NAMESPACE. (before-compile): Generate dl-tunable-list.h early. * config.h.in: Add HAVE_TUNABLES. * config.make.in: Add have-tunables. * configure.ac: Add --enable-tunables option. * configure: Regenerate. * csu/init-first.c (__libc_init_first): Move __libc_init_secure earlier... * csu/init-first.c (LIBC_START_MAIN):... to here. Include dl-tunables.h, libc-internal.h. (LIBC_START_MAIN) [!SHARED]: Initialize tunables for static binaries. * elf/Makefile (dl-routines): Add dl-tunables. * elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE namespace. * elf/dl-support (_dl_nondynamic_init): Unset MALLOC_CHECK_ only when !HAVE_TUNABLES. * elf/rtld.c (process_envvars): Likewise. * elf/dl-sysdep.c [HAVE_TUNABLES]: Include dl-tunables.h (_dl_sysdep_start): Call __tunables_init. * elf/dl-tunable-types.h: New file. * elf/dl-tunables.c: New file. * elf/dl-tunables.h: New file. * elf/dl-tunables.list: New file. * malloc/tst-malloc-usable-static.c: New test case. * malloc/Makefile (tests-static): Add it. * malloc/arena.c [HAVE_TUNABLES]: Include dl-tunables.h. Define TUNABLE_NAMESPACE. (DL_TUNABLE_CALLBACK (set_mallopt_check)): New function. (DL_TUNABLE_CALLBACK_FNDECL): New macro. Use it to define callback functions. (ptmalloc_init): Set tunable values. * scripts/gen-tunables.awk: New file. * sysdeps/mach/hurd/dl-sysdep.c: Include dl-tunables.h. (_dl_sysdep_start): Call __tunables_init.
2016-12-31 19:02:17 +01:00
#include <libc-internal.h>
elf: Implement __libc_early_init This function is defined in libc.so, and the dynamic loader calls right after relocation has been finished, before any ELF constructors or the preinit function is invoked. It is also used in the static build for initializing parts of the static libc. To locate __libc_early_init, a direct symbol lookup function is used, _dl_lookup_direct. It does not search the entire symbol scope and consults merely a single link map. This function could also be used to implement lookups in the vDSO (as an optimization). A per-namespace variable (libc_map) is added for locating libc.so, to avoid repeated traversals of the search scope. It is similar to GL(dl_initfirst). An alternative would have been to thread a context argument from _dl_open down to _dl_map_object_from_fd (where libc.so is identified). This could have avoided the global variable, but the change would be larger as a result. It would not have been possible to use this to replace GL(dl_initfirst) because that global variable is used to pass the function pointer past the stack switch from dl_main to the main program. Replacing that requires adding a new argument to _dl_init, which in turn needs changes to the architecture-specific libc.so startup code written in assembler. __libc_early_init should not be used to replace _dl_var_init (as it exists today on some architectures). Instead, _dl_lookup_direct should be used to look up a new variable symbol in libc.so, and that should then be initialized from the dynamic loader, immediately after the object has been loaded in _dl_map_object_from_fd (before relocation is run). This way, more IFUNC resolvers which depend on these variables will work. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-04-24 22:31:15 +02:00
#include <elf/libc-early-init.h>
#include <stdbool.h>
#include <elf-initfini.h>
#include <shlib-compat.h>
Add framework for tunables The tunables framework allows us to uniformly manage and expose global variables inside glibc as switches to users. tunables/README has instructions for glibc developers to add new tunables. Tunables support can be enabled by passing the --enable-tunables configure flag to the configure script. This patch only adds a framework and does not pose any limitations on how tunable values are read from the user. It also adds environment variables used in malloc behaviour tweaking to the tunables framework as a PoC of the compatibility interface. * manual/install.texi: Add --enable-tunables option. * INSTALL: Regenerate. * README.tunables: New file. * Makeconfig (CPPFLAGS): Define TOP_NAMESPACE. (before-compile): Generate dl-tunable-list.h early. * config.h.in: Add HAVE_TUNABLES. * config.make.in: Add have-tunables. * configure.ac: Add --enable-tunables option. * configure: Regenerate. * csu/init-first.c (__libc_init_first): Move __libc_init_secure earlier... * csu/init-first.c (LIBC_START_MAIN):... to here. Include dl-tunables.h, libc-internal.h. (LIBC_START_MAIN) [!SHARED]: Initialize tunables for static binaries. * elf/Makefile (dl-routines): Add dl-tunables. * elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE namespace. * elf/dl-support (_dl_nondynamic_init): Unset MALLOC_CHECK_ only when !HAVE_TUNABLES. * elf/rtld.c (process_envvars): Likewise. * elf/dl-sysdep.c [HAVE_TUNABLES]: Include dl-tunables.h (_dl_sysdep_start): Call __tunables_init. * elf/dl-tunable-types.h: New file. * elf/dl-tunables.c: New file. * elf/dl-tunables.h: New file. * elf/dl-tunables.list: New file. * malloc/tst-malloc-usable-static.c: New test case. * malloc/Makefile (tests-static): Add it. * malloc/arena.c [HAVE_TUNABLES]: Include dl-tunables.h. Define TUNABLE_NAMESPACE. (DL_TUNABLE_CALLBACK (set_mallopt_check)): New function. (DL_TUNABLE_CALLBACK_FNDECL): New macro. Use it to define callback functions. (ptmalloc_init): Set tunable values. * scripts/gen-tunables.awk: New file. * sysdeps/mach/hurd/dl-sysdep.c: Include dl-tunables.h. (_dl_sysdep_start): Call __tunables_init.
2016-12-31 19:02:17 +01:00
#include <elf/dl-tunables.h>
Update. 1998-03-18 14:25 Ulrich Drepper <drepper@cygnus.com> * string/bits/string2.h: Add optimization for strdup. Always define __strsep and __strtok_r and make real names available when feature select macros are defined. 1998-03-18 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/install.texi (Installation): Use i486-linux as example instead of the unsupported sunos4. (Reporting Bugs): Mention glibcbug script. (Tools for Installation): gcc 2.8.1/egcs 1.0.2 is required. 1998-03-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/wordexp-tst.sh: Make portable. Add more tests. * posix/Makefile (do-globtest do-wordexp-test): New targets. 1998-03-18 13:38 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/libc-start.c: Moved to ... * sysdeps/generic/libc-start.c: ...here, replacing former content. * sysdeps/unix/sysv/linux/Dist: Add netash/ash.h and netpacket/packet.h. * sysdeps/unix/sysv/linux/bits/socket.h: Pretty print. 1998-03-17 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/bits/resource.h: Remove trailing comma in enumerator for strict standard compliance. * sysdeps/generic/bits/resource.h: Likewise. 1998-03-18 10:04 Philip Blundell <pb@nexus.co.uk> * sysdeps/arm/sysdep.h (__ARM_USES_FP): Deleted. (PLTJMP): New macro. * sysdeps/arm/fpu/__longjmp.S: New file, implementation of longjmp() when floating point enabled. * sysdeps/arm/fpu/setjmp.S: Likewise for setjmp(). * sysdeps/arm/__longjmp.S: Remove floating point code. * sysdeps/arm/setjmp.S: Likewise. * sysdeps/arm/bsd-setjmp.S: Call __sigsetjmp by correct name. * sysdeps/arm/bsd-_setjmp.S: Likewise. * sysdeps/arm/memset.S: New file; optimised ARM implementation of memset(). * sysdeps/generic/setsockopt.c (setsockopt): Keep in step with prototype. 1998-03-17 16:16 Philip Blundell <pb@nexus.co.uk> Based on patches from Pat Beirne and Scott Bambrough: * sysdeps/arm/__longjmp.S: Use ip, not r2, as temporary. * sysdeps/arm/bits/fenv.h: New file. * sysdeps/arm/dl-machine.h: New file. Add ELF support. * sysdeps/arm/elf/setjmp.S: Likewise. * sysdeps/arm/elf/start.S: Likewise. * sysdeps/arm/init-first.c: Likewise. * sysdeps/arm/setjmp.S: Call __sigjmp_save through PLT * sysdeps/arm/sysdep.h: Change format of .type directive. Correct comment about floating point to reflect current reality. * sysdeps/unix/arm/brk.S: Support PIC. * sysdeps/unix/arm/sysdep.S (syscall_error): Support PIC and re-entrant code. * sysdeps/unix/sysv/linux/arm/socket.S: Check correctly for error return; call syscall_error through PLT. * sysdeps/unix/sysv/linux/arm/sysdep.h (ENTRY): Correct error jump. 1998-03-04 12:01 Philip Blundell <pb@nexus.co.uk> * sysdeps/unix/sysv/linux/netpacket/packet.h: New file. * sysdeps/unix/sysv/linux/netash/ash.h: Likewise. * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Install them.
1998-03-18 15:42:25 +01:00
extern void __libc_init_first (int argc, char **argv, char **envp);
#include <tls.h>
#ifndef SHARED
# include <dl-osinfo.h>
# ifndef THREAD_SET_STACK_GUARD
/* Only exported for architectures that don't store the stack guard canary
in thread local area. */
uintptr_t __stack_chk_guard attribute_relro;
# endif
# ifndef THREAD_SET_POINTER_GUARD
/* Only exported for architectures that don't store the pointer guard
value in thread local area. */
uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
# endif
#endif
#ifndef SHARED
# include <link.h>
# include <dl-irel.h>
# ifdef ELF_MACHINE_IRELA
# define IREL_T ElfW(Rela)
# define IPLT_START __rela_iplt_start
# define IPLT_END __rela_iplt_end
# define IREL elf_irela
# elif defined ELF_MACHINE_IREL
# define IREL_T ElfW(Rel)
# define IPLT_START __rel_iplt_start
# define IPLT_END __rel_iplt_end
# define IREL elf_irel
# endif
static void
apply_irel (void)
{
# ifdef IREL
/* We use weak references for these so that we'll still work with a linker
that doesn't define them. Such a linker doesn't support IFUNC at all
and so uses won't work, but a statically-linked program that doesn't
use any IFUNC symbols won't have a problem. */
extern const IREL_T IPLT_START[] __attribute__ ((weak));
extern const IREL_T IPLT_END[] __attribute__ ((weak));
for (const IREL_T *ipltent = IPLT_START; ipltent < IPLT_END; ++ipltent)
IREL (ipltent);
# endif
}
#endif
#ifdef LIBC_START_MAIN
# ifdef LIBC_START_DISABLE_INLINE
# define STATIC static
# 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_impl
# define DO_DEFINE_LIBC_START_MAIN_VERSION 1
#endif
#ifdef MAIN_AUXVEC_ARG
/* main gets passed a pointer to the auxiliary. */
# define MAIN_AUXVEC_DECL , void *
# define MAIN_AUXVEC_PARAM , auxvec
#else
# define MAIN_AUXVEC_DECL
# define MAIN_AUXVEC_PARAM
#endif
#ifndef ARCH_INIT_CPU_FEATURES
# define ARCH_INIT_CPU_FEATURES()
#endif
/* Obtain the definition of __libc_start_call_main. */
#include <libc_start_call_main.h>
#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 */
powerpc: Fix float128 IFUNC relocations [BZ #21707] The patch proposed by Peter Bergner [1] to libgcc in order to fix [BZ #21707] adds a dependency on a symbol provided by the loader, forcing the loader to be linked to tests after libgcc was linked. It also requires to read the thread pointer during IRELA relocations. Tested on powerpc, powerpc64, powerpc64le, s390x and x86_64. [1] https://sourceware.org/ml/libc-alpha/2017-06/msg01383.html [BZ #21707] * csu/libc-start.c (LIBC_START_MAIN): Perform IREL{,A} relocations before or after initializing the TCB on statically linked executables. That's a per-architecture definition. * elf/rtld.c (dl_main): Add a comment about thread-local variables initialization. * sysdeps/generic/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL. * sysdeps/powerpc/Makefile: [$(subdir) = elf && $(multi-arch) != no] (tests-static-internal): Add tst-tlsifunc-static. [$(subdir) = elf && $(multi-arch) != no && $(build-shared) == yes] (tests-internal): Add tst-tlsifunc. * sysdeps/powerpc/tst-tlsifunc.c: New file. * sysdeps/powerpc/tst-tlsifunc-static.c: Likewise. * sysdeps/powerpc/powerpc64le/Makefile (f128-loader-link): New variable. [$(subdir) = math] (test-float128% test-ifloat128%): Force linking to the loader after linking to libgcc. [$(subdir) = wcsmbs || $(subdir) = stdlib] (bug-strtod bug-strtod2) (bug-strtod2 tst-strtod-round tst-wcstod-round tst-strtod6 tst-strrom) (tst-strfrom-locale strfrom-skeleton): Likewise. * sysdeps/unix/sysv/linux/powerpc/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL.
2017-07-17 22:48:59 +02:00
#include <libc-start.h>
STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
MAIN_AUXVEC_DECL),
int argc,
char **argv,
#ifdef LIBC_START_MAIN_AUXVEC_ARG
ElfW(auxv_t) *auxvec,
#endif
__typeof (main) init,
void (*fini) (void),
void (*rtld_fini) (void),
void *stack_end)
Update. 2000-11-20 Ulrich Drepper <drepper@redhat.com> * csu/gmon-start.c: Always have prototype for __gmon_start. * csu/version.c: Add prototypes for __libc_print_version and __libc_main. * iconv/gconv.c: Include gconv_int.h and gconv.h. * iconv/gconv.h (struct __gconv_step): Remove const from __from_name and __to_name. * iconv/gconv_builtin.h: Add ASCII module definitions. * iconv/gconv_conf.c (__gconv_path_elem): Remove const. (add_module): Add cast to avoid warning. Rework construction of strings for new module. * iconv/gconv_db.c (__gconv_alias_compare): Make s1 and s2 const. (derivation_compare): Likewise. * iconv/gconv_dl.c (do_release_shlib): Remove const from nodep. (__gconv_release_shlib): Cast do_release_shlib as parameter for twalk. * iconv/gconv_int.h (__gconv_path_elem): Remove const. (struct gconv_alias): Remove const from fromname and toname. * iconv/gconv_simple.c: Include gconv_builtin.h to get prototypes for loop functions. (internal_ucs4_loop): Use correct const-ness. (ucs4_internal_loop): Likewise. (internal_ucs4le_loop): Likewise. (ucs4le_internal_loop_single): Likewise. * iconv/gconv_trans.c (__gconv_transliterate): Make from_idx, from_tbl, to_idx, to_tbl, winbuf, winbufend const. Change casts in assignments appropriately. (struct known_trans): Remove const from fname. (trans_compare): Make s1 and s2 const. * iconv/loop.c (LOOPFC): Make outend parameter const. Add cast to avoid warning. * iconv/skeleton.c: Remove cast in calls of loop functions. * iconvdata/gconv-modules: Remove US-ASCII definitions. * iconvdata/iso646.c: Remove US_ASCII support. * include/set-hooks.h (DEFINE_HOOK): Also generate prototype. * include/unistd.h: Add __libc_check_standard_fds prototype. * string/bits/string2.h (__mempcpy_args): Add const to casts. * sysdeps/generic/initfini.c: Add prototypes for dummy, _init, and _fini. * sysdeps/generic/libc-start.c: Add prototype for __libc_start_main. * sysdeps/i386/i486/bits/string.h (strcmp): Add const to casts. * sysdeps/unix/sysv/linux/dl-osinfo.h (dl_fatal): Add cast to avoid warning. * sysdeps/unix/sysv/linux/init-first.c: Add prototypes for __libc_init_first and _dl_start. * sysdeps/unix/sysv/linux/mips/clone.S: Fix comments.
2000-11-20 10:16:41 +01:00
__attribute__ ((noreturn));
* csu/elf-init.c (__libc_csu_fini): Don't do anything here. * sysdeps/generic/libc-start.c: Don't register program destructor here. * dlfcn/Makefile: Add rules to build dlfcn.c. (LDFLAGS-dl.so): Removed. * dlfcn/dlclose.c: _dl_close is now in ld.so, use function pointer table. * dlfcn/dlmopen.c: Likewise for _dl_open. * dlfcn/dlopen.c: Likewise. * dlfcn/dlopenold.c: Likewise. * elf/dl-libc.c: Likewise for _dl_open and _dl_close. * elf/Makefile (routines): Remove dl-open and dl-close. (dl-routines): Add dl-open, dl-close, and dl-trampoline. Add rules to build and run tst-audit1. * elf/tst-audit1.c: New file. * elf/tst-auditmod1.c: New file. * elf/Versions [libc]: Remove _dl_open and _dl_close. * elf/dl-close.c: Change for use inside ld.so instead of libc.so. * elf/dl-open.c: Likewise. * elf/dl-debug.c (_dl_debug_initialize): Allow reinitialization, signaled by nonzero parameter. * elf/dl-init.c: Fix use of r_state. * elf/dl-load.c: Likewise. * elf/dl-close.c: Add auditing checkpoints. * elf/dl-open.c: Likewise. * elf/dl-fini.c: Likewise. * elf/dl-load.c: Likewise. * elf/dl-sym.c: Likewise. * sysdeps/generic/libc-start.c: Likewise. * elf/dl-object.c: Allocate memory for auditing information. * elf/dl-reloc.c: Remove RESOLV. We now always need the map. Correctly initialize slotinfo. * elf/dynamic-link.h: Adjust after removal of RESOLV. * sysdeps/hppa/dl-lookupcfg.h: Likewise. * sysdeps/ia64/dl-lookupcfg.h: Likewise. * sysdeps/powerpc/powerpc64/dl-lookupcfg.h: Removed. * elf/dl-runtime.c (_dl_fixup): Little cleanup. (_dl_profile_fixup): New parameters to point to register struct and variable for frame size. Add auditing checkpoints. (_dl_call_pltexit): New function. Don't define trampoline code here. * elf/rtld.c: Recognize LD_AUDIT. Load modules on startup. Remove all the functions from _rtld_global_ro which only _dl_open and _dl_close needed. Add auditing checkpoints. * elf/link.h: Define symbols for auditing interfaces. * include/link.h: Likewise. * include/dlfcn.h: Define __RTLD_AUDIT. Remove prototypes for _dl_open and _dl_close. Adjust access to argc and argv in libdl. * dlfcn/dlfcn.c: New file. * sysdeps/generic/dl-lookupcfg.h: Remove all content now that RESOLVE is gone. * sysdeps/generic/ldsodefs.h: Add definitions for auditing interfaces. * sysdeps/generic/unsecvars.h: Add LD_AUDIT. * sysdeps/i386/dl-machine.h: Remove trampoline code here. Adjust for removal of RESOLVE. * sysdeps/x86_64/dl-machine.h: Likewise. * sysdeps/generic/dl-trampoline.c: New file. * sysdeps/i386/dl-trampoline.c: New file. * sysdeps/x86_64/dl-trampoline.c: New file. * sysdeps/generic/dl-tls.c: Cleanups. Fixup for dtv_t change. Fix updating of DTV. * sysdeps/generic/libc-tls.c: Likewise. * sysdeps/arm/bits/link.h: Renamed to ... * sysdeps/arm/buts/linkmap.h: ...this. * sysdeps/generic/bits/link.h: Renamed to... * sysdeps/generic/bits/linkmap.h: ...this. * sysdeps/hppa/bits/link.h: Renamed to... * sysdeps/hppa/bits/linkmap.h: ...this. * sysdeps/hppa/i386/link.h: Renamed to... * sysdeps/hppa/i386/linkmap.h: ...this. * sysdeps/hppa/ia64/link.h: Renamed to... * sysdeps/hppa/ia64/linkmap.h: ...this. * sysdeps/hppa/s390/link.h: Renamed to... * sysdeps/hppa/s390/linkmap.h: ...this. * sysdeps/hppa/sh/link.h: Renamed to... * sysdeps/hppa/sh/linkmap.h: ...this. * sysdeps/hppa/x86_64/link.h: Renamed to... * sysdeps/hppa/x86_64/linkmap.h: ...this. 2005-01-06 Ulrich Drepper <drepper@redhat.com> * allocatestack.c (init_one_static_tls): Adjust initialization of DTV entry for static tls deallocation fix. * sysdeps/alpha/tls.h (dtv_t): Change pointer type to be struct which also contains information whether the memory pointed to is static TLS or not. * sysdeps/i386/tls.h: Likewise. * sysdeps/ia64/tls.h: Likewise. * sysdeps/powerpc/tls.h: Likewise. * sysdeps/s390/tls.h: Likewise. * sysdeps/sh/tls.h: Likewise. * sysdeps/sparc/tls.h: Likewise. * sysdeps/x86_64/tls.h: Likewise.
2005-01-06 23:40:27 +01:00
/* 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,
#ifdef LIBC_START_MAIN_AUXVEC_ARG
ElfW(auxv_t) *auxvec,
#endif
__typeof (main) init,
void (*fini) (void),
void (*rtld_fini) (void), void *stack_end)
{
#ifndef SHARED
char **ev = &argv[argc + 1];
__environ = ev;
/* Store the lowest stack address. This is done in ld.so if this is
the code for the DSO. */
Update. 1998-06-07 13:32 Ulrich Drepper <drepper@cygnus.com> * libc.map: Add _dl_profile. * elf/dl-reloc.c (_dl_relocate_object): Take extra argument, pass this to ELF_DYNAMIC_RELOCATE. Always allocate array for relocation result if LD_PROFILE is defined. * elf/ldsodefs.h: Adjust prototypes. * elf/dl-open.c (_dl_open): Call relocation function with extra argument. * elf/rtld.c: Likewise. * elf/dl-profile.c (_dl_mcount): Don't mark as internal function. Correct loop condition. * elf/dynamic-link.h: Don't examine _dl_profile variable, pass consider_profile to runtime setup function. * sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Use _dl_runtime_profile for all shared objects if LD_PROFILE is defined. * elf/dl-support.c: Define __libc_stack_end. * elf/rtld.c: Likewise. * sysdeps/generic/libc-start.c: Store last stack address in __libc_stack_end. * sysdeps/i386/dl-machine.h (_dl_start_user): Store stack address. * sysdeps/i386/elf/start.s: Call __libc_start_main with extra argument. * elf/elf.h: Include <features.h>, not <sys/cdefs.h>. Include <stdint.h>, not <inttypes.h>. * elf/sprof.c: Implement flat profiling. * libio/fgetc.c: Call _IO_cleanup_region_end with 0 and call _IO_funlockfile explicitly. * libio/fileops.c: Likewise. * libio/fputc.c: Likewise. * libio/freopen.c: Likewise. * libio/freopen64.c: Likewise. * libio/fseek.c: Likewise. * libio/fseeko.c: Likewise. * libio/fseeko64.c: Likewise. * libio/ftello.c: Likewise. * libio/ftello64.c: Likewise. * libio/getc.c: Likewise. * libio/getchar.c: Likewise. * libio/iofclose.c: Likewise. * libio/iofflush.c: Likewise. * libio/iofgetpos.c: Likewise. * libio/iofgetpos64.c: Likewise. * libio/iofgets.c: Likewise. * libio/iofputs.c: Likewise. * libio/iofread.c: Likewise. * libio/iofsetpos.c: Likewise. * libio/iofsetpos64.c: Likewise. * libio/ioftell.c: Likewise. * libio/iofwrite.c: Likewise. * libio/iogetdelim.c: Likewise. * libio/iogets.c: Likewise. * libio/ioputs.c: Likewise. * libio/ioseekoff.c: Likewise. * libio/ioseekpos.c: Likewise. * libio/iosetbuffer.c: Likewise. * libio/iosetvbuf.c: Likewise. * libio/ioungetc.c: Likewise. * libio/iovsprintf.c: Likewise. * libio/iovsscanf.c: Likewise. * libio/oldfileops.c: Likewise. * libio/oldiofclose.c: Likewise. * libio/peekc.c: Likewise. * libio/putc.c: Likewise. * libio/putchar.c: Likewise. * libio/rewind.c: Likewise. * malloc/mtrace.c: Pretty print. * misc/mntent.h (struct mentent): Make string elements const char *. * nis/nis_printf.c: Optimize I/O a little bit. * signal/Makefile (distribute): Add sigset-cvt-mask.h. * sysdeps/generic/sigset-cvt-mask.h: New file. * sysdeps/unix/sysv/linux/sigset-cvt-mask.h: New file. * sysdeps/unix/sysv/sysv4/sigset-cvt-mask.h: New file. * sysdeps/posix/sigvec.c: Rewrite the use definitions from sigset-cvt-mask.h to do the dirty work. Patches by Joe Keane. * sysdeps/posix/mkstemp.c: Save one precious byte of rodata. * sysdeps/unix/sysv/linux/i386/sysdep.h: Rewrite PSEUDO etc to make syscall_error label in case of PIC anonymous. * sysdeps/unix/sysv/linux/i386/i686/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/i386/clone.S: Adapt for this change. * sysdeps/unix/sysv/linux/i386/mmap.S: Adapt for this change. * sysdeps/unix/sysv/linux/i386/s_pread64.S: Adapt for this change. * sysdeps/unix/sysv/linux/i386/s_pwrite64.S: Adapt for this change. * sysdeps/unix/sysv/linux/i386/socket.S: Adapt for this change. * sysdeps/unix/sysv/linux/i386/syscall.S: Adapt for this change.
1998-06-07 16:06:56 +02:00
__libc_stack_end = stack_end;
Update. 1998-03-18 14:25 Ulrich Drepper <drepper@cygnus.com> * string/bits/string2.h: Add optimization for strdup. Always define __strsep and __strtok_r and make real names available when feature select macros are defined. 1998-03-18 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/install.texi (Installation): Use i486-linux as example instead of the unsupported sunos4. (Reporting Bugs): Mention glibcbug script. (Tools for Installation): gcc 2.8.1/egcs 1.0.2 is required. 1998-03-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/wordexp-tst.sh: Make portable. Add more tests. * posix/Makefile (do-globtest do-wordexp-test): New targets. 1998-03-18 13:38 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/libc-start.c: Moved to ... * sysdeps/generic/libc-start.c: ...here, replacing former content. * sysdeps/unix/sysv/linux/Dist: Add netash/ash.h and netpacket/packet.h. * sysdeps/unix/sysv/linux/bits/socket.h: Pretty print. 1998-03-17 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/bits/resource.h: Remove trailing comma in enumerator for strict standard compliance. * sysdeps/generic/bits/resource.h: Likewise. 1998-03-18 10:04 Philip Blundell <pb@nexus.co.uk> * sysdeps/arm/sysdep.h (__ARM_USES_FP): Deleted. (PLTJMP): New macro. * sysdeps/arm/fpu/__longjmp.S: New file, implementation of longjmp() when floating point enabled. * sysdeps/arm/fpu/setjmp.S: Likewise for setjmp(). * sysdeps/arm/__longjmp.S: Remove floating point code. * sysdeps/arm/setjmp.S: Likewise. * sysdeps/arm/bsd-setjmp.S: Call __sigsetjmp by correct name. * sysdeps/arm/bsd-_setjmp.S: Likewise. * sysdeps/arm/memset.S: New file; optimised ARM implementation of memset(). * sysdeps/generic/setsockopt.c (setsockopt): Keep in step with prototype. 1998-03-17 16:16 Philip Blundell <pb@nexus.co.uk> Based on patches from Pat Beirne and Scott Bambrough: * sysdeps/arm/__longjmp.S: Use ip, not r2, as temporary. * sysdeps/arm/bits/fenv.h: New file. * sysdeps/arm/dl-machine.h: New file. Add ELF support. * sysdeps/arm/elf/setjmp.S: Likewise. * sysdeps/arm/elf/start.S: Likewise. * sysdeps/arm/init-first.c: Likewise. * sysdeps/arm/setjmp.S: Call __sigjmp_save through PLT * sysdeps/arm/sysdep.h: Change format of .type directive. Correct comment about floating point to reflect current reality. * sysdeps/unix/arm/brk.S: Support PIC. * sysdeps/unix/arm/sysdep.S (syscall_error): Support PIC and re-entrant code. * sysdeps/unix/sysv/linux/arm/socket.S: Check correctly for error return; call syscall_error through PLT. * sysdeps/unix/sysv/linux/arm/sysdep.h (ENTRY): Correct error jump. 1998-03-04 12:01 Philip Blundell <pb@nexus.co.uk> * sysdeps/unix/sysv/linux/netpacket/packet.h: New file. * sysdeps/unix/sysv/linux/netash/ash.h: Likewise. * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Install them.
1998-03-18 15:42:25 +01:00
# ifdef HAVE_AUX_VECTOR
/* First process the auxiliary vector since we need to find the
program header to locate an eventually present PT_TLS entry. */
# ifndef LIBC_START_MAIN_AUXVEC_ARG
ElfW(auxv_t) *auxvec;
{
char **evp = ev;
while (*evp++ != NULL)
;
auxvec = (ElfW(auxv_t) *) evp;
}
# endif
_dl_aux_init (auxvec);
if (GL(dl_phdr) == NULL)
# endif
{
/* Starting from binutils-2.23, the linker will define the
magic symbol __ehdr_start to point to our own ELF header
if it is visible in a segment that also includes the phdrs.
So we can set up _dl_phdr and _dl_phnum even without any
information from auxv. */
extern const ElfW(Ehdr) __ehdr_start
# if BUILD_PIE_DEFAULT
__attribute__ ((visibility ("hidden")));
# else
__attribute__ ((weak, visibility ("hidden")));
if (&__ehdr_start != NULL)
# endif
{
assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr));
GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff;
GL(dl_phnum) = __ehdr_start.e_phnum;
}
}
Add framework for tunables The tunables framework allows us to uniformly manage and expose global variables inside glibc as switches to users. tunables/README has instructions for glibc developers to add new tunables. Tunables support can be enabled by passing the --enable-tunables configure flag to the configure script. This patch only adds a framework and does not pose any limitations on how tunable values are read from the user. It also adds environment variables used in malloc behaviour tweaking to the tunables framework as a PoC of the compatibility interface. * manual/install.texi: Add --enable-tunables option. * INSTALL: Regenerate. * README.tunables: New file. * Makeconfig (CPPFLAGS): Define TOP_NAMESPACE. (before-compile): Generate dl-tunable-list.h early. * config.h.in: Add HAVE_TUNABLES. * config.make.in: Add have-tunables. * configure.ac: Add --enable-tunables option. * configure: Regenerate. * csu/init-first.c (__libc_init_first): Move __libc_init_secure earlier... * csu/init-first.c (LIBC_START_MAIN):... to here. Include dl-tunables.h, libc-internal.h. (LIBC_START_MAIN) [!SHARED]: Initialize tunables for static binaries. * elf/Makefile (dl-routines): Add dl-tunables. * elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE namespace. * elf/dl-support (_dl_nondynamic_init): Unset MALLOC_CHECK_ only when !HAVE_TUNABLES. * elf/rtld.c (process_envvars): Likewise. * elf/dl-sysdep.c [HAVE_TUNABLES]: Include dl-tunables.h (_dl_sysdep_start): Call __tunables_init. * elf/dl-tunable-types.h: New file. * elf/dl-tunables.c: New file. * elf/dl-tunables.h: New file. * elf/dl-tunables.list: New file. * malloc/tst-malloc-usable-static.c: New test case. * malloc/Makefile (tests-static): Add it. * malloc/arena.c [HAVE_TUNABLES]: Include dl-tunables.h. Define TUNABLE_NAMESPACE. (DL_TUNABLE_CALLBACK (set_mallopt_check)): New function. (DL_TUNABLE_CALLBACK_FNDECL): New macro. Use it to define callback functions. (ptmalloc_init): Set tunable values. * scripts/gen-tunables.awk: New file. * sysdeps/mach/hurd/dl-sysdep.c: Include dl-tunables.h. (_dl_sysdep_start): Call __tunables_init.
2016-12-31 19:02:17 +01:00
__tunables_init (__environ);
ARCH_INIT_CPU_FEATURES ();
/* Do static pie self relocation after tunables and cpu features
are setup for ifunc resolvers. Before this point relocations
must be avoided. */
_dl_relocate_static_pie ();
/* Perform IREL{,A} relocations. */
powerpc: Fix float128 IFUNC relocations [BZ #21707] The patch proposed by Peter Bergner [1] to libgcc in order to fix [BZ #21707] adds a dependency on a symbol provided by the loader, forcing the loader to be linked to tests after libgcc was linked. It also requires to read the thread pointer during IRELA relocations. Tested on powerpc, powerpc64, powerpc64le, s390x and x86_64. [1] https://sourceware.org/ml/libc-alpha/2017-06/msg01383.html [BZ #21707] * csu/libc-start.c (LIBC_START_MAIN): Perform IREL{,A} relocations before or after initializing the TCB on statically linked executables. That's a per-architecture definition. * elf/rtld.c (dl_main): Add a comment about thread-local variables initialization. * sysdeps/generic/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL. * sysdeps/powerpc/Makefile: [$(subdir) = elf && $(multi-arch) != no] (tests-static-internal): Add tst-tlsifunc-static. [$(subdir) = elf && $(multi-arch) != no && $(build-shared) == yes] (tests-internal): Add tst-tlsifunc. * sysdeps/powerpc/tst-tlsifunc.c: New file. * sysdeps/powerpc/tst-tlsifunc-static.c: Likewise. * sysdeps/powerpc/powerpc64le/Makefile (f128-loader-link): New variable. [$(subdir) = math] (test-float128% test-ifloat128%): Force linking to the loader after linking to libgcc. [$(subdir) = wcsmbs || $(subdir) = stdlib] (bug-strtod bug-strtod2) (bug-strtod2 tst-strtod-round tst-wcstod-round tst-strtod6 tst-strrom) (tst-strfrom-locale strfrom-skeleton): Likewise. * sysdeps/unix/sysv/linux/powerpc/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL.
2017-07-17 22:48:59 +02:00
ARCH_SETUP_IREL ();
/* The stack guard goes into the TCB, so initialize it early. */
ARCH_SETUP_TLS ();
powerpc: Fix float128 IFUNC relocations [BZ #21707] The patch proposed by Peter Bergner [1] to libgcc in order to fix [BZ #21707] adds a dependency on a symbol provided by the loader, forcing the loader to be linked to tests after libgcc was linked. It also requires to read the thread pointer during IRELA relocations. Tested on powerpc, powerpc64, powerpc64le, s390x and x86_64. [1] https://sourceware.org/ml/libc-alpha/2017-06/msg01383.html [BZ #21707] * csu/libc-start.c (LIBC_START_MAIN): Perform IREL{,A} relocations before or after initializing the TCB on statically linked executables. That's a per-architecture definition. * elf/rtld.c (dl_main): Add a comment about thread-local variables initialization. * sysdeps/generic/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL. * sysdeps/powerpc/Makefile: [$(subdir) = elf && $(multi-arch) != no] (tests-static-internal): Add tst-tlsifunc-static. [$(subdir) = elf && $(multi-arch) != no && $(build-shared) == yes] (tests-internal): Add tst-tlsifunc. * sysdeps/powerpc/tst-tlsifunc.c: New file. * sysdeps/powerpc/tst-tlsifunc-static.c: Likewise. * sysdeps/powerpc/powerpc64le/Makefile (f128-loader-link): New variable. [$(subdir) = math] (test-float128% test-ifloat128%): Force linking to the loader after linking to libgcc. [$(subdir) = wcsmbs || $(subdir) = stdlib] (bug-strtod bug-strtod2) (bug-strtod2 tst-strtod-round tst-wcstod-round tst-strtod6 tst-strrom) (tst-strfrom-locale strfrom-skeleton): Likewise. * sysdeps/unix/sysv/linux/powerpc/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL.
2017-07-17 22:48:59 +02:00
/* In some architectures, IREL{,A} relocations happen after TLS setup in
order to let IFUNC resolvers benefit from TCB information, e.g. powerpc's
hwcap and platform fields available in the TCB. */
ARCH_APPLY_IREL ();
/* Set up the stack checker's canary. */
uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
# ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
# else
__stack_chk_guard = stack_chk_guard;
# endif
/* Initialize libpthread if linked in. */
if (__pthread_initialize_minimal != NULL)
__pthread_initialize_minimal ();
/* Set up the pointer guard value. */
uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
stack_chk_guard);
# ifdef THREAD_SET_POINTER_GUARD
THREAD_SET_POINTER_GUARD (pointer_chk_guard);
# else
__pointer_chk_guard_local = pointer_chk_guard;
# endif
powerpc: Fix float128 IFUNC relocations [BZ #21707] The patch proposed by Peter Bergner [1] to libgcc in order to fix [BZ #21707] adds a dependency on a symbol provided by the loader, forcing the loader to be linked to tests after libgcc was linked. It also requires to read the thread pointer during IRELA relocations. Tested on powerpc, powerpc64, powerpc64le, s390x and x86_64. [1] https://sourceware.org/ml/libc-alpha/2017-06/msg01383.html [BZ #21707] * csu/libc-start.c (LIBC_START_MAIN): Perform IREL{,A} relocations before or after initializing the TCB on statically linked executables. That's a per-architecture definition. * elf/rtld.c (dl_main): Add a comment about thread-local variables initialization. * sysdeps/generic/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL. * sysdeps/powerpc/Makefile: [$(subdir) = elf && $(multi-arch) != no] (tests-static-internal): Add tst-tlsifunc-static. [$(subdir) = elf && $(multi-arch) != no && $(build-shared) == yes] (tests-internal): Add tst-tlsifunc. * sysdeps/powerpc/tst-tlsifunc.c: New file. * sysdeps/powerpc/tst-tlsifunc-static.c: Likewise. * sysdeps/powerpc/powerpc64le/Makefile (f128-loader-link): New variable. [$(subdir) = math] (test-float128% test-ifloat128%): Force linking to the loader after linking to libgcc. [$(subdir) = wcsmbs || $(subdir) = stdlib] (bug-strtod bug-strtod2) (bug-strtod2 tst-strtod-round tst-wcstod-round tst-strtod6 tst-strrom) (tst-strfrom-locale strfrom-skeleton): Likewise. * sysdeps/unix/sysv/linux/powerpc/libc-start.h: New file. Define ARCH_APPLY_IREL and ARCH_SETUP_IREL.
2017-07-17 22:48:59 +02:00
#endif /* !SHARED */
/* Register the destructor of the dynamic linker if there is any. */
if (__glibc_likely (rtld_fini != NULL))
__cxa_atexit ((void (*) (void *)) rtld_fini, NULL, NULL);
#ifndef SHARED
elf: Implement __libc_early_init This function is defined in libc.so, and the dynamic loader calls right after relocation has been finished, before any ELF constructors or the preinit function is invoked. It is also used in the static build for initializing parts of the static libc. To locate __libc_early_init, a direct symbol lookup function is used, _dl_lookup_direct. It does not search the entire symbol scope and consults merely a single link map. This function could also be used to implement lookups in the vDSO (as an optimization). A per-namespace variable (libc_map) is added for locating libc.so, to avoid repeated traversals of the search scope. It is similar to GL(dl_initfirst). An alternative would have been to thread a context argument from _dl_open down to _dl_map_object_from_fd (where libc.so is identified). This could have avoided the global variable, but the change would be larger as a result. It would not have been possible to use this to replace GL(dl_initfirst) because that global variable is used to pass the function pointer past the stack switch from dl_main to the main program. Replacing that requires adding a new argument to _dl_init, which in turn needs changes to the architecture-specific libc.so startup code written in assembler. __libc_early_init should not be used to replace _dl_var_init (as it exists today on some architectures). Instead, _dl_lookup_direct should be used to look up a new variable symbol in libc.so, and that should then be initialized from the dynamic loader, immediately after the object has been loaded in _dl_map_object_from_fd (before relocation is run). This way, more IFUNC resolvers which depend on these variables will work. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-04-24 22:31:15 +02:00
/* Perform early initialization. In the shared case, this function
is called from the dynamic loader as early as possible. */
__libc_early_init (true);
elf: Implement __libc_early_init This function is defined in libc.so, and the dynamic loader calls right after relocation has been finished, before any ELF constructors or the preinit function is invoked. It is also used in the static build for initializing parts of the static libc. To locate __libc_early_init, a direct symbol lookup function is used, _dl_lookup_direct. It does not search the entire symbol scope and consults merely a single link map. This function could also be used to implement lookups in the vDSO (as an optimization). A per-namespace variable (libc_map) is added for locating libc.so, to avoid repeated traversals of the search scope. It is similar to GL(dl_initfirst). An alternative would have been to thread a context argument from _dl_open down to _dl_map_object_from_fd (where libc.so is identified). This could have avoided the global variable, but the change would be larger as a result. It would not have been possible to use this to replace GL(dl_initfirst) because that global variable is used to pass the function pointer past the stack switch from dl_main to the main program. Replacing that requires adding a new argument to _dl_init, which in turn needs changes to the architecture-specific libc.so startup code written in assembler. __libc_early_init should not be used to replace _dl_var_init (as it exists today on some architectures). Instead, _dl_lookup_direct should be used to look up a new variable symbol in libc.so, and that should then be initialized from the dynamic loader, immediately after the object has been loaded in _dl_map_object_from_fd (before relocation is run). This way, more IFUNC resolvers which depend on these variables will work. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-04-24 22:31:15 +02:00
Update. 2000-03-30 Ulrich Drepper <drepper@redhat.com> Implement dynamic determination of constructor/destructor order in the dynamic linker. * elf/Versions [ld.so] (GLIBC_2.0): Remove _dl_init_next. (GLIBC_2.2): Add _dl_init. * elf/dl-close.c: Also call all destructors in FINI_ARRAY. r_duplist is not anymore allocated separately. l_initfini is and therefore free it if necessary. * elf/dl-deps.c: If a searchlist has to be allocated, put all in one malloc block. Otherwise allocate l_initfini list only. Put dependencies for the object in l_initfini list. Sort dependencies for the object to be loaded topologically. * elf/dl-fini.c: Before running the destructors sort the topologically. * elf/dl-init.c (_dl_init): Renamed from _dl_init_next. Rewrite to call constructors instead of iterating over the pointers. Get list of objects for which to run constructors from l_initfini element. Accept argc, argv, and env as parameters and pass them to the constructors. * elf/ld-load.c (_dl_map_object_from_fd): Initialize l_ldnum member with size of dynamic section. * elf/dl-open.c (dl_open_worker): Only call _dl_init instead of _dl_init_next and calling constructors ourself. * elf/dl-preinit.c (_dl_preinit): Renamed from _dl_preinit_next. Take argc, argv, and env as parameters and pass them to the constructors. Rewrite to call all constructors and not iterate over the pointers. * elf/dynamic-link.h: Don't relocate DT_FINI_ARRAY entry. Don't precompute l_initcount and l_preinitcount. * elf/link.h (struct link_map): Add l_ldnum member. Make l_phdr_allocated part of the bitfield. Remove l_runcount, l_initcount, and l_preinitcount. Add l_initfini. * sysdeps/generic/ldsodefs.h: Replace _dl_init_next prototype with one for _dl_init. * sysdeps/i386/dl-machine (RTLD_START): Rewrite to match new init function interface. * sysdeps/unix/sysv/linux/init-first.h: Removed. * sysdeps/unix/sysv/linux/Dist: Delete file here as well. * sysdeps/unix/sysv/linux/init-first.c [PIC]: Don't use SYSDEP_CALL_INIT. Make _init a strong alias of init. The calling conventions now match. * sysdeps/generic/libc-start.c: Calling __libc_init_first has no effect for shared objects. Don't emit message and call only for static library.
2000-03-30 18:30:49 +02:00
/* Call the initializer of the libc. This is only needed here if we
are compiling for the static library in which case we haven't
run the constructors in `_dl_start_user'. */
Update. 1998-03-18 14:25 Ulrich Drepper <drepper@cygnus.com> * string/bits/string2.h: Add optimization for strdup. Always define __strsep and __strtok_r and make real names available when feature select macros are defined. 1998-03-18 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/install.texi (Installation): Use i486-linux as example instead of the unsupported sunos4. (Reporting Bugs): Mention glibcbug script. (Tools for Installation): gcc 2.8.1/egcs 1.0.2 is required. 1998-03-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/wordexp-tst.sh: Make portable. Add more tests. * posix/Makefile (do-globtest do-wordexp-test): New targets. 1998-03-18 13:38 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/libc-start.c: Moved to ... * sysdeps/generic/libc-start.c: ...here, replacing former content. * sysdeps/unix/sysv/linux/Dist: Add netash/ash.h and netpacket/packet.h. * sysdeps/unix/sysv/linux/bits/socket.h: Pretty print. 1998-03-17 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/bits/resource.h: Remove trailing comma in enumerator for strict standard compliance. * sysdeps/generic/bits/resource.h: Likewise. 1998-03-18 10:04 Philip Blundell <pb@nexus.co.uk> * sysdeps/arm/sysdep.h (__ARM_USES_FP): Deleted. (PLTJMP): New macro. * sysdeps/arm/fpu/__longjmp.S: New file, implementation of longjmp() when floating point enabled. * sysdeps/arm/fpu/setjmp.S: Likewise for setjmp(). * sysdeps/arm/__longjmp.S: Remove floating point code. * sysdeps/arm/setjmp.S: Likewise. * sysdeps/arm/bsd-setjmp.S: Call __sigsetjmp by correct name. * sysdeps/arm/bsd-_setjmp.S: Likewise. * sysdeps/arm/memset.S: New file; optimised ARM implementation of memset(). * sysdeps/generic/setsockopt.c (setsockopt): Keep in step with prototype. 1998-03-17 16:16 Philip Blundell <pb@nexus.co.uk> Based on patches from Pat Beirne and Scott Bambrough: * sysdeps/arm/__longjmp.S: Use ip, not r2, as temporary. * sysdeps/arm/bits/fenv.h: New file. * sysdeps/arm/dl-machine.h: New file. Add ELF support. * sysdeps/arm/elf/setjmp.S: Likewise. * sysdeps/arm/elf/start.S: Likewise. * sysdeps/arm/init-first.c: Likewise. * sysdeps/arm/setjmp.S: Call __sigjmp_save through PLT * sysdeps/arm/sysdep.h: Change format of .type directive. Correct comment about floating point to reflect current reality. * sysdeps/unix/arm/brk.S: Support PIC. * sysdeps/unix/arm/sysdep.S (syscall_error): Support PIC and re-entrant code. * sysdeps/unix/sysv/linux/arm/socket.S: Check correctly for error return; call syscall_error through PLT. * sysdeps/unix/sysv/linux/arm/sysdep.h (ENTRY): Correct error jump. 1998-03-04 12:01 Philip Blundell <pb@nexus.co.uk> * sysdeps/unix/sysv/linux/netpacket/packet.h: New file. * sysdeps/unix/sysv/linux/netash/ash.h: Likewise. * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Install them.
1998-03-18 15:42:25 +01:00
__libc_init_first (argc, argv, __environ);
/* 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
only for statically linked applications since otherwise the dynamic
loader did the work already. */
if (__builtin_expect (__libc_enable_secure, 0))
__libc_check_standard_fds ();
#endif /* !SHARED */
* elf/dl-runtime.c (fixup, profile_fixup): The final arg to _dl_lookup_*symbol is DL_LOOKUP_NOPLT not ELF_MACHINE_JMP_SLOT. * elf/elf.h (EM_SPARC64): Remove. (EM_SPARC32PLUS, EM_SPARCV9): Add. (HWCAP_SPARC_V9): Add. * elf/ldsodefs.h (_dl_hwcap): Declare. * sysdeps/sparc/sparc32/dl-machine.h (_dl_hwcap, _dl_hwcap_mask): Weaken so dlopen from static progies works. (WEAKADDR): New macro. (elf_machine_matches_host): Accept EM_SPARC32PLUS on a v9 cpu. (LD_SO_PRELOAD): New macro. (elf_machine_fixup_plt): Cope with weak _dl_hwcap. (elf_machine_rela): Weaken _dl_rtld_map. * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Rename __libc_clone to __clone, and remove the later's alias. * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c: Copy to/from the kernel's structure. 1998-04-06 Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz> * elf/dl-runtime.c (fixup, profile_fixup): The final arg to _dl_lookup_*symbol is DL_LOOKUP_NOPLT not ELF_MACHINE_JMP_SLOT. * elf/elf.h (EM_SPARC64): Remove. (EM_SPARC32PLUS, EM_SPARCV9): Add. (HWCAP_SPARC_V9): Add. * elf/ldsodefs.h (_dl_hwcap): Declare. * sysdeps/sparc/sparc32/dl-machine.h (_dl_hwcap, _dl_hwcap_mask): Weaken so dlopen from static progies works. (WEAKADDR): New macro. (elf_machine_matches_host): Accept EM_SPARC32PLUS on a v9 cpu. (LD_SO_PRELOAD): New macro. (elf_machine_fixup_plt): Cope with weak _dl_hwcap. (elf_machine_rela): Weaken _dl_rtld_map. * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Rename __libc_clone to __clone, and remove the later's alias. * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c: Copy to/from the kernel's structure. * sysdeps/generic/libc-start.c: Allow init and fini to be null.
1998-04-06 21:08:46 +02:00
/* Call the initializer of the program, if any. */
#ifdef SHARED
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
2004-03-06 09:19:29 +01:00
GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
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);
* csu/elf-init.c (__libc_csu_fini): Don't do anything here. * sysdeps/generic/libc-start.c: Don't register program destructor here. * dlfcn/Makefile: Add rules to build dlfcn.c. (LDFLAGS-dl.so): Removed. * dlfcn/dlclose.c: _dl_close is now in ld.so, use function pointer table. * dlfcn/dlmopen.c: Likewise for _dl_open. * dlfcn/dlopen.c: Likewise. * dlfcn/dlopenold.c: Likewise. * elf/dl-libc.c: Likewise for _dl_open and _dl_close. * elf/Makefile (routines): Remove dl-open and dl-close. (dl-routines): Add dl-open, dl-close, and dl-trampoline. Add rules to build and run tst-audit1. * elf/tst-audit1.c: New file. * elf/tst-auditmod1.c: New file. * elf/Versions [libc]: Remove _dl_open and _dl_close. * elf/dl-close.c: Change for use inside ld.so instead of libc.so. * elf/dl-open.c: Likewise. * elf/dl-debug.c (_dl_debug_initialize): Allow reinitialization, signaled by nonzero parameter. * elf/dl-init.c: Fix use of r_state. * elf/dl-load.c: Likewise. * elf/dl-close.c: Add auditing checkpoints. * elf/dl-open.c: Likewise. * elf/dl-fini.c: Likewise. * elf/dl-load.c: Likewise. * elf/dl-sym.c: Likewise. * sysdeps/generic/libc-start.c: Likewise. * elf/dl-object.c: Allocate memory for auditing information. * elf/dl-reloc.c: Remove RESOLV. We now always need the map. Correctly initialize slotinfo. * elf/dynamic-link.h: Adjust after removal of RESOLV. * sysdeps/hppa/dl-lookupcfg.h: Likewise. * sysdeps/ia64/dl-lookupcfg.h: Likewise. * sysdeps/powerpc/powerpc64/dl-lookupcfg.h: Removed. * elf/dl-runtime.c (_dl_fixup): Little cleanup. (_dl_profile_fixup): New parameters to point to register struct and variable for frame size. Add auditing checkpoints. (_dl_call_pltexit): New function. Don't define trampoline code here. * elf/rtld.c: Recognize LD_AUDIT. Load modules on startup. Remove all the functions from _rtld_global_ro which only _dl_open and _dl_close needed. Add auditing checkpoints. * elf/link.h: Define symbols for auditing interfaces. * include/link.h: Likewise. * include/dlfcn.h: Define __RTLD_AUDIT. Remove prototypes for _dl_open and _dl_close. Adjust access to argc and argv in libdl. * dlfcn/dlfcn.c: New file. * sysdeps/generic/dl-lookupcfg.h: Remove all content now that RESOLVE is gone. * sysdeps/generic/ldsodefs.h: Add definitions for auditing interfaces. * sysdeps/generic/unsecvars.h: Add LD_AUDIT. * sysdeps/i386/dl-machine.h: Remove trampoline code here. Adjust for removal of RESOLVE. * sysdeps/x86_64/dl-machine.h: Likewise. * sysdeps/generic/dl-trampoline.c: New file. * sysdeps/i386/dl-trampoline.c: New file. * sysdeps/x86_64/dl-trampoline.c: New file. * sysdeps/generic/dl-tls.c: Cleanups. Fixup for dtv_t change. Fix updating of DTV. * sysdeps/generic/libc-tls.c: Likewise. * sysdeps/arm/bits/link.h: Renamed to ... * sysdeps/arm/buts/linkmap.h: ...this. * sysdeps/generic/bits/link.h: Renamed to... * sysdeps/generic/bits/linkmap.h: ...this. * sysdeps/hppa/bits/link.h: Renamed to... * sysdeps/hppa/bits/linkmap.h: ...this. * sysdeps/hppa/i386/link.h: Renamed to... * sysdeps/hppa/i386/linkmap.h: ...this. * sysdeps/hppa/ia64/link.h: Renamed to... * sysdeps/hppa/ia64/linkmap.h: ...this. * sysdeps/hppa/s390/link.h: Renamed to... * sysdeps/hppa/s390/linkmap.h: ...this. * sysdeps/hppa/sh/link.h: Renamed to... * sysdeps/hppa/sh/linkmap.h: ...this. * sysdeps/hppa/x86_64/link.h: Renamed to... * sysdeps/hppa/x86_64/linkmap.h: ...this. 2005-01-06 Ulrich Drepper <drepper@redhat.com> * allocatestack.c (init_one_static_tls): Adjust initialization of DTV entry for static tls deallocation fix. * sysdeps/alpha/tls.h (dtv_t): Change pointer type to be struct which also contains information whether the memory pointed to is static TLS or not. * sysdeps/i386/tls.h: Likewise. * sysdeps/ia64/tls.h: Likewise. * sysdeps/powerpc/tls.h: Likewise. * sysdeps/s390/tls.h: Likewise. * sysdeps/sh/tls.h: Likewise. * sysdeps/sparc/tls.h: Likewise. * sysdeps/x86_64/tls.h: Likewise.
2005-01-06 23:40:27 +01:00
/* Auditing checkpoint: we have a new object. */
_dl_audit_preinit (GL(dl_ns)[LM_ID_BASE]._ns_loaded);
* csu/elf-init.c (__libc_csu_fini): Don't do anything here. * sysdeps/generic/libc-start.c: Don't register program destructor here. * dlfcn/Makefile: Add rules to build dlfcn.c. (LDFLAGS-dl.so): Removed. * dlfcn/dlclose.c: _dl_close is now in ld.so, use function pointer table. * dlfcn/dlmopen.c: Likewise for _dl_open. * dlfcn/dlopen.c: Likewise. * dlfcn/dlopenold.c: Likewise. * elf/dl-libc.c: Likewise for _dl_open and _dl_close. * elf/Makefile (routines): Remove dl-open and dl-close. (dl-routines): Add dl-open, dl-close, and dl-trampoline. Add rules to build and run tst-audit1. * elf/tst-audit1.c: New file. * elf/tst-auditmod1.c: New file. * elf/Versions [libc]: Remove _dl_open and _dl_close. * elf/dl-close.c: Change for use inside ld.so instead of libc.so. * elf/dl-open.c: Likewise. * elf/dl-debug.c (_dl_debug_initialize): Allow reinitialization, signaled by nonzero parameter. * elf/dl-init.c: Fix use of r_state. * elf/dl-load.c: Likewise. * elf/dl-close.c: Add auditing checkpoints. * elf/dl-open.c: Likewise. * elf/dl-fini.c: Likewise. * elf/dl-load.c: Likewise. * elf/dl-sym.c: Likewise. * sysdeps/generic/libc-start.c: Likewise. * elf/dl-object.c: Allocate memory for auditing information. * elf/dl-reloc.c: Remove RESOLV. We now always need the map. Correctly initialize slotinfo. * elf/dynamic-link.h: Adjust after removal of RESOLV. * sysdeps/hppa/dl-lookupcfg.h: Likewise. * sysdeps/ia64/dl-lookupcfg.h: Likewise. * sysdeps/powerpc/powerpc64/dl-lookupcfg.h: Removed. * elf/dl-runtime.c (_dl_fixup): Little cleanup. (_dl_profile_fixup): New parameters to point to register struct and variable for frame size. Add auditing checkpoints. (_dl_call_pltexit): New function. Don't define trampoline code here. * elf/rtld.c: Recognize LD_AUDIT. Load modules on startup. Remove all the functions from _rtld_global_ro which only _dl_open and _dl_close needed. Add auditing checkpoints. * elf/link.h: Define symbols for auditing interfaces. * include/link.h: Likewise. * include/dlfcn.h: Define __RTLD_AUDIT. Remove prototypes for _dl_open and _dl_close. Adjust access to argc and argv in libdl. * dlfcn/dlfcn.c: New file. * sysdeps/generic/dl-lookupcfg.h: Remove all content now that RESOLVE is gone. * sysdeps/generic/ldsodefs.h: Add definitions for auditing interfaces. * sysdeps/generic/unsecvars.h: Add LD_AUDIT. * sysdeps/i386/dl-machine.h: Remove trampoline code here. Adjust for removal of RESOLVE. * sysdeps/x86_64/dl-machine.h: Likewise. * sysdeps/generic/dl-trampoline.c: New file. * sysdeps/i386/dl-trampoline.c: New file. * sysdeps/x86_64/dl-trampoline.c: New file. * sysdeps/generic/dl-tls.c: Cleanups. Fixup for dtv_t change. Fix updating of DTV. * sysdeps/generic/libc-tls.c: Likewise. * sysdeps/arm/bits/link.h: Renamed to ... * sysdeps/arm/buts/linkmap.h: ...this. * sysdeps/generic/bits/link.h: Renamed to... * sysdeps/generic/bits/linkmap.h: ...this. * sysdeps/hppa/bits/link.h: Renamed to... * sysdeps/hppa/bits/linkmap.h: ...this. * sysdeps/hppa/i386/link.h: Renamed to... * sysdeps/hppa/i386/linkmap.h: ...this. * sysdeps/hppa/ia64/link.h: Renamed to... * sysdeps/hppa/ia64/linkmap.h: ...this. * sysdeps/hppa/s390/link.h: Renamed to... * sysdeps/hppa/s390/linkmap.h: ...this. * sysdeps/hppa/sh/link.h: Renamed to... * sysdeps/hppa/sh/linkmap.h: ...this. * sysdeps/hppa/x86_64/link.h: Renamed to... * sysdeps/hppa/x86_64/linkmap.h: ...this. 2005-01-06 Ulrich Drepper <drepper@redhat.com> * allocatestack.c (init_one_static_tls): Adjust initialization of DTV entry for static tls deallocation fix. * sysdeps/alpha/tls.h (dtv_t): Change pointer type to be struct which also contains information whether the memory pointed to is static TLS or not. * sysdeps/i386/tls.h: Likewise. * sysdeps/ia64/tls.h: Likewise. * sysdeps/powerpc/tls.h: Likewise. * sysdeps/s390/tls.h: Likewise. * sysdeps/sh/tls.h: Likewise. * sysdeps/sparc/tls.h: Likewise. * sysdeps/x86_64/tls.h: Likewise.
2005-01-06 23:40:27 +01:00
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS))
2004-03-06 09:19:29 +01:00
GLRO(dl_debug_printf) ("\ntransferring control: %s\n\n", argv[0]);
#else /* !SHARED */
call_init (argc, argv, __environ);
Update. 1998-03-18 14:25 Ulrich Drepper <drepper@cygnus.com> * string/bits/string2.h: Add optimization for strdup. Always define __strsep and __strtok_r and make real names available when feature select macros are defined. 1998-03-18 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/install.texi (Installation): Use i486-linux as example instead of the unsupported sunos4. (Reporting Bugs): Mention glibcbug script. (Tools for Installation): gcc 2.8.1/egcs 1.0.2 is required. 1998-03-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/wordexp-tst.sh: Make portable. Add more tests. * posix/Makefile (do-globtest do-wordexp-test): New targets. 1998-03-18 13:38 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/libc-start.c: Moved to ... * sysdeps/generic/libc-start.c: ...here, replacing former content. * sysdeps/unix/sysv/linux/Dist: Add netash/ash.h and netpacket/packet.h. * sysdeps/unix/sysv/linux/bits/socket.h: Pretty print. 1998-03-17 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/bits/resource.h: Remove trailing comma in enumerator for strict standard compliance. * sysdeps/generic/bits/resource.h: Likewise. 1998-03-18 10:04 Philip Blundell <pb@nexus.co.uk> * sysdeps/arm/sysdep.h (__ARM_USES_FP): Deleted. (PLTJMP): New macro. * sysdeps/arm/fpu/__longjmp.S: New file, implementation of longjmp() when floating point enabled. * sysdeps/arm/fpu/setjmp.S: Likewise for setjmp(). * sysdeps/arm/__longjmp.S: Remove floating point code. * sysdeps/arm/setjmp.S: Likewise. * sysdeps/arm/bsd-setjmp.S: Call __sigsetjmp by correct name. * sysdeps/arm/bsd-_setjmp.S: Likewise. * sysdeps/arm/memset.S: New file; optimised ARM implementation of memset(). * sysdeps/generic/setsockopt.c (setsockopt): Keep in step with prototype. 1998-03-17 16:16 Philip Blundell <pb@nexus.co.uk> Based on patches from Pat Beirne and Scott Bambrough: * sysdeps/arm/__longjmp.S: Use ip, not r2, as temporary. * sysdeps/arm/bits/fenv.h: New file. * sysdeps/arm/dl-machine.h: New file. Add ELF support. * sysdeps/arm/elf/setjmp.S: Likewise. * sysdeps/arm/elf/start.S: Likewise. * sysdeps/arm/init-first.c: Likewise. * sysdeps/arm/setjmp.S: Call __sigjmp_save through PLT * sysdeps/arm/sysdep.h: Change format of .type directive. Correct comment about floating point to reflect current reality. * sysdeps/unix/arm/brk.S: Support PIC. * sysdeps/unix/arm/sysdep.S (syscall_error): Support PIC and re-entrant code. * sysdeps/unix/sysv/linux/arm/socket.S: Check correctly for error return; call syscall_error through PLT. * sysdeps/unix/sysv/linux/arm/sysdep.h (ENTRY): Correct error jump. 1998-03-04 12:01 Philip Blundell <pb@nexus.co.uk> * sysdeps/unix/sysv/linux/netpacket/packet.h: New file. * sysdeps/unix/sysv/linux/netash/ash.h: Likewise. * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Install them.
1998-03-18 15:42:25 +01:00
_dl_debug_initialize (0, LM_ID_BASE);
#endif
__libc_start_call_main (main, argc, argv MAIN_AUXVEC_PARAM);
}
/* 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