]> git.ipfire.org Git - thirdparty/elfutils.git/blame - libebl/eblobjnotetypename.c
libebl: consistently use _(Str) instead of gettext(Str)
[thirdparty/elfutils.git] / libebl / eblobjnotetypename.c
CommitLineData
b08d5a8f 1/* Return note type name.
72e30c2e 2 Copyright (C) 2002, 2007, 2009, 2011, 2016, 2018 Red Hat, Inc.
de2ed97f 3 This file is part of elfutils.
b08d5a8f
UD
4 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
5
de2ed97f
MW
6 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
b08d5a8f 8
de2ed97f
MW
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
361df7da
UD
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
de2ed97f
MW
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/>. */
b08d5a8f
UD
29
30#ifdef HAVE_CONFIG_H
31# include <config.h>
32#endif
33
34#include <inttypes.h>
35#include <stdio.h>
bb9d1b4b 36#include <string.h>
b08d5a8f
UD
37#include <libeblP.h>
38
39
40const char *
1ccdfb68 41ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
7a3f6fe6 42 GElf_Word descsz,
1ccdfb68 43 char *buf, size_t len)
b08d5a8f 44{
bb9d1b4b 45 const char *res = ebl->object_note_type_name (name, type, buf, len);
b08d5a8f
UD
46
47 if (res == NULL)
48 {
bb9d1b4b
MW
49 if (strcmp (name, "stapsdt") == 0)
50 {
51 snprintf (buf, len, "Version: %" PRIu32, type);
52 return buf;
53 }
54
6e723c78
MW
55#define ELF_NOTE_GOPKGLIST 1
56#define ELF_NOTE_GOABIHASH 2
57#define ELF_NOTE_GODEPS 3
58#define ELF_NOTE_GOBUILDID 4
59
60 static const char *goknowntypes[] =
61 {
62#define KNOWNSTYPE(name) [ELF_NOTE_GO##name] = #name
63 KNOWNSTYPE (PKGLIST),
64 KNOWNSTYPE (ABIHASH),
65 KNOWNSTYPE (DEPS),
66 KNOWNSTYPE (BUILDID),
67#undef KNOWNSTYPE
68 };
69
70 if (strcmp (name, "Go") == 0)
71 {
72 if (type < sizeof (goknowntypes) / sizeof (goknowntypes[0])
73 && goknowntypes[type] != NULL)
74 return goknowntypes[type];
75 else
76 {
2e0ae048 77 snprintf (buf, len, "%s: %" PRIu32, _("<unknown>"), type);
6e723c78
MW
78 return buf;
79 }
80 }
81
72e30c2e
MW
82 if (strncmp (name, ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX,
83 strlen (ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX)) == 0)
84 {
85 /* GNU Build Attribute notes (ab)use the owner name to store
86 most of their data. Don't decode everything here. Just
87 the type.*/
88 char *t = buf;
89 const char *gba = "GNU Build Attribute";
90 int w = snprintf (t, len, "%s ", gba);
91 t += w;
92 len -= w;
93 if (type == NT_GNU_BUILD_ATTRIBUTE_OPEN)
c338a054 94 snprintf (t, len, "OPEN");
72e30c2e 95 else if (type == NT_GNU_BUILD_ATTRIBUTE_FUNC)
c338a054 96 snprintf (t, len, "FUNC");
72e30c2e 97 else
c338a054 98 snprintf (t, len, "%x", type);
72e30c2e
MW
99
100 return buf;
101 }
102
6e723c78
MW
103 if (strcmp (name, "GNU") != 0)
104 {
7a3f6fe6
MW
105 /* NT_VERSION is special, all data is in the name. */
106 if (descsz == 0 && type == NT_VERSION)
107 return "VERSION";
108
2e0ae048 109 snprintf (buf, len, "%s: %" PRIu32, _("<unknown>"), type);
6e723c78
MW
110 return buf;
111 }
112
7a3f6fe6 113 /* And finally all the "GNU" note types. */
b08d5a8f
UD
114 static const char *knowntypes[] =
115 {
116#define KNOWNSTYPE(name) [NT_##name] = #name
7a3f6fe6 117 KNOWNSTYPE (GNU_ABI_TAG),
87d4780b
RM
118 KNOWNSTYPE (GNU_HWCAP),
119 KNOWNSTYPE (GNU_BUILD_ID),
bc1b92e9 120 KNOWNSTYPE (GNU_GOLD_VERSION),
5199e158 121 KNOWNSTYPE (GNU_PROPERTY_TYPE_0),
b08d5a8f
UD
122 };
123
124 /* Handle standard names. */
125 if (type < sizeof (knowntypes) / sizeof (knowntypes[0])
126 && knowntypes[type] != NULL)
127 res = knowntypes[type];
128 else
129 {
2e0ae048 130 snprintf (buf, len, "%s: %" PRIu32, _("<unknown>"), type);
b08d5a8f
UD
131
132 res = buf;
133 }
134 }
135
136 return res;
137}