1995-12-03 10:00:22 +00:00
|
|
|
/* Dynamic linker system dependencies for Linux.
|
2023-01-06 21:08:04 +00:00
|
|
|
Copyright (C) 1995-2023 Free Software Foundation, Inc.
|
1997-06-23 21:55:26 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1997-06-23 21:55:26 +00:00
|
|
|
|
|
|
|
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
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1997-06-23 21:55:26 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
1995-12-03 10:00:22 +00:00
|
|
|
|
2022-02-03 09:58:59 +00:00
|
|
|
#include <_itoa.h>
|
|
|
|
#include <assert.h>
|
2022-02-28 10:50:41 +00:00
|
|
|
#include <dl-auxv.h>
|
2022-02-03 09:58:59 +00:00
|
|
|
#include <dl-osinfo.h>
|
2022-02-28 10:50:41 +00:00
|
|
|
#include <dl-parse_auxv.h>
|
2022-02-03 09:58:59 +00:00
|
|
|
#include <dl-procinfo.h>
|
|
|
|
#include <dl-tunables.h>
|
|
|
|
#include <elf.h>
|
|
|
|
#include <errno.h>
|
2008-03-08 07:35:10 +00:00
|
|
|
#include <fcntl.h>
|
2004-08-15 23:33:02 +00:00
|
|
|
#include <ldsodefs.h>
|
2022-02-03 09:58:59 +00:00
|
|
|
#include <libc-internal.h>
|
|
|
|
#include <libintl.h>
|
Avoid cancellable I/O primitives in ld.so.
Neither the <dlfcn.h> entry points, nor lazy symbol resolution, nor
initial shared library load-up, are cancellation points, so ld.so
should exclusively use I/O primitives that are not cancellable. We
currently achieve this by having the cancellation hooks compile as
no-ops when IS_IN(rtld); this patch changes to using exclusively
_nocancel primitives in the source code instead, which makes the
intent clearer and significantly reduces the amount of code compiled
under IS_IN(rtld) as well as IS_IN(libc) -- in particular,
elf/Makefile no longer thinks we require a copy of unwind.c in
rtld-libc.a. (The older mechanism is preserved as a backstop.)
The bulk of the change is splitting up the files that define the
_nocancel I/O functions, so they don't also define the variants that
*are* cancellation points; after which, the existing logic for picking
out the bits of libc that need to be recompiled as part of ld.so Just
Works. I did this for all of the _nocancel functions, not just the
ones used by ld.so, for consistency.
fcntl was a little tricky because it's only a cancellation point for
certain opcodes (F_SETLKW(64), which can block), and the existing
__fcntl_nocancel wasn't applying the FCNTL_ADJUST_CMD hook, which
strikes me as asking for trouble, especially as the only nontrivial
definition of FCNTL_ADJUST_CMD (for powerpc64) changes F_*LK* opcodes.
To fix this, fcntl_common moves to fcntl_nocancel.c along with
__fcntl_nocancel, and changes its name to the extern (but hidden)
symbol __fcntl_nocancel_adjusted, so that regular fcntl can continue
calling it. __fcntl_nocancel now applies FCNTL_ADJUST_CMD; so that
both both fcntl.c and fcntl_nocancel.c can see it, the only nontrivial
definition moves from sysdeps/u/s/l/powerpc/powerpc64/fcntl.c to
.../powerpc64/sysdep.h and becomes entirely a macro, instead of a macro
that calls an inline function.
The nptl version of libpthread also changes a little, because its
"compat-routines" formerly included files that defined all the
_nocancel functions it uses; instead of continuing to duplicate them,
I exported the relevant ones from libc.so as GLIBC_PRIVATE. Since the
Linux fcntl.c calls a function defined by fcntl_nocancel.c, it can no
longer be used from libpthread.so; instead, introduce a custom
forwarder, pt-fcntl.c, and export __libc_fcntl from libc.so as
GLIBC_PRIVATE. The nios2-linux ABI doesn't include a copy of vfork()
in libpthread, and it was handling that by manipulating
libpthread-routines in .../linux/nios2/Makefile; it is cleaner to do
what other such ports do, and have a pt-vfork.S that defines no symbols.
Right now, it appears that Hurd does not implement _nocancel I/O, so
sysdeps/generic/not-cancel.h will forward everything back to the
regular functions. This changed the names of some of the functions
that sysdeps/mach/hurd/dl-sysdep.c needs to interpose.
* elf/dl-load.c, elf/dl-misc.c, elf/dl-profile.c, elf/rtld.c
* sysdeps/unix/sysv/linux/dl-sysdep.c
Include not-cancel.h. Use __close_nocancel instead of __close,
__open64_nocancel instead of __open, __read_nocancel instead of
__libc_read, and __write_nocancel instead of __libc_write.
* csu/check_fds.c (check_one_fd)
* sysdeps/posix/fdopendir.c (__fdopendir)
* sysdeps/posix/opendir.c (__alloc_dir): Use __fcntl_nocancel
instead of __fcntl and/or __libc_fcntl.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np)
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np)
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system):
Use __open64_nocancel instead of __open_nocancel.
* sysdeps/unix/sysv/linux/not-cancel.h: Move all of the
hidden_proto declarations to the end and issue them if either
IS_IN(libc) or IS_IN(rtld).
* sysdeps/unix/sysv/linux/Makefile [subdir=io] (sysdep_routines):
Add close_nocancel, fcntl_nocancel, nanosleep_nocancel,
open_nocancel, open64_nocancel, openat_nocancel, pause_nocancel,
read_nocancel, waitpid_nocancel, write_nocancel.
* io/Versions [GLIBC_PRIVATE]: Add __libc_fcntl,
__fcntl_nocancel, __open64_nocancel, __write_nocancel.
* posix/Versions: Add __nanosleep_nocancel, __pause_nocancel.
* nptl/pt-fcntl.c: New file.
* nptl/Makefile (pthread-compat-wrappers): Remove fcntl.
(libpthread-routines): Add pt-fcntl.
* include/fcntl.h (__fcntl_nocancel_adjusted): New function.
(__libc_fcntl): Remove attribute_hidden.
* sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Call
__fcntl_nocancel_adjusted, not fcntl_common.
(__fcntl_nocancel): Move to new file fcntl_nocancel.c.
(fcntl_common): Rename to __fcntl_nocancel_adjusted; also move
to fcntl_nocancel.c.
* sysdeps/unix/sysv/linux/fcntl_nocancel.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h:
Define FCNTL_ADJUST_CMD here, as a self-contained macro.
* sysdeps/unix/sysv/linux/close.c: Move __close_nocancel to...
* sysdeps/unix/sysv/linux/close_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/nanosleep.c: Move __nanosleep_nocancel to...
* sysdeps/unix/sysv/linux/nanosleep_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/open.c: Move __open_nocancel to...
* sysdeps/unix/sysv/linux/open_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/open64.c: Move __open64_nocancel to...
* sysdeps/unix/sysv/linux/open64_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/openat.c: Move __openat_nocancel to...
* sysdeps/unix/sysv/linux/openat_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/openat64.c: Move __openat64_nocancel to...
* sysdeps/unix/sysv/linux/openat64_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/pause.c: Move __pause_nocancel to...
* sysdeps/unix/sysv/linux/pause_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/read.c: Move __read_nocancel to...
* sysdeps/unix/sysv/linux/read_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/waitpid.c: Move __waitpid_nocancel to...
* sysdeps/unix/sysv/linux/waitpid_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/write.c: Move __write_nocancel to...
* sysdeps/unix/sysv/linux/write_nocancel.c: ...this new file.
* sysdeps/unix/sysv/linux/nios2/Makefile: Don't override
libpthread-routines.
* sysdeps/unix/sysv/linux/nios2/pt-vfork.S: New file which
defines nothing.
* sysdeps/mach/hurd/dl-sysdep.c: Define __read instead of
__libc_read, and __write instead of __libc_write. Define
__open64 in addition to __open.
2018-04-03 22:26:44 +00:00
|
|
|
#include <not-cancel.h>
|
2022-02-03 09:58:59 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <tls.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <dl-machine.h>
|
2022-02-28 10:50:41 +00:00
|
|
|
#include <dl-hwcap-check.h>
|
1995-12-03 10:00:22 +00:00
|
|
|
|
2008-03-08 17:52:13 +00:00
|
|
|
#ifdef SHARED
|
2022-02-03 09:58:59 +00:00
|
|
|
extern char **_environ attribute_hidden;
|
|
|
|
extern char _end[] attribute_hidden;
|
|
|
|
|
|
|
|
/* Protect SUID program against misuse of file descriptors. */
|
|
|
|
extern void __libc_check_standard_fds (void);
|
|
|
|
|
|
|
|
int __libc_enable_secure attribute_relro = 0;
|
|
|
|
rtld_hidden_data_def (__libc_enable_secure)
|
|
|
|
/* This variable contains the lowest stack address ever used. */
|
|
|
|
void *__libc_stack_end attribute_relro = NULL;
|
|
|
|
rtld_hidden_data_def(__libc_stack_end)
|
|
|
|
void *_dl_random attribute_relro = NULL;
|
|
|
|
|
|
|
|
#ifndef DL_STACK_END
|
|
|
|
# define DL_STACK_END(cookie) ((void *) (cookie))
|
|
|
|
#endif
|
1995-12-03 10:00:22 +00:00
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
/* Arguments passed to dl_main. */
|
|
|
|
struct dl_main_arguments
|
1995-12-03 10:00:22 +00:00
|
|
|
{
|
2022-02-28 10:50:41 +00:00
|
|
|
const ElfW(Phdr) *phdr;
|
|
|
|
ElfW(Word) phnum;
|
2022-02-03 09:58:59 +00:00
|
|
|
ElfW(Addr) user_entry;
|
2022-02-28 10:50:41 +00:00
|
|
|
};
|
2022-02-03 09:58:59 +00:00
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
/* Separate function, so that dl_main can be called without the large
|
|
|
|
array on the stack. */
|
|
|
|
static void
|
|
|
|
_dl_sysdep_parse_arguments (void **start_argptr,
|
|
|
|
struct dl_main_arguments *args)
|
|
|
|
{
|
2022-02-03 09:58:59 +00:00
|
|
|
_dl_argc = (intptr_t) *start_argptr;
|
|
|
|
_dl_argv = (char **) (start_argptr + 1); /* Necessary aliasing violation. */
|
|
|
|
_environ = _dl_argv + _dl_argc + 1;
|
2022-02-03 09:58:59 +00:00
|
|
|
for (char **tmp = _environ; ; ++tmp)
|
2022-02-03 09:58:59 +00:00
|
|
|
if (*tmp == NULL)
|
|
|
|
{
|
|
|
|
/* Another necessary aliasing violation. */
|
|
|
|
GLRO(dl_auxv) = (ElfW(auxv_t) *) (tmp + 1);
|
|
|
|
break;
|
|
|
|
}
|
2022-02-03 09:58:59 +00:00
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
dl_parse_auxv_t auxv_values = { 0, };
|
|
|
|
_dl_parse_auxv (GLRO(dl_auxv), auxv_values);
|
2022-02-03 09:58:59 +00:00
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
args->phdr = (const ElfW(Phdr) *) auxv_values[AT_PHDR];
|
|
|
|
args->phnum = auxv_values[AT_PHNUM];
|
|
|
|
args->user_entry = auxv_values[AT_ENTRY];
|
|
|
|
}
|
2022-02-03 09:58:59 +00:00
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
ElfW(Addr)
|
|
|
|
_dl_sysdep_start (void **start_argptr,
|
|
|
|
void (*dl_main) (const ElfW(Phdr) *phdr, ElfW(Word) phnum,
|
|
|
|
ElfW(Addr) *user_entry, ElfW(auxv_t) *auxv))
|
|
|
|
{
|
|
|
|
__libc_stack_end = DL_STACK_END (start_argptr);
|
2022-02-03 09:58:59 +00:00
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
struct dl_main_arguments dl_main_args;
|
|
|
|
_dl_sysdep_parse_arguments (start_argptr, &dl_main_args);
|
2022-02-03 09:58:59 +00:00
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
dl_hwcap_check ();
|
2022-02-11 15:01:19 +00:00
|
|
|
|
2022-02-03 09:58:59 +00:00
|
|
|
__tunables_init (_environ);
|
|
|
|
|
|
|
|
/* Initialize DSO sorting algorithm after tunables. */
|
|
|
|
_dl_sort_maps_init ();
|
|
|
|
|
1995-12-03 10:00:22 +00:00
|
|
|
__brk (0); /* Initialize the break. */
|
|
|
|
|
2022-02-03 09:58:59 +00:00
|
|
|
#ifdef DL_PLATFORM_INIT
|
|
|
|
DL_PLATFORM_INIT;
|
2008-03-08 17:52:13 +00:00
|
|
|
#endif
|
2008-03-08 07:35:10 +00:00
|
|
|
|
2022-02-03 09:58:59 +00:00
|
|
|
/* Determine the length of the platform name. */
|
|
|
|
if (GLRO(dl_platform) != NULL)
|
|
|
|
GLRO(dl_platformlen) = strlen (GLRO(dl_platform));
|
|
|
|
|
|
|
|
if (__sbrk (0) == _end)
|
|
|
|
/* The dynamic linker was run as a program, and so the initial break
|
|
|
|
starts just after our bss, at &_end. The malloc in dl-minimal.c
|
|
|
|
will consume the rest of this page, so tell the kernel to move the
|
|
|
|
break up that far. When the user program examines its break, it
|
|
|
|
will see this new value and not clobber our data. */
|
|
|
|
__sbrk (GLRO(dl_pagesize)
|
2022-06-28 08:57:55 +00:00
|
|
|
- (((uintptr_t) _end) & (GLRO(dl_pagesize) - 1)));
|
2022-02-03 09:58:59 +00:00
|
|
|
|
|
|
|
/* If this is a SUID program we make sure that FDs 0, 1, and 2 are
|
|
|
|
allocated. If necessary we are doing it ourself. If it is not
|
|
|
|
possible we stop the program. */
|
|
|
|
if (__builtin_expect (__libc_enable_secure, 0))
|
|
|
|
__libc_check_standard_fds ();
|
|
|
|
|
2022-02-28 10:50:41 +00:00
|
|
|
(*dl_main) (dl_main_args.phdr, dl_main_args.phnum,
|
|
|
|
&dl_main_args.user_entry, GLRO(dl_auxv));
|
|
|
|
return dl_main_args.user_entry;
|
2022-02-03 09:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_dl_sysdep_start_cleanup (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_dl_show_auxv (void)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
ElfW(auxv_t) *av;
|
|
|
|
|
|
|
|
/* Terminate string. */
|
|
|
|
buf[63] = '\0';
|
|
|
|
|
|
|
|
/* The following code assumes that the AT_* values are encoded
|
|
|
|
starting from 0 with AT_NULL, 1 for AT_IGNORE, and all other values
|
|
|
|
close by (otherwise the array will be too large). In case we have
|
|
|
|
to support a platform where these requirements are not fulfilled
|
|
|
|
some alternative implementation has to be used. */
|
|
|
|
for (av = GLRO(dl_auxv); av->a_type != AT_NULL; ++av)
|
|
|
|
{
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char label[22];
|
|
|
|
enum { unknown = 0, dec, hex, str, ignore } form : 8;
|
|
|
|
} auxvars[] =
|
|
|
|
{
|
|
|
|
[AT_EXECFD - 2] = { "EXECFD: ", dec },
|
|
|
|
[AT_EXECFN - 2] = { "EXECFN: ", str },
|
|
|
|
[AT_PHDR - 2] = { "PHDR: 0x", hex },
|
|
|
|
[AT_PHENT - 2] = { "PHENT: ", dec },
|
|
|
|
[AT_PHNUM - 2] = { "PHNUM: ", dec },
|
|
|
|
[AT_PAGESZ - 2] = { "PAGESZ: ", dec },
|
|
|
|
[AT_BASE - 2] = { "BASE: 0x", hex },
|
|
|
|
[AT_FLAGS - 2] = { "FLAGS: 0x", hex },
|
|
|
|
[AT_ENTRY - 2] = { "ENTRY: 0x", hex },
|
|
|
|
[AT_NOTELF - 2] = { "NOTELF: ", hex },
|
|
|
|
[AT_UID - 2] = { "UID: ", dec },
|
|
|
|
[AT_EUID - 2] = { "EUID: ", dec },
|
|
|
|
[AT_GID - 2] = { "GID: ", dec },
|
|
|
|
[AT_EGID - 2] = { "EGID: ", dec },
|
|
|
|
[AT_PLATFORM - 2] = { "PLATFORM: ", str },
|
|
|
|
[AT_HWCAP - 2] = { "HWCAP: ", hex },
|
|
|
|
[AT_CLKTCK - 2] = { "CLKTCK: ", dec },
|
|
|
|
[AT_FPUCW - 2] = { "FPUCW: ", hex },
|
|
|
|
[AT_DCACHEBSIZE - 2] = { "DCACHEBSIZE: 0x", hex },
|
|
|
|
[AT_ICACHEBSIZE - 2] = { "ICACHEBSIZE: 0x", hex },
|
|
|
|
[AT_UCACHEBSIZE - 2] = { "UCACHEBSIZE: 0x", hex },
|
|
|
|
[AT_IGNOREPPC - 2] = { "IGNOREPPC", ignore },
|
|
|
|
[AT_SECURE - 2] = { "SECURE: ", dec },
|
|
|
|
[AT_BASE_PLATFORM - 2] = { "BASE_PLATFORM: ", str },
|
|
|
|
[AT_SYSINFO - 2] = { "SYSINFO: 0x", hex },
|
|
|
|
[AT_SYSINFO_EHDR - 2] = { "SYSINFO_EHDR: 0x", hex },
|
|
|
|
[AT_RANDOM - 2] = { "RANDOM: 0x", hex },
|
|
|
|
[AT_HWCAP2 - 2] = { "HWCAP2: 0x", hex },
|
|
|
|
[AT_MINSIGSTKSZ - 2] = { "MINSIGSTKSZ: ", dec },
|
|
|
|
[AT_L1I_CACHESIZE - 2] = { "L1I_CACHESIZE: ", dec },
|
|
|
|
[AT_L1I_CACHEGEOMETRY - 2] = { "L1I_CACHEGEOMETRY: 0x", hex },
|
|
|
|
[AT_L1D_CACHESIZE - 2] = { "L1D_CACHESIZE: ", dec },
|
|
|
|
[AT_L1D_CACHEGEOMETRY - 2] = { "L1D_CACHEGEOMETRY: 0x", hex },
|
|
|
|
[AT_L2_CACHESIZE - 2] = { "L2_CACHESIZE: ", dec },
|
|
|
|
[AT_L2_CACHEGEOMETRY - 2] = { "L2_CACHEGEOMETRY: 0x", hex },
|
|
|
|
[AT_L3_CACHESIZE - 2] = { "L3_CACHESIZE: ", dec },
|
|
|
|
[AT_L3_CACHEGEOMETRY - 2] = { "L3_CACHEGEOMETRY: 0x", hex },
|
|
|
|
};
|
|
|
|
unsigned int idx = (unsigned int) (av->a_type - 2);
|
|
|
|
|
|
|
|
if ((unsigned int) av->a_type < 2u
|
|
|
|
|| (idx < sizeof (auxvars) / sizeof (auxvars[0])
|
|
|
|
&& auxvars[idx].form == ignore))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
assert (AT_NULL == 0);
|
|
|
|
assert (AT_IGNORE == 1);
|
|
|
|
|
|
|
|
/* Some entries are handled in a special way per platform. */
|
|
|
|
if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (idx < sizeof (auxvars) / sizeof (auxvars[0])
|
|
|
|
&& auxvars[idx].form != unknown)
|
|
|
|
{
|
|
|
|
const char *val = (char *) av->a_un.a_val;
|
|
|
|
|
|
|
|
if (__builtin_expect (auxvars[idx].form, dec) == dec)
|
|
|
|
val = _itoa ((unsigned long int) av->a_un.a_val,
|
|
|
|
buf + sizeof buf - 1, 10, 0);
|
|
|
|
else if (__builtin_expect (auxvars[idx].form, hex) == hex)
|
|
|
|
val = _itoa ((unsigned long int) av->a_un.a_val,
|
|
|
|
buf + sizeof buf - 1, 16, 0);
|
|
|
|
|
|
|
|
_dl_printf ("AT_%s%s\n", auxvars[idx].label, val);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unknown value: print a generic line. */
|
|
|
|
char buf2[17];
|
|
|
|
buf2[sizeof (buf2) - 1] = '\0';
|
|
|
|
const char *val2 = _itoa ((unsigned long int) av->a_un.a_val,
|
|
|
|
buf2 + sizeof buf2 - 1, 16, 0);
|
|
|
|
const char *val = _itoa ((unsigned long int) av->a_type,
|
|
|
|
buf + sizeof buf - 1, 16, 0);
|
|
|
|
_dl_printf ("AT_??? (0x%s): 0x%s\n", val, val2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SHARED */
|