|
Packit |
032894 |
/* Return note type name.
|
|
Packit |
032894 |
Copyright (C) 2002, 2007, 2009, 2011, 2016, 2018 Red Hat, Inc.
|
|
Packit |
032894 |
This file is part of elfutils.
|
|
Packit |
032894 |
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
This file is free software; you can redistribute it and/or modify
|
|
Packit |
032894 |
it under the terms of either
|
|
Packit |
032894 |
|
|
Packit |
032894 |
* the GNU Lesser General Public License as published by the Free
|
|
Packit |
032894 |
Software Foundation; either version 3 of the License, or (at
|
|
Packit |
032894 |
your option) any later version
|
|
Packit |
032894 |
|
|
Packit |
032894 |
or
|
|
Packit |
032894 |
|
|
Packit |
032894 |
* the GNU General Public License as published by the Free
|
|
Packit |
032894 |
Software Foundation; either version 2 of the License, or (at
|
|
Packit |
032894 |
your option) any later version
|
|
Packit |
032894 |
|
|
Packit |
032894 |
or both in parallel, as here.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit |
032894 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
032894 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
032894 |
General Public License for more details.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
You should have received copies of the GNU General Public License and
|
|
Packit |
032894 |
the GNU Lesser General Public License along with this program. If
|
|
Packit |
032894 |
not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
032894 |
# include <config.h>
|
|
Packit |
032894 |
#endif
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#include <inttypes.h>
|
|
Packit |
032894 |
#include <stdio.h>
|
|
Packit |
032894 |
#include <string.h>
|
|
Packit |
032894 |
#include <libeblP.h>
|
|
Packit |
032894 |
|
|
Packit |
032894 |
|
|
Packit |
032894 |
const char *
|
|
Packit |
032894 |
ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
|
|
Packit |
032894 |
GElf_Word descsz,
|
|
Packit |
032894 |
char *buf, size_t len)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
const char *res = ebl->object_note_type_name (name, type, buf, len);
|
|
Packit |
032894 |
|
|
Packit |
032894 |
if (res == NULL)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
if (strcmp (name, "stapsdt") == 0)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
snprintf (buf, len, "Version: %" PRIu32, type);
|
|
Packit |
032894 |
return buf;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#define ELF_NOTE_GOPKGLIST 1
|
|
Packit |
032894 |
#define ELF_NOTE_GOABIHASH 2
|
|
Packit |
032894 |
#define ELF_NOTE_GODEPS 3
|
|
Packit |
032894 |
#define ELF_NOTE_GOBUILDID 4
|
|
Packit |
032894 |
|
|
Packit |
032894 |
static const char *goknowntypes[] =
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
#define KNOWNSTYPE(name) [ELF_NOTE_GO##name] = #name
|
|
Packit |
032894 |
KNOWNSTYPE (PKGLIST),
|
|
Packit |
032894 |
KNOWNSTYPE (ABIHASH),
|
|
Packit |
032894 |
KNOWNSTYPE (DEPS),
|
|
Packit |
032894 |
KNOWNSTYPE (BUILDID),
|
|
Packit |
032894 |
#undef KNOWNSTYPE
|
|
Packit |
032894 |
};
|
|
Packit |
032894 |
|
|
Packit |
032894 |
if (strcmp (name, "Go") == 0)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
if (type < sizeof (goknowntypes) / sizeof (goknowntypes[0])
|
|
Packit |
032894 |
&& goknowntypes[type] != NULL)
|
|
Packit |
032894 |
return goknowntypes[type];
|
|
Packit |
032894 |
else
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
snprintf (buf, len, "%s: %" PRIu32, gettext ("<unknown>"), type);
|
|
Packit |
032894 |
return buf;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
if (strncmp (name, ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX,
|
|
Packit |
032894 |
strlen (ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX)) == 0)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
/* GNU Build Attribute notes (ab)use the owner name to store
|
|
Packit |
032894 |
most of their data. Don't decode everything here. Just
|
|
Packit |
032894 |
the type.*/
|
|
Packit |
032894 |
char *t = buf;
|
|
Packit |
032894 |
const char *gba = "GNU Build Attribute";
|
|
Packit |
032894 |
int w = snprintf (t, len, "%s ", gba);
|
|
Packit |
032894 |
t += w;
|
|
Packit |
032894 |
len -= w;
|
|
Packit |
032894 |
if (type == NT_GNU_BUILD_ATTRIBUTE_OPEN)
|
|
Packit |
032894 |
snprintf (t, len, "OPEN");
|
|
Packit |
032894 |
else if (type == NT_GNU_BUILD_ATTRIBUTE_FUNC)
|
|
Packit |
032894 |
snprintf (t, len, "FUNC");
|
|
Packit |
032894 |
else
|
|
Packit |
032894 |
snprintf (t, len, "%x", type);
|
|
Packit |
032894 |
|
|
Packit |
032894 |
return buf;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
if (strcmp (name, "GNU") != 0)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
/* NT_VERSION is special, all data is in the name. */
|
|
Packit |
032894 |
if (descsz == 0 && type == NT_VERSION)
|
|
Packit |
032894 |
return "VERSION";
|
|
Packit |
032894 |
|
|
Packit |
032894 |
snprintf (buf, len, "%s: %" PRIu32, gettext ("<unknown>"), type);
|
|
Packit |
032894 |
return buf;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
/* And finally all the "GNU" note types. */
|
|
Packit |
032894 |
static const char *knowntypes[] =
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
#define KNOWNSTYPE(name) [NT_##name] = #name
|
|
Packit |
032894 |
KNOWNSTYPE (GNU_ABI_TAG),
|
|
Packit |
032894 |
KNOWNSTYPE (GNU_HWCAP),
|
|
Packit |
032894 |
KNOWNSTYPE (GNU_BUILD_ID),
|
|
Packit |
032894 |
KNOWNSTYPE (GNU_GOLD_VERSION),
|
|
Packit |
032894 |
KNOWNSTYPE (GNU_PROPERTY_TYPE_0),
|
|
Packit |
032894 |
};
|
|
Packit |
032894 |
|
|
Packit |
032894 |
/* Handle standard names. */
|
|
Packit |
032894 |
if (type < sizeof (knowntypes) / sizeof (knowntypes[0])
|
|
Packit |
032894 |
&& knowntypes[type] != NULL)
|
|
Packit |
032894 |
res = knowntypes[type];
|
|
Packit |
032894 |
else
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
snprintf (buf, len, "%s: %" PRIu32, gettext ("<unknown>"), type);
|
|
Packit |
032894 |
|
|
Packit |
032894 |
res = buf;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
return res;
|
|
Packit |
032894 |
}
|