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