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

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