1 /* Miscellaneous support functions for dynamic linker
2 Copyright (C) 1997, 1998, 1999, 2000 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 not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
28 #include <stdio-common/_itoa.h>
31 /* This is the only dl-sysdep.c function that is actually needed at run-time
35 _dl_sysdep_open_zero_fill (void)
37 return __open ("/dev/zero", O_RDONLY
);
41 /* Read the whole contents of FILE into new mmap'd space with given
42 protections. *SIZEP gets the size of the file. */
45 _dl_sysdep_read_whole_file (const char *file
, size_t *sizep
, int prot
)
49 int fd
= __open (file
, O_RDONLY
);
52 if (__fxstat64 (_STAT_VER
, fd
, &st
) < 0
53 /* No need to map the file if it is empty. */
58 /* Map a copy of the file contents. */
59 result
= __mmap (0, st
.st_size
, prot
,
69 if (result
== MAP_FAILED
)
79 /* Descriptor to write debug messages to. */
84 _dl_sysdep_output (int fd
, const char *msg
, ...)
91 size_t len
= strlen (msg
);
92 __libc_write (fd
, msg
, len
);
93 msg
= va_arg (ap
, const char *);
101 _dl_debug_message (int new_line
, const char *msg
, ...)
103 /* We print the strings we get passed one after the other but start all
104 lines using the current PID. */
111 /* Get the next argument. */
112 msg
= va_arg (ap
, const char *);
117 /* We actually will print something in this line. So print the
118 PID now if needed. */
125 assert (pid
>= 0 && pid
< 100000);
126 p
= _itoa_word (pid
, &buf
[5], 10, 0);
131 __libc_write (_dl_debug_fd
, buf
, 7);
135 endp
= msg
+ strcspn (msg
, "\n");
138 __libc_write (_dl_debug_fd
, msg
, endp
- msg
);
139 msg
= va_arg (ap
, const char *);
143 __libc_write (_dl_debug_fd
, msg
, endp
- msg
+ 1);