From patchwork Mon Nov 7 17:57:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiong Wang X-Patchwork-Id: 81148 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1140186qge; Mon, 7 Nov 2016 09:58:29 -0800 (PST) X-Received: by 10.99.240.83 with SMTP id s19mr12306150pgj.175.1478541509267; Mon, 07 Nov 2016 09:58:29 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f62si7697944pfd.54.2016.11.07.09.58.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Nov 2016 09:58:29 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-return-94392-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of binutils-return-94392-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-94392-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=Y44cPZCrj0/fb7IbNGZyoPRLFtdaf 8lPPMyESMD3LHjdb0UeVyGABTflI1ZhulBAHhBo/B2K5NPHbl2t9ZSYNvLGyt3Aj PJChw4pUGL6CWc8EJzZXt/gizpgZP/602qpCe7nvtvwg83OmEnANfDKIQHKg97MW org4WYEV0jq+EQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=EmBxpoodfQJbmKoVWFsGys9iCnY=; b=rfv z3kkxc6/h3PTyTCjU71yHDcpiRbwxUFgJ6H8A66avZeJzaDuikFXS5ooSGq/v2ch 1qRw3PvDjPpn15cB+eDktAEg5n1ZG66zktCaK417wnn1zwlsa6J4Sz05eCiNvpUo 6b/SStKjgoVpCEJTMgLgdW0otjrdAz480Ijavy5U= Received: (qmail 63760 invoked by alias); 7 Nov 2016 17:58:09 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk 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 63745 invoked by uid 89); 7 Nov 2016 17:58:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=2878 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Nov 2016 17:57:57 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B47C5CF6; Mon, 7 Nov 2016 09:57:55 -0800 (PST) Received: from [10.2.206.198] (e104437-lin.cambridge.arm.com [10.2.206.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 674BE3F25D for ; Mon, 7 Nov 2016 09:57:55 -0800 (PST) To: Binutils From: Jiong Wang Subject: [RFC/AARCH64] PR target/20737, Bind defined symbol locally in PIE Message-ID: <23d23b5f-616a-74e8-3304-33012e9ee486@foss.arm.com> Date: Mon, 7 Nov 2016 17:57:54 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes As reported on the PR, we need to bind defined symbol locally in PIE, this patch fix this. OK for master? bfd/ 2016-11-04 Jiong Wang PR target/20737 * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Bind defined symbol locally in PIE. ld/ 2016-11-04 Jiong Wang PR target/20737 * testsuite/ld-aarch64/pie-bind-locally-a.s: New test source. * testsuite/ld-aarch64/pie-bind-locally-b.s: Likewise. * testsuite/ld-aarch64/pie-bind-locally.d: New testcase. * testsuite/ld-aarch64/aarch64-elf.exp: Run new testcase. diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 544a8ea19dfb9197f13e41b8517aa56935c87a4a..4ebdbe20d7178ce46e6b8f2a77784ec00c2fff92 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -5193,7 +5193,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, else if (h != NULL && h->dynindx != -1 && (!bfd_link_pic (info) - || !SYMBOLIC_BIND (info, h) + || !(bfd_link_pie (info) + || SYMBOLIC_BIND (info, h)) || !h->def_regular)) outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type); else diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index ab84f01258dffdfac7d86843247d50a1de400a85..d4d7f5a0b8fa5626158eff4727b729d64398d206 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -287,6 +287,8 @@ run_dump_test "rela-abs-relative" run_dump_test "rela-abs-relative-be" run_dump_test "rela-abs-relative-opt" +run_dump_test "pie-bind-locally" + set aarch64elflinktests { {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s} {} "copy-reloc-so.so"} diff --git a/ld/testsuite/ld-aarch64/pie-bind-locally-a.s b/ld/testsuite/ld-aarch64/pie-bind-locally-a.s new file mode 100644 index 0000000000000000000000000000000000000000..f64d48de5ace8efb2795390cfd27567aca0a8896 --- /dev/null +++ b/ld/testsuite/ld-aarch64/pie-bind-locally-a.s @@ -0,0 +1,5 @@ + .text + .align 2 + .global _start +_start: + ldr x0, [x0, #:got_lo12:_start] diff --git a/ld/testsuite/ld-aarch64/pie-bind-locally-b.s b/ld/testsuite/ld-aarch64/pie-bind-locally-b.s new file mode 100644 index 0000000000000000000000000000000000000000..6083941e0f37aa518f803b7f8d03a88f15a602ad --- /dev/null +++ b/ld/testsuite/ld-aarch64/pie-bind-locally-b.s @@ -0,0 +1,6 @@ + .section .data.rel,"aw",%progbits + .align 3 + .type q, %object + .size q, 8 +q: + .xword _start diff --git a/ld/testsuite/ld-aarch64/pie-bind-locally.d b/ld/testsuite/ld-aarch64/pie-bind-locally.d new file mode 100644 index 0000000000000000000000000000000000000000..3689543a9fa82dcd682cc87e7a2f0cf16f77dbb4 --- /dev/null +++ b/ld/testsuite/ld-aarch64/pie-bind-locally.d @@ -0,0 +1,9 @@ +#source: pie-bind-locally-a.s +#source: pie-bind-locally-b.s +#ld: -pie +#readelf: -Wr + +Relocation section '\.rela\.dyn' at offset .* contains 2 entries: +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_AARCH64_RELATIVE[ ].* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_AARCH64_RELATIVE[ ].*