Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 1 | /* Describe known auxv types. |
Roland McGrath | d5ff667 | 2009-04-01 18:28:41 -0700 | [diff] [blame] | 2 | Copyright (C) 2007, 2008, 2009 Red Hat, Inc. |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 3 | This file is part of elfutils. |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 4 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 5 | This file is free software; you can redistribute it and/or modify |
| 6 | it under the terms of either |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 7 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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 |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 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 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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/>. */ |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 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") \ |
Roland McGrath | 1d8bb25 | 2008-08-07 08:39:41 +0000 | [diff] [blame] | 45 | TYPE (EXECFN, "s") \ |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 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") \ |
Roland McGrath | d5ff667 | 2009-04-01 18:28:41 -0700 | [diff] [blame] | 60 | TYPE (BASE_PLATFORM, "s") \ |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 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") \ |
Roland McGrath | d5ff667 | 2009-04-01 18:28:41 -0700 | [diff] [blame] | 73 | TYPE (L3_CACHESHAPE, "d") \ |
| 74 | TYPE (RANDOM, "p") |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 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, 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 McGrath | 1d8bb25 | 2008-08-07 08:39:41 +0000 | [diff] [blame] | 95 | if (result == 0 && a_type < nauxv_types && auxv_types[a_type].name != NULL) |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 96 | { |
| 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 | } |