packaging: update homepage url
[platform/upstream/elfutils.git] / libebl / eblauxvinfo.c
1 /* Describe known auxv types.
2    Copyright (C) 2007, 2008, 2009 Red Hat, Inc.
3    This file is part of elfutils.
4
5    This file is free software; you can redistribute it and/or modify
6    it under the terms of either
7
8      * 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
21    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
25    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/>.  */
28
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")                                                          \
45   TYPE (EXECFN, "s")                                                          \
46   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")                                                        \
60   TYPE (BASE_PLATFORM, "s")                                                   \
61   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")                                                   \
73   TYPE (L3_CACHESHAPE, "d")                                                   \
74   TYPE (RANDOM, "p")
75
76 static 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
87 int
88 ebl_auxv_info (Ebl *ebl, GElf_Xword a_type, const char **name,
89                const char **format)
90 {
91   int result = ebl->auxv_info (a_type, name, format);
92   if (result == 0 && a_type < nauxv_types && auxv_types[a_type].name != NULL)
93     {
94       /* The machine specific function did not know this type.  */
95       *name = auxv_types[a_type].name;
96       *format = auxv_types[a_type].format;
97       result = 1;
98     }
99   return result;
100 }