Blame SOURCES/gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch

59b2e3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
59b2e3
From: Keith Seitz <keiths@redhat.com>
59b2e3
Date: Mon, 16 Nov 2020 12:42:09 -0500
59b2e3
Subject: gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch
59b2e3
59b2e3
;; Backport of "Exclude debuginfo files from 'outside of ELF segments'
59b2e3
;; warning"  (Keith Seitz)
59b2e3
59b2e3
    Exclude debuginfo files from "outside of ELF segments" warning
59b2e3
59b2e3
    When GDB loads an ELF file, it will warn when a section is not located
59b2e3
    in an ELF segment:
59b2e3
59b2e3
    $ ./gdb -q -iex "set build-id-verbose 0" --ex "b systemctl_main" -ex "r" -batch --args systemctl kexec
59b2e3
    Breakpoint 1 at 0xc24d: file ../src/systemctl/systemctl.c, line 8752.
59b2e3
    warning: Loadable section ".note.gnu.property" outside of ELF segments
59b2e3
      in .gnu_debugdata for /lib64/libgcc_s.so.1
59b2e3
    [Thread debugging using libthread_db enabled]
59b2e3
    Using host libthread_db library "/lib64/libthread_db.so.1".
59b2e3
    warning: Loadable section ".note.gnu.property" outside of ELF segments
59b2e3
      in .gnu_debugdata for /lib64/libcap.so.2
59b2e3
    warning: Loadable section ".note.gnu.property" outside of ELF segments
59b2e3
      in .gnu_debugdata for /lib64/libacl.so.1
59b2e3
    warning: Loadable section ".note.gnu.property" outside of ELF segments
59b2e3
      in .gnu_debugdata for /lib64/libcryptsetup.so.12
59b2e3
    warning: Loadable section ".note.gnu.property" outside of ELF segments
59b2e3
      in .gnu_debugdata for /lib64/libgcrypt.so.20
59b2e3
    warning: Loadable section ".note.gnu.property" outside of ELF segments
59b2e3
      in .gnu_debugdata for /lib64/libip4tc.so.2
59b2e3
    [snip]
59b2e3
    This has feature has also been reported by various users, most notably
59b2e3
    the Fedora-EOL'd bug 1553086.
59b2e3
59b2e3
    Mark Wielaard explains the issue quite nicely in
59b2e3
59b2e3
       https://sourceware.org/bugzilla/show_bug.cgi?id=24717#c2
59b2e3
59b2e3
    The short of it is, the ELF program headers for debuginfo files are
59b2e3
    not suited to this particular use case. Consequently, the warning
59b2e3
    generated above really is useless and should be ignored.
59b2e3
59b2e3
    This patch follows the same heuristic that BFD itself uses.
59b2e3
59b2e3
    gdb/ChangeLog
59b2e3
    2020-11-13  Keith Seitz  <keiths@redhat.com>
59b2e3
59b2e3
            https://bugzilla.redhat.com/show_bug.cgi?id=1553086
59b2e3
            * elfread.c (elf_symfile_segments): Omit "Loadable section ...
59b2e3
            outside of ELF segments" warning for debugin
59b2e3
59b2e3
diff --git a/gdb/elfread.c b/gdb/elfread.c
59b2e3
--- a/gdb/elfread.c
59b2e3
+++ b/gdb/elfread.c
59b2e3
@@ -151,7 +151,12 @@ elf_symfile_segments (bfd *abfd)
59b2e3
 	 RealView) use SHT_NOBITS for uninitialized data.  Since it is
59b2e3
 	 uninitialized, it doesn't need a program header.  Such
59b2e3
 	 binaries are not relocatable.  */
59b2e3
-      if (bfd_section_size (sect) > 0 && j == num_segments
59b2e3
+
59b2e3
+      /* Exclude debuginfo files from this warning, too, since those
59b2e3
+	 are often not strictly compliant with the standard. See, e.g.,
59b2e3
+	 ld/24717 for more discussion.  */
59b2e3
+      if (!is_debuginfo_file (abfd)
59b2e3
+	  && bfd_section_size (sect) > 0 && j == num_segments
59b2e3
 	  && (bfd_section_flags (sect) & SEC_LOAD) != 0)
59b2e3
 	warning (_("Loadable section \"%s\" outside of ELF segments"),
59b2e3
 		 bfd_section_name (sect));