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 <m...@redhat.com>
---
 libebl/ChangeLog            |  6 ++++++
 libebl/eblobjnotetypename.c | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index aa3d686..26a4f94 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,9 @@
+2016-02-12  Mark Wielaard  <m...@redhat.com>
+
+       * 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  <m...@redhat.com>
 
        * eblobjnote.c (ebl_object_note): Add brackets around if statement
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 8e2e329..db040d2 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 <drep...@redhat.com>, 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 ("<unknown>"), type);
+             return buf;
+           }
+       }
+
+      if (strcmp (name, "GNU") != 0)
+       {
+         snprintf (buf, len, "%s: %" PRIu32, gettext ("<unknown>"), type);
+         return buf;
+       }
+
       static const char *knowntypes[] =
        {
 #define KNOWNSTYPE(name) [NT_##name] = #name
-- 
1.8.3.1

Reply via email to