From patchwork Tue Nov 22 14:52:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiong Wang X-Patchwork-Id: 83415 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2135358qge; Tue, 22 Nov 2016 06:52:30 -0800 (PST) X-Received: by 10.84.215.138 with SMTP id l10mr388184pli.166.1479826350763; Tue, 22 Nov 2016 06:52:30 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f17si197138plj.199.2016.11.22.06.52.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Nov 2016 06:52:30 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-return-94552-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-94552-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-94552-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=ImxiUjNGgXU6ew0u84PlH0WNoBcTt nvFP23plqBi8N5kPvnAH361zA7fD8ojdkhhLAEE4RuTIwE+fKbNDCsiPwZ9FXXPy F3BBRncG8QWTzFJEsHeMAZJbDEv11s5OjhnhE3QouKE7R/cxpWyJKStyMwKE0JZk YbF/gpli5foXAs= 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=vrJ7yDNo3LTfhDw0v/vyyj13Gkw=; b=U0c avaDsUECmvs23xXfahqkS5EDGMbANkVjUj/7i1jwOSje828X4mg4zbNTGBF2Op0E qGN7KJ0r/sEH8yJRbvGbdI5MpbUMmyYHeP9aRvp69zNmatebiqvcoFpYJujrK+H9 L6AUluz4VPKPMlYA3gXoM60WHHjUuXOV+D3r5cFE= Received: (qmail 22367 invoked by alias); 22 Nov 2016 14:52:14 -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 22357 invoked by uid 89); 22 Nov 2016 14:52:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=exclude, dyn, 20737 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; Tue, 22 Nov 2016 14:52:03 +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 2E30CC14; Tue, 22 Nov 2016 06:52:02 -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 D4A023F24D for ; Tue, 22 Nov 2016 06:52:01 -0800 (PST) To: Binutils From: Jiong Wang Subject: [ARM] PR target/20737, Bind defined symbol locally in PIE Message-ID: <3556b9a5-4b42-8654-c93e-8bfe9389365e@foss.arm.com> Date: Tue, 22 Nov 2016 14:52:00 +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 On 07/11/16 17:57, Jiong Wang wrote: > 2016-11-04 Jiong Wang > > PR target/20737 > * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Bind defined > symbol locally in PIE. Attached patch is a follow up fix on ARM, no regression on cross & native arm-linux check. ok for master? Thanks. bfd/ 2016-11-22 Jiong Wang PR target/20737 * elf32-arm.c (elf32_arm_final_link_relocate): Bind defined symbol locally in PIE. ld/ 2016-11-22 Jiong Wang PR target/20737 * testsuite/ld-arm/pie-bind-locally-a.s: New test source. * testsuite/ld-arm/pie-bind-locally-b.s: Likewise. * testsuite/ld-arm/pie-bind-locally.d: New testcase. * testsuite/ld-arm/arm-elf.exp: Run new testcase. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index dced01aa00d7f1270558a08ba5d5a2867fd990d9..049fd102f299222d5139c2f79fcae6236bf841f4 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -10147,7 +10147,8 @@ elf32_arm_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 = ELF32_R_INFO (h->dynindx, r_type); else diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 02a35f4729f1536b3f06260aaf3a6ca6ef0de994..2b1e5b8dea9e1245ff7648c067170eba0ff43711 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -345,6 +345,7 @@ run_dump_test "movw-shared-3" run_dump_test "movw-shared-4" run_dump_test "rel32-reject" run_dump_test "rel32-reject-pie" +run_dump_test "pie-bind-locally" # Exclude non-ARM-EABI targets. diff --git a/ld/testsuite/ld-arm/pie-bind-locally-a.s b/ld/testsuite/ld-arm/pie-bind-locally-a.s new file mode 100644 index 0000000000000000000000000000000000000000..76a2f67d4387b018bedfb09e17267940d7644d6d --- /dev/null +++ b/ld/testsuite/ld-arm/pie-bind-locally-a.s @@ -0,0 +1,5 @@ + .text + .align 2 + .global _start +_start: + .word _start(GOT) diff --git a/ld/testsuite/ld-arm/pie-bind-locally-b.s b/ld/testsuite/ld-arm/pie-bind-locally-b.s new file mode 100644 index 0000000000000000000000000000000000000000..8e6ff4f0f981cbe3c1e6bff9b47b01f4b031d58c --- /dev/null +++ b/ld/testsuite/ld-arm/pie-bind-locally-b.s @@ -0,0 +1,6 @@ + .section .data.rel,"aw",%progbits + .align 2 + .type q, %object + .size q, 4 +q: + .word _start diff --git a/ld/testsuite/ld-arm/pie-bind-locally.d b/ld/testsuite/ld-arm/pie-bind-locally.d new file mode 100644 index 0000000000000000000000000000000000000000..7ea031c79b4614b6d6527e81aeb7330caafa77d9 --- /dev/null +++ b/ld/testsuite/ld-arm/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 '\.rel\.dyn' at offset .* contains 2 entries: +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_ARM_RELATIVE[ ].* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_ARM_RELATIVE[ ].*