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

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