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
38
39 const char *
ebl_dynamic_tag_name(Ebl * ebl,int64_t tag,char * buf,size_t len)40 ebl_dynamic_tag_name (Ebl *ebl, int64_t tag, char *buf, size_t len)
41 {
42 const char *res = ebl != NULL ? ebl->dynamic_tag_name (tag, buf, len) : NULL;
43
44 if (res == NULL)
45 {
46 if (tag >= 0 && tag < DT_NUM)
47 {
48 static const char *stdtags[] =
49 {
50 "NULL", "NEEDED", "PLTRELSZ", "PLTGOT", "HASH", "STRTAB",
51 "SYMTAB", "RELA", "RELASZ", "RELAENT", "STRSZ", "SYMENT",
52 "INIT", "FINI", "SONAME", "RPATH", "SYMBOLIC", "REL", "RELSZ",
53 "RELENT", "PLTREL", "DEBUG", "TEXTREL", "JMPREL", "BIND_NOW",
54 "INIT_ARRAY", "FINI_ARRAY", "INIT_ARRAYSZ", "FINI_ARRAYSZ",
55 "RUNPATH", "FLAGS", "ENCODING", "PREINIT_ARRAY",
56 "PREINIT_ARRAYSZ"
57 };
58
59 res = stdtags[tag];
60 }
61 else if (tag == DT_VERSYM)
62 res = "VERSYM";
63 else if (tag >= DT_GNU_PRELINKED && tag <= DT_SYMINENT)
64 {
65 static const char *valrntags[] =
66 {
67 "GNU_PRELINKED", "GNU_CONFLICTSZ", "GNU_LIBLISTSZ",
68 "CHECKSUM", "PLTPADSZ", "MOVEENT", "MOVESZ", "FEATURE_1",
69 "POSFLAG_1", "SYMINSZ", "SYMINENT"
70 };
71
72 res = valrntags[tag - DT_GNU_PRELINKED];
73 }
74 else if (tag >= DT_GNU_HASH && tag <= DT_SYMINFO)
75 {
76 static const char *addrrntags[] =
77 {
78 "GNU_HASH", "TLSDESC_PLT", "TLSDESC_GOT",
79 "GNU_CONFLICT", "GNU_LIBLIST", "CONFIG", "DEPAUDIT", "AUDIT",
80 "PLTPAD", "MOVETAB", "SYMINFO"
81 };
82
83 res = addrrntags[tag - DT_GNU_HASH];
84 }
85 else if (tag >= DT_RELACOUNT && tag <= DT_VERNEEDNUM)
86 {
87 static const char *suntags[] =
88 {
89 "RELACOUNT", "RELCOUNT", "FLAGS_1", "VERDEF", "VERDEFNUM",
90 "VERNEED", "VERNEEDNUM"
91 };
92
93 res = suntags[tag - DT_RELACOUNT];
94 }
95 else if (tag == DT_AUXILIARY)
96 res = "AUXILIARY";
97 else if (tag == DT_FILTER)
98 res = "FILTER";
99 else
100 {
101 snprintf (buf, len, gettext ("<unknown>: %#" PRIx64), tag);
102
103 res = buf;
104
105 }
106 }
107
108 return res;
109 }
110