aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/dl-cache.c2
-rw-r--r--sysdeps/generic/libc-start.c24
-rw-r--r--sysdeps/i386/dl-machine.h4
-rw-r--r--sysdeps/i386/elf/start.S8
-rw-r--r--sysdeps/unix/sysv/linux/libc-start.c31
5 files changed, 62 insertions, 7 deletions
diff --git a/sysdeps/generic/dl-cache.c b/sysdeps/generic/dl-cache.c
index 43a987a..2a2be57 100644
--- a/sysdeps/generic/dl-cache.c
+++ b/sysdeps/generic/dl-cache.c
@@ -18,7 +18,7 @@
Boston, MA 02111-1307, USA. */
#include <link.h>
-#include <stddef.h>
+#include <unistd.h>
#include <sys/mman.h>
/* 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 0000000..1241988
--- /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 2aaa5b7..394188d 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 7416c0a..e8ed204 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 0000000..f142195
--- /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 <link.h>
+
+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);
+}