]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libebl: Don't assume ELF notes are "GNU" when unknown, recognize "Go" notes.
authorMark Wielaard <mjw@redhat.com>
Fri, 12 Feb 2016 14:04:00 +0000 (15:04 +0100)
committerMark Wielaard <mjw@redhat.com>
Mon, 15 Feb 2016 22:51:20 +0000 (23:51 +0100)
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 <mjw@redhat.com>
libebl/ChangeLog
libebl/eblobjnotetypename.c

index aa3d6867552c99679f05529a05912e8419ea1608..26a4f941b98769e55608a06e52826382d0ffbd91 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-12  Mark Wielaard  <mjw@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  <mjw@redhat.com>
 
        * eblobjnote.c (ebl_object_note): Add brackets around if statement
index 8e2e329b84b9c64da5f878dc2be3b0e660bd4726..db040d29367a7b696842452cf8ec00c2b63536c9 100644 (file)
@@ -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 <drepper@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