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

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