From patchwork Thu Mar 20 15:46:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 26714 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0E7020143 for ; Thu, 20 Mar 2014 15:46:37 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf3572112iec.8 for ; Thu, 20 Mar 2014 08:46:37 -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:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=29WgRlPuieW05jzZXsYoqIHOCin4br82W67+syNRhkc=; b=fRZJmOYV7YZ/m6o/mqWmACl6ChUzYXKF5TWRCtVom/Vrm06jehDDoGeAJW3VFVPX+o jFnRAkUvfnsA7aHetSM+gV0smoYPERy7mujWO+E1RWUwXoJhZttRcGwYm4rmCQmy6osG xf0LC3BKZbDSG37r7Ujm2ogDBmdbs14AFQlDz/3j5/L+HVg74hjsQuj3OGYljjNm/Ez5 28CJ2PGpv9d+jV+SFFl1aCe0zFzB6JNXKF4UHVe6t+EY+0TzyX2Cim9929qNcn9q+AtS 6bviVtNo1tVokrUdeSuHPHvsjg29CHyKyRad0fcaHaIKEhL5rOEwYmYZWBjutMhuxV2j 1Wmg== X-Gm-Message-State: ALoCoQkE55CVFza4FdtBMuqfcylVtNbIeHVV22126c1JGpSgzR7uuhG05CSowkO7oMGr8myLFoj8 X-Received: by 10.42.51.141 with SMTP id e13mr15574766icg.28.1395330396816; Thu, 20 Mar 2014 08:46:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.239 with SMTP id m102ls278417qga.8.gmail; Thu, 20 Mar 2014 08:46:36 -0700 (PDT) X-Received: by 10.58.112.98 with SMTP id ip2mr4251012veb.35.1395330396675; Thu, 20 Mar 2014 08:46:36 -0700 (PDT) Received: from mail-vc0-x230.google.com (mail-vc0-x230.google.com [2607:f8b0:400c:c03::230]) by mx.google.com with ESMTPS id kj3si529109vdb.33.2014.03.20.08.46.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 08:46:36 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c03::230; Received: by mail-vc0-f176.google.com with SMTP id lc6so1138979vcb.7 for ; Thu, 20 Mar 2014 08:46:36 -0700 (PDT) X-Received: by 10.52.163.236 with SMTP id yl12mr3812804vdb.39.1395330396600; Thu, 20 Mar 2014 08:46:36 -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.220.78.9 with SMTP id i9csp398503vck; Thu, 20 Mar 2014 08:46:36 -0700 (PDT) X-Received: by 10.66.231.40 with SMTP id td8mr47810428pac.103.1395330395635; Thu, 20 Mar 2014 08:46:35 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j4si1734598pad.391.2014.03.20.08.46.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Mar 2014 08:46:35 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-83208-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 13237 invoked by alias); 20 Mar 2014 15:46:19 -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: binutils-owner@sourceware.org Delivered-To: mailing list binutils@sourceware.org Received: (qmail 13228 invoked by uid 89); 20 Mar 2014 15:46:18 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f181.google.com Received: from mail-we0-f181.google.com (HELO mail-we0-f181.google.com) (74.125.82.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 20 Mar 2014 15:46:16 +0000 Received: by mail-we0-f181.google.com with SMTP id q58so748438wes.12 for ; Thu, 20 Mar 2014 08:46:13 -0700 (PDT) X-Received: by 10.194.77.50 with SMTP id p18mr7875280wjw.68.1395330373212; Thu, 20 Mar 2014 08:46:13 -0700 (PDT) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginm.net. [82.1.113.198]) by mx.google.com with ESMTPSA id ee5sm7499043wib.8.2014.03.20.08.46.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Mar 2014 08:46:12 -0700 (PDT) From: Will Newton To: binutils@sourceware.org Subject: [PATCH v2] bfd/elfnn-aarch64.c: Fix calculation of DT_RELASZ Date: Thu, 20 Mar 2014 15:46:08 +0000 Message-Id: <1395330368-19311-1-git-send-email-will.newton@linaro.org> X-IsSubscribed: yes X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c03::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 The current code subtracts the size of the output section containing relplt from RELASZ. In some cases this will be the same output section as the dynamic relocs causing a value of zero to be output. Calculating the size from input sections seems to make more sense. bfd/ChangeLog: 2014-03-20 Will Newton * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_sections): Set value of DT_PLTRELSZ and DT_RELASZ based on the size of input sections rather than output sections. ld/testsuite/ChangeLog: 2014-03-20 Will Newton * ld-aarch64/aarch64-elf.exp: Add relasz dump test. * ld-aarch64/relasz.d: New file. * ld-aarch64/relasz.s: Likewise. --- bfd/elfnn-aarch64.c | 4 ++-- ld/testsuite/ld-aarch64/aarch64-elf.exp | 2 ++ ld/testsuite/ld-aarch64/relasz.d | 18 ++++++++++++++++++ ld/testsuite/ld-aarch64/relasz.s | 9 +++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 ld/testsuite/ld-aarch64/relasz.d create mode 100644 ld/testsuite/ld-aarch64/relasz.s Changes in v2: - Add testcase diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index c2adcc9..638938d 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -6993,7 +6993,7 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, break; case DT_PLTRELSZ: - s = htab->root.srelplt->output_section; + s = htab->root.srelplt; dyn.d_un.d_val = s->size; break; @@ -7007,7 +7007,7 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, about changing the DT_RELA entry. */ if (htab->root.srelplt != NULL) { - s = htab->root.srelplt->output_section; + s = htab->root.srelplt; dyn.d_un.d_val -= s->size; } break; diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 32cf73a..845ea20 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -157,3 +157,5 @@ run_dump_test "ifunc-19b" run_dump_test "ifunc-20" run_dump_test "ifunc-21" run_dump_test "ifunc-22" + +run_dump_test "relasz" diff --git a/ld/testsuite/ld-aarch64/relasz.d b/ld/testsuite/ld-aarch64/relasz.d new file mode 100644 index 0000000..5cc5595 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relasz.d @@ -0,0 +1,18 @@ +#source: relasz.s +#ld: -shared -Taarch64.ld +#readelf: -d +# Check that the RELASZ section has the correct size even if we are +# using a non-default linker script that merges .rela.dyn and .rela.plt +# in the output. + +Dynamic section at offset 0x[0-9a-f]+ contains 9 entries: + Tag Type Name/Value + 0x0000000000000004 \(HASH\) 0x[0-9a-f]+ + 0x0000000000000005 \(STRTAB\) 0x[0-9a-f]+ + 0x0000000000000006 \(SYMTAB\) 0x[0-9a-f]+ + 0x000000000000000a \(STRSZ\) [0-9]+ \(bytes\) + 0x000000000000000b \(SYMENT\) [0-9]+ \(bytes\) + 0x0000000000000007 \(RELA\) 0x[0-9a-f]+ + 0x0000000000000008 \(RELASZ\) 24 \(bytes\) + 0x0000000000000009 \(RELAENT\) 24 \(bytes\) + 0x0000000000000000 \(NULL\) 0x0 diff --git a/ld/testsuite/ld-aarch64/relasz.s b/ld/testsuite/ld-aarch64/relasz.s new file mode 100644 index 0000000..8c7f891 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relasz.s @@ -0,0 +1,9 @@ + .text + .global func + .type func, %function +func: + adrp x0, :got:foo + ldr x0, [x0, #:got_lo12:foo] + ldr w0, [x0] + ret + .size func, .-func