From: Mark Wielaard Date: Fri, 12 Feb 2016 14:04:00 +0000 (+0100) Subject: libebl: Don't assume ELF notes are "GNU" when unknown, recognize "Go" notes. X-Git-Tag: elfutils-0.166~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e723c787212aae2589ad3c000bd38dd21b12095;p=thirdparty%2Felfutils.git libebl: Don't assume ELF notes are "GNU" when unknown, recognize "Go" notes. We used to assume any unknown ELF note provider name was "GNU" and didn't recognize any of the "Go" provider types. We now check the provider name explictly in ebl_object_note_type_name and recognize the following Go note names: PKGLIST, ABIHASH, DEPS and BUILDID. But there is no attempt yet in ebl_object_note to decode the description of these notes. https://bugzilla.redhat.com/show_bug.cgi?id=1295951 Signed-off-by: Mark Wielaard --- diff --git a/libebl/ChangeLog b/libebl/ChangeLog index aa3d68675..26a4f941b 100644 --- a/libebl/ChangeLog +++ b/libebl/ChangeLog @@ -1,3 +1,9 @@ +2016-02-12 Mark Wielaard + + * eblobjnotetypename.c (ebl_object_note_type_name): Check name is + "Go" and use new goknowntypes then. Otherwise check name is not + "GNU" and return "unknown". + 2016-01-09 Mark Wielaard * eblobjnote.c (ebl_object_note): Add brackets around if statement diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c index 8e2e329b8..db040d293 100644 --- a/libebl/eblobjnotetypename.c +++ b/libebl/eblobjnotetypename.c @@ -1,5 +1,5 @@ /* Return note type name. - Copyright (C) 2002, 2007, 2009, 2011 Red Hat, Inc. + Copyright (C) 2002, 2007, 2009, 2011, 2016 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2002. @@ -51,6 +51,39 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type, return buf; } +#define ELF_NOTE_GOPKGLIST 1 +#define ELF_NOTE_GOABIHASH 2 +#define ELF_NOTE_GODEPS 3 +#define ELF_NOTE_GOBUILDID 4 + + static const char *goknowntypes[] = + { +#define KNOWNSTYPE(name) [ELF_NOTE_GO##name] = #name + KNOWNSTYPE (PKGLIST), + KNOWNSTYPE (ABIHASH), + KNOWNSTYPE (DEPS), + KNOWNSTYPE (BUILDID), +#undef KNOWNSTYPE + }; + + if (strcmp (name, "Go") == 0) + { + if (type < sizeof (goknowntypes) / sizeof (goknowntypes[0]) + && goknowntypes[type] != NULL) + return goknowntypes[type]; + else + { + snprintf (buf, len, "%s: %" PRIu32, gettext (""), type); + return buf; + } + } + + if (strcmp (name, "GNU") != 0) + { + snprintf (buf, len, "%s: %" PRIu32, gettext (""), type); + return buf; + } + static const char *knowntypes[] = { #define KNOWNSTYPE(name) [NT_##name] = #name