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

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