From patchwork Tue Nov 26 08:54:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 21766 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56214202DA for ; Tue, 26 Nov 2013 08:54:15 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id oz11sf12900798veb.4 for ; Tue, 26 Nov 2013 00:54:14 -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=4IuXgk/t4u4a1mQ7gxxxTWZW1aMhFdsTEp2l6FZm84c=; b=WB308ZZQH4mwG1lmHwl8Genu8aawFsIL4+6h7NugglVKpgISwQIu6pNzXwVtwhp/bP Vgf/K20CinrwRf5rsL6nweU5Ho9uTMHVwcv56QZ03XgCIdUejgF7zfc/HPpSGe8DOAio Sg7w5az+eyoczXajk3GVnZn2hUqSkN70Wc+AzCc0eKvsoR1TWnlu5tRisOlXA7t+LEVl iWk5L01qUjYqQwPgtJcPYG364jHIG6I9nS3YHbiJX8sOFQCQ8QVL8ERbLk7x3103dpEU WFoKoBgLxp0hhr1b297YjTgBxkpqNz8DwjGVy6itVbVtOFSyEHSsVXsHMvbJCpTqtkYw 9bfQ== X-Gm-Message-State: ALoCoQm3KenstvcoZplb78L9aG/7WpCR+8ZJjJlJsZADRsrabGUkGJwl3aa6QVvkr6GUCo0Pm4l+ X-Received: by 10.236.131.202 with SMTP id m50mr14050378yhi.42.1385456054667; Tue, 26 Nov 2013 00:54:14 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.37.163 with SMTP id z3ls85809qej.1.gmail; Tue, 26 Nov 2013 00:54:14 -0800 (PST) X-Received: by 10.52.28.6 with SMTP id x6mr23948930vdg.3.1385456054590; Tue, 26 Nov 2013 00:54:14 -0800 (PST) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id h7si19198449vee.71.2013.11.26.00.54.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 00:54:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.180 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.180; Received: by mail-ve0-f180.google.com with SMTP id jz11so3685456veb.39 for ; Tue, 26 Nov 2013 00:54:14 -0800 (PST) X-Received: by 10.220.70.147 with SMTP id d19mr128146vcj.48.1385456054493; Tue, 26 Nov 2013 00:54:14 -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 u4csp196150vcz; Tue, 26 Nov 2013 00:54:14 -0800 (PST) X-Received: by 10.194.110.138 with SMTP id ia10mr26248134wjb.3.1385456053568; Tue, 26 Nov 2013 00:54:13 -0800 (PST) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by mx.google.com with ESMTPS id b5si661980wik.81.2013.11.26.00.54.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 00:54:13 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.45 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=74.125.82.45; Received: by mail-wg0-f45.google.com with SMTP id y10so3197845wgg.12 for ; Tue, 26 Nov 2013 00:54:12 -0800 (PST) X-Received: by 10.180.206.41 with SMTP id ll9mr2715596wic.7.1385456052265; Tue, 26 Nov 2013 00:54:12 -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 a19sm58231228wib.1.2013.11.26.00.54.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 26 Nov 2013 00:54:11 -0800 (PST) Message-ID: <529461B1.8080200@linaro.org> Date: Tue, 26 Nov 2013 08:54:09 +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 2/2] bfd/elfnn-aarch64.c: Handle static links with ifunc correctly. 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.180 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 code for handling GOT references to ifunc symbols in static links was missing. bfd/ChangeLog: 2013-11-25 Will Newton * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Handle STT_GNU_IFUNC symbols correctly in static links. 2013-11-25 Will Newton * ld-aarch64/aarch64-elf.exp: Add ifunc-22. * ld-aarch64/ifunc-22.d: New file. * ld-aarch64/ifunc-22.s: Likewise. --- bfd/elfnn-aarch64.c | 30 +++++++++++++++++++++++++++++- ld/testsuite/ld-aarch64/aarch64-elf.exp | 1 + ld/testsuite/ld-aarch64/ifunc-22.d | 11 +++++++++++ ld/testsuite/ld-aarch64/ifunc-22.s | 14 ++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-aarch64/ifunc-22.d create mode 100644 ld/testsuite/ld-aarch64/ifunc-22.s OK for trunk and binutils_2_24-branch? diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 7cce6f4..1467f5d 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -6824,7 +6824,34 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, + htab->root.sgot->output_offset + (h->got.offset & ~(bfd_vma) 1)); - if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) + if (h->def_regular + && h->type == STT_GNU_IFUNC) + { + if (info->shared) + { + /* Generate R_AARCH64_GLOB_DAT. */ + goto do_glob_dat; + } + else + { + asection *plt; + + if (!h->pointer_equality_needed) + abort (); + + /* For non-shared object, we can't use .got.plt, which + contains the real function addres if we need pointer + equality. We load the GOT entry with the PLT entry. */ + plt = htab->root.splt ? htab->root.splt : htab->root.iplt; + bfd_put_NN (output_bfd, (plt->output_section->vma + + plt->output_offset + + h->plt.offset), + htab->root.sgot->contents + + (h->got.offset & ~(bfd_vma) 1)); + return TRUE; + } + } + else if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) { if (!h->def_regular) return FALSE; @@ -6838,6 +6865,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, else { BFD_ASSERT ((h->got.offset & 1) == 0); +do_glob_dat: bfd_put_NN (output_bfd, (bfd_vma) 0, htab->root.sgot->contents + h->got.offset); rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (GLOB_DAT)); diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index a6b3ea2..692bf34 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -156,3 +156,4 @@ run_dump_test "ifunc-19a" run_dump_test "ifunc-19b" run_dump_test "ifunc-20" run_dump_test "ifunc-21" +run_dump_test "ifunc-22" diff --git a/ld/testsuite/ld-aarch64/ifunc-22.d b/ld/testsuite/ld-aarch64/ifunc-22.d new file mode 100644 index 0000000..f28b039 --- /dev/null +++ b/ld/testsuite/ld-aarch64/ifunc-22.d @@ -0,0 +1,11 @@ +#source: ifunc-22.s +#objdump: -s -j .got +#ld: -static +#target: aarch64*-*-* + +# Ensure GOT is populated correctly in static link + +.*: file format elf64-(little|big)aarch64 + +Contents of section \.got: + 4100f0 00000000 00000000 d0004000 00000000 ..........@..... diff --git a/ld/testsuite/ld-aarch64/ifunc-22.s b/ld/testsuite/ld-aarch64/ifunc-22.s new file mode 100644 index 0000000..69a87bb --- /dev/null +++ b/ld/testsuite/ld-aarch64/ifunc-22.s @@ -0,0 +1,14 @@ + .text + .type ifunc, @gnu_indirect_function + .global ifunc +ifunc: + ret + .size ifunc, .-ifunc + .type _start, @function + .globl _start +_start: + adrp x0, :got:ifunc + ldr x0, [x0, #:got_lo12:ifunc] + .size _start, .-_start + .data + .xword ifunc