From patchwork Wed Oct 22 05:29:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 39246 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4D7E9202DB for ; Wed, 22 Oct 2014 05:30:02 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf1590946lab.3 for ; Tue, 21 Oct 2014 22:30:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=+lcqCfudYxJFgaa/sxAqiJnLZbjJ5ZKk95C48hpyoBk=; b=E0R7GR2zuAG4ZkY2oSnVLOP1Z3tpDr39xbjiUvSIMcrH7kY6owFCapD4gvXpWAG0FT MR8pgAGyxHih167unGpz5VoZZfT6MuZ5MDkRcwB0TrTgRqMdVb0rxccompU2OGOkj0gk IAv1U08c+CRxAV3yReBB5BvBGpNgXdM3eIuHFONA6B9tdv2uo7DZsptJCY86EzEWOTcg oZtUk4/nv4fnIcVWSMg8lb8xRM6Z6BvxmY35qbBfHobD+ZsCK5vkKit98ZGfzmdVqlaP 66+sOuM2lG2dhGz1uWDEeYcBrjNjsNhxVJgbFvmOhNBCGU3Gn/TF3jWuT9M1KZjDsjZ2 14WA== X-Gm-Message-State: ALoCoQlu6b/qhRmACEH47ATACalxaC1zisFWgeJq8Im2VURJaEQURqWYD0CG1vbr+3D8SFU6Bkbe X-Received: by 10.180.72.141 with SMTP id d13mr4419804wiv.6.1413955800970; Tue, 21 Oct 2014 22:30:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.100 with SMTP id w4ls139074laz.16.gmail; Tue, 21 Oct 2014 22:30:00 -0700 (PDT) X-Received: by 10.112.219.3 with SMTP id pk3mr39287103lbc.18.1413955800544; Tue, 21 Oct 2014 22:30:00 -0700 (PDT) Received: from mail-lb0-x231.google.com (mail-lb0-x231.google.com. [2a00:1450:4010:c04::231]) by mx.google.com with ESMTPS id w6si21852979lad.65.2014.10.21.22.30.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 22:30:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::231 as permitted sender) client-ip=2a00:1450:4010:c04::231; Received: by mail-lb0-f177.google.com with SMTP id w7so2175852lbi.22 for ; Tue, 21 Oct 2014 22:30:00 -0700 (PDT) X-Received: by 10.152.5.38 with SMTP id p6mr34399025lap.44.1413955800406; Tue, 21 Oct 2014 22:30:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp14291lbz; Tue, 21 Oct 2014 22:29:59 -0700 (PDT) X-Received: by 10.66.166.71 with SMTP id ze7mr15023146pab.5.1413955798958; Tue, 21 Oct 2014 22:29:58 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id bq8si13162692pdb.227.2014.10.21.22.29.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 22:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-116887-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 3038 invoked by alias); 22 Oct 2014 05:29:52 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Subscribe: List-Archive: List-Post: , List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 3015 invoked by uid 89); 22 Oct 2014 05:29:52 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f182.google.com Received: from mail-pd0-f182.google.com (HELO mail-pd0-f182.google.com) (209.85.192.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 22 Oct 2014 05:29:51 +0000 Received: by mail-pd0-f182.google.com with SMTP id y10so2781513pdj.41 for ; Tue, 21 Oct 2014 22:29:49 -0700 (PDT) X-Received: by 10.70.38.201 with SMTP id i9mr15830514pdk.127.1413955789300; Tue, 21 Oct 2014 22:29:49 -0700 (PDT) Received: from kamensky-w530.hsd1.ca.comcast.net ([24.6.79.41]) by mx.google.com with ESMTPSA id ty8sm13522576pab.26.2014.10.21.22.29.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 22:29:48 -0700 (PDT) From: Victor Kamensky To: gdb-patches@sourceware.org Cc: victor.kamensky@linaro.org Subject: [RFC PATCH] fix xfer from section that ends at max of CORE_ADDR Date: Tue, 21 Oct 2014 22:29:41 -0700 Message-Id: <1413955781-5130-1-git-send-email-victor.kamensky@linaro.org> X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::231 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 Fix section_table_xfer_memory_partial function to deals with section entry that may have its endaddr at 0, because that section ends at max of CORE_ADDR and address next after it would be 0 once stored back to CORE_ADDR (overflow). bigcore.exp test run into this issue while running in ARM V7 rootfs on top of ARM V8 kernel (compat mode). In that core file the following section existed (from readelf -a execute on core file): LOAD 0xffe23000 0xffff1000 0x00000000 0x0f000 0x0f000 RW 0x1000 and gdb could not read from it. gdb/ChangeLog: 2014-10-21 Victor Kamensky * exec.c (section_table_xfer_memory_partial): Use ULONGEST for section start and end addresses to handle section that may has its end at max of CORE_ADDR and therefore such section endaddr field would be 0. --- gdb/exec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index f32589b..7c9b4b6 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -697,11 +697,18 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf, struct bfd_section *asect = p->the_bfd_section; bfd *abfd = asect->owner; + /* To deals with possible overflow where p->endaddr is 0, + because of section ends on max of CORE_ADDR, copy section + addr and endaddr to ULONGEST type. Recover section length + first, and use it to determine section_endaddr. */ + ULONGEST section_addr = p->addr; + ULONGEST section_endaddr = section_addr + (p->endaddr - p->addr); + if (section_name && strcmp (section_name, asect->name) != 0) continue; /* not the section we need. */ - if (memaddr >= p->addr) + if (memaddr >= section_addr) { - if (memend <= p->endaddr) + if (memend <= section_endaddr) { /* Entire transfer is within this section. */ if (writebuf) @@ -721,7 +728,7 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf, else return TARGET_XFER_EOF; } - else if (memaddr >= p->endaddr) + else if (memaddr >= section_endaddr) { /* This section ends before the transfer starts. */ continue;