* signal/signal.h [__USE_BSD] (_sys_siglist, sys_siglist): Declare
[glibc.git] / sysdeps / generic / dl-sysdep.c
blobb7b895ffce4d7718e1c3ed48be30636cd4641f58
1 /* Operating system support for run-time dynamic linker. Generic Unix version.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 #include <elf.h>
21 #include <sys/types.h>
22 #include <fcntl.h>
23 #include <link.h>
24 #include <unistd.h>
26 extern int _dl_argc;
27 extern char **_dl_argv;
28 extern char **_environ;
29 extern void _start (void);
31 Elf32_Addr
32 _dl_sysdep_start (void **start_argptr,
33 void (*dl_main) (const Elf32_Phdr *phdr, Elf32_Word phnum,
34 Elf32_Addr *user_entry))
36 const Elf32_Phdr *phdr;
37 Elf32_Word phnum;
38 Elf32_Addr user_entry;
39 Elf32_auxv_t *av;
40 uid_t uid, euid;
41 gid_t gid, egid;
43 user_entry = (Elf32_Addr) &_start;
44 _dl_argc = *(int *) start_argptr;
45 _dl_argv = (char **) start_argptr + 1;
46 _environ = &_dl_argv[_dl_argc + 1];
47 start_argptr = (void **) _environ;
48 while (*start_argptr)
49 ++start_argptr;
51 for (av = (void *) ++start_argptr; av->a_type != AT_NULL; ++av)
52 switch (av->a_type)
54 case AT_PHDR:
55 phdr = av->a_un.a_ptr;
56 break;
57 case AT_PHNUM:
58 phnum = av->a_un.a_val;
59 break;
60 case AT_ENTRY:
61 user_entry = av->a_un.a_val;
62 break;
63 case AT_UID:
64 uid = av->a_un.a_val;
65 break;
66 case AT_GID:
67 gid = av->a_un.a_val;
68 break;
69 case AT_EUID:
70 euid = av->a_un.a_val;
71 break;
72 case AT_EGID:
73 egid = av->a_un.a_val;
74 break;
77 _dl_secure = uid != euid || gid != egid;
79 (*dl_main) (phdr, phnum, &user_entry);
80 return user_entry;
83 int
84 _dl_sysdep_open_zero_fill (void)
86 return open ("/dev/zero", O_RDONLY);
89 #include <stdarg.h>
91 void
92 _dl_sysdep_fatal (const char *msg, ...)
94 va_list ap;
96 va_start (ap, msg);
99 size_t len = strlen (msg);
100 write (STDERR_FILENO, msg, len);
101 msg = va_arg (ap, const char *);
102 } while (msg);
103 va_end (ap);
105 _exit (127);
109 void
110 _dl_sysdep_message (const char *msg, ...)
112 va_list ap;
114 va_start (ap, msg);
117 size_t len = strlen (msg);
118 write (STDOUT_FILENO, msg, len);
119 msg = va_arg (ap, const char *);
120 } while (msg);
121 va_end (ap);