1 /* Return dynamic tag name.
2 Copyright (C) 2001, 2002, 2006, 2008 Red Hat, Inc.
3 This file is part of elfutils.
4 Written by Ulrich Drepper <drepper@redhat.com>, 2001.
5
6 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
8
9 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version
12
13 or
14
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version
18
19 or both in parallel, as here.
20
21 elfutils is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
25
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
29
30 #ifdef HAVE_CONFIG_H
31 # include <config.h>
32 #endif
33
34 #include <inttypes.h>
35 #include <stdio.h>
36 #include <libeblP.h>
37 #include "system.h"
38
39
40 const char *
ebl_dynamic_tag_name(Ebl * ebl,int64_t tag,char * buf,size_t len)41 ebl_dynamic_tag_name (Ebl *ebl, int64_t tag, char *buf, size_t len)
42 {
43 const char *res = ebl != NULL ? ebl->dynamic_tag_name (tag, buf, len) : NULL;
44
45 if (res == NULL)
46 {
47 if (tag >= 0 && tag < DT_NUM)
48 {
49 static const char *stdtags[] =
50 {
51 "NULL", "NEEDED", "PLTRELSZ", "PLTGOT", "HASH", "STRTAB",
52 "SYMTAB", "RELA", "RELASZ", "RELAENT", "STRSZ", "SYMENT",
53 "INIT", "FINI", "SONAME", "RPATH", "SYMBOLIC", "REL", "RELSZ",
54 "RELENT", "PLTREL", "DEBUG", "TEXTREL", "JMPREL", "BIND_NOW",
55 "INIT_ARRAY", "FINI_ARRAY", "INIT_ARRAYSZ", "FINI_ARRAYSZ",
56 "RUNPATH", "FLAGS", "ENCODING", "PREINIT_ARRAY",
57 "PREINIT_ARRAYSZ", "SYMTAB_SHNDX"
58 };
59 eu_static_assert (sizeof (stdtags) / sizeof (const char *) == DT_NUM);
60
61 res = stdtags[tag];
62 }
63 else if (tag == DT_VERSYM)
64 res = "VERSYM";
65 else if (tag >= DT_GNU_PRELINKED && tag <= DT_SYMINENT)
66 {
67 static const char *valrntags[] =
68 {
69 "GNU_PRELINKED", "GNU_CONFLICTSZ", "GNU_LIBLISTSZ",
70 "CHECKSUM", "PLTPADSZ", "MOVEENT", "MOVESZ", "FEATURE_1",
71 "POSFLAG_1", "SYMINSZ", "SYMINENT"
72 };
73
74 res = valrntags[tag - DT_GNU_PRELINKED];
75 }
76 else if (tag >= DT_GNU_HASH && tag <= DT_SYMINFO)
77 {
78 static const char *addrrntags[] =
79 {
80 "GNU_HASH", "TLSDESC_PLT", "TLSDESC_GOT",
81 "GNU_CONFLICT", "GNU_LIBLIST", "CONFIG", "DEPAUDIT", "AUDIT",
82 "PLTPAD", "MOVETAB", "SYMINFO"
83 };
84
85 res = addrrntags[tag - DT_GNU_HASH];
86 }
87 else if (tag >= DT_RELACOUNT && tag <= DT_VERNEEDNUM)
88 {
89 static const char *suntags[] =
90 {
91 "RELACOUNT", "RELCOUNT", "FLAGS_1", "VERDEF", "VERDEFNUM",
92 "VERNEED", "VERNEEDNUM"
93 };
94
95 res = suntags[tag - DT_RELACOUNT];
96 }
97 else if (tag == DT_AUXILIARY)
98 res = "AUXILIARY";
99 else if (tag == DT_FILTER)
100 res = "FILTER";
101 else
102 {
103 snprintf (buf, len, gettext ("<unknown>: %#" PRIx64), tag);
104
105 res = buf;
106
107 }
108 }
109
110 return res;
111 }
112