From patchwork Tue Nov 26 08:54:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 21765 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E938C202DA for ; Tue, 26 Nov 2013 08:54:10 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id m1sf18221967oag.1 for ; Tue, 26 Nov 2013 00:54:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=ONTAtBC0Ip0jtLMRDdesTguiBpuuVMKoagn6h2VRrXU=; b=AdJwchC9ZgDz5PrI2sOAdMRDkyOLLqoEOgXEGyUOOyyjS7WJI4zuMG5iVNFBVE4yZY oPLjbx8qk0c7f2GCiwGlQQTogjByHl/nmLGw8UOnMxDxc29J1eHNGaqQF2iMeU60RLpy ObnCnm4w+avsg397Tt/msG3hAZP+HNT8iaV/fA3IMKNlSRfsigNTgkE4CQ7uf6p9iZaB Lr+gBoTe0PopxVWqnux+BpWWfycP6048EptTZtY27dwfeL+1gKbBR5mQGAa2FmeSymqu TpGAseelgVzYK66PgKu+AKAqwrsB9igDKfnISLegKl6kc2PpFDR3FtfmStCznwJqgJPw VjMw== X-Gm-Message-State: ALoCoQkegueG5x+PzbPNpGc9JMkSAkcD/zgUk83EjjAc38+lL4Edh0howRF4hdJl9fSpmP1w0P2y X-Received: by 10.182.74.226 with SMTP id x2mr10364501obv.1.1385456049754; Tue, 26 Nov 2013 00:54:09 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.198 with SMTP id m6ls2501560qeo.43.gmail; Tue, 26 Nov 2013 00:54:09 -0800 (PST) X-Received: by 10.58.187.51 with SMTP id fp19mr230464vec.47.1385456049590; Tue, 26 Nov 2013 00:54:09 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id th8si12105717vdc.115.2013.11.26.00.54.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 00:54:09 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so3861418veb.13 for ; Tue, 26 Nov 2013 00:54:09 -0800 (PST) X-Received: by 10.52.97.35 with SMTP id dx3mr25676976vdb.18.1385456049263; Tue, 26 Nov 2013 00:54:09 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp196138vcz; Tue, 26 Nov 2013 00:54:05 -0800 (PST) X-Received: by 10.194.78.51 with SMTP id y19mr4842448wjw.62.1385456045081; Tue, 26 Nov 2013 00:54:05 -0800 (PST) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by mx.google.com with ESMTPS id fx5si19026944wjb.84.2013.11.26.00.54.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 00:54:05 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.43 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=74.125.82.43; Received: by mail-wg0-f43.google.com with SMTP id k14so2440563wgh.10 for ; Tue, 26 Nov 2013 00:54:04 -0800 (PST) X-Received: by 10.180.198.46 with SMTP id iz14mr10729235wic.40.1385456044403; Tue, 26 Nov 2013 00:54:04 -0800 (PST) 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 hv5sm58086765wib.2.2013.11.26.00.54.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 26 Nov 2013 00:54:03 -0800 (PST) Message-ID: <529461A9.4060909@linaro.org> Date: Tue, 26 Nov 2013 08:54:01 +0000 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: binutils@sourceware.org CC: Patch Tracking Subject: [PATCH 1/2] bfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms. X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The .got.plt header size was not being correctly taken into account when calculating the offset for relocations against ifunc symbols. bfd/ChangeLog: 2013-11-25 Will Newton * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Ensure PLT_INDEX is calculated using correct header size. ld/testsuite/ChangeLog: 2013-11-25 Will Newton * ld-aarch64/aarch64-elf.exp: Add ifunc-21 test. * ld-aarch64/ifunc-21.d: New file. * ld-aarch64/ifunc-21.s: Likewise. --- bfd/elfnn-aarch64.c | 3 ++- ld/testsuite/ld-aarch64/aarch64-elf.exp | 1 + ld/testsuite/ld-aarch64/ifunc-21.d | 31 +++++++++++++++++++++++++++++++ ld/testsuite/ld-aarch64/ifunc-21.s | 13 +++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-aarch64/ifunc-21.d create mode 100644 ld/testsuite/ld-aarch64/ifunc-21.s OK for trunk and binutils_2_24-branch? I am aware these changes are quite late but they only touch STT_GNU_IFUNC code paths. diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 48fa3d2..7cce6f4 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -3589,7 +3589,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, if (globals->root.splt != NULL) { - plt_index = h->plt.offset / globals->plt_entry_size - 1; + plt_index = ((h->plt.offset - globals->plt_header_size) / + globals->plt_entry_size); off = (plt_index + 3) * GOT_ENTRY_SIZE; base_got = globals->root.sgotplt; } diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 5c150dd..a6b3ea2 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -155,3 +155,4 @@ run_dump_test "ifunc-18b" run_dump_test "ifunc-19a" run_dump_test "ifunc-19b" run_dump_test "ifunc-20" +run_dump_test "ifunc-21" diff --git a/ld/testsuite/ld-aarch64/ifunc-21.d b/ld/testsuite/ld-aarch64/ifunc-21.d new file mode 100644 index 0000000..fa139b2 --- /dev/null +++ b/ld/testsuite/ld-aarch64/ifunc-21.d @@ -0,0 +1,31 @@ +#source: ifunc-21.s +#ld: -shared -z nocombreloc +#objdump: -d -s -j .got.plt -j .text +#target: aarch64*-*-* + +# Ensure the .got.plt slot used is correct + +.*: file format elf64-(little|big)aarch64 + +Contents of section .text: + 02a0 .* +Contents of section .got.plt: + 103a8 0+ 0+ 0+ 0+ .* + 103b8 0+ 0+ [0-9a-f]+ 0+ .* + +Disassembly of section .text: + +0+2a0 : + 2a0: d65f03c0 ret + +0+2a4 : + 2a4: 90000080 adrp x0, 10000 <.*> + 2a8: f941e000 ldr x0, \[x0,#960\] + 2ac: d65f03c0 ret + +Disassembly of section .got.plt: + +.*: +.* +.* +.* diff --git a/ld/testsuite/ld-aarch64/ifunc-21.s b/ld/testsuite/ld-aarch64/ifunc-21.s new file mode 100644 index 0000000..a1563dc --- /dev/null +++ b/ld/testsuite/ld-aarch64/ifunc-21.s @@ -0,0 +1,13 @@ + .text + .type ifunc, @gnu_indirect_function + .hidden ifunc +ifunc: + ret + .size ifunc, .-ifunc + .type bar, @function + .globl bar +bar: + adrp x0, :got:ifunc + ldr x0, [x0, #:got_lo12:ifunc] + ret + .size bar, .-bar