1 /* Return section type name.
2 Copyright (C) 2001, 2002 Red Hat, Inc.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2001.
5 This program is Open Source software; you can redistribute it and/or
6 modify it under the terms of the Open Software License version 1.0 as
7 published by the Open Source Initiative.
9 You should have received a copy of the Open Software License along
10 with this program; if not, you may obtain a copy of the Open Software
11 License version 1.0 from http://www.opensource.org/licenses/osl.php or
12 by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13 3001 King Ranch Road, Ukiah, CA 95482. */
24 ebl_section_type_name (ebl, section, buf, len)
30 const char *res = ebl->section_type_name (section, buf, len);
34 static const char *knowntypes[] =
36 #define KNOWNSTYPE(name) [SHT_##name] = #name
38 KNOWNSTYPE (PROGBITS),
49 KNOWNSTYPE (INIT_ARRAY),
50 KNOWNSTYPE (FINI_ARRAY),
51 KNOWNSTYPE (PREINIT_ARRAY),
53 KNOWNSTYPE (SYMTAB_SHNDX)
56 /* Handle standard names. */
57 if ((size_t) section < sizeof (knowntypes) / sizeof (knowntypes[0])
58 && knowntypes[section] != NULL)
59 res = knowntypes[section];
60 /* The symbol versioning/Sun extensions. */
61 else if (section >= SHT_LOSUNW && section <= SHT_HISUNW)
63 static const char *sunwtypes[] =
66 #define KNOWNSTYPE(name) [SHT_##name - SHT_LOSUNW] = #name
67 KNOWNSTYPE (SUNW_move),
68 KNOWNSTYPE (SUNW_COMDAT),
69 KNOWNSTYPE (SUNW_syminfo),
70 KNOWNSTYPE (GNU_verdef),
71 KNOWNSTYPE (GNU_verneed),
72 KNOWNSTYPE (GNU_versym)
74 res = sunwtypes[section - SHT_LOSUNW];
78 /* A few GNU additions. */
79 if (section == SHT_CHECKSUM)
81 else if (section == SHT_GNU_LIBLIST)
83 /* Handle OS-specific section names. */
86 if (section >= SHT_LOOS && section <= SHT_HIOS)
87 snprintf (buf, len, "SHT_LOOS+%x", section - SHT_LOOS);
88 /* Handle processor-specific section names. */
89 else if (section >= SHT_LOPROC && section <= SHT_HIPROC)
90 snprintf (buf, len, "SHT_LOPROC+%x", section - SHT_LOPROC);
91 else if ((unsigned int) section >= SHT_LOUSER
92 && (unsigned int) section <= SHT_HIUSER)
93 snprintf (buf, len, "SHT_LOUSER+%x", section - SHT_LOUSER);
95 snprintf (buf, len, "%s: %d", gettext ("<unknown>"), section);