]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove hack for GDB which sets the section size to 0
authorKevin Buettner <kevinb@redhat.com>
Thu, 5 Mar 2020 00:42:40 +0000 (17:42 -0700)
committerKevin Buettner <kevinb@redhat.com>
Wed, 22 Jul 2020 19:32:24 +0000 (12:32 -0700)
This commit removes a hack for GDB which was introduced in 2007.
See:

    https://sourceware.org/ml/binutils/2007-08/msg00044.html

That hack mostly allowed GDB's handling of core files to continue to
work without any changes to GDB.

The problem with setting the section size to zero is that GDB won't
know how big that section is/was.  Often, this doesn't matter because
the data in question are found in the exec file.  But it can happen
that the section describes memory that had been allocated, but never
written to.  In this instance, the contents of that memory region are
not written to the core file.  Also, since the region in question was
dynamically allocated, it won't appear in the exec file.  We don't
want these regions to appear as inaccessible to GDB (since they *were*
accessible when the process was live), so it's important that GDB know
the size of the region.

I've made changes to GDB which correctly handles this case.  When
attempting to access memory, GDB will first consider core file data
for which both SEC_ALLOC and SEC_HAS_CONTENTS is set.  Next, if that
fails, GDB will attempt to find the data in the exec file.  Finally,
if that also fails, GDB will attempt to access memory in the sections
which are flagged as SEC_ALLOC, but not SEC_HAS_CONTENTS.

bfd/ChangeLog:

* elf.c (_bfd_elf_make_section_from_phdr): Remove hack for GDB.

bfd/ChangeLog
bfd/elf.c

index 411c19068df18f97e5ea08adbc30af4bd0815480..adbf6f3b20bce3988daae30ca52c9c5cf69816cf 100644 (file)
@@ -1,3 +1,7 @@
+2020-07-22  Kevin Buettner  <kevinb@redhat.com>
+
+       * elf.c (_bfd_elf_make_section_from_phdr): Remove hack for GDB.
+       
 2020-07-22  Max Filippov  <jcmvbkbc@gmail.com>
 
        PR 26246
index 9ca42e10d8e5b28090d6ce73cc65fbd456210123..991a71ca32a5107fff2b6f3863cdd2ad9b9d256d 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3026,14 +3026,6 @@ _bfd_elf_make_section_from_phdr (bfd *abfd,
       newsect->alignment_power = bfd_log2 (align);
       if (hdr->p_type == PT_LOAD)
        {
-         /* Hack for gdb.  Segments that have not been modified do
-            not have their contents written to a core file, on the
-            assumption that a debugger can find the contents in the
-            executable.  We flag this case by setting the fake
-            section size to zero.  Note that "real" bss sections will
-            always have their contents dumped to the core file.  */
-         if (bfd_get_format (abfd) == bfd_core)
-           newsect->size = 0;
          newsect->flags |= SEC_ALLOC;
          if (hdr->p_flags & PF_X)
            newsect->flags |= SEC_CODE;