From 7dea968e78d0903e5f6069f2bf72a9961f49465f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 6 Mar 1998 17:21:43 +0000 Subject: Update. 1998-03-06 17:04 Ulrich Drepper * libc.map: Add _dl_debug_impcalls, _dl_debug_fd, _dl_sysdep_output, __libc_start_main. * csu/Makefile (routines): Add libc-start. * elf/dl-error.c: Remove declaration of _dl_argv. Include . * elf/dl-lookup.c: Likewise. * elf/dl-version.c: Likewise. * sysdeps/i386/dl-machine.h: Likewise. * elf/link.h: Declare _dl_argv, _dl_debug_fd. Declare _dl_sysdep_output. Make _dl_sysdep_fatal, _dl_sysdep_error and _dl_sysdep_message macros which use _dl_sysdep_output. * elf/dl-fini.c: Write out which destructor is called while debugging. * elf/dl-init.c: Likewise for constructor. * elf/dl-load.c: Use _dl_debug_message instead of _dl_sysdep_message. * elf/dl-misc.c: Remove _dl_sysdep_fatal, _dl_sysdep_error and _dl_sysdep_message. Add _dl_sysdep_output. * elf/rtld.c: Recognize LD_DEBUG_OUTPUT. Set _dl_debug_fd if this file can be opened. For LD_DEBUG=libs also set _dl_debug_impcalls. * sysdeps/generic/dl-cache.c: Include unistd.h. * sysdeps/generic/libc-start.c: New file. * sysdeps/i386/elf/start.S: Don't call main directly, call * sysdeps/unix/sysv/linux/libc-start.c: New file. __libc_start_main instead. * elf/Makefile ($(objpfx)ld.so): Add $(load-map-file) as dependency. --- sysdeps/generic/dl-cache.c | 2 +- sysdeps/generic/libc-start.c | 24 ++++++++++++++++++++++++ sysdeps/i386/dl-machine.h | 4 +--- sysdeps/i386/elf/start.S | 8 +++++--- sysdeps/unix/sysv/linux/libc-start.c | 31 +++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 sysdeps/generic/libc-start.c create mode 100644 sysdeps/unix/sysv/linux/libc-start.c (limited to 'sysdeps') diff --git a/sysdeps/generic/dl-cache.c b/sysdeps/generic/dl-cache.c index 43a987a1fd..2a2be570e9 100644 --- a/sysdeps/generic/dl-cache.c +++ b/sysdeps/generic/dl-cache.c @@ -18,7 +18,7 @@ Boston, MA 02111-1307, USA. */ #include -#include +#include #include /* System-dependent function to read a file's whole contents diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c new file mode 100644 index 0000000000..12419887a1 --- /dev/null +++ b/sysdeps/generic/libc-start.c @@ -0,0 +1,24 @@ +/* Copyright (C) 1998 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +int +__libc_start_main (int (*main) (int, char **, char **), int argc, + char **argv, char **envp) +{ + return (*main) (argc, argv, envp); +} diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 2aaa5b7617..394188d0e4 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -1,5 +1,5 @@ /* Machine-dependent ELF dynamic relocation inline functions. i386 version. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998 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 @@ -302,8 +302,6 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc, #ifdef RESOLVE -extern char **_dl_argv; - /* Perform the relocation specified by RELOC and SYM (which is fully resolved). MAP is the object containing the reloc. */ diff --git a/sysdeps/i386/elf/start.S b/sysdeps/i386/elf/start.S index 7416c0ace9..e8ed2043ff 100644 --- a/sysdeps/i386/elf/start.S +++ b/sysdeps/i386/elf/start.S @@ -1,5 +1,5 @@ /* Startup code compliant to the ELF i386 ABI. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998 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 @@ -88,9 +88,11 @@ _start: call atexit popl %eax - /* Call the user's main function, and exit with its value. */ - call main + /* Call the user's main function, and exit with its value. + But let the libc call main. */ + movl $main, %eax pushl %eax + call __libc_start_main call exit hlt /* Crash if somehow `exit' does return. */ diff --git a/sysdeps/unix/sysv/linux/libc-start.c b/sysdeps/unix/sysv/linux/libc-start.c new file mode 100644 index 0000000000..f142195fbc --- /dev/null +++ b/sysdeps/unix/sysv/linux/libc-start.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1998 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +int +__libc_start_main (int (*main) (int, char **, char **), int argc, + char **argv, char **envp) +{ +#ifdef PIC + if (_dl_debug_impcalls) + _dl_debug_message ("\ttransferring control: ", argv[0], "\n\n", NULL); +#endif + + return (*main) (argc, argv, envp); +} -- cgit 1.4.1