Blame SOURCES/gdb-6.6-buildid-locate-rpm-scl.patch

132741
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
132741
From: Fedora GDB patches <invalid@email.com>
132741
Date: Fri, 27 Oct 2017 21:07:50 +0200
132741
Subject: gdb-6.6-buildid-locate-rpm-scl.patch
132741
132741
;; [SCL] Skip deprecated .gdb_index warning for Red Hat built files (BZ 953585).
132741
;;=push+jan
132741
132741
warning: Skipping deprecated .gdb_index section
132741
https://bugzilla.redhat.com/show_bug.cgi?id=953585
132741
132741
diff --git a/gdb/build-id.c b/gdb/build-id.c
132741
--- a/gdb/build-id.c
132741
+++ b/gdb/build-id.c
132741
@@ -742,7 +742,11 @@ static int missing_rpm_list_entries;
132741
 /* Returns the count of newly added rpms.  */
132741
 
132741
 static int
132741
+#ifndef GDB_INDEX_VERIFY_VENDOR
132741
 missing_rpm_enlist (const char *filename)
132741
+#else
132741
+missing_rpm_enlist_1 (const char *filename, int verify_vendor)
132741
+#endif
132741
 {
132741
   static int rpm_init_done = 0;
132741
   rpmts ts;
132741
@@ -849,7 +853,11 @@ missing_rpm_enlist (const char *filename)
132741
   mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
132741
   if (mi != NULL)
132741
     {
132741
+#ifndef GDB_INDEX_VERIFY_VENDOR
132741
       for (;;)
132741
+#else
132741
+      if (!verify_vendor) for (;;)
132741
+#endif
132741
 	{
132741
 	  Header h;
132741
 	  char *debuginfo, **slot, *s, *s2;
132741
@@ -967,6 +975,37 @@ missing_rpm_enlist (const char *filename)
132741
 	    xfree (debuginfo);
132741
 	  count++;
132741
 	}
132741
+#ifdef GDB_INDEX_VERIFY_VENDOR
132741
+      else /* verify_vendor */
132741
+	{
132741
+	  int vendor_pass = 0, vendor_fail = 0;
132741
+
132741
+	  for (;;)
132741
+	    {
132741
+	      Header h;
132741
+	      errmsg_t err;
132741
+	      char *vendor;
132741
+
132741
+	      h = rpmdbNextIterator_p (mi);
132741
+	      if (h == NULL)
132741
+		break;
132741
+
132741
+	      vendor = headerFormat_p (h, "%{vendor}", &err;;
132741
+	      if (!vendor)
132741
+		{
132741
+		  warning (_("Error querying the rpm file `%s': %s"), filename,
132741
+			   err);
132741
+		  continue;
132741
+		}
132741
+	      if (strcmp (vendor, "Red Hat, Inc.") == 0)
132741
+		vendor_pass = 1;
132741
+	      else
132741
+		vendor_fail = 1;
132741
+	      xfree (vendor);
132741
+	    }
132741
+	  count = vendor_pass != 0 && vendor_fail == 0;
132741
+	}
132741
+#endif
132741
 
132741
       rpmdbFreeIterator_p (mi);
132741
     }
132741
@@ -976,6 +1015,20 @@ missing_rpm_enlist (const char *filename)
132741
   return count;
132741
 }
132741
 
132741
+#ifdef GDB_INDEX_VERIFY_VENDOR
132741
+missing_rpm_enlist (const char *filename)
132741
+{
132741
+  return missing_rpm_enlist_1 (filename, 0);
132741
+}
132741
+
132741
+extern int rpm_verify_vendor (const char *filename);
132741
+int
132741
+rpm_verify_vendor (const char *filename)
132741
+{
132741
+  return missing_rpm_enlist_1 (filename, 1);
132741
+}
132741
+#endif
132741
+
132741
 static bool
132741
 missing_rpm_list_compar (const char *ap, const char *bp)
132741
 {
132741
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
132741
--- a/gdb/dwarf2/read.c
132741
+++ b/gdb/dwarf2/read.c
132741
@@ -3034,6 +3034,16 @@ read_gdb_index_from_buffer (const char *filename,
132741
      "set use-deprecated-index-sections on".  */
132741
   if (version < 6 && !deprecated_ok)
132741
     {
132741
+#ifdef GDB_INDEX_VERIFY_VENDOR
132741
+      extern int rpm_verify_vendor (const char *filename);
132741
+
132741
+      /* Red Hat Developer Toolset exception.  */
132741
+      if (rpm_verify_vendor (filename))
132741
+	{}
132741
+      else
132741
+      {
132741
+
132741
+#endif
132741
       static int warning_printed = 0;
132741
       if (!warning_printed)
132741
 	{
132741
@@ -3045,6 +3055,10 @@ to use the section anyway."),
132741
 	  warning_printed = 1;
132741
 	}
132741
       return 0;
132741
+#ifdef GDB_INDEX_VERIFY_VENDOR
132741
+
132741
+      }
132741
+#endif
132741
     }
132741
   /* Version 7 indices generated by gold refer to the CU for a symbol instead
132741
      of the TU (for symbols coming from TUs),