1 /* Operating system support for run-time dynamic linker. Generic Unix version.
2 Copyright (C) 1995, 96 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. */
21 #include <sys/types.h>
30 extern char **_dl_argv
;
31 extern char **_environ
;
32 extern void _start (void);
33 extern int _dl_secure
;
36 _dl_sysdep_start (void **start_argptr
,
37 void (*dl_main
) (const ElfW(Phdr
) *phdr
, ElfW(Word
) phnum
,
38 ElfW(Addr
) *user_entry
))
40 const ElfW(Phdr
) *phdr
;
42 ElfW(Addr
) user_entry
;
48 user_entry
= (ElfW(Addr
)) &_start
;
49 _dl_argc
= *(long *) start_argptr
;
50 _dl_argv
= (char **) start_argptr
+ 1;
51 _environ
= &_dl_argv
[_dl_argc
+ 1];
52 start_argptr
= (void **) _environ
;
57 #define M(type) (1 << (type))
59 for (av
= (void *) ++start_argptr
;
60 av
->a_type
!= AT_NULL
;
61 seen
|= M ((++av
)->a_type
))
65 phdr
= av
->a_un
.a_ptr
;
68 phnum
= av
->a_un
.a_val
;
71 user_entry
= av
->a_un
.a_val
;
80 euid
= av
->a_un
.a_val
;
83 egid
= av
->a_un
.a_val
;
87 /* Linux doesn't provide us with any of these values on the stack
88 when the dynamic linker is run directly as a program. */
90 #define SEE(UID, uid) if ((seen & M (AT_##UID)) == 0) uid = __get##uid ()
97 _dl_secure
= uid
!= euid
|| gid
!= egid
;
103 (*dl_main
) (phdr
, phnum
, &user_entry
);
108 _dl_sysdep_start_cleanup (void)
113 _dl_sysdep_open_zero_fill (void)
115 return __open ("/dev/zero", O_RDONLY
);
119 _dl_sysdep_fatal (const char *msg
, ...)
126 size_t len
= strlen (msg
);
127 __write (STDERR_FILENO
, msg
, len
);
128 msg
= va_arg (ap
, const char *);
137 _dl_sysdep_message (const char *msg
, ...)
144 size_t len
= strlen (msg
);
145 __write (STDOUT_FILENO
, msg
, len
);
146 msg
= va_arg (ap
, const char *);