From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 29130383F867 for ; Wed, 22 Jul 2020 00:59:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 29130383F867 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-ss9cR7EDPKmD5mOJq5WrvA-1; Tue, 21 Jul 2020 20:59:10 -0400 X-MC-Unique: ss9cR7EDPKmD5mOJq5WrvA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A5961932486 for ; Wed, 22 Jul 2020 00:59:09 +0000 (UTC) Received: from f32-1.lan (ovpn-112-21.phx2.redhat.com [10.3.112.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6963F5C662; Wed, 22 Jul 2020 00:59:09 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH v5 01/14] Remove hack for GDB which sets the section size to 0 Date: Tue, 21 Jul 2020 17:58:19 -0700 Message-Id: <20200722005832.863276-2-kevinb@redhat.com> In-Reply-To: <20200722005832.863276-1-kevinb@redhat.com> References: <20200722005832.863276-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2020 00:59:15 -0000 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/elf.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bfd/elf.c b/bfd/elf.c index 9ca42e10d8..991a71ca32 100644 --- 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; -- 2.26.2