mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-05 19:35:52 +03:00
* sysdeps/mach/hurd/i386/init-first.c: Replace PIC #ifdefs with SHARED.
(init1): Don't initialize __environ here, since init already does it. (first_init): New function, broken out of _init. (_hurd_stack_setup): Use it. [SHARED] (_dl_init_first): New function, renamed from old _init. (init1) [SHARED]: Don't call posixland_init here. (posixland_init): Take ENVP arg, so signature is usual for initializer. [SHARED] (_init): Define as alias for posixland_init. [! SHARED] (__libc_first_init): Define as alias for posixland_init. * sysdeps/i386/dl-machine.h (RTLD_START): Insert the macro RTLD_START_SPECIAL_INIT before calling initializers. (RTLD_START_SPECIAL_INIT): Define to empty if undefined. * sysdeps/mach/hurd/i386/dl-machine.h: New file. * sysdeps/mach/hurd/dl-sysdep.c (_dl_init_first): New weak function. * elf/Versions ({libc,ld.so}: GLIBC_2.2): Add _dl_init_first.
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -1,5 +1,21 @@
|
|||||||
2000-04-02 Roland McGrath <roland@baalperazim.frob.com>
|
2000-04-02 Roland McGrath <roland@baalperazim.frob.com>
|
||||||
|
|
||||||
|
* sysdeps/mach/hurd/i386/init-first.c: Replace PIC #ifdefs with SHARED.
|
||||||
|
(init1): Don't initialize __environ here, since init already does it.
|
||||||
|
(first_init): New function, broken out of _init.
|
||||||
|
(_hurd_stack_setup): Use it.
|
||||||
|
[SHARED] (_dl_init_first): New function, renamed from old _init.
|
||||||
|
(init1) [SHARED]: Don't call posixland_init here.
|
||||||
|
(posixland_init): Take ENVP arg, so signature is usual for initializer.
|
||||||
|
[SHARED] (_init): Define as alias for posixland_init.
|
||||||
|
[! SHARED] (__libc_first_init): Define as alias for posixland_init.
|
||||||
|
* sysdeps/i386/dl-machine.h (RTLD_START): Insert the macro
|
||||||
|
RTLD_START_SPECIAL_INIT before calling initializers.
|
||||||
|
(RTLD_START_SPECIAL_INIT): Define to empty if undefined.
|
||||||
|
* sysdeps/mach/hurd/i386/dl-machine.h: New file.
|
||||||
|
* sysdeps/mach/hurd/dl-sysdep.c (_dl_init_first): New weak function.
|
||||||
|
* elf/Versions ({libc,ld.so}: GLIBC_2.2): Add _dl_init_first.
|
||||||
|
|
||||||
* stdio-common/tmpfile.c [! USE_IN_LIBIO]: No alias needed,
|
* stdio-common/tmpfile.c [! USE_IN_LIBIO]: No alias needed,
|
||||||
since we define the function with the name `tmpfile'.
|
since we define the function with the name `tmpfile'.
|
||||||
|
|
||||||
|
@@ -8,6 +8,9 @@ libc {
|
|||||||
_dl_mcount_wrapper; _dl_mcount_wrapper_check;
|
_dl_mcount_wrapper; _dl_mcount_wrapper_check;
|
||||||
}
|
}
|
||||||
GLIBC_2.2 {
|
GLIBC_2.2 {
|
||||||
|
# this is defined in ld.so and overridden by libc
|
||||||
|
_dl_init_first;
|
||||||
|
|
||||||
# functions used in other libraries
|
# functions used in other libraries
|
||||||
_dl_sym; _dl_vsym;
|
_dl_sym; _dl_vsym;
|
||||||
}
|
}
|
||||||
@@ -50,5 +53,8 @@ ld.so {
|
|||||||
}
|
}
|
||||||
GLIBC_2.2 {
|
GLIBC_2.2 {
|
||||||
_dl_init;
|
_dl_init;
|
||||||
|
|
||||||
|
# this is defined in ld.so and overridden by libc
|
||||||
|
_dl_init_first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* Machine-dependent ELF dynamic relocation inline functions. i386 version.
|
/* Machine-dependent ELF dynamic relocation inline functions. i386 version.
|
||||||
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@@ -223,19 +223,24 @@ _dl_start_user:\n\
|
|||||||
popl %esi\n\
|
popl %esi\n\
|
||||||
# Adjust the stack pointer to skip _dl_skip_args words.\n\
|
# Adjust the stack pointer to skip _dl_skip_args words.\n\
|
||||||
leal (%esp,%eax,4), %esp\n\
|
leal (%esp,%eax,4), %esp\n\
|
||||||
# Subtract _dl_skip_args from it.\n\
|
# Subtract _dl_skip_args from argc.\n\
|
||||||
subl %eax, %esi\n\
|
subl %eax, %esi\n\
|
||||||
|
# Push argc back on the stack.\n\
|
||||||
|
push %esi\n\
|
||||||
|
# The special initializer gets called with the stack just\n\
|
||||||
|
# as the application's entry point will see it; it can\n\
|
||||||
|
# switch stacks if it moves these contents over.\n\
|
||||||
|
" RTLD_START_SPECIAL_INIT "\n\
|
||||||
# Load the parameters again.\n\
|
# Load the parameters again.\n\
|
||||||
leal 4(%esp,%esi,4), %edx\n\
|
# (eax, edx, ecx, *--esp) = (_dl_loaded, argc, argv, envp)\n\
|
||||||
movl %esp, %ecx\n\
|
leal 8(%esp,%esi,4), %edx\n\
|
||||||
|
leal 4(%esp), %ecx\n\
|
||||||
pushl %edx\n\
|
pushl %edx\n\
|
||||||
movl %esi, %edx\n\
|
movl %esi, %edx\n\
|
||||||
movl _dl_loaded@GOT(%ebx), %eax\n\
|
movl _dl_loaded@GOT(%ebx), %eax\n\
|
||||||
movl (%eax), %eax\n\
|
movl (%eax), %eax\n\
|
||||||
# Call the function to run the initializers.\n\
|
# Call the function to run the initializers.\n\
|
||||||
call _dl_init@PLT\n\
|
call _dl_init@PLT\n\
|
||||||
# Push argc back on the stack.\n\
|
|
||||||
push %esi\n\
|
|
||||||
# Pass our finalizer function to the user in %edx, as per ELF ABI.\n\
|
# Pass our finalizer function to the user in %edx, as per ELF ABI.\n\
|
||||||
movl _dl_fini@GOT(%ebx), %edx\n\
|
movl _dl_fini@GOT(%ebx), %edx\n\
|
||||||
# Jump to the user's entry point.\n\
|
# Jump to the user's entry point.\n\
|
||||||
@@ -243,6 +248,10 @@ _dl_start_user:\n\
|
|||||||
.previous\n\
|
.previous\n\
|
||||||
");
|
");
|
||||||
|
|
||||||
|
#ifndef RTLD_START_SPECIAL_INIT
|
||||||
|
#define RTLD_START_SPECIAL_INIT /* nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Nonzero iff TYPE should not be allowed to resolve to one of
|
/* Nonzero iff TYPE should not be allowed to resolve to one of
|
||||||
the main executable's symbols, as for a COPY reloc. */
|
the main executable's symbols, as for a COPY reloc. */
|
||||||
#define elf_machine_lookup_noexec_p(type) ((type) == R_386_COPY)
|
#define elf_machine_lookup_noexec_p(type) ((type) == R_386_COPY)
|
||||||
|
@@ -730,3 +730,9 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
|
|||||||
*sz = 1;
|
*sz = 1;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void weak_function
|
||||||
|
_dl_init_first (int argc, ...)
|
||||||
|
{
|
||||||
|
/* This no-op definition only gets used if libc is not linked in. */
|
||||||
|
}
|
||||||
|
7
sysdeps/mach/hurd/i386/dl-machine.h
Normal file
7
sysdeps/mach/hurd/i386/dl-machine.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/* Dynamic linker magic for Hurd/i386.
|
||||||
|
This file just gets us a call to _dl_first_init inserted
|
||||||
|
into the asm in sysdeps/i386/dl-machine.h that contains
|
||||||
|
the initializer code. */
|
||||||
|
|
||||||
|
#define RTLD_START_SPECIAL_INIT "call _dl_init_first@PLT"
|
||||||
|
#include_next "dl-machine.h"
|
@@ -1,5 +1,5 @@
|
|||||||
/* Initialization code run first thing by the ELF startup code. For i386/Hurd.
|
/* Initialization code run first thing by the ELF startup code. For i386/Hurd.
|
||||||
Copyright (C) 1995, 96, 97, 98, 99 Free Software Foundation, Inc.
|
Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@@ -35,7 +35,7 @@ unsigned int __hurd_threadvar_max;
|
|||||||
unsigned long int __hurd_threadvar_stack_offset;
|
unsigned long int __hurd_threadvar_stack_offset;
|
||||||
unsigned long int __hurd_threadvar_stack_mask;
|
unsigned long int __hurd_threadvar_stack_mask;
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef SHARED
|
||||||
int __libc_enable_secure;
|
int __libc_enable_secure;
|
||||||
#endif
|
#endif
|
||||||
int __libc_multiple_libcs = 1;
|
int __libc_multiple_libcs = 1;
|
||||||
@@ -53,8 +53,8 @@ DEFINE_HOOK (_hurd_preinit_hook, (void));
|
|||||||
|
|
||||||
/* We call this once the Hurd magic is all set up and we are ready to be a
|
/* We call this once the Hurd magic is all set up and we are ready to be a
|
||||||
Posixoid program. This does the same things the generic version does. */
|
Posixoid program. This does the same things the generic version does. */
|
||||||
static void internal_function
|
static void
|
||||||
posixland_init (int argc, char **argv)
|
posixland_init (int argc, char **argv, char **envp)
|
||||||
{
|
{
|
||||||
__libc_init (argc, argv, __environ);
|
__libc_init (argc, argv, __environ);
|
||||||
|
|
||||||
@@ -76,7 +76,6 @@ init1 (int argc, char *arg0, ...)
|
|||||||
|
|
||||||
__libc_argc = argc;
|
__libc_argc = argc;
|
||||||
__libc_argv = argv;
|
__libc_argv = argv;
|
||||||
__environ = envp;
|
|
||||||
|
|
||||||
while (*envp)
|
while (*envp)
|
||||||
++envp;
|
++envp;
|
||||||
@@ -111,10 +110,8 @@ init1 (int argc, char *arg0, ...)
|
|||||||
d->portarray, d->portarraysize,
|
d->portarray, d->portarraysize,
|
||||||
d->intarray, d->intarraysize);
|
d->intarray, d->intarraysize);
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef SHARED
|
||||||
__libc_enable_secure = d->flags & EXEC_SECURE;
|
__libc_enable_secure = d->flags & EXEC_SECURE;
|
||||||
#else
|
|
||||||
posixland_init(argc, argv);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,38 +244,49 @@ asm ("
|
|||||||
");
|
");
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIC
|
/* Do the first essential initializations that must precede all else. */
|
||||||
/* This function is called to initialize the shared C library.
|
static inline void
|
||||||
It is called just before the user _start code from i386/elf/start.S,
|
first_init (void)
|
||||||
with the stack set up as that code gets it. */
|
|
||||||
|
|
||||||
/* NOTE! The linker notices the magical name `_init' and sets the DT_INIT
|
|
||||||
pointer in the dynamic section based solely on that. It is convention
|
|
||||||
for this function to be in the `.init' section, but the symbol name is
|
|
||||||
the only thing that really matters!! */
|
|
||||||
void
|
|
||||||
_init (int argc, ...)
|
|
||||||
{
|
{
|
||||||
/* Initialize data structures so we can do RPCs. */
|
/* Initialize data structures so we can do RPCs. */
|
||||||
__mach_init ();
|
__mach_init ();
|
||||||
|
|
||||||
RUN_HOOK (_hurd_preinit_hook, ());
|
RUN_HOOK (_hurd_preinit_hook, ());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* This function is called specially by the dynamic linker to do early
|
||||||
|
initialization of the shared C library before normal initializers
|
||||||
|
expecting a Posixoid environment can run. It gets called with the
|
||||||
|
stack set up just as the user will see it, so it can switch stacks. */
|
||||||
|
|
||||||
|
void
|
||||||
|
_dl_init_first (int argc, ...)
|
||||||
|
{
|
||||||
|
first_init ();
|
||||||
|
|
||||||
init (&argc);
|
init (&argc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* The regular posixland initialization is what goes into libc's
|
||||||
|
normal initializer. */
|
||||||
|
/* NOTE! The linker notices the magical name `_init' and sets the DT_INIT
|
||||||
|
pointer in the dynamic section based solely on that. It is convention
|
||||||
|
for this function to be in the `.init' section, but the symbol name is
|
||||||
|
the only thing that really matters!! */
|
||||||
|
strong_alias (posixland_init, _init);
|
||||||
|
|
||||||
void
|
void
|
||||||
__libc_init_first (int argc, char **argv, char **envp)
|
__libc_init_first (int argc, char **argv, char **envp)
|
||||||
#ifdef PIC
|
|
||||||
{
|
{
|
||||||
/* Everything was done in the shared library initializer, _init. */
|
/* Everything was done in the shared library initializer, _init. */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
strong_alias (posixland_init, __libc_init_first);
|
||||||
posixland_init(argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX This is all a crock and I am not happy with it.
|
/* XXX This is all a crock and I am not happy with it.
|
||||||
This poorly-named function is called by static-start.S,
|
This poorly-named function is called by static-start.S,
|
||||||
@@ -295,9 +303,9 @@ _hurd_stack_setup (int argc __attribute__ ((unused)), ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Push the user return address after the argument data, and then
|
/* Push the user return address after the argument data, and then
|
||||||
jump to `doinit1' (above), so it is as if __libc_init_first's
|
jump to `doinit1' (above), so it is as if __libc_init_first's
|
||||||
caller had called `doinit1' with the argument data already on the
|
caller had called `doinit1' with the argument data already on the
|
||||||
stack. */
|
stack. */
|
||||||
*--data = (&argc)[-1];
|
*--data = (&argc)[-1];
|
||||||
asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */
|
asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */
|
||||||
"movl $0, %%ebp\n" /* Clear outermost frame pointer. */
|
"movl $0, %%ebp\n" /* Clear outermost frame pointer. */
|
||||||
@@ -305,10 +313,7 @@ _hurd_stack_setup (int argc __attribute__ ((unused)), ...)
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize data structures so we can do RPCs. */
|
first_init ();
|
||||||
__mach_init ();
|
|
||||||
|
|
||||||
RUN_HOOK (_hurd_preinit_hook, ());
|
|
||||||
|
|
||||||
_hurd_startup ((void **) &argc, &doinit);
|
_hurd_startup ((void **) &argc, &doinit);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user