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

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