blob: 5c310b29a7b7228630e4f86256dc94f7bfacf3e7 [file] [log] [blame]
Roland McGrathcb6d8652007-08-23 08:10:54 +00001/* Describe known auxv types.
Roland McGrathd5ff6672009-04-01 18:28:41 -07002 Copyright (C) 2007, 2008, 2009 Red Hat, Inc.
Mark Wielaardde2ed972012-06-05 17:15:16 +02003 This file is part of elfutils.
Roland McGrathcb6d8652007-08-23 08:10:54 +00004
Mark Wielaardde2ed972012-06-05 17:15:16 +02005 This file is free software; you can redistribute it and/or modify
6 it under the terms of either
Roland McGrathcb6d8652007-08-23 08:10:54 +00007
Mark Wielaardde2ed972012-06-05 17:15:16 +02008 * the GNU Lesser General Public License as published by the Free
9 Software Foundation; either version 3 of the License, or (at
10 your option) any later version
11
12 or
13
14 * the GNU General Public License as published by the Free
15 Software Foundation; either version 2 of the License, or (at
16 your option) any later version
17
18 or both in parallel, as here.
19
20 elfutils is distributed in the hope that it will be useful, but
Roland McGrathcb6d8652007-08-23 08:10:54 +000021 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
24
Mark Wielaardde2ed972012-06-05 17:15:16 +020025 You should have received copies of the GNU General Public License and
26 the GNU Lesser General Public License along with this program. If
27 not, see <http://www.gnu.org/licenses/>. */
Roland McGrathcb6d8652007-08-23 08:10:54 +000028
29#ifdef HAVE_CONFIG_H
30# include <config.h>
31#endif
32
33#include <assert.h>
34#include <byteswap.h>
35#include <endian.h>
36#include <inttypes.h>
37#include <stdio.h>
38#include <stddef.h>
39#include <libeblP.h>
40
41#define AUXV_TYPES \
42 TYPE (NULL, "") \
43 TYPE (IGNORE, "") \
44 TYPE (EXECFD, "d") \
Roland McGrath1d8bb252008-08-07 08:39:41 +000045 TYPE (EXECFN, "s") \
Roland McGrathcb6d8652007-08-23 08:10:54 +000046 TYPE (PHDR, "p") \
47 TYPE (PHENT, "u") \
48 TYPE (PHNUM, "u") \
49 TYPE (PAGESZ, "u") \
50 TYPE (BASE, "p") \
51 TYPE (FLAGS, "x") \
52 TYPE (ENTRY, "p") \
53 TYPE (NOTELF, "") \
54 TYPE (UID, "u") \
55 TYPE (EUID, "u") \
56 TYPE (GID, "u") \
57 TYPE (EGID, "u") \
58 TYPE (CLKTCK, "u") \
59 TYPE (PLATFORM, "s") \
Roland McGrathd5ff6672009-04-01 18:28:41 -070060 TYPE (BASE_PLATFORM, "s") \
Roland McGrathcb6d8652007-08-23 08:10:54 +000061 TYPE (HWCAP, "x") \
62 TYPE (FPUCW, "x") \
63 TYPE (DCACHEBSIZE, "d") \
64 TYPE (ICACHEBSIZE, "d") \
65 TYPE (UCACHEBSIZE, "d") \
66 TYPE (IGNOREPPC, "") \
67 TYPE (SECURE, "u") \
68 TYPE (SYSINFO, "p") \
69 TYPE (SYSINFO_EHDR, "p") \
70 TYPE (L1I_CACHESHAPE, "d") \
71 TYPE (L1D_CACHESHAPE, "d") \
72 TYPE (L2_CACHESHAPE, "d") \
Roland McGrathd5ff6672009-04-01 18:28:41 -070073 TYPE (L3_CACHESHAPE, "d") \
74 TYPE (RANDOM, "p")
Roland McGrathcb6d8652007-08-23 08:10:54 +000075
76static const struct
77{
78 const char *name, *format;
79} auxv_types[] =
80 {
81#define TYPE(name, fmt) [AT_##name] = { #name, fmt },
82 AUXV_TYPES
83#undef TYPE
84 };
85#define nauxv_types (sizeof auxv_types / sizeof auxv_types[0])
86
87int
88ebl_auxv_info (ebl, a_type, name, format)
89 Ebl *ebl;
90 GElf_Xword a_type;
91 const char **name;
92 const char **format;
93{
94 int result = ebl->auxv_info (a_type, name, format);
Roland McGrath1d8bb252008-08-07 08:39:41 +000095 if (result == 0 && a_type < nauxv_types && auxv_types[a_type].name != NULL)
Roland McGrathcb6d8652007-08-23 08:10:54 +000096 {
97 /* The machine specific function did not know this type. */
98 *name = auxv_types[a_type].name;
99 *format = auxv_types[a_type].format;
100 result = 1;
101 }
102 return result;
103}