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

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