1 /* Return section type 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.
6 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
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
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
19 or both in parallel, as here.
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.
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/>. */
39 ebl_section_type_name (ebl, section, buf, len)
45 const char *res = ebl->section_type_name (section, buf, len);
49 static const char *knowntypes[] =
51 #define KNOWNSTYPE(name) [SHT_##name] = #name
53 KNOWNSTYPE (PROGBITS),
64 KNOWNSTYPE (INIT_ARRAY),
65 KNOWNSTYPE (FINI_ARRAY),
66 KNOWNSTYPE (PREINIT_ARRAY),
68 KNOWNSTYPE (SYMTAB_SHNDX)
71 /* Handle standard names. */
72 if ((size_t) section < sizeof (knowntypes) / sizeof (knowntypes[0])
73 && knowntypes[section] != NULL)
74 res = knowntypes[section];
75 /* The symbol versioning/Sun extensions. */
76 else if (section >= SHT_LOSUNW && section <= SHT_HISUNW)
78 static const char *sunwtypes[] =
81 #define KNOWNSTYPE(name) [SHT_##name - SHT_LOSUNW] = #name
82 KNOWNSTYPE (SUNW_move),
83 KNOWNSTYPE (SUNW_COMDAT),
84 KNOWNSTYPE (SUNW_syminfo),
85 KNOWNSTYPE (GNU_verdef),
86 KNOWNSTYPE (GNU_verneed),
87 KNOWNSTYPE (GNU_versym)
89 res = sunwtypes[section - SHT_LOSUNW];
92 /* A few GNU additions. */
104 case SHT_GNU_ATTRIBUTES:
105 res = "GNU_ATTRIBUTES";
109 /* Handle OS-specific section names. */
110 if (section >= SHT_LOOS && section <= SHT_HIOS)
111 snprintf (buf, len, "SHT_LOOS+%x", section - SHT_LOOS);
112 /* Handle processor-specific section names. */
113 else if (section >= SHT_LOPROC && section <= SHT_HIPROC)
114 snprintf (buf, len, "SHT_LOPROC+%x", section - SHT_LOPROC);
115 else if ((unsigned int) section >= SHT_LOUSER
116 && (unsigned int) section <= SHT_HIUSER)
117 snprintf (buf, len, "SHT_LOUSER+%x", section - SHT_LOUSER);
119 snprintf (buf, len, "%s: %d", gettext ("<unknown>"), section);