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