From patchwork Thu Mar 22 14:38:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132294 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp929918ljb; Thu, 22 Mar 2018 07:39:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELsNcKimAvuaO136khW5rE54DcUE9JcTQuE6SiqlM8eDrJp54IPQUqcwpRewmDotMDrOgPjM X-Received: by 2002:a17:902:684d:: with SMTP id f13-v6mr15245567pln.230.1521729574476; Thu, 22 Mar 2018 07:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729574; cv=none; d=google.com; s=arc-20160816; b=rjph2tq9qMAH42noLyAKe/Kxbb1VQsCUuMs/+HpFKX25CtgbbufXRKr2MI/3h3/YMn IlBoJwYGRDt6rnygZr0g9HyJn2Vazec3OX3ea9KeKENBL35N2DpY9KqryAijZSZOKOc0 IuFkklI2yUXT0oU8dDN9dZI4wDmtlBcg5qIm5Z4uUOnKbCHzSbcEph9qt9RMVXW3Uxc1 UKtC3KOaQONRDhakj27f0xeC7pO5IzQqX8ZBbWjwWy2utv1ezCVJ4OPSc9fcUE1Hvmta 0bUsBrFJiYy67vkLP498bJuOweUXrkSDylEgLdxRj/hAHZmYrL2ZhMFOOdGs5dhXjxJT xiLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=11E5wagt5u/0aqjVSheLjtn+Ngm23i+nGOwNB908VYg=; b=hVb6r6bFlKL+NKR1IZnE6N3xUdv6Un537HTGlCmbG4E1C26HlMK3/qjSOUGUgu7O4k 51Xl6K4Zl7Xmh268KvvXStlDyId+SxspZ0b0du+0FAbZ1g/LQETDHIqsQuq9HjmyitZA b3nSK73lmdZ8bSdbBW2K1G9zQPCJbW+ooUKS+EoEuyiMbw1CTOe88zJFxmDjCrNmS1Fc d+ugeZn9ihh7brgJP2wnH7Wz3eNaJ3he+IuCB2hJZphQe0T18zKZN3f/3D7QRBZx1ekO U697WsQ+MAja9+aL3/lf2MD3OcqmH6nofYpDygX36JIgPuQEYwKoVFDjsx0w1YHd40gW kHoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=jrk0NAiq; spf=pass (google.com: domain of binutils-return-101080-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101080-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z62si4474570pgd.819.2018.03.22.07.39.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:39:34 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101080-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 header.s=default header.b=jrk0NAiq; spf=pass (google.com: domain of binutils-return-101080-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101080-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=kH7cbIKiHHGDopMKBW2tLsGoiN8vVil/aMd7xYsylJl Q1ZUZUVte8XXGpgYMDVL1MKD9g3BTnZODD748qretiiYp0lfliiMDFdUcu6PfGdF AaM3FdvBbwb+uyUoimypMA/3H/CuXw8tX4zcsGzMUs1VBtmVqNh76kEsRY8/ihpI = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=MlFaAfltJuvXddm3VaQ3WX92W0M=; b=jrk0NAiqQgDHP5uRv mJLWOnJPrirSm5VqUN28AIFrclQ+oXsQpG+2nJHrUhBZHn77bDN/Q9f/8p+7YIyG zzqh5HxJKw+IIAa2Tix9JJ3Ist9s/JiukQaq6tMmWiruINqjNKOQBXmvSIQlGJvh Usdhfwn++bUk7MmNkxcOT/z52E= Received: (qmail 33005 invoked by alias); 22 Mar 2018 14:39:21 -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 32990 invoked by uid 89); 22 Mar 2018 14:39:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=relocating X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:39:18 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdAuU030982 for ; Thu, 22 Mar 2018 15:39:15 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gvebr80su-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:39:15 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 550EC3A for ; Thu, 22 Mar 2018 14:39:15 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 35CF12AFC for ; Thu, 22 Mar 2018 14:39:15 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:39:14 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 01/12] [ARM] Add armelf_linux_fdpiceabi and armelfb_linux_fdpiceabi BFD backends Date: Thu, 22 Mar 2018 15:38:19 +0100 Message-ID: <20180322143850.1766-2-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes Initial definition of these new backends. 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * config.bfd (arm*b-*-linux-*): Add arm_elf32_fdpic_be_vec and arm_elf32_fdpic_le_vec to targ_selvecs. (arm*-*-linux-*): Likewise. * configure.ac: Add support for arm_elf32_fdpic_be_vec and arm_elf32_fdpic_le_vec. * configure: Regenerate. * elf32-arm.c (struct elf32_arm_link_hash_table): Add fdpic_p. (elf32_arm_link_hash_table_create): Initialize fdpic_p. (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, TARGET_BIG_SYM) (TARGET_BIG_NAME, elf_match_priority): Define for FDPIC targets. (elf32_arm_fdpic_link_hash_table_create): New. * targets.c (_bfd_target_vector): Add arm_elf32_fdpic_be_vec and arm_elf32_fdpic_le_vec. ld/ * Makefile.am (ALL_EMULATION_SOURCES): Add earmelf_linux_fdpiceabi.c and earmelfb_linux_fdpiceabi.c. (earmelf_linux_fdpiceabi.c, earmelfb_linux_fdpiceabi.c): New rules. * Makefile.in: Regenerate. * configure.tgt (arm*b-*-linux-*eabi*): Add armelf_linux_fdpiceabi and armelfb_linux_fdpiceabi. (arm*-*-linux-*eabi*): Likewise. * emulparams/armelf_linux_fdpiceabi.sh: New. * emulparams/armelfb_linux_fdpiceabi.sh: New. --- bfd/config.bfd | 4 +-- bfd/configure | 2 ++ bfd/configure.ac | 2 ++ bfd/elf32-arm.c | 44 ++++++++++++++++++++++++++++++++ bfd/targets.c | 4 +++ ld/Makefile.am | 13 ++++++++++ ld/Makefile.in | 15 +++++++++++ ld/configure.tgt | 4 +-- ld/emulparams/armelf_linux_fdpiceabi.sh | 13 ++++++++++ ld/emulparams/armelfb_linux_fdpiceabi.sh | 2 ++ 10 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 ld/emulparams/armelf_linux_fdpiceabi.sh create mode 100644 ld/emulparams/armelfb_linux_fdpiceabi.sh -- 2.6.3 diff --git a/bfd/config.bfd b/bfd/config.bfd index f04a993..2fe22eb 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -436,7 +436,7 @@ case "${targ}" in ;; armeb-*-elf | arm*b-*-freebsd* | arm*b-*-linux-* | armeb-*-eabi*) targ_defvec=arm_elf32_be_vec - targ_selvecs=arm_elf32_le_vec + targ_selvecs="arm_elf32_fdpic_be_vec arm_elf32_le_vec arm_elf32_fdpic_le_vec" ;; arm-*-kaos*) targ_defvec=arm_elf32_le_vec @@ -446,7 +446,7 @@ case "${targ}" in arm*-*-uclinux* | arm-*-kfreebsd*-gnu | \ arm*-*-eabi* | arm-*-rtems*) targ_defvec=arm_elf32_le_vec - targ_selvecs=arm_elf32_be_vec + targ_selvecs="arm_elf32_fdpic_le_vec arm_elf32_be_vec arm_elf32_fdpic_be_vec" ;; arm*-*-vxworks | arm*-*-windiss) targ_defvec=arm_elf32_vxworks_le_vec diff --git a/bfd/configure b/bfd/configure index d1fe335..a023806 100755 --- a/bfd/configure +++ b/bfd/configure @@ -14355,6 +14355,8 @@ do arm_coff_le_vec) tb="$tb coff-arm.lo $coff" ;; arm_elf32_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_nacl_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_nacl_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_symbian_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; diff --git a/bfd/configure.ac b/bfd/configure.ac index 20e2c02..64df7db 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -432,6 +432,8 @@ do arm_coff_le_vec) tb="$tb coff-arm.lo $coff" ;; arm_elf32_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_nacl_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_nacl_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; arm_elf32_symbian_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index ce9c2f2..565bb40 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3228,6 +3228,9 @@ struct elf32_arm_link_hash_table unsigned int bfd_count; unsigned int top_index; asection **input_list; + + /* True if the target system uses FDPIC. */ + int fdpic_p; }; static inline int @@ -3806,6 +3809,7 @@ elf32_arm_link_hash_table_create (bfd *abfd) #endif ret->use_rel = TRUE; ret->obfd = abfd; + ret->fdpic_p = 0; if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc, sizeof (struct elf32_arm_stub_hash_entry))) @@ -19411,6 +19415,46 @@ elf32_arm_nacl_plt_sym_val (bfd_vma i, const asection *plt, #define ELF_COMMONPAGESIZE 0x1000 +/* FDPIC Targets. */ + +#undef TARGET_LITTLE_SYM +#define TARGET_LITTLE_SYM arm_elf32_fdpic_le_vec +#undef TARGET_LITTLE_NAME +#define TARGET_LITTLE_NAME "elf32-littlearm-fdpic" +#undef TARGET_BIG_SYM +#define TARGET_BIG_SYM arm_elf32_fdpic_be_vec +#undef TARGET_BIG_NAME +#define TARGET_BIG_NAME "elf32-bigarm-fdpic" +#undef elf_match_priority +#define elf_match_priority 128 + +/* Like elf32_arm_link_hash_table_create -- but overrides + appropriately for FDPIC. */ + +static struct bfd_link_hash_table * +elf32_arm_fdpic_link_hash_table_create (bfd *abfd) +{ + struct bfd_link_hash_table *ret; + + ret = elf32_arm_link_hash_table_create (abfd); + if (ret) + { + struct elf32_arm_link_hash_table *htab = (struct elf32_arm_link_hash_table *) ret; + + htab->fdpic_p = 1; + } + return ret; +} + +#undef elf32_bed +#define elf32_bed elf32_arm_fdpic_bed + +#undef bfd_elf32_bfd_link_hash_table_create +#define bfd_elf32_bfd_link_hash_table_create elf32_arm_fdpic_link_hash_table_create + +#include "elf32-target.h" +#undef elf_match_priority + /* VxWorks Targets. */ #undef TARGET_LITTLE_SYM diff --git a/bfd/targets.c b/bfd/targets.c index 43102d4..79e3309 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -612,6 +612,8 @@ extern const bfd_target arm_coff_be_vec; extern const bfd_target arm_coff_le_vec; extern const bfd_target arm_elf32_be_vec; extern const bfd_target arm_elf32_le_vec; +extern const bfd_target arm_elf32_fdpic_be_vec; +extern const bfd_target arm_elf32_fdpic_le_vec; extern const bfd_target arm_elf32_nacl_be_vec; extern const bfd_target arm_elf32_nacl_le_vec; extern const bfd_target arm_elf32_symbian_be_vec; @@ -1021,6 +1023,8 @@ static const bfd_target * const _bfd_target_vector[] = &arm_coff_le_vec, &arm_elf32_be_vec, &arm_elf32_le_vec, + &arm_elf32_fdpic_be_vec, + &arm_elf32_fdpic_le_vec, &arm_elf32_symbian_be_vec, &arm_elf32_symbian_le_vec, &arm_elf32_vxworks_be_vec, diff --git a/ld/Makefile.am b/ld/Makefile.am index d94fce7..31ac592 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -176,6 +176,7 @@ ALL_EMULATION_SOURCES = \ earmelf_fuchsia.c \ earmelf_linux.c \ earmelf_linux_eabi.c \ + earmelf_linux_fdpiceabi.c \ earmelf_nacl.c \ earmelf_nbsd.c \ earmelf_phoenix.c \ @@ -185,6 +186,7 @@ ALL_EMULATION_SOURCES = \ earmelfb_fuchsia.c \ earmelfb_linux.c \ earmelfb_linux_eabi.c \ + earmelfb_linux_fdpiceabi.c \ earmelfb_nacl.c \ earmelfb_nbsd.c \ earmnbsd.c \ @@ -780,6 +782,11 @@ earmelf_linux_eabi.c: $(srcdir)/emulparams/armelf_linux_eabi.sh \ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} +earmelf_linux_fdpiceabi.c: $(srcdir)/emulparams/armelf_linux_fdpiceabi.sh \ + $(srcdir)/emulparams/armelf_linux.sh \ + $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ + $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + earmelf_nacl.c: $(srcdir)/emulparams/armelf_nacl.sh \ $(srcdir)/emulparams/armelf_linux_eabi.sh \ $(srcdir)/emulparams/armelf_linux.sh \ @@ -826,6 +833,12 @@ earmelfb_linux_eabi.c: $(srcdir)/emulparams/armelfb_linux_eabi.sh \ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} +earmelfb_linux_fdpiceabi.c: $(srcdir)/emulparams/armelfb_linux_fdpiceabi.sh \ + $(srcdir)/emulparams/armelfb_linux_fdpiceabi.sh \ + $(srcdir)/emulparams/armelf_linux.sh \ + $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ + $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + earmelfb_nacl.c: $(srcdir)/emulparams/armelfb_nacl.sh \ $(srcdir)/emulparams/armelf_nacl.sh \ $(srcdir)/emulparams/armelf_linux_eabi.sh \ diff --git a/ld/Makefile.in b/ld/Makefile.in index 704694b..897a2fb 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -545,6 +545,7 @@ ALL_EMULATION_SOURCES = \ earmelf_fuchsia.c \ earmelf_linux.c \ earmelf_linux_eabi.c \ + earmelf_linux_fdpiceabi.c \ earmelf_nacl.c \ earmelf_nbsd.c \ earmelf_phoenix.c \ @@ -554,6 +555,7 @@ ALL_EMULATION_SOURCES = \ earmelfb_fuchsia.c \ earmelfb_linux.c \ earmelfb_linux_eabi.c \ + earmelfb_linux_fdpiceabi.c \ earmelfb_nacl.c \ earmelfb_nbsd.c \ earmnbsd.c \ @@ -1155,6 +1157,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fuchsia.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_linux.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_linux_eabi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_linux_fdpiceabi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nacl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nbsd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_phoenix.Po@am__quote@ @@ -1164,6 +1167,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_fuchsia.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_linux.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_linux_eabi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_linux_fdpiceabi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_nacl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_nbsd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmnbsd.Po@am__quote@ @@ -2344,6 +2348,11 @@ earmelf_linux_eabi.c: $(srcdir)/emulparams/armelf_linux_eabi.sh \ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} +earmelf_linux_fdpiceabi.c: $(srcdir)/emulparams/armelf_linux_fdpiceabi.sh \ + $(srcdir)/emulparams/armelf_linux.sh \ + $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ + $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + earmelf_nacl.c: $(srcdir)/emulparams/armelf_nacl.sh \ $(srcdir)/emulparams/armelf_linux_eabi.sh \ $(srcdir)/emulparams/armelf_linux.sh \ @@ -2390,6 +2399,12 @@ earmelfb_linux_eabi.c: $(srcdir)/emulparams/armelfb_linux_eabi.sh \ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} +earmelfb_linux_fdpiceabi.c: $(srcdir)/emulparams/armelfb_linux_fdpiceabi.sh \ + $(srcdir)/emulparams/armelf_linux_fdpiceabi.sh \ + $(srcdir)/emulparams/armelf_linux.sh \ + $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ + $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + earmelfb_nacl.c: $(srcdir)/emulparams/armelfb_nacl.sh \ $(srcdir)/emulparams/armelf_nacl.sh \ $(srcdir)/emulparams/armelf_linux_eabi.sh \ diff --git a/ld/configure.tgt b/ld/configure.tgt index 7897448..ea2aff8 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -129,7 +129,7 @@ arm*-*-symbianelf*) targ_emul=armsymbian;; arm-*-kaos*) targ_emul=armelf ;; arm9e-*-elf) targ_emul=armelf ;; arm*b-*-linux-*eabi*) targ_emul=armelfb_linux_eabi - targ_extra_emuls=armelf_linux_eabi + targ_extra_emuls="armelf_linux_eabi armelf_linux_fdpiceabi armelfb_linux_fdpiceabi" targ_extra_libpath=$targ_extra_emuls ;; arm*b-*-linux-*) targ_emul=armelfb_linux @@ -137,7 +137,7 @@ arm*b-*-linux-*) targ_emul=armelfb_linux targ_extra_libpath="armelf_linux" ;; arm*-*-linux-*eabi*) targ_emul=armelf_linux_eabi - targ_extra_emuls=armelfb_linux_eabi + targ_extra_emuls="armelfb_linux_eabi armelf_linux_fdpiceabi armelfb_linux_fdpiceabi" targ_extra_libpath=$targ_extra_emuls ;; arm*-*-linux-*) targ_emul=armelf_linux diff --git a/ld/emulparams/armelf_linux_fdpiceabi.sh b/ld/emulparams/armelf_linux_fdpiceabi.sh new file mode 100644 index 0000000..104cf38 --- /dev/null +++ b/ld/emulparams/armelf_linux_fdpiceabi.sh @@ -0,0 +1,13 @@ +. ${srcdir}/emulparams/armelf_linux.sh + +OUTPUT_FORMAT="elf32-littlearm-fdpic" +BIG_OUTPUT_FORMAT="elf32-bigarm-fdpic" +LITTLE_OUTPUT_FORMAT="elf32-littlearm-fdpic" + +# Use the ARM ABI-compliant exception-handling sections. +OTHER_READONLY_SECTIONS=" + .ARM.extab ${RELOCATING-0} : { *(.ARM.extab${RELOCATING+* .gnu.linkonce.armextab.*}) } + ${RELOCATING+ PROVIDE_HIDDEN (__exidx_start = .); } + .ARM.exidx ${RELOCATING-0} : { *(.ARM.exidx${RELOCATING+* .gnu.linkonce.armexidx.*}) } + ${RELOCATING+ PROVIDE_HIDDEN (__exidx_end = .); }" + diff --git a/ld/emulparams/armelfb_linux_fdpiceabi.sh b/ld/emulparams/armelfb_linux_fdpiceabi.sh new file mode 100644 index 0000000..988ea7a --- /dev/null +++ b/ld/emulparams/armelfb_linux_fdpiceabi.sh @@ -0,0 +1,2 @@ +. ${srcdir}/emulparams/armelf_linux_fdpiceabi.sh +OUTPUT_FORMAT="elf32-bigarm-fdpic" From patchwork Thu Mar 22 14:38:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132295 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp930277ljb; Thu, 22 Mar 2018 07:39:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELurwAr4uftJwQyR8ZCQ9xtztFYTvOUsZtzY8/6QQrMofTBUHPGwia06VI5OwlIst0p8hTM+ X-Received: by 10.98.32.89 with SMTP id g86mr20911979pfg.35.1521729593325; Thu, 22 Mar 2018 07:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729593; cv=none; d=google.com; s=arc-20160816; b=KXMOjKYShFoDbFqD6qVOzL5FcP3AvhBdaMm/9Ujoo5+KF9z4u9ng47OWc3rkzk2Iot 6YolHkB8Q0LRRMcZKO1BRoPhCj8q0SiTEh3wZn+7hK0z/qSxLGqENaTXarsvW+1LM9zP raAN7bF50bogZ60EE/+Ou32BA3Ywp1IenOtHF8GyYLC+EVk+vHPvUxexp71w0yHzri7u 5tdSAmB3PrwPp9XIFdBFmGwDX5YkpfBrfbGJISM5CKU1Wp8V4025PijlCb3I/oVPvXFY CkwGRFEn474YiPeARQ44qx67XGFKrT02EmHBmYCn7HgCEbNA2EVKFE74Q77lhj6F3oBd b6Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=LyE4VZvHRovGTJuu3ZE2yoGacMaSNmzOPvULvsU+dWM=; b=erZ8FWy7laYveOsbaM/OlpHfxQLmHSBZww4o+dVILrwxteR+Ce42Dkgaa+yuh/Cb97 NSlIOs/YoJQhIJLge5hrqrAUkTrQNcRTpfSvYNbVy7ucbEctLDvH7aD6P/LMp7EKngfJ cz7FiD5GJE94hs9O0APzU25Ts3PEPw9ZlvRxsu15BY2WfEW6y2fGAj+TPbg8ye2pO3IR /Jr2aKRX/uEKRpjFoZnFr4JcKuXz44sjBAjUUD25sBQzjEZQoTG1SRosFdrpw+pA4zW1 Q6C2n3KVn7mUEFnxvijlXnuhL3YNYh0LwwpDfND+nuSpkBJeyRoJaRojsu5hZ997P3yr Tvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=UmmHMoNY; spf=pass (google.com: domain of binutils-return-101081-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101081-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g4si4478126pgq.322.2018.03.22.07.39.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101081-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 header.s=default header.b=UmmHMoNY; spf=pass (google.com: domain of binutils-return-101081-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101081-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=CFxWDQwVg2rqyLFvIiGPvXH0hMfxFq9SDeXxvBPocPy sk1BGvFQjixUQp/QwF926XOl+HjIc0nN3KgIZSaIutbf+XkxVDZk1n3K7tEo3qVx qZ7rDPF+ciurlXOGl4ZraAXrZt9xsCzcurvOZwUxtrbSr+CC9XEjOuGO29PjImf0 = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=4E2OrLzwgGCISrFs1GqOJY4xBnk=; b=UmmHMoNYXWfGuk38s ePLizIY5SyPWXwSn9JWWLhw2AuO2R3gFn28Jv85DpT8D/jfUVzf8jzNuMUsSKe92 obrENuIszz6jXfDzm8SOvy88YNZwiqzpShCifTm30LCQnio80v0BJRe4mQwYwqyP 17zdn07z7wJKPVdPm9N0T12kKE= Received: (qmail 43310 invoked by alias); 22 Mar 2018 14:39:40 -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 42533 invoked by uid 89); 22 Mar 2018 14:39:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:39:38 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdPsu030795 for ; Thu, 22 Mar 2018 15:39:36 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv69ptjxs-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:39:36 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 869F034 for ; Thu, 22 Mar 2018 14:39:35 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6D5822B09 for ; Thu, 22 Mar 2018 14:39:35 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:39:34 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 02/12] [ARM] Add FDPIC OSABI flag support. Date: Thu, 22 Mar 2018 15:38:20 +0100 Message-ID: <20180322143850.1766-3-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes ELF files targetting ARM FDPIC use the ELFOSABI_ARM_FDPIC flag. Set it appropriately in file generators (eg. gas), and handle it in readers (eg. readelf). 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * elf32-arm.c (elf32_arm_print_private_bfd_data): Support EF_ARM_PIC and ELFOSABI_ARM_FDPIC. (elf32_arm_post_process_headers): Support ELFOSABI_ARM_FDPIC. (ELF_OSABI): Define to ELFOSABI_ARM_FDPIC. binutils/ * readelf.c (decode_ARM_machine_flags): Support EF_ARM_PIC. (get_osabi_name): Support ELFOSABI_ARM_FDPIC. gas/ * config/tc-arm.c (arm_fdpic): New. (elf32_arm_target_format): Support FDPIC. (OPTION_FDPIC): New. (md_longopts): Support FDPIC. (md_parse_option): Likewise. (md_show_usage): Likewise. include/ * elf/arm.h (EF_ARM_FDPIC): New. --- bfd/elf32-arm.c | 14 +++++++++++++- binutils/readelf.c | 7 +++++++ gas/config/tc-arm.c | 34 +++++++++++++++++++++++++++++++--- include/elf/common.h | 1 + 4 files changed, 52 insertions(+), 4 deletions(-) -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 565bb40..a0b0be3 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -14280,7 +14280,13 @@ elf32_arm_print_private_bfd_data (bfd *abfd, void * ptr) if (flags & EF_ARM_RELEXEC) fprintf (file, _(" [relocatable executable]")); - flags &= ~EF_ARM_RELEXEC; + if (flags & EF_ARM_PIC) + fprintf (file, _(" [position independent]")); + + if (elf_elfheader (abfd)->e_ident[EI_OSABI] == ELFOSABI_ARM_FDPIC) + fprintf (file, _(" [FDPIC ABI supplement]")); + + flags &= ~ (EF_ARM_RELEXEC | EF_ARM_PIC); if (flags) fprintf (file, _("")); @@ -16642,6 +16648,9 @@ elf32_arm_post_process_headers (bfd * abfd, struct bfd_link_info * link_info ATT globals = elf32_arm_hash_table (link_info); if (globals != NULL && globals->byteswap_code) i_ehdrp->e_flags |= EF_ARM_BE8; + + if (globals->fdpic_p) + i_ehdrp->e_ident[EI_OSABI] |= ELFOSABI_ARM_FDPIC; } if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_VER5 @@ -19427,6 +19436,8 @@ elf32_arm_nacl_plt_sym_val (bfd_vma i, const asection *plt, #define TARGET_BIG_NAME "elf32-bigarm-fdpic" #undef elf_match_priority #define elf_match_priority 128 +#undef ELF_OSABI +#define ELF_OSABI ELFOSABI_ARM_FDPIC /* Like elf32_arm_link_hash_table_create -- but overrides appropriately for FDPIC. */ @@ -19454,6 +19465,7 @@ elf32_arm_fdpic_link_hash_table_create (bfd *abfd) #include "elf32-target.h" #undef elf_match_priority +#undef ELF_OSABI /* VxWorks Targets. */ diff --git a/binutils/readelf.c b/binutils/readelf.c index b85db9f..8f10754 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -2577,6 +2577,12 @@ decode_ARM_machine_flags (unsigned e_flags, char buf[]) e_flags &= ~ EF_ARM_RELEXEC; } + if (e_flags & EF_ARM_PIC) + { + strcat (buf, ", position independent"); + e_flags &= ~ EF_ARM_PIC; + } + /* Now handle EABI specific flags. */ switch (eabi) { @@ -3717,6 +3723,7 @@ get_osabi_name (Filedata * filedata, unsigned int osabi) switch (osabi) { case ELFOSABI_ARM: return "ARM"; + case ELFOSABI_ARM_FDPIC: return "ARM FDPIC"; default: break; } diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index eda9890..8a3a282 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -75,6 +75,9 @@ static struct unsigned sp_restored:1; } unwind; +/* Whether --fdpic was given. */ +static int arm_fdpic; + #endif /* OBJ_ELF */ /* Results from operand parsing worker functions. */ @@ -25111,10 +25114,20 @@ elf32_arm_target_format (void) ? "elf32-bigarm-nacl" : "elf32-littlearm-nacl"); #else - if (target_big_endian) - return "elf32-bigarm"; + if (arm_fdpic) + { + if (target_big_endian) + return "elf32-bigarm-fdpic"; + else + return "elf32-littlearm-fdpic"; + } else - return "elf32-littlearm"; + { + if (target_big_endian) + return "elf32-bigarm"; + else + return "elf32-littlearm"; + } #endif } @@ -25634,6 +25647,7 @@ const char * md_shortopts = "m:k"; #endif #endif #define OPTION_FIX_V4BX (OPTION_MD_BASE + 2) +#define OPTION_FDPIC (OPTION_MD_BASE + 3) struct option md_longopts[] = { @@ -25644,6 +25658,9 @@ struct option md_longopts[] = {"EL", no_argument, NULL, OPTION_EL}, #endif {"fix-v4bx", no_argument, NULL, OPTION_FIX_V4BX}, +#ifdef OBJ_ELF + {"fdpic", no_argument, NULL, OPTION_FDPIC}, +#endif {NULL, no_argument, NULL, 0} }; @@ -26815,6 +26832,12 @@ md_parse_option (int c, const char * arg) fix_v4bx = TRUE; break; +#ifdef OBJ_ELF + case OPTION_FDPIC: + arm_fdpic = TRUE; + break; +#endif /* OBJ_ELF */ + case 'a': /* Listing option. Just ignore these, we don't support additional ones. */ @@ -26909,6 +26932,11 @@ md_show_usage (FILE * fp) fprintf (fp, _("\ --fix-v4bx Allow BX in ARMv4 code\n")); + +#ifdef OBJ_ELF + fprintf (fp, _("\ + --fdpic generate an FDPIC object file\n")); +#endif /* OBJ_ELF */ } #ifdef OBJ_ELF diff --git a/include/elf/common.h b/include/elf/common.h index 61a1ca7..a317d83 100644 --- a/include/elf/common.h +++ b/include/elf/common.h @@ -78,6 +78,7 @@ #define ELFOSABI_C6000_ELFABI 64 /* Bare-metal TMS320C6000 */ #define ELFOSABI_C6000_LINUX 65 /* Linux TMS320C6000 */ +#define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC */ #define ELFOSABI_ARM 97 /* ARM */ #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ From patchwork Thu Mar 22 14:38:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132296 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp930795ljb; Thu, 22 Mar 2018 07:40:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELvOz8S8g8I8X6Lfdj87hg6/Aw+ozZUfp/lkvhLwsMyioWjTJ52smRk6u0TN8lqR4kyhN4Jl X-Received: by 2002:a17:902:24:: with SMTP id 33-v6mr25365476pla.341.1521729620347; Thu, 22 Mar 2018 07:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729620; cv=none; d=google.com; s=arc-20160816; b=G+/dW+EzVrcBwCtEbzPKwT3GyrdFyXQDnvt5kscIdJ2n/VhUpL3b8oI568KOWSUC+X SvZeJKO+zDUZwAI80CRq5fn6iQ5RZ8z2/hGXlUNVBIxa0gIG5q1tlFgqt0uPin5mFnvX h5cdoLOZM8tIw7439NCWU5FKGJnjL5+A8GRF8zZ/Hm4wcaBG/qFiHeF47gMho3uWhjkw HYf5ZNetNSQiU7r4DY89uQqv1cO2OwXJ2woTbYFDZxi+puW71ouGUbgIlXGyj8TFVJII aeE+J40FpGcnyi0wYaO9NwGfrHJtgG/Q5RdWGGFrgjnZnpJ260daphepB9Z4YDQhBwKr gcMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=CmqDTcLP9BZpktFBlxPdwZTcfkQPbU46m4kCZjGT6pw=; b=YrSMt6ziRcNiUTm+MbOJD1BikIODlPgoJk0dEK45Rf5iwMqYxvACSgJvgJxBascT3P iGo/Y7dWjMf2u3vwWFy26w+PbiEvTtUc3CmY2ydnSZwQvQjqp6hGrYP+t0N/a+K+Iriw LMuU+qVP7ocq9Zygpa/AO680wRdxYRcYaxETCs2WVaFgz9qRvbd1FqShl/YjvEr8TNVF HtsUL8vI6ueCbfL+ms6LtvxSyKMFB0acr0Ej7TfS78YOxHV44jiUhANp5elK1fFSbdm1 ICWT943upNEklwNO0JerKOdgfYtMrX+lMN1idaxbtmjIhuAT2aOsZPG1+k0c5hhtQwxR xpVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NhXuItsP; spf=pass (google.com: domain of binutils-return-101082-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101082-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u24si4897507pfh.326.2018.03.22.07.40.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101082-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 header.s=default header.b=NhXuItsP; spf=pass (google.com: domain of binutils-return-101082-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101082-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=p5Li2EPkBudHPU4QxEygC74ofc542VooVmM5BTXopqJ tp2miUwPMfYWRVEK9URljL0A2ebHM4IfIATJH0OK6cM4IiFHZKOYBECh6kdVlJaZ vVUS8B3eGkaDtsEBDIr3+vb3WZoIsYinFMtJpkdpYgOmBFxRQh1g18en7A5RiOwM = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=Gh9xgXfI0ockZ7mOmVMnos5e5ik=; b=NhXuItsP87CA7oHPi r8prq9EVFxrfMQqigRZ2lkT6hOvd+I+0NOPWQmj880IKjjZ5a+BorZUVzhcq+Txm UnQ8QLvlrYZQ/SBiR+EurvZRnbGdGnus8y/LxzWB0GMiNec+tVm59Gjuj1Xi1PhY FFLviID5UMan8TjFAfE+4Q2Qq4= Received: (qmail 66494 invoked by alias); 22 Mar 2018 14:40:06 -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 63553 invoked by uid 89); 22 Mar 2018 14:40:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:39:59 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdAn9000359 for ; Thu, 22 Mar 2018 15:39:56 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv6742kth-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:39:56 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E096A31 for ; Thu, 22 Mar 2018 14:39:55 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AA9A52B0A for ; Thu, 22 Mar 2018 14:39:55 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:39:55 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 03/12] [ARM] Add FDPIC relocations definitions Date: Thu, 22 Mar 2018 15:38:21 +0100 Message-ID: <20180322143850.1766-4-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes Add FDPIC relocation definitions in BFD and gas. Gas rejects them if the --fdpic option was not specified. 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * bfd-in2.c (BFD_RELOC_ARM_GOTFUNCDESC) (BFD_RELOC_ARM_GOTOFFFUNCDESC, BFD_RELOC_ARM_FUNCDESC) (BFD_RELOC_ARM_FUNCDESC_VALUE): New. * elf32-arm.c (elf32_arm_howto_table_2): Add R_ARM_GOTFUNCDESC, R_ARM_GOTOFFFUNCDESC, R_ARM_FUNCDESC, R_ARM_FUNCDESC_VALUE. (elf32_arm_howto_from_type): Take new members of elf32_arm_howto_table_2 into account. (elf32_arm_reloc_map): Add BFD_RELOC_ARM_GOTFUNCDESC, BFD_RELOC_ARM_GOTOFFFUNCDESC, BFD_RELOC_ARM_FUNCDESC, BFD_RELOC_ARM_FUNCDESC_VALUE. * reloc.c: Add BFD_RELOC_ARM_GOTFUNCDESC, BFD_RELOC_ARM_GOTOFFFUNCDESC, BFD_RELOC_ARM_FUNCDESC, BFD_RELOC_ARM_FUNCDESC_VALUE. gas/ * config/tc-arm.c (reloc_names): Add gotfuncdesc, gotofffuncdesc, funcdesc. (md_apply_fix): Support the new relocations. (tc_gen_reloc): Likewise. * testsuite/gas/arm/reloc-fdpic.d: New. * testsuite/gas/arm/reloc-fdpic.s: New. include/ * elf/arm.h (R_ARM_GOTFUNCDESC, R_ARM_GOTOFFFUNCDESC) (R_ARM_FUNCDESC) (R_ARM_FUNCDESC_VALUE): Define new relocations. --- bfd/bfd-in2.h | 6 ++++ bfd/elf32-arm.c | 63 +++++++++++++++++++++++++++++++++++-- bfd/reloc.c | 11 +++++++ gas/config/tc-arm.c | 27 +++++++++++++++- gas/testsuite/gas/arm/reloc-fdpic.d | 20 ++++++++++++ gas/testsuite/gas/arm/reloc-fdpic.s | 9 ++++++ include/elf/arm.h | 4 +++ 7 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 gas/testsuite/gas/arm/reloc-fdpic.d create mode 100644 gas/testsuite/gas/arm/reloc-fdpic.s -- 2.6.3 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 9742c1a..0c2279f 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -3565,6 +3565,12 @@ pc-relative or some form of GOT-indirect relocation. */ BFD_RELOC_ARM_THUMB_MOVW_PCREL, BFD_RELOC_ARM_THUMB_MOVT_PCREL, +/* ARM FDPIC specific relocations. */ + BFD_RELOC_ARM_GOTFUNCDESC, + BFD_RELOC_ARM_GOTOFFFUNCDESC, + BFD_RELOC_ARM_FUNCDESC, + BFD_RELOC_ARM_FUNCDESC_VALUE, + /* Relocations for setting up GOTs and PLTs for shared libraries. */ BFD_RELOC_ARM_JUMP_SLOT, BFD_RELOC_ARM_GLOB_DAT, diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index a0b0be3..3805f71 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -1746,7 +1746,7 @@ static reloc_howto_type elf32_arm_howto_table_1[] = }; /* 160 onwards: */ -static reloc_howto_type elf32_arm_howto_table_2[1] = +static reloc_howto_type elf32_arm_howto_table_2[5] = { HOWTO (R_ARM_IRELATIVE, /* type */ 0, /* rightshift */ @@ -1760,7 +1760,59 @@ static reloc_howto_type elf32_arm_howto_table_2[1] = TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE) /* pcrel_offset */ + FALSE), /* pcrel_offset */ + HOWTO (R_ARM_GOTFUNCDESC, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_ARM_GOTFUNCDESC", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO (R_ARM_GOTOFFFUNCDESC, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_ARM_GOTOFFFUNCDESC",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO (R_ARM_FUNCDESC, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_ARM_FUNCDESC", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO (R_ARM_FUNCDESC_VALUE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 64, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_ARM_FUNCDESC_VALUE",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ }; /* 249-255 extended, currently unused, relocations: */ @@ -1829,7 +1881,8 @@ elf32_arm_howto_from_type (unsigned int r_type) if (r_type < ARRAY_SIZE (elf32_arm_howto_table_1)) return &elf32_arm_howto_table_1[r_type]; - if (r_type == R_ARM_IRELATIVE) + if (r_type >= R_ARM_IRELATIVE + && r_type < R_ARM_IRELATIVE + ARRAY_SIZE (elf32_arm_howto_table_2)) return &elf32_arm_howto_table_2[r_type - R_ARM_IRELATIVE]; if (r_type >= R_ARM_RREL32 @@ -1913,6 +1966,10 @@ static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] = {BFD_RELOC_ARM_TLS_IE32, R_ARM_TLS_IE32}, {BFD_RELOC_ARM_TLS_LE32, R_ARM_TLS_LE32}, {BFD_RELOC_ARM_IRELATIVE, R_ARM_IRELATIVE}, + {BFD_RELOC_ARM_GOTFUNCDESC, R_ARM_GOTFUNCDESC}, + {BFD_RELOC_ARM_GOTOFFFUNCDESC, R_ARM_GOTOFFFUNCDESC}, + {BFD_RELOC_ARM_FUNCDESC, R_ARM_FUNCDESC}, + {BFD_RELOC_ARM_FUNCDESC_VALUE, R_ARM_FUNCDESC_VALUE}, {BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT}, {BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY}, {BFD_RELOC_ARM_MOVW, R_ARM_MOVW_ABS_NC}, diff --git a/bfd/reloc.c b/bfd/reloc.c index 42e35b9..5715317 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -3217,6 +3217,17 @@ ENUMDOC Low and High halfword relocations for MOVW and MOVT instructions. ENUM + BFD_RELOC_ARM_GOTFUNCDESC +ENUMX + BFD_RELOC_ARM_GOTOFFFUNCDESC +ENUMX + BFD_RELOC_ARM_FUNCDESC +ENUMX + BFD_RELOC_ARM_FUNCDESC_VALUE +ENUMDOC + ARM FDPIC specific relocations. + +ENUM BFD_RELOC_ARM_JUMP_SLOT ENUMX BFD_RELOC_ARM_GLOB_DAT diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 8a3a282..e869084 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -19320,7 +19320,13 @@ static struct reloc_entry reloc_names[] = { "tlscall", BFD_RELOC_ARM_TLS_CALL}, { "TLSCALL", BFD_RELOC_ARM_TLS_CALL}, { "tlsdescseq", BFD_RELOC_ARM_TLS_DESCSEQ}, - { "TLSDESCSEQ", BFD_RELOC_ARM_TLS_DESCSEQ} + { "TLSDESCSEQ", BFD_RELOC_ARM_TLS_DESCSEQ}, + { "gotfuncdesc", BFD_RELOC_ARM_GOTFUNCDESC }, + { "GOTFUNCDESC", BFD_RELOC_ARM_GOTFUNCDESC }, + { "gotofffuncdesc", BFD_RELOC_ARM_GOTOFFFUNCDESC }, + { "GOTOFFFUNCDESC", BFD_RELOC_ARM_GOTOFFFUNCDESC }, + { "funcdesc", BFD_RELOC_ARM_FUNCDESC }, + { "FUNCDESC", BFD_RELOC_ARM_FUNCDESC } }; #endif @@ -24024,6 +24030,22 @@ md_apply_fix (fixS * fixP, if (fixP->fx_done || !seg->use_rela_p) md_number_to_chars (buf, fixP->fx_offset, 4); break; + + /* Relocations for FDPIC. */ + case BFD_RELOC_ARM_GOTFUNCDESC: + case BFD_RELOC_ARM_GOTOFFFUNCDESC: + case BFD_RELOC_ARM_FUNCDESC: + if (arm_fdpic) + { + if (fixP->fx_done || !seg->use_rela_p) + md_number_to_chars (buf, 0, 4); + } + else + { + as_bad_where (fixP->fx_file, fixP->fx_line, + _("Relocation supported only in FDPIC mode")); + } + break; #endif case BFD_RELOC_RVA: @@ -24785,6 +24807,9 @@ tc_gen_reloc (asection *section, fixS *fixp) case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC: case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC: case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC: + case BFD_RELOC_ARM_GOTFUNCDESC: + case BFD_RELOC_ARM_GOTOFFFUNCDESC: + case BFD_RELOC_ARM_FUNCDESC: code = fixp->fx_r_type; break; diff --git a/gas/testsuite/gas/arm/reloc-fdpic.d b/gas/testsuite/gas/arm/reloc-fdpic.d new file mode 100644 index 0000000..768c3a1 --- /dev/null +++ b/gas/testsuite/gas/arm/reloc-fdpic.d @@ -0,0 +1,20 @@ +#as: --fdpic +#objdump: -dr --show-raw-insn +#name: FDPIC relocations +# This test is only valid on ELF based ports. +#not-target: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix* + +.*: +file format .*arm.* + + +Disassembly of section .text: + +00000000 : +.* + 0: R_ARM_GOTFUNCDESC myfunc + 4: R_ARM_GOTOFFFUNCDESC myfunc + 8: R_ARM_FUNCDESC myfunc + +0000000c : + c: e12fff1e bx lr +.* \ No newline at end of file diff --git a/gas/testsuite/gas/arm/reloc-fdpic.s b/gas/testsuite/gas/arm/reloc-fdpic.s new file mode 100644 index 0000000..cbb61c5 --- /dev/null +++ b/gas/testsuite/gas/arm/reloc-fdpic.s @@ -0,0 +1,9 @@ + .syntax unified + + .word myfunc(GOTFUNCDESC) + .word myfunc(GOTOFFFUNCDESC) + .word myfunc(FUNCDESC) + + .type myfunc, %function +myfunc: + bx lr diff --git a/include/elf/arm.h b/include/elf/arm.h index fb9c5f6..158f7b1 100644 --- a/include/elf/arm.h +++ b/include/elf/arm.h @@ -240,6 +240,10 @@ START_RELOC_NUMBERS (elf_arm_reloc_type) RELOC_NUMBER (R_ARM_THM_ALU_ABS_G3_NC,135) RELOC_NUMBER (R_ARM_IRELATIVE, 160) + RELOC_NUMBER (R_ARM_GOTFUNCDESC, 161) + RELOC_NUMBER (R_ARM_GOTOFFFUNCDESC, 162) + RELOC_NUMBER (R_ARM_FUNCDESC, 163) + RELOC_NUMBER (R_ARM_FUNCDESC_VALUE, 164) /* Extensions? R=read-only? */ RELOC_NUMBER (R_ARM_RXPC25, 249) From patchwork Thu Mar 22 14:38:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132297 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp931264ljb; Thu, 22 Mar 2018 07:40:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELunYEy8S/joyfQBHOG/TuOLJxDNvLpP+erxzN0ZL5lPOEuH4JXWkC6p5MgcTAACuLxgZQ0U X-Received: by 2002:a17:902:6b82:: with SMTP id p2-v6mr25631882plk.326.1521729647916; Thu, 22 Mar 2018 07:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729647; cv=none; d=google.com; s=arc-20160816; b=DMkkfFpnw6w2WRiSRpm9Umgquief6Qm1fbawtHGBzy85tauyUO4QWhARImvxo5ACel SQau7daT+3w4aFYBIc8R4L5t+gM5DSlhgDhWaygvCvGEUzB6NS+2H0YI3+YrDd3tgZ8b lDnHF+DeZpvn+VzXFIerTYvqOIWc4BAZlsN9783DV236KZ76XvDVFrpFsElDgGu3D6Cp 9KqNUJvl/qQFceMuN4yyS8rcevLj6G7srabDUDc4xftXHl554+d7I3r1yl8UfX48smRy r84my1bo7xMF98LErVduvx7l8XBcykwWZ/EUEW6n4CZCxzFuzJTWlG6ibutnXPi5uKV2 iA3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=vnn64NceTN+OzyO9c9oWGIu6sDAKTdoeHOF2omcUVv0=; b=iRai9qXWC+qvPrytZFPd0Jd52nT/4qDxCwWMYgv0bUFNjJsfs1mAR/5ulWRrtI+qWT S1WJSGDB8DmC+X5ivQze2DUZUkSRW5mvxkqeNHSf67shuDEMD+PzVTrwiODNk4mN2as+ +N9BkCX3ehERlo7aBRV2vm6kPMNan2Eysm0eghUPImuRmJHjlP7733X0gb1fDFbFMNIq xJFYASeuZ6W3hrzFT3BJ4j5uIsuPqpPgv+YXoLagFSmKE4WYjwGXQ/9Xm+cZLC97pwo1 hKfDLo24YGTVJZpmerX4Hu5znvSDAjuY7XTvWn6WHkSI1EYLD8RPpOiranIj8PbC9J+z 7Fgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AST8JZow; spf=pass (google.com: domain of binutils-return-101083-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101083-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id az10-v6si6060322plb.145.2018.03.22.07.40.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101083-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 header.s=default header.b=AST8JZow; spf=pass (google.com: domain of binutils-return-101083-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101083-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=G1O+1sTqhYmXh4k64N5KxQL8DwyA5mwMRlQFg5YHPuA swm8m7EzNJGYBib/F8B5N21Vv0Tgze01ta3AJVoINYQjSeh794sHHjjPSStpWrOX /xioaC90sszqjOvPKopMWmKzaxi+lfMYysPabWUWO+6zhH4JOIKJHzk1gVJZPDiM = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=VPX5GRyxziBRSUObAqmwUKOHwP0=; b=AST8JZowo20YbrUl3 ZZbUjwbVD11RS7SNNkGyFTuz2EPPt8ib2OKCNn4eS/jUKItCP6pP7MyV3ApP6jFt 9G12y83EKcv4jd8YplerdButzuw/Ew8jBBRNMijoOpn58vmgptG27TPsZ/o2hsOE kWa2farV8MxEpQvy712Ms9WKIE= Received: (qmail 75058 invoked by alias); 22 Mar 2018 14:40:30 -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 75042 invoked by uid 89); 22 Mar 2018 14:40:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:40:20 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdPt7030795 for ; Thu, 22 Mar 2018 15:40:17 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv69ptk1g-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:40:17 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5591C31 for ; Thu, 22 Mar 2018 14:40:16 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F13F62B0C for ; Thu, 22 Mar 2018 14:40:15 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:40:15 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 04/12] [ARM] Implement FDPIC relocations. Date: Thu, 22 Mar 2018 15:38:22 +0100 Message-ID: <20180322143850.1766-5-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes This is the main BFD patch, that enables the linker to actually handle the FDPIC relocation. 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * elf32-arm.c (struct fdpic_local): New. (elf_arm_obj_tdata): Add local_fdpic_cnts field. (elf32_arm_local_fdpic_cnts): New. (struct fdpic_global): New. (elf32_arm_link_hash_entry): Add fdpic_cnts field. (elf32_arm_link_hash_table): Add srofixup field. (arm_elf_add_rofixup): New. (arm_elf_fill_funcdesc): New. (elf32_arm_link_hash_newfunc): Handle fdpic_cnts. (elf32_arm_allocate_local_sym_info): Likewise. (create_got_section): Create .rofixup section. (elf32_arm_copy_indirect_symbol): Handle fdpic_cnts. (bfd_elf32_arm_set_target_params): Handle FDPIC. (elf32_arm_final_link_relocate): Likewise. (elf32_arm_check_relocs): Likewise. (allocate_dynrelocs_for_symbol): Likewise. (elf32_arm_size_dynamic_sections): Likewise. (elf32_arm_finish_dynamic_sections): Likewise. (elf32_arm_output_arch_local_syms): Likewise. (elf32_arm_fdpic_omit_section_dynsym): New. ld/ * emulparams/armelf_linux_fdpiceabi.sh: Add .rofixup section. --- bfd/elf32-arm.c | 728 ++++++++++++++++++++++++++++++-- ld/emulparams/armelf_linux_fdpiceabi.sh | 8 +- 2 files changed, 705 insertions(+), 31 deletions(-) -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 3805f71..5892255 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3001,6 +3001,13 @@ struct arm_local_iplt_info struct elf_dyn_relocs *dyn_relocs; }; +/* Structure to handle FDPIC support for local functions. */ +struct fdpic_local { + unsigned int funcdesc_cnt; + unsigned int gotofffuncdesc_cnt; + int funcdesc_offset; +}; + struct elf_arm_obj_tdata { struct elf_obj_tdata root; @@ -3019,6 +3026,9 @@ struct elf_arm_obj_tdata /* Zero to warn when linking objects with incompatible wchar_t sizes. */ int no_wchar_size_warning; + + /* Maintains FDPIC counters and funcdesc info. */ + struct fdpic_local *local_fdpic_cnts; }; #define elf_arm_tdata(bfd) \ @@ -3033,6 +3043,9 @@ struct elf_arm_obj_tdata #define elf32_arm_local_iplt(bfd) \ (elf_arm_tdata (bfd)->local_iplt) +#define elf32_arm_local_fdpic_cnts(bfd) \ + (elf_arm_tdata (bfd)->local_fdpic_cnts) + #define is_arm_elf(bfd) \ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ && elf_tdata (bfd) != NULL \ @@ -3047,6 +3060,15 @@ elf32_arm_mkobject (bfd *abfd) #define elf32_arm_hash_entry(ent) ((struct elf32_arm_link_hash_entry *)(ent)) +/* Structure to handle FDPIC support for extern functions. */ +struct fdpic_global { + unsigned int gotofffuncdesc_cnt; + unsigned int gotfuncdesc_cnt; + unsigned int funcdesc_cnt; + int funcdesc_offset; + int gotfuncdesc_offset; +}; + /* Arm ELF linker hash entry. */ struct elf32_arm_link_hash_entry { @@ -3082,6 +3104,9 @@ struct elf32_arm_link_hash_entry /* A pointer to the most recently used stub hash entry against this symbol. */ struct elf32_arm_stub_hash_entry *stub_cache; + + /* Counter for FDPIC relocations against this symbol. */ + struct fdpic_global fdpic_cnts; }; /* Traverse an arm ELF linker hash table. */ @@ -3288,8 +3313,22 @@ struct elf32_arm_link_hash_table /* True if the target system uses FDPIC. */ int fdpic_p; + + /* Fixup section. Used for FDPIC. */ + asection *srofixup; }; +/* Add an FDPIC read-only fixup. */ +static void +arm_elf_add_rofixup (bfd *output_bfd, asection *srofixup, bfd_vma offset) +{ + bfd_vma fixup_offset; + + fixup_offset = srofixup->reloc_count++ * 4; + BFD_ASSERT (fixup_offset < srofixup->size); + bfd_put_32 (output_bfd, offset, srofixup->contents + fixup_offset); +} + static inline int ctz (unsigned int mask) { @@ -3327,6 +3366,57 @@ elf32_arm_popcount (unsigned int mask) #endif } +static void elf32_arm_add_dynreloc (bfd *output_bfd, struct bfd_link_info *info, + asection *sreloc, Elf_Internal_Rela *rel); + +static void +arm_elf_fill_funcdesc(bfd *output_bfd, + struct bfd_link_info *info, + int *funcdesc_offset, + int dynindx, + int offset, + bfd_vma addr, + bfd_vma dynreloc_value, + bfd_vma seg) +{ + if ((*funcdesc_offset & 1) == 0) + { + struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (info); + asection *sgot = globals->root.sgot; + + if (bfd_link_pic(info)) + { + asection *srelgot = globals->root.srelgot; + Elf_Internal_Rela outrel; + + outrel.r_info = ELF32_R_INFO (dynindx, R_ARM_FUNCDESC_VALUE); + outrel.r_offset = sgot->output_section->vma + sgot->output_offset + offset; + outrel.r_addend = 0; + + elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel); + bfd_put_32 (output_bfd, addr, sgot->contents + offset); + bfd_put_32 (output_bfd, seg, sgot->contents + offset + 4); + } + else + { + struct elf_link_hash_entry *hgot = globals->root.hgot; + bfd_vma got_value = hgot->root.u.def.value + + hgot->root.u.def.section->output_section->vma + + hgot->root.u.def.section->output_offset; + + arm_elf_add_rofixup(output_bfd, globals->srofixup, + sgot->output_section->vma + sgot->output_offset + + offset); + arm_elf_add_rofixup(output_bfd, globals->srofixup, + sgot->output_section->vma + sgot->output_offset + + offset + 4); + bfd_put_32 (output_bfd, dynreloc_value, sgot->contents + offset); + bfd_put_32 (output_bfd, got_value, sgot->contents + offset + 4); + } + *funcdesc_offset |= 1; + } +} + /* Create an entry in an ARM ELF linker hash table. */ static struct bfd_hash_entry * @@ -3362,6 +3452,12 @@ elf32_arm_link_hash_newfunc (struct bfd_hash_entry * entry, ret->export_glue = NULL; ret->stub_cache = NULL; + + ret->fdpic_cnts.gotofffuncdesc_cnt = 0; + ret->fdpic_cnts.gotfuncdesc_cnt = 0; + ret->fdpic_cnts.funcdesc_cnt = 0; + ret->fdpic_cnts.funcdesc_offset = -1; + ret->fdpic_cnts.gotfuncdesc_offset = -1; } return (struct bfd_hash_entry *) ret; @@ -3383,11 +3479,15 @@ elf32_arm_allocate_local_sym_info (bfd *abfd) size = num_syms * (sizeof (bfd_signed_vma) + sizeof (struct arm_local_iplt_info *) + sizeof (bfd_vma) - + sizeof (char)); + + sizeof (char) + + sizeof (struct fdpic_local)); data = bfd_zalloc (abfd, size); if (data == NULL) return FALSE; + elf32_arm_local_fdpic_cnts (abfd) = (struct fdpic_local *) data; + data += num_syms * sizeof (struct fdpic_local); + elf_local_got_refcounts (abfd) = (bfd_signed_vma *) data; data += num_syms * sizeof (bfd_signed_vma); @@ -3569,6 +3669,16 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) if (! _bfd_elf_create_got_section (dynobj, info)) return FALSE; + /* Also create .rofixup. */ + if (htab->fdpic_p) + { + htab->srofixup = bfd_make_section_with_flags (dynobj, ".rofixup", + (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS + | SEC_IN_MEMORY | SEC_LINKER_CREATED | SEC_READONLY)); + if (htab->srofixup == NULL || ! bfd_set_section_alignment (dynobj, htab->srofixup, 2)) + return FALSE; + } + return TRUE; } @@ -3808,6 +3918,11 @@ elf32_arm_copy_indirect_symbol (struct bfd_link_info *info, edir->plt.noncall_refcount += eind->plt.noncall_refcount; eind->plt.noncall_refcount = 0; + /* Copy FDPIC counters. */ + edir->fdpic_cnts.gotofffuncdesc_cnt += eind->fdpic_cnts.gotofffuncdesc_cnt; + edir->fdpic_cnts.gotfuncdesc_cnt += eind->fdpic_cnts.gotfuncdesc_cnt; + edir->fdpic_cnts.funcdesc_cnt += eind->fdpic_cnts.funcdesc_cnt; + /* We should only allocate a function to .iplt once the final symbol information is known. */ BFD_ASSERT (!eind->is_iplt); @@ -8788,7 +8903,10 @@ bfd_elf32_arm_set_target_params (struct bfd *output_bfd, globals->use_blx |= params->use_blx; globals->vfp11_fix = params->vfp11_denorm_fix; globals->stm32l4xx_fix = params->stm32l4xx_fix; - globals->pic_veneer = params->pic_veneer; + if (globals->fdpic_p) + globals->pic_veneer = 1; + else + globals->pic_veneer = params->pic_veneer; globals->fix_cortex_a8 = params->fix_cortex_a8; globals->fix_arm1176 = params->fix_arm1176; globals->cmse_implib = params->cmse_implib; @@ -10147,7 +10265,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, relocations are copied into the output file to be resolved at run time. */ if ((bfd_link_pic (info) - || globals->root.is_relocatable_executable) + || globals->root.is_relocatable_executable + || globals->fdpic_p) && (input_section->flags & SEC_ALLOC) && !(globals->vxworks_p && strcmp (input_section->output_section->name, @@ -10168,6 +10287,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { Elf_Internal_Rela outrel; bfd_boolean skip, relocate; + int isrofixup = 0; if ((r_type == R_ARM_REL32 || r_type == R_ARM_REL32_NOI) && !h->def_regular) @@ -10223,7 +10343,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, int symbol; /* This symbol is local, or marked to become local. */ - BFD_ASSERT (r_type == R_ARM_ABS32 || r_type == R_ARM_ABS32_NOI); + BFD_ASSERT (r_type == R_ARM_ABS32 || r_type == R_ARM_ABS32_NOI + || (globals->fdpic_p && !bfd_link_pic(info))); if (globals->symbian_p) { asection *osec; @@ -10269,6 +10390,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, must use an R_ARM_IRELATIVE relocation to obtain the correct run-time address. */ outrel.r_info = ELF32_R_INFO (symbol, R_ARM_IRELATIVE); + else if (globals->fdpic_p && !bfd_link_pic(info)) + isrofixup = 1; else outrel.r_info = ELF32_R_INFO (symbol, R_ARM_RELATIVE); if (globals->use_rel) @@ -10277,7 +10400,10 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, outrel.r_addend += dynreloc_value; } - elf32_arm_add_dynreloc (output_bfd, info, sreloc, &outrel); + if (isrofixup) + arm_elf_add_rofixup(output_bfd, globals->srofixup, outrel.r_offset); + else + elf32_arm_add_dynreloc (output_bfd, info, sreloc, &outrel); /* If this reloc is against an external symbol, we do not want to fiddle with the addend. Otherwise, we need to include the symbol @@ -11153,8 +11279,10 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, else { Elf_Internal_Rela outrel; + int isrofixup = 0; - if (h->dynindx != -1 && !SYMBOL_REFERENCES_LOCAL (info, h)) + if (((h->dynindx != -1) || globals->fdpic_p) + && !SYMBOL_REFERENCES_LOCAL (info, h)) { /* If the symbol doesn't resolve locally in a static object, we have an undefined reference. If the @@ -11177,6 +11305,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak)) outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); + else if (globals->fdpic_p) + isrofixup = 1; else outrel.r_info = 0; outrel.r_addend = dynreloc_value; @@ -11185,20 +11315,27 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, /* The GOT entry is initialized to zero by default. See if we should install a different value. */ if (outrel.r_addend != 0 - && (outrel.r_info == 0 || globals->use_rel)) + && (outrel.r_info == 0 || globals->use_rel || isrofixup)) { bfd_put_32 (output_bfd, outrel.r_addend, sgot->contents + off); outrel.r_addend = 0; } - if (outrel.r_info != 0) + if (outrel.r_info != 0 && !isrofixup) { outrel.r_offset = (sgot->output_section->vma + sgot->output_offset + off); elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel); } + else if (isrofixup) + { + arm_elf_add_rofixup(output_bfd, + elf32_arm_hash_table(info)->srofixup, + sgot->output_section->vma + + sgot->output_offset + off); + } h->got.offset |= 1; } value = sgot->output_offset + off; @@ -11236,6 +11373,14 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel); } + else if (globals->fdpic_p) + { + /* For FDPIC executables, we use rofixup to fix + address at runtime. */ + arm_elf_add_rofixup(output_bfd, globals->srofixup, + sgot->output_section->vma + sgot->output_offset + + off); + } local_got_offsets[r_symndx] |= 1; } @@ -11295,12 +11440,24 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, globals->tls_ldm_got.offset |= 1; } - value = sgot->output_section->vma + sgot->output_offset + off - - (input_section->output_section->vma + input_section->output_offset + rel->r_offset); + if (globals->fdpic_p) + { + bfd_put_32(output_bfd, + globals->root.sgot->output_offset + off, + contents + rel->r_offset); + + return bfd_reloc_ok; + } + else + { + value = sgot->output_section->vma + sgot->output_offset + off + - (input_section->output_section->vma + + input_section->output_offset + rel->r_offset); - return _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, rel->r_offset, value, - rel->r_addend); + return _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, value, + rel->r_addend); + } } case R_ARM_TLS_CALL: @@ -11653,9 +11810,23 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, - (input_section->output_section->vma + input_section->output_offset + rel->r_offset)); - return _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, rel->r_offset, value, - rel->r_addend); + if (globals->fdpic_p && (r_type == R_ARM_TLS_GD32 || + r_type == R_ARM_TLS_IE32)) + { + /* For FDPIC relocations, resolve to the offset of the GOT + entry from the start of GOT. */ + bfd_put_32(output_bfd, + globals->root.sgot->output_offset + off, + contents + rel->r_offset); + + return bfd_reloc_ok; + } + else + { + return _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, value, + rel->r_addend); + } } case R_ARM_TLS_LE32: @@ -12237,6 +12408,244 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, *unresolved_reloc_p = FALSE; return bfd_reloc_ok; + case R_ARM_GOTOFFFUNCDESC: + { + if (h == NULL) + { + struct fdpic_local *local_fdpic_cnts = elf32_arm_local_fdpic_cnts(input_bfd); + int dynindx = elf_section_data (sym_sec->output_section)->dynindx; + int offset = local_fdpic_cnts[r_symndx].funcdesc_offset & ~1; + bfd_vma addr = dynreloc_value - sym_sec->output_section->vma; + bfd_vma seg = -1; + + if (bfd_link_pic(info) && dynindx == 0) + abort(); + + /* Resolve relocation. */ + bfd_put_32(output_bfd, (offset + sgot->output_offset) + , contents + rel->r_offset); + /* Emit R_ARM_FUNCDESC_VALUE or two fixups on funcdesc if + not done yet. */ + arm_elf_fill_funcdesc(output_bfd, info, + &local_fdpic_cnts[r_symndx].funcdesc_offset, + dynindx, offset, addr, dynreloc_value, seg); + } + else + { + int dynindx; + int offset = eh->fdpic_cnts.funcdesc_offset & ~1; + bfd_vma addr; + bfd_vma seg = -1; + + /* For static binaries, sym_sec can be null. */ + if (sym_sec) + { + dynindx = elf_section_data (sym_sec->output_section)->dynindx; + addr = dynreloc_value - sym_sec->output_section->vma; + } + else + { + dynindx = 0; + addr = 0; + } + + if (bfd_link_pic(info) && dynindx == 0) + abort(); + + /* This case cannot occur since funcdesc is allocated by + the dynamic loader so we cannot resolve the relocation. */ + if (h->dynindx != -1) + abort(); + + /* Resolve relocation. */ + bfd_put_32(output_bfd, (offset + sgot->output_offset), + contents + rel->r_offset); + /* Emit R_ARM_FUNCDESC_VALUE on funcdesc if not done yet. */ + arm_elf_fill_funcdesc(output_bfd, info, + &eh->fdpic_cnts.funcdesc_offset, + dynindx, offset, addr, dynreloc_value, seg); + } + } + *unresolved_reloc_p = FALSE; + return bfd_reloc_ok; + + case R_ARM_GOTFUNCDESC: + { + if (h != NULL) + { + Elf_Internal_Rela outrel; + + /* Resolve relocation. */ + bfd_put_32(output_bfd, ((eh->fdpic_cnts.gotfuncdesc_offset & ~1) + + sgot->output_offset), + contents + rel->r_offset); + /* Add funcdesc and associated R_ARM_FUNCDESC_VALUE. */ + if(h->dynindx == -1) + { + int dynindx; + int offset = eh->fdpic_cnts.funcdesc_offset & ~1; + bfd_vma addr; + bfd_vma seg = -1; + + /* For static binaries sym_sec can be null. */ + if (sym_sec) + { + dynindx = elf_section_data (sym_sec->output_section)->dynindx; + addr = dynreloc_value - sym_sec->output_section->vma; + } + else + { + dynindx = 0; + addr = 0; + } + + if (bfd_link_pic(info) && dynindx == 0) + abort(); + + /* Emit R_ARM_FUNCDESC_VALUE on funcdesc if not done yet. */ + arm_elf_fill_funcdesc(output_bfd, info, + &eh->fdpic_cnts.funcdesc_offset, + dynindx, offset, addr, dynreloc_value, seg); + } + + /* Add a dynamic relocation on GOT entry if not already done. */ + if ((eh->fdpic_cnts.gotfuncdesc_offset & 1) == 0) + { + if (h->dynindx == -1) + { + outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); + if (h->root.type == bfd_link_hash_undefweak) + bfd_put_32(output_bfd, 0, sgot->contents + + (eh->fdpic_cnts.gotfuncdesc_offset & ~1)); + else + bfd_put_32(output_bfd, sgot->output_section->vma + + sgot->output_offset + + (eh->fdpic_cnts.funcdesc_offset & ~1), + sgot->contents + + (eh->fdpic_cnts.gotfuncdesc_offset & ~1)); + } + else + { + outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_FUNCDESC); + } + outrel.r_offset = sgot->output_section->vma + + sgot->output_offset + + (eh->fdpic_cnts.gotfuncdesc_offset & ~1); + outrel.r_addend = 0; + if (h->dynindx == -1 && !bfd_link_pic(info)) + if (h->root.type == bfd_link_hash_undefweak) + arm_elf_add_rofixup(output_bfd, globals->srofixup, -1); + else + arm_elf_add_rofixup(output_bfd, globals->srofixup, outrel.r_offset); + else + elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel); + eh->fdpic_cnts.gotfuncdesc_offset |= 1; + } + } + else + { + /* Such relocation on static function should not have been + emitted by the compiler. */ + abort(); + } + } + *unresolved_reloc_p = FALSE; + return bfd_reloc_ok; + + case R_ARM_FUNCDESC: + { + if (h == NULL) + { + struct fdpic_local *local_fdpic_cnts = elf32_arm_local_fdpic_cnts(input_bfd); + Elf_Internal_Rela outrel; + int dynindx = elf_section_data (sym_sec->output_section)->dynindx; + int offset = local_fdpic_cnts[r_symndx].funcdesc_offset & ~1; + bfd_vma addr = dynreloc_value - sym_sec->output_section->vma; + bfd_vma seg = -1; + + if (bfd_link_pic(info) && dynindx == 0) + abort(); + + /* Replace static FUNCDESC relocation with a + R_ARM_RELATIVE dynamic relocation or with a rofixup for + executable. */ + outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); + outrel.r_offset = input_section->output_section->vma + + input_section->output_offset + rel->r_offset; + outrel.r_addend = 0; + if (bfd_link_pic(info)) + elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel); + else + arm_elf_add_rofixup(output_bfd, globals->srofixup, outrel.r_offset); + + bfd_put_32 (input_bfd, sgot->output_section->vma + + sgot->output_offset + offset, hit_data); + + /* Emit R_ARM_FUNCDESC_VALUE on funcdesc if not done yet. */ + arm_elf_fill_funcdesc(output_bfd, info, + &local_fdpic_cnts[r_symndx].funcdesc_offset, + dynindx, offset, addr, dynreloc_value, seg); + } + else + { + if (h->dynindx == -1) + { + int dynindx; + int offset = eh->fdpic_cnts.funcdesc_offset & ~1; + bfd_vma addr; + bfd_vma seg = -1; + Elf_Internal_Rela outrel; + + /* For static binaries sym_sec can be null. */ + if (sym_sec) + { + dynindx = elf_section_data (sym_sec->output_section)->dynindx; + addr = dynreloc_value - sym_sec->output_section->vma; + } + else + { + dynindx = 0; + addr = 0; + } + + if (bfd_link_pic(info) && dynindx == 0) + abort(); + + /* Replace static FUNCDESC relocation with a + R_ARM_RELATIVE dynamic relocation. */ + outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); + outrel.r_offset = input_section->output_section->vma + + input_section->output_offset + rel->r_offset; + outrel.r_addend = 0; + if (bfd_link_pic(info)) + elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel); + else + arm_elf_add_rofixup(output_bfd, globals->srofixup, outrel.r_offset); + + bfd_put_32 (input_bfd, sgot->output_section->vma + + sgot->output_offset + offset, hit_data); + + /* Emit R_ARM_FUNCDESC_VALUE on funcdesc if not done yet. */ + arm_elf_fill_funcdesc(output_bfd, info, + &eh->fdpic_cnts.funcdesc_offset, + dynindx, offset, addr, dynreloc_value, seg); + } + else + { + Elf_Internal_Rela outrel; + + /* Add a dynamic relocation. */ + outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_FUNCDESC); + outrel.r_offset = input_section->output_section->vma + + input_section->output_offset + rel->r_offset; + outrel.r_addend = 0; + elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel); + } + } + } + *unresolved_reloc_p = FALSE; + return bfd_reloc_ok; + default: return bfd_reloc_notsupported; } @@ -14499,6 +14908,54 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, r_type = elf32_arm_tls_transition (info, r_type, h); switch (r_type) { + case R_ARM_GOTOFFFUNCDESC: + { + if (h == NULL) + { + if (!elf32_arm_allocate_local_sym_info (abfd)) + return FALSE; + elf32_arm_local_fdpic_cnts(abfd)[r_symndx].gotofffuncdesc_cnt += 1; + elf32_arm_local_fdpic_cnts(abfd)[r_symndx].funcdesc_offset = -1; + } + else + { + eh->fdpic_cnts.gotofffuncdesc_cnt++; + } + } + break; + + case R_ARM_GOTFUNCDESC: + { + if (h == NULL) + { + /* Such a relocation is not supposed to be generated + by gcc on a static function. */ + /* Anyway if needed it could be handled. */ + abort(); + } + else + { + eh->fdpic_cnts.gotfuncdesc_cnt++; + } + } + break; + + case R_ARM_FUNCDESC: + { + if (h == NULL) + { + if (!elf32_arm_allocate_local_sym_info (abfd)) + return FALSE; + elf32_arm_local_fdpic_cnts(abfd)[r_symndx].funcdesc_cnt += 1; + elf32_arm_local_fdpic_cnts(abfd)[r_symndx].funcdesc_offset = -1; + } + else + { + eh->fdpic_cnts.funcdesc_cnt++; + } + } + break; + case R_ARM_GOT32: case R_ARM_GOT_PREL: case R_ARM_TLS_GD32: @@ -14640,7 +15097,8 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_ARM_THM_MOVT_PREL: /* Should the interworking branches be listed here? */ - if ((bfd_link_pic (info) || htab->root.is_relocatable_executable) + if ((bfd_link_pic (info) || htab->root.is_relocatable_executable + || htab->fdpic_p) && (sec->flags & SEC_ALLOC) != 0) { if (h == NULL @@ -14793,6 +15251,18 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, if (elf32_arm_howto_from_type (r_type)->pc_relative) p->pc_count += 1; p->count += 1; + if (h == NULL && htab->fdpic_p && !bfd_link_pic(info) + && r_type != R_ARM_ABS32 && r_type != R_ARM_ABS32_NOI) { + /* Here we only support R_ARM_ABS32 and R_ARM_ABS32_NOI + that will become rofixup. */ + /* This is due to the fact that we suppose all will become rofixup. */ + fprintf(stderr, "FDPIC does not yet support %d relocation to become dynamic for executable\n", r_type); + _bfd_error_handler + (_("FDPIC does not yet support %s relocation" + " to become dynamic for executable"), + elf32_arm_howto_table_1[r_type].name); + abort(); + } } } @@ -15455,7 +15925,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ - if (h->dynindx == -1 && !h->forced_local + if (htab->root.dynamic_sections_created && h->dynindx == -1 && !h->forced_local && h->root.type == bfd_link_hash_undefweak) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) @@ -15535,7 +16005,8 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) if ((tls_type & GOT_TLS_GD) && indx != 0) elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1); } - else if (indx != -1 && !SYMBOL_REFERENCES_LOCAL (info, h)) + else if (((indx != -1) || htab->fdpic_p) + && !SYMBOL_REFERENCES_LOCAL (info, h)) { if (htab->root.dynamic_sections_created) /* Reserve room for the GOT entry's R_ARM_GLOB_DAT relocation. */ @@ -15552,11 +16023,110 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) || h->root.type != bfd_link_hash_undefweak)) /* Reserve room for the GOT entry's R_ARM_RELATIVE relocation. */ elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1); + else if (htab->fdpic_p && tls_type == GOT_NORMAL) + /* Reserve room for rofixup for FDPIC executable. */ + /* TLS relocs do not need space since they are completely + resolved. */ + htab->srofixup->size += 4; } } else h->got.offset = (bfd_vma) -1; + /* FDPIC support. */ + if (eh->fdpic_cnts.gotofffuncdesc_cnt > 0) + { + /* Symbol musn't be exported. */ + if (h->dynindx != -1) + abort(); + + /* We only allocate one function descriptor with its associated relocation. */ + if (eh->fdpic_cnts.funcdesc_offset == -1) + { + asection *s = htab->root.sgot; + + eh->fdpic_cnts.funcdesc_offset = s->size; + s->size += 8; + /* We will add an R_ARM_FUNCDESC_VALUE relocation or two rofixups. */ + if (bfd_link_pic(info)) + elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1); + else + htab->srofixup->size += 8; + } + } + + if (eh->fdpic_cnts.gotfuncdesc_cnt > 0) + { + asection *s = htab->root.sgot; + + if (htab->root.dynamic_sections_created && h->dynindx == -1 + && !h->forced_local) + if (! bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; + + if (h->dynindx == -1) + { + /* We only allocate one function descriptor with its associated relocation. q */ + if (eh->fdpic_cnts.funcdesc_offset == -1) + { + + eh->fdpic_cnts.funcdesc_offset = s->size; + s->size += 8; + /* We will add an R_ARM_FUNCDESC_VALUE relocation or two rofixups. */ + if (bfd_link_pic(info)) + elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1); + else + htab->srofixup->size += 8; + } + } + + /* Add one entry into the GOT and a R_ARM_FUNCDESC or + R_ARM_RELATIVE/rofixup relocation on it. */ + eh->fdpic_cnts.gotfuncdesc_offset = s->size; + s->size += 4; + if (h->dynindx == -1 && !bfd_link_pic(info)) + htab->srofixup->size += 4; + else + elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1); + } + + if (eh->fdpic_cnts.funcdesc_cnt > 0) + { + if (htab->root.dynamic_sections_created && h->dynindx == -1 + && !h->forced_local) + if (! bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; + + if (h->dynindx == -1) + { + /* We only allocate one function descriptor with its associated relocation. */ + if (eh->fdpic_cnts.funcdesc_offset == -1) + { + asection *s = htab->root.sgot; + + eh->fdpic_cnts.funcdesc_offset = s->size; + s->size += 8; + /* We will add an R_ARM_FUNCDESC_VALUE relocation or two rofixups. */ + if (bfd_link_pic(info)) + elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1); + else + htab->srofixup->size += 8; + } + } + if (h->dynindx == -1 && !bfd_link_pic(info)) + { + /* For FDPIC executable we replace R_ARM_RELATIVE with a rofixup. */ + htab->srofixup->size += 4 * eh->fdpic_cnts.funcdesc_cnt; + } + else + { + /* Will need one dynamic reloc per reference. will be either + R_ARM_FUNCDESC or R_ARM_RELATIVE for hidden symbols. */ + elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, + eh->fdpic_cnts.funcdesc_cnt); + } + } + /* Allocate stubs for exported Thumb functions on v4t. */ if (!htab->use_blx && h->dynindx != -1 && h->def_regular @@ -15599,7 +16169,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) space for pc-relative relocs that have become local due to symbol visibility changes. */ - if (bfd_link_pic (info) || htab->root.is_relocatable_executable) + if (bfd_link_pic (info) || htab->root.is_relocatable_executable || htab->fdpic_p) { /* Relocs that use pc_count are PC-relative forms, which will appear on something like ".long foo - ." or "movw REG, foo - .". We want @@ -15646,7 +16216,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) /* Make sure undefined weak symbols are output as a dynamic symbol in PIEs. */ - else if (h->dynindx == -1 + else if (htab->root.dynamic_sections_created && h->dynindx == -1 && !h->forced_local) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) @@ -15702,10 +16272,15 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; + if (h->type == STT_GNU_IFUNC && eh->plt.noncall_refcount == 0 && SYMBOL_REFERENCES_LOCAL (info, h)) elf32_arm_allocate_irelocs (info, sreloc, p->count); + else if (h->dynindx != -1 && (!bfd_link_pic(info) || !info->symbolic || !h->def_regular)) + elf32_arm_allocate_dynrelocs (info, sreloc, p->count); + else if (htab->fdpic_p && !bfd_link_pic(info)) + htab->srofixup->size += 4 * p->count; else elf32_arm_allocate_dynrelocs (info, sreloc, p->count); } @@ -15800,6 +16375,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, asection *srel; bfd_boolean is_vxworks = htab->vxworks_p; unsigned int symndx; + struct fdpic_local *local_fdpic_cnts; if (! is_arm_elf (ibfd)) continue; @@ -15829,7 +16405,10 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - elf32_arm_allocate_dynrelocs (info, srel, p->count); + if (htab->fdpic_p && !bfd_link_pic(info)) + htab->srofixup->size += 4 * p->count; + else + elf32_arm_allocate_dynrelocs (info, srel, p->count); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -15846,15 +16425,54 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, local_iplt_ptr = elf32_arm_local_iplt (ibfd); local_tls_type = elf32_arm_local_got_tls_type (ibfd); local_tlsdesc_gotent = elf32_arm_local_tlsdesc_gotent (ibfd); + local_fdpic_cnts = elf32_arm_local_fdpic_cnts (ibfd); symndx = 0; s = htab->root.sgot; srel = htab->root.srelgot; for (; local_got < end_local_got; ++local_got, ++local_iplt_ptr, ++local_tls_type, - ++local_tlsdesc_gotent, ++symndx) + ++local_tlsdesc_gotent, ++symndx, ++local_fdpic_cnts) { *local_tlsdesc_gotent = (bfd_vma) -1; local_iplt = *local_iplt_ptr; + + /* FDPIC support. */ + if (local_fdpic_cnts->gotofffuncdesc_cnt > 0) + { + if (local_fdpic_cnts->funcdesc_offset == -1) + { + local_fdpic_cnts->funcdesc_offset = s->size; + s->size += 8; + + /* We will add an R_ARM_FUNCDESC_VALUE relocation or two rofixups. */ + if (bfd_link_pic(info)) + elf32_arm_allocate_dynrelocs (info, srel, 1); + else + htab->srofixup->size += 8; + } + } + + if (local_fdpic_cnts->funcdesc_cnt > 0) + { + if (local_fdpic_cnts->funcdesc_offset == -1) + { + local_fdpic_cnts->funcdesc_offset = s->size; + s->size += 8; + + /* We will add an R_ARM_FUNCDESC_VALUE relocation or two rofixups. */ + if (bfd_link_pic(info)) + elf32_arm_allocate_dynrelocs (info, srel, 1); + else + htab->srofixup->size += 8; + } + + /* We will add n R_ARM_RELATIVE relocations or n rofixups. */ + if (bfd_link_pic(info)) + elf32_arm_allocate_dynrelocs (info, srel, local_fdpic_cnts->funcdesc_cnt); + else + htab->srofixup->size += 4 * local_fdpic_cnts->funcdesc_cnt; + } + if (local_iplt != NULL) { struct elf_dyn_relocs *p; @@ -15929,13 +16547,15 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, && (local_iplt == NULL || local_iplt->arm.noncall_refcount == 0)) elf32_arm_allocate_irelocs (info, srel, 1); - else if (bfd_link_pic (info) || output_bfd->flags & DYNAMIC) + else if (bfd_link_pic (info) || output_bfd->flags & DYNAMIC || htab->fdpic_p) { - if ((bfd_link_pic (info) && !(*local_tls_type & GOT_TLS_GDESC)) - || *local_tls_type & GOT_TLS_GD) + if ((bfd_link_pic (info) && !(*local_tls_type & GOT_TLS_GDESC))) elf32_arm_allocate_dynrelocs (info, srel, 1); + else if (htab->fdpic_p && *local_tls_type & GOT_NORMAL) + htab->srofixup->size += 4; - if (bfd_link_pic (info) && *local_tls_type & GOT_TLS_GDESC) + if ((bfd_link_pic (info) || htab->fdpic_p) + && *local_tls_type & GOT_TLS_GDESC) { elf32_arm_allocate_dynrelocs (info, htab->root.srelplt, 1); @@ -15960,6 +16580,11 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, else htab->tls_ldm_got.offset = -1; + /* At the very end of the .rofixup section is a pointer to the GOT, + reserve space for it. */ + if (htab->fdpic_p && htab->srofixup != NULL) + htab->srofixup->size += 4; + /* Allocate global sym .plt and .got entries, and space for global sym dynamic relocs. */ elf_link_hash_traverse (& htab->root, allocate_dynrelocs_for_symbol, info); @@ -16050,7 +16675,8 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, && s != htab->root.iplt && s != htab->root.igotplt && s != htab->root.sdynbss - && s != htab->root.sdynrelro) + && s != htab->root.sdynrelro + && s != htab->srofixup) { /* It's not one of our sections, so don't allocate space. */ continue; @@ -16682,6 +17308,21 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; } + /* At the very end of the .rofixup section is a pointer to the GOT. */ + if (htab->fdpic_p && htab->srofixup != NULL) + { + struct elf_link_hash_entry *hgot = htab->root.hgot; + + bfd_vma got_value = hgot->root.u.def.value + + hgot->root.u.def.section->output_section->vma + + hgot->root.u.def.section->output_offset; + + arm_elf_add_rofixup(output_bfd, htab->srofixup, got_value); + + /* Make sure we allocated and generated the same number of fixups. */ + BFD_ASSERT (htab->srofixup->reloc_count * 4 == htab->srofixup->size); + } + return TRUE; } @@ -17301,7 +17942,7 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, if (!elf32_arm_output_map_sym (&osi, ARM_MAP_THUMB, 16)) return FALSE; } - else if (!htab->symbian_p) + else if (!htab->symbian_p && !htab->fdpic_p) { if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0)) return FALSE; @@ -19514,15 +20155,44 @@ elf32_arm_fdpic_link_hash_table_create (bfd *abfd) return ret; } +/* We need dynamic symbols for every section, since segments can + relocate independently. */ +static bfd_boolean +elf32_arm_fdpic_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info + ATTRIBUTE_UNUSED, + asection *p ATTRIBUTE_UNUSED) +{ + switch (elf_section_data (p)->this_hdr.sh_type) + { + case SHT_PROGBITS: + case SHT_NOBITS: + /* If sh_type is yet undecided, assume it could be + SHT_PROGBITS/SHT_NOBITS. */ + case SHT_NULL: + return FALSE; + + /* There shouldn't be section relative relocations + against any other section. */ + default: + return TRUE; + } +} + #undef elf32_bed #define elf32_bed elf32_arm_fdpic_bed #undef bfd_elf32_bfd_link_hash_table_create #define bfd_elf32_bfd_link_hash_table_create elf32_arm_fdpic_link_hash_table_create +#undef elf_backend_omit_section_dynsym +#define elf_backend_omit_section_dynsym elf32_arm_fdpic_omit_section_dynsym + #include "elf32-target.h" + #undef elf_match_priority #undef ELF_OSABI +#undef elf_backend_omit_section_dynsym /* VxWorks Targets. */ diff --git a/ld/emulparams/armelf_linux_fdpiceabi.sh b/ld/emulparams/armelf_linux_fdpiceabi.sh index 104cf38..aa604aa 100644 --- a/ld/emulparams/armelf_linux_fdpiceabi.sh +++ b/ld/emulparams/armelf_linux_fdpiceabi.sh @@ -9,5 +9,9 @@ OTHER_READONLY_SECTIONS=" .ARM.extab ${RELOCATING-0} : { *(.ARM.extab${RELOCATING+* .gnu.linkonce.armextab.*}) } ${RELOCATING+ PROVIDE_HIDDEN (__exidx_start = .); } .ARM.exidx ${RELOCATING-0} : { *(.ARM.exidx${RELOCATING+* .gnu.linkonce.armexidx.*}) } - ${RELOCATING+ PROVIDE_HIDDEN (__exidx_end = .); }" - + ${RELOCATING+ PROVIDE_HIDDEN (__exidx_end = .); } + .rofixup : { + ${RELOCATING+__ROFIXUP_LIST__ = .;} + *(.rofixup) + ${RELOCATING+__ROFIXUP_END__ = .;} +}" From patchwork Thu Mar 22 14:38:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132298 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp931617ljb; Thu, 22 Mar 2018 07:41:09 -0700 (PDT) X-Google-Smtp-Source: AG47ELvCdTCmmsAGf0eYTmyPrukmS9KJ1s706xZW06xWYvU0hUVu3QfuZvIlbPopgYI4yuu6VcN+ X-Received: by 10.99.96.130 with SMTP id u124mr18323827pgb.252.1521729669050; Thu, 22 Mar 2018 07:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729669; cv=none; d=google.com; s=arc-20160816; b=hChwB1dLHcVobiWy5qhBzGA2m5MOwYKUlNMsvjunRSAUMNvmVKgJDRaDVEewOmDqgI r9fx5OxYWoq/UMwdTNVS0QDk9lZsmVjRBgey62gemXsB3FYrVxkrLQ/lyahg2WPiSFxK b0iu/DFqCkEMPrCHObcEPd6w8w7MUmA63SitlFX3G8C4vf+bOCRi1DFiH5qmP8KNagKx FNqtONxgAytChgAadtdawkC0N0hLQ7VfjKtC/3TJ2OgL20T+b7O+r3K+Us/wg7JBCvYl K87qYYBh5CXih5TuSdg/hmMx/6/jvAwqGtwOqsoXcWV7FCRUkQVWTXA0IW8zniRoQYha n0OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=ac3XfSeXKlgH/X5Dc7pJdc2TInh2uwru/P8LOM6W4uQ=; b=sK6pWU5FLNBUTanVK8jnigyOlkankXlOtA5R+FrMaGOYurCpqAOa+3Ji+1qfs3M30l ZaeScOqkozosBc1cYXiUUT1jM3/UC8YUSz7fo2ZtUnAxdXiz1teqsdU1zzwYqIf9RS0S 1FRHeu3iKTuhW68Q39LpQd0OWNvLHLAiyt+JfsGmiquaVa/4OoOCQ0J3I14o9nTbSg7T CqlSBVEZwdIhH+LAFDKU8X8igzpkh2xHe6ZjEImteR1iWcR49IZX5CKOX6DXC1l5kqXw XkhTuffWnvukFXwooqIffF+/RDJexlCwnkw2T6vqSr4i4eBJuF8FdTRsXuyFXeyZV0Xl B1jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=cJ+bT+rl; spf=pass (google.com: domain of binutils-return-101084-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101084-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 204si4438744pgf.771.2018.03.22.07.41.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101084-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 header.s=default header.b=cJ+bT+rl; spf=pass (google.com: domain of binutils-return-101084-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101084-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=sAJkW2ZLOWeIrSJT9788Qrofq0KXW8iJfb57+GwSv3R 0GY8vGNnon+6UZjcDLa9n8IWIZQiT6685gMGm3gP9wJ0QyQ5aOJ8QOmY0CjDRuXu XrpEVGav3VlDMxXNawAiApa5JBcN8VRXuACPZqYiuf8PoO6TZNZe+3R2FhgW9WFg = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=/hx2rUKeNvubSUuvLvDCs+Z3u8w=; b=cJ+bT+rlirG+naO7g usj8GL3rPn6c6Gaf1rmoVJ4T+OtdudK7VQ4wIlhvnLrkoHa7U29htVSZDqzwqcc0 +c3YhZmvcE/6/nzRwOQbWF6hA8rPfAuP/CJ0P5bF4yI7b+DOBaWN4pp8eQiVo0Tc /UOfLVuDhtKnVxE0wjFM+qfcrE= Received: (qmail 76254 invoked by alias); 22 Mar 2018 14:40:43 -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 76191 invoked by uid 89); 22 Mar 2018 14:40:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:40:39 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEcfnu001270 for ; Thu, 22 Mar 2018 15:40:37 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gv9sx1fh8-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:40:37 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5B7C241 for ; Thu, 22 Mar 2018 14:40:36 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 29FE72B0F for ; Thu, 22 Mar 2018 14:40:36 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:40:35 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 05/12] [ARM] Implement PLT for FDPIC. Date: Thu, 22 Mar 2018 15:38:23 +0100 Message-ID: <20180322143850.1766-6-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes FDPIC requires special PLT entries, defined in this patch. Note that lazy binding is not supported because of a race condition for lack of an atomic 64-bits load instruction. 2018-XX-XX Christophe Lyon Mickaël Guêné * elf32-arm.c (elf32_arm_fdpic_plt_entry): New. (elf32_arm_create_dynamic_sections): Handle FDPIC. (elf32_arm_allocate_plt_entry): Likewise. (elf32_arm_populate_plt_entry): Likewise. (elf32_arm_output_plt_map_1): Likewise. --- bfd/elf32-arm.c | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 143 insertions(+), 9 deletions(-) -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 5892255..d84edb1 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2229,6 +2229,22 @@ static const unsigned long dl_tlsdesc_lazy_trampoline [] = 0x00000018, /* 4: .word _GLOBAL_OFFSET_TABLE_ - 2b - 8 */ }; +/* ARM FDPIC PLT entry. */ +/* The last 5 words contain PLT lazy fragment code and data. */ +static const bfd_vma elf32_arm_fdpic_plt_entry [] = + { + 0xe59fc008, /* ldr r12, .L1 */ + 0xe08cc009, /* add r12, r12, r9 */ + 0xe59c9004, /* ldr r9, [r12, #4] */ + 0xe59cf000, /* ldr pc, [r12] */ + 0x00000000, /* L1. .word foo(GOTOFFFUNCDESC) */ + 0x00000000, /* L1. .word foo(funcdesc_value_reloc_offset) */ + 0xe51fc00c, /* ldr r12, [pc, #-12] */ + 0xe92d1000, /* push {r12} */ + 0xe599c004, /* ldr r12, [r9, #4] */ + 0xe599f000, /* ldr pc, [r9] */ + }; + #ifdef FOUR_WORD_PLT /* The first entry in a procedure linkage table looks like @@ -3856,6 +3872,14 @@ elf32_arm_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) htab->obfd = saved_obfd; } + if (htab->fdpic_p) { + htab->plt_header_size = 0; + if (info->flags & DF_BIND_NOW) + htab->plt_entry_size = 4 * (ARRAY_SIZE(elf32_arm_fdpic_plt_entry) - 5); + else + htab->plt_entry_size = 4 * ARRAY_SIZE(elf32_arm_fdpic_plt_entry); + } + if (!htab->root.splt || !htab->root.srelplt || !htab->root.sdynbss @@ -9392,8 +9416,22 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, splt = htab->root.splt; sgotplt = htab->root.sgotplt; - /* Allocate room for an R_JUMP_SLOT relocation in .rel.plt. */ - elf32_arm_allocate_dynrelocs (info, htab->root.srelplt, 1); + if (htab->fdpic_p) + { + /* Allocate room for R_ARM_FUNCDESC_VALUE. */ + /* For lazy binding, relocations will be put into .rel.plt, in + .rel.got otherwise. */ + /* FIXME: today we don't support lazy binding so put it in .rel.got */ + if (info->flags & DF_BIND_NOW) + elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1); + else + elf32_arm_allocate_dynrelocs (info, htab->root.srelplt, 1); + } + else + { + /* Allocate room for an R_JUMP_SLOT relocation in .rel.plt. */ + elf32_arm_allocate_dynrelocs (info, htab->root.srelplt, 1); + } /* If this is the first .plt entry, make room for the special first entry. */ @@ -9417,7 +9455,11 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, arm_plt->got_offset = sgotplt->size; else arm_plt->got_offset = sgotplt->size - 8 * htab->num_tls_desc; - sgotplt->size += 4; + if (htab->fdpic_p) + /* Function descriptor takes 64 bits in GOT. */ + sgotplt->size += 8; + else + sgotplt->size += 4; } } @@ -9526,7 +9568,11 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, in all the symbols for which we are making plt entries. After the reserved .got.plt entries, all symbols appear in the same order as in .plt. */ - plt_index = (got_offset - got_header_size) / 4; + if (htab->fdpic_p) + /* Function descriptor takes 8 bytes. */ + plt_index = (got_offset - got_header_size) / 8; + else + plt_index = (got_offset - got_header_size) / 4; /* Calculate the address of the GOT entry. */ got_address = (sgot->output_section->vma @@ -9634,6 +9680,42 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, | (tail_displacement & 0x00ffffff), ptr + 12); } + else if (htab->fdpic_p) + { + /* Fill-up Thumb stub if needed. */ + if (elf32_arm_plt_needs_thumb_stub_p (info, arm_plt)) + { + put_thumb_insn (htab, output_bfd, + elf32_arm_plt_thumb_stub[0], ptr - 4); + put_thumb_insn (htab, output_bfd, + elf32_arm_plt_thumb_stub[1], ptr - 2); + } + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[0], ptr + 0); + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[1], ptr + 4); + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[2], ptr + 8); + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[3], ptr + 12); + bfd_put_32 (output_bfd, got_offset, ptr + 16); + + if (!(info->flags & DF_BIND_NOW)) + { + /* funcdesc_value_reloc_offset. */ + bfd_put_32 (output_bfd, + htab->root.srelplt->reloc_count * RELOC_SIZE (htab), + ptr + 20); + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[6], ptr + 24); + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[7], ptr + 28); + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[8], ptr + 32); + put_arm_insn(htab, output_bfd, + elf32_arm_fdpic_plt_entry[9], ptr + 36); + } + } else if (using_thumb_only (htab)) { /* PR ld/16017: Generate thumb only PLT entries. */ @@ -9744,22 +9826,61 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, } else { - rel.r_info = ELF32_R_INFO (dynindx, R_ARM_JUMP_SLOT); - initial_got_entry = (splt->output_section->vma - + splt->output_offset); + /* For FDPIC we will have to resolve a R_ARM_FUNCDESC_VALUE + used by PLT entry. */ + if (htab->fdpic_p) + { + rel.r_info = ELF32_R_INFO (dynindx, R_ARM_FUNCDESC_VALUE); + initial_got_entry = 0; + } + else + { + rel.r_info = ELF32_R_INFO (dynindx, R_ARM_JUMP_SLOT); + initial_got_entry = (splt->output_section->vma + + splt->output_offset); + } } /* Fill in the entry in the global offset table. */ bfd_put_32 (output_bfd, initial_got_entry, sgot->contents + got_offset); + + if (htab->fdpic_p && !(info->flags & DF_BIND_NOW)) + { + /* Setup initial funcdesc value. */ + /* FIXME: we don't support lazy binding because there is a + race condition between both words getting written and + some other thread attempting to read them. The ARM + architecture does not have an atomic 64 bit load/store + instruction that could be used to prevent it; it is + recommended that threaded FDPIC applications run with the + LD_BIND_NOW environment variable set. */ + bfd_put_32(output_bfd, plt_address + 0x18, + sgot->contents + got_offset); + bfd_put_32(output_bfd, -1 /*TODO*/, + sgot->contents + got_offset + 4); + } } if (dynindx == -1) elf32_arm_add_dynreloc (output_bfd, info, srel, &rel); else { - loc = srel->contents + plt_index * RELOC_SIZE (htab); - SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); + if (htab->fdpic_p) + { + /* For FDPIC we put PLT relocationss into .rel.got when not + lazy binding otherwise we put them in .rel.plt. For now, + we don't support lazy binding so put it in .rel.got. */ + if (info->flags & DF_BIND_NOW) + elf32_arm_add_dynreloc(output_bfd, info, htab->root.srelgot, &rel); + else + elf32_arm_add_dynreloc(output_bfd, info, htab->root.srelplt, &rel); + } + else + { + loc = srel->contents + plt_index * RELOC_SIZE (htab); + SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); + } } return TRUE; @@ -17577,6 +17698,19 @@ elf32_arm_output_plt_map_1 (output_arch_syminfo *osi, if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr)) return FALSE; } + else if (htab->fdpic_p) + { + if (elf32_arm_plt_needs_thumb_stub_p (osi->info, arm_plt)) + if (!elf32_arm_output_map_sym (osi, ARM_MAP_THUMB, addr - 4)) + return FALSE; + if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr)) + return FALSE; + if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 16)) + return FALSE; + if (htab->plt_entry_size == 4 * ARRAY_SIZE(elf32_arm_fdpic_plt_entry)) + if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr + 24)) + return FALSE; + } else if (using_thumb_only (htab)) { if (!elf32_arm_output_map_sym (osi, ARM_MAP_THUMB, addr)) From patchwork Thu Mar 22 14:38:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132299 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp931900ljb; Thu, 22 Mar 2018 07:41:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELuQxQ5ZGxMvnLFlA5bcRO33alczI2d0dmiMCMGWs/ylfpxd/a2VZWs/elySKhMMYv/Y7tDR X-Received: by 2002:a17:902:6a17:: with SMTP id m23-v6mr25123128plk.342.1521729683890; Thu, 22 Mar 2018 07:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729683; cv=none; d=google.com; s=arc-20160816; b=A4Zw5bZBgdUFRlRnmSKClw7I8RCNxHDtPiGk5TDeu5lOeH0K8wQWHdDg4UNIdnMJJS h2W6WqyjfJGGQtz1N9oilVybzF3uBn9uyuNi+AoRW/S47NuvgA2hoE8b4iMtw6P0uH+Z aMtQj6kF99jtLgPmw3MhkSxOx8jbFYyYrQewLbc2Eass3wGsGauFL/wvkYFmcS3zXYbX jk1jS0x4ZC5PFfwfP+CE+tRiljHwPNmfsvIzc47keEkfx3UnFTYsx9I29Bj/kPZHd+WX px8zXnWbqyhRBK0ud/gv20SxhP73uljQsHbIOlMXqW6SeMh0v0Lky9bZlU4qAbh8MmNF ozww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=y7x9Z4uH+G22SvbeQa6XCE6WFt/EuL5szljrSaIKdkg=; b=YcIGhcmB4Mu2RVYYW+9oWiDgU8rGG4O2hBDebuKp1ZoyZPeiGeOSChX+cKu2Gdl0ce bYioBkgRD44mtpfiiEA+Dq/txrdsClA96fU0k9DIAXpjxd9kKIfsFh1/Q30y22XhpJqM r9GVbZdgj01v8mxEQngJHRsdxA2wS2qt5MqEkDIzgwMM+5KImsrotT5VgL+J6gn502gy k8mp+tZ97yzDbjOO6qimOJAmVsbsx04z+3DfyLCgj6qbF80dEuX1zDrj2W+H9In1knxi 683q6O0vhp1PR3THRNTELlo1aH3O3oZ1TPL8PfWN4HjV1VawAnvktGabugl3YnQtRXrB hXrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IPo4JHfz; spf=pass (google.com: domain of binutils-return-101085-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101085-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n5si4536141pgs.106.2018.03.22.07.41.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101085-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 header.s=default header.b=IPo4JHfz; spf=pass (google.com: domain of binutils-return-101085-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101085-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=mm2ZGWO3YmGElqpCjHNXqGlRdDobI2cgHCj9rkw6FWf zMqxS34dlW/7lgTXNJwx/BvJ9daYejn07ffsVZMqRa/M5VuGyhosRgW73LJBC6A8 ejJ+ZODpXsSVHrAHKNuQ40W3hDFTLthnRlxGYixgsnQpAGgz0lWj0hWDYYl7Dcbg = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=WkKTLAwpLQ79AkYd29gRBNPrcAw=; b=IPo4JHfzSdy7L8Knl DIZ48ajV9a+QTw/5KWnuLhRhgp/ppUg2Obn73KlakDoHO07eTnq8xPr8ZVewDO2l Ch65B8Nztf5RtHCSA9wEo1cUTr8C/vGpCiC2CzocdxogGy/TCK+y16Go4yF9M7Ut CszalTHTqPq7P2+5LNqbZQFNUQ= Received: (qmail 78641 invoked by alias); 22 Mar 2018 14:41: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 78538 invoked by uid 89); 22 Mar 2018 14:41:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:40:59 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdAo0030991 for ; Thu, 22 Mar 2018 15:40:57 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gvebr812m-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:40:57 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8FA6E34 for ; Thu, 22 Mar 2018 14:40:56 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 68D4F2B0E for ; Thu, 22 Mar 2018 14:40:56 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:40:55 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 06/12] [ARM] Add TLS relocations for FDPIC. Date: Thu, 22 Mar 2018 15:38:24 +0100 Message-ID: <20180322143850.1766-7-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes Define and handle TLS relocations for FDPIC in BFD and gas. In gas, the new relocations are rejected if the --fdpic option was not specified. We also define the __tdata_start symbol to mark the start of the .tdata section. This allows FDPIC static binaries to find the start of .tdata section, since phdr->p_vaddr of TLS segment is not a valid value for FDPIC. 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/: * bfd-in2.h (BFD_RELOC_ARM_TLS_GD32_FDPIC) (BFD_RELOC_ARM_TLS_LDM32_FDPIC, BFD_RELOC_ARM_TLS_IE32_FDPIC): New relocations. * elf32-arm.c (elf32_arm_howto_table_2): Add R_ARM_TLS_GD32_FDPIC, R_ARM_TLS_LDM32_FDPIC, R_ARM_TLS_IE32_FDPIC relocations. (elf32_arm_reloc_map): Add R_ARM_TLS_GD32_FDPIC, R_ARM_TLS_LDM32_FDPIC, R_ARM_TLS_IE32_FDPIC. (struct elf32_arm_link_hash_table): Update comment. (elf32_arm_final_link_relocate): Handle TLS FDPIC relocations. (IS_ARM_TLS_RELOC): Likewise. (elf32_arm_check_relocs): Likewise. (allocate_dynrelocs_for_symbol): Likewise. (elf32_arm_size_dynamic_sections): Update comment. * reloc.c: Add BFD_RELOC_ARM_TLS_GD32_FDPIC, BFD_RELOC_ARM_TLS_LDM32_FDPIC, BFD_RELOC_ARM_TLS_IE32_FDPIC. gas/ * config/tc-arm.c (reloc_names): Add TLSGD_FDPIC, TLSLDM_FDPIC, GOTTPOFF_FDIC relocations. (md_apply_fix): Handle the new TLS FDPIC relocations. (tc_gen_reloc): Likewise. (arm_fix_adjustable): Likewise. include/ * elf/arm.h: Add R_ARM_TLS_GD32_FDPIC, R_ARM_TLS_LDM32_FDPIC, R_ARM_TLS_IE32_FDPIC. ld/ * scripttempl/elf.sc: Define __tdata_start for .tdata section. * Define __tdata_start symbol to mark start of .tdata section This allow fdpic static binaries to find start of .tdata section since phdr->p_vaddr of TLS segment is not a valid value for fdpic. * Add fdpic tls specific relocations --- bfd/bfd-in2.h | 3 ++ bfd/elf32-arm.c | 79 +++++++++++++++++++++++++++++++++++++++++++-------- bfd/reloc.c | 6 ++++ gas/config/tc-arm.c | 26 ++++++++++++++++- include/elf/arm.h | 3 ++ ld/scripttempl/elf.sc | 6 +++- 6 files changed, 109 insertions(+), 14 deletions(-) -- 2.6.3 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 0c2279f..82152c6 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -3570,6 +3570,9 @@ pc-relative or some form of GOT-indirect relocation. */ BFD_RELOC_ARM_GOTOFFFUNCDESC, BFD_RELOC_ARM_FUNCDESC, BFD_RELOC_ARM_FUNCDESC_VALUE, + BFD_RELOC_ARM_TLS_GD32_FDPIC, + BFD_RELOC_ARM_TLS_LDM32_FDPIC, + BFD_RELOC_ARM_TLS_IE32_FDPIC, /* Relocations for setting up GOTs and PLTs for shared libraries. */ BFD_RELOC_ARM_JUMP_SLOT, diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index d84edb1..0e03c77 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -1746,7 +1746,7 @@ static reloc_howto_type elf32_arm_howto_table_1[] = }; /* 160 onwards: */ -static reloc_howto_type elf32_arm_howto_table_2[5] = +static reloc_howto_type elf32_arm_howto_table_2[8] = { HOWTO (R_ARM_IRELATIVE, /* type */ 0, /* rightshift */ @@ -1813,6 +1813,45 @@ static reloc_howto_type elf32_arm_howto_table_2[5] = 0, /* src_mask */ 0xffffffff, /* dst_mask */ FALSE), /* pcrel_offset */ + HOWTO (R_ARM_TLS_GD32_FDPIC, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_ARM_TLS_GD32_FDPIC",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO (R_ARM_TLS_LDM32_FDPIC, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_ARM_TLS_LDM32_FDPIC",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO (R_ARM_TLS_IE32_FDPIC, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_ARM_TLS_IE32_FDPIC",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ }; /* 249-255 extended, currently unused, relocations: */ @@ -1970,6 +2009,9 @@ static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] = {BFD_RELOC_ARM_GOTOFFFUNCDESC, R_ARM_GOTOFFFUNCDESC}, {BFD_RELOC_ARM_FUNCDESC, R_ARM_FUNCDESC}, {BFD_RELOC_ARM_FUNCDESC_VALUE, R_ARM_FUNCDESC_VALUE}, + {BFD_RELOC_ARM_TLS_GD32_FDPIC, R_ARM_TLS_GD32_FDPIC}, + {BFD_RELOC_ARM_TLS_LDM32_FDPIC, R_ARM_TLS_LDM32_FDPIC}, + {BFD_RELOC_ARM_TLS_IE32_FDPIC, R_ARM_TLS_IE32_FDPIC}, {BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT}, {BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY}, {BFD_RELOC_ARM_MOVW, R_ARM_MOVW_ABS_NC}, @@ -3280,7 +3322,7 @@ struct elf32_arm_link_hash_table /* Offset in .plt section of tls_arm_trampoline. */ bfd_vma tls_trampoline; - /* Data for R_ARM_TLS_LDM32 relocations. */ + /* Data for R_ARM_TLS_LDM32/R_ARM_TLS_LDM32_FDPIC relocations. */ union { bfd_signed_vma refcount; @@ -11523,6 +11565,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, rel->r_addend); case R_ARM_TLS_LDM32: + case R_ARM_TLS_LDM32_FDPIC: { bfd_vma off; @@ -11561,7 +11604,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, globals->tls_ldm_got.offset |= 1; } - if (globals->fdpic_p) + if (r_type == R_ARM_TLS_LDM32_FDPIC) { bfd_put_32(output_bfd, globals->root.sgot->output_offset + off, @@ -11584,7 +11627,9 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, case R_ARM_TLS_CALL: case R_ARM_THM_TLS_CALL: case R_ARM_TLS_GD32: + case R_ARM_TLS_GD32_FDPIC: case R_ARM_TLS_IE32: + case R_ARM_TLS_IE32_FDPIC: case R_ARM_TLS_GOTDESC: case R_ARM_TLS_DESCSEQ: case R_ARM_THM_TLS_DESCSEQ: @@ -11772,7 +11817,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, local_got_offsets[r_symndx] |= 1; } - if ((tls_type & GOT_TLS_GD) && r_type != R_ARM_TLS_GD32) + if ((tls_type & GOT_TLS_GD) && r_type != R_ARM_TLS_GD32 && r_type != R_ARM_TLS_GD32_FDPIC) off += 8; else if (tls_type & GOT_TLS_GDESC) off = offplt; @@ -11931,8 +11976,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, - (input_section->output_section->vma + input_section->output_offset + rel->r_offset)); - if (globals->fdpic_p && (r_type == R_ARM_TLS_GD32 || - r_type == R_ARM_TLS_IE32)) + if (globals->fdpic_p && (r_type == R_ARM_TLS_GD32_FDPIC || + r_type == R_ARM_TLS_IE32_FDPIC)) { /* For FDPIC relocations, resolve to the offset of the GOT entry from the start of GOT. */ @@ -12848,13 +12893,16 @@ arm_add_to_rel (bfd * abfd, #define IS_ARM_TLS_RELOC(R_TYPE) \ ((R_TYPE) == R_ARM_TLS_GD32 \ + || (R_TYPE) == R_ARM_TLS_GD32_FDPIC \ || (R_TYPE) == R_ARM_TLS_LDO32 \ || (R_TYPE) == R_ARM_TLS_LDM32 \ + || (R_TYPE) == R_ARM_TLS_LDM32_FDPIC \ || (R_TYPE) == R_ARM_TLS_DTPOFF32 \ || (R_TYPE) == R_ARM_TLS_DTPMOD32 \ || (R_TYPE) == R_ARM_TLS_TPOFF32 \ || (R_TYPE) == R_ARM_TLS_LE32 \ || (R_TYPE) == R_ARM_TLS_IE32 \ + || (R_TYPE) == R_ARM_TLS_IE32_FDPIC \ || IS_ARM_TLS_GNU_RELOC (R_TYPE)) /* Specific set of relocations for the gnu tls dialect. */ @@ -15080,7 +15128,9 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_ARM_GOT32: case R_ARM_GOT_PREL: case R_ARM_TLS_GD32: + case R_ARM_TLS_GD32_FDPIC: case R_ARM_TLS_IE32: + case R_ARM_TLS_IE32_FDPIC: case R_ARM_TLS_GOTDESC: case R_ARM_TLS_DESCSEQ: case R_ARM_THM_TLS_DESCSEQ: @@ -15093,8 +15143,10 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, switch (r_type) { case R_ARM_TLS_GD32: tls_type = GOT_TLS_GD; break; + case R_ARM_TLS_GD32_FDPIC: tls_type = GOT_TLS_GD; break; case R_ARM_TLS_IE32: tls_type = GOT_TLS_IE; break; + case R_ARM_TLS_IE32_FDPIC: tls_type = GOT_TLS_IE; break; case R_ARM_TLS_GOTDESC: case R_ARM_TLS_CALL: case R_ARM_THM_TLS_CALL: @@ -15152,7 +15204,8 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, /* Fall through. */ case R_ARM_TLS_LDM32: - if (r_type == R_ARM_TLS_LDM32) + case R_ARM_TLS_LDM32_FDPIC: + if (r_type == R_ARM_TLS_LDM32 || r_type == R_ARM_TLS_LDM32_FDPIC) htab->tls_ldm_got.refcount++; /* Fall through. */ @@ -16081,15 +16134,17 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) if (tls_type & GOT_TLS_GD) { - /* R_ARM_TLS_GD32 needs 2 consecutive GOT slots. If - the symbol is both GD and GDESC, got.offset may - have been overwritten. */ + /* R_ARM_TLS_GD32 and R_ARM_TLS_GD32_FDPIC need two + consecutive GOT slots. If the symbol is both GD + and GDESC, got.offset may have been + overwritten. */ h->got.offset = s->size; s->size += 8; } if (tls_type & GOT_TLS_IE) - /* R_ARM_TLS_IE32 needs one GOT slot. */ + /* R_ARM_TLS_IE32/R_ARM_TLS_IE32_FDPIC need one GOT + slot. */ s->size += 4; } @@ -16692,7 +16747,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, if (htab->tls_ldm_got.refcount > 0) { /* Allocate two GOT entries and one dynamic relocation (if necessary) - for R_ARM_TLS_LDM32 relocations. */ + for R_ARM_TLS_LDM32/R_ARM_TLS_LDM32_FDPIC relocations. */ htab->tls_ldm_got.offset = htab->root.sgot->size; htab->root.sgot->size += 8; if (bfd_link_pic (info)) diff --git a/bfd/reloc.c b/bfd/reloc.c index 5715317..ff589e5 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -3224,6 +3224,12 @@ ENUMX BFD_RELOC_ARM_FUNCDESC ENUMX BFD_RELOC_ARM_FUNCDESC_VALUE +ENUMX + BFD_RELOC_ARM_TLS_GD32_FDPIC +ENUMX + BFD_RELOC_ARM_TLS_LDM32_FDPIC +ENUMX + BFD_RELOC_ARM_TLS_IE32_FDPIC ENUMDOC ARM FDPIC specific relocations. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index e869084..806eb24 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -19326,7 +19326,10 @@ static struct reloc_entry reloc_names[] = { "gotofffuncdesc", BFD_RELOC_ARM_GOTOFFFUNCDESC }, { "GOTOFFFUNCDESC", BFD_RELOC_ARM_GOTOFFFUNCDESC }, { "funcdesc", BFD_RELOC_ARM_FUNCDESC }, - { "FUNCDESC", BFD_RELOC_ARM_FUNCDESC } + { "FUNCDESC", BFD_RELOC_ARM_FUNCDESC }, + { "tlsgd_fdpic", BFD_RELOC_ARM_TLS_GD32_FDPIC }, { "TLSGD_FDPIC", BFD_RELOC_ARM_TLS_GD32_FDPIC }, + { "tlsldm_fdpic", BFD_RELOC_ARM_TLS_LDM32_FDPIC }, { "TLSLDM_FDPIC", BFD_RELOC_ARM_TLS_LDM32_FDPIC }, + { "gottpoff_fdpic", BFD_RELOC_ARM_TLS_IE32_FDPIC }, { "GOTTPOFF_FDIC", BFD_RELOC_ARM_TLS_IE32_FDPIC }, }; #endif @@ -24014,6 +24017,21 @@ md_apply_fix (fixS * fixP, S_SET_THREAD_LOCAL (fixP->fx_addsy); break; + /* Same handling as above, but with the arm_fdpic guard. */ + case BFD_RELOC_ARM_TLS_GD32_FDPIC: + case BFD_RELOC_ARM_TLS_IE32_FDPIC: + case BFD_RELOC_ARM_TLS_LDM32_FDPIC: + if (arm_fdpic) + { + S_SET_THREAD_LOCAL (fixP->fx_addsy); + } + else + { + as_bad_where (fixP->fx_file, fixP->fx_line, + _("Relocation supported only in FDPIC mode")); + } + break; + case BFD_RELOC_ARM_GOT32: case BFD_RELOC_ARM_GOTOFF: break; @@ -24815,9 +24833,12 @@ tc_gen_reloc (asection *section, fixS *fixp) case BFD_RELOC_ARM_TLS_GOTDESC: case BFD_RELOC_ARM_TLS_GD32: + case BFD_RELOC_ARM_TLS_GD32_FDPIC: case BFD_RELOC_ARM_TLS_LE32: case BFD_RELOC_ARM_TLS_IE32: + case BFD_RELOC_ARM_TLS_IE32_FDPIC: case BFD_RELOC_ARM_TLS_LDM32: + case BFD_RELOC_ARM_TLS_LDM32_FDPIC: /* BFD will include the symbol's address in the addend. But we don't want that, so subtract it out again here. */ if (!S_IS_COMMON (fixp->fx_addsy)) @@ -25083,9 +25104,12 @@ arm_fix_adjustable (fixS * fixP) || fixP->fx_r_type == BFD_RELOC_ARM_GOT32 || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32 + || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32_FDPIC || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LE32 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_IE32 + || fixP->fx_r_type == BFD_RELOC_ARM_TLS_IE32_FDPIC || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDM32 + || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDM32_FDPIC || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDO32 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GOTDESC || fixP->fx_r_type == BFD_RELOC_ARM_TLS_CALL diff --git a/include/elf/arm.h b/include/elf/arm.h index 158f7b1..fdae08a 100644 --- a/include/elf/arm.h +++ b/include/elf/arm.h @@ -244,6 +244,9 @@ START_RELOC_NUMBERS (elf_arm_reloc_type) RELOC_NUMBER (R_ARM_GOTOFFFUNCDESC, 162) RELOC_NUMBER (R_ARM_FUNCDESC, 163) RELOC_NUMBER (R_ARM_FUNCDESC_VALUE, 164) + RELOC_NUMBER (R_ARM_TLS_GD32_FDPIC, 165) + RELOC_NUMBER (R_ARM_TLS_LDM32_FDPIC, 166) + RELOC_NUMBER (R_ARM_TLS_IE32_FDPIC, 167) /* Extensions? R=read-only? */ RELOC_NUMBER (R_ARM_RXPC25, 249) diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 9787ab5..5ccdd41 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -587,7 +587,11 @@ cat < X-Patchwork-Id: 132300 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp932102ljb; Thu, 22 Mar 2018 07:41:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELs+oYPvbFWZb8F/yNc6qFWlrhWdnTAJrc5Rg6cD/OW76E/XqWKWBl+YxZNbIwwn6Pg98u1x X-Received: by 10.101.85.9 with SMTP id f9mr18211047pgr.189.1521729697821; Thu, 22 Mar 2018 07:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729697; cv=none; d=google.com; s=arc-20160816; b=G+7jGE3NATmjKacpkGdBiX8ZeAkzpiN5okznKA/wOUtC9nj/3ug8Clj7Aka/t8UkA8 rQ9LLIS5ikWulXAjnoHo5b29ECpKXfMAN8H2lpsCceepAswo4alls6mdsek+OamYCw/I Ob74AdbJ+3zt9YF2pO3+KcJuDIlEpzt1SQyf5xFNHluL+sQEFKsxLuPi3FptXayUI/o4 0kUCc95kJgB1UYL8LG86Oszt4YzgzI+nKGvfkW8ocozBfDi8gHrYu6HfLxNcCmqS9H7U YQwZIyhB5bOnLsGhTgWRG89hpEvhVbuq4ukxYgt9HOKe6MihGzJ4X4g0FSr9ig7AQceo S8yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=vTxJvWMKxcBzIVvZh6qnR4PnmgmkNMu6w4++um4MZIk=; b=Lh9ATkx7L/YJQkfAKGoFo8SpFRbQdkgfc/9w76wy+srvWyClyZivCi0Ajf1clseJbH UP9tTnTpVNWDFDM4P5sfevYyjQZLaKLtxWlgEBfIXyejV+2PTeAlwRLiOcW3/AIb/dW0 msP7pUHDyNc33vRuHyIC8vZI4CFzpobpxKH5vcEUcAcQPQTgD5qL6ZdsClmOH43cVEtM PSkFkQaQ4Jt+tVF7aAnXMY75v/A3WPrMIBJ6ECHwho8Fgi4hc0EtfkmOJDoBf2M64B6Q p9FE6BGyk6ylm95zzsIXUDvcmn3oVZl78lgCiwzF6TwEBQhZ1oboH1doRYYbI6OZ6jxx n+nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=m8RfKDJ2; spf=pass (google.com: domain of binutils-return-101086-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101086-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 70-v6si6441119ple.639.2018.03.22.07.41.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:41:37 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101086-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 header.s=default header.b=m8RfKDJ2; spf=pass (google.com: domain of binutils-return-101086-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101086-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=wSC0zvmt9xfwjkAwTR3KrvpqlY3SPP3ywonHNIrhSWJ yBIvt0yBeeegAs02Q7IROZIAEBQpZXiCi+eBg6sJtLr8f7hK96W7b5TjruIGcbaX EoU80jbtDuC7YWYX4Mi8TwDvtHqwC1gmSgslJxs33Be7kaNJCUIq0gz9gZtsnidM = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=euupn47Bcx8FQaWz2P8+BycmF38=; b=m8RfKDJ21iz7DljNe 2w7i0YLY7EdIu0ixp9XRr2aaUbKOpAmKcDIJT9JQtubOfl71a58K2caexLZZ2IqS GxFHsVOAcpX7E6mIwwqlxwnptQT9cy3TgZ5p+kS9/2IJSlxhhZbfmo9KttT8N7Rz Yk9+agdv8d0v9AhXCjMIkwKO2w= Received: (qmail 80251 invoked by alias); 22 Mar 2018 14:41:24 -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 80168 invoked by uid 89); 22 Mar 2018 14:41:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:41:22 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEcfo4001270 for ; Thu, 22 Mar 2018 15:41:20 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gv9sx1fmd-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:41:20 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A697B31 for ; Thu, 22 Mar 2018 14:41:16 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 94A7C2B11 for ; Thu, 22 Mar 2018 14:41:16 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:41:16 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 07/12] [ARM] FDPIC: Add stack segment Date: Thu, 22 Mar 2018 15:38:25 +0100 Message-ID: <20180322143850.1766-8-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes The size of the stack segment defaults to 32KB, and can be overridden by defining the __stacksize symbol. 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * elf32-arm.c (DEFAULT_STACK_SIZE): New. (elf32_arm_always_size_sections): Create stack segment. --- bfd/elf32-arm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 0e03c77..6ba4ee4 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2251,6 +2251,9 @@ typedef unsigned short int insn16; section. */ #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" +/* FDPIC default stack size. */ +#define DEFAULT_STACK_SIZE 0x8000 + static const unsigned long tls_trampoline [] = { 0xe08e0000, /* add r0, lr, r0 */ @@ -16488,6 +16491,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) /* Not an error, just cut short the traversal. */ return FALSE; } + return TRUE; } @@ -16958,6 +16962,9 @@ elf32_arm_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) { asection *tls_sec; + struct elf32_arm_link_hash_table *htab; + + htab = elf32_arm_hash_table (info); if (bfd_link_relocatable (info)) return TRUE; @@ -16990,6 +16997,12 @@ elf32_arm_always_size_sections (bfd *output_bfd, (*bed->elf_backend_hide_symbol) (info, tlsbase, TRUE); } } + + if (htab->fdpic_p && !bfd_link_relocatable (info) + && !bfd_elf_stack_segment_size (output_bfd, info, + "__stacksize", DEFAULT_STACK_SIZE)) + return FALSE; + return TRUE; } From patchwork Thu Mar 22 14:38:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132301 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp932524ljb; Thu, 22 Mar 2018 07:42:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELudtyDcYmkn6cLRll85FfHsRTKtCqEbKzv/HgSGg7QI5Bqk5oO/N5rYSdeqnmxDSDcSczfY X-Received: by 2002:a17:902:3181:: with SMTP id x1-v6mr7997394plb.338.1521729722962; Thu, 22 Mar 2018 07:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729722; cv=none; d=google.com; s=arc-20160816; b=fvzamKcuAs6atRBazoZxkcH+XIgl2kMyCnUy25uB9s4+qB75QpYpA1KCLFNasdVdc/ aPLJKA8ln96b9dbyUgoCUe9+0UAx6qH7WdrCQYpnMRteJCeVoS5IU/Due7txj6mAdcKf lcgRM4LX9rWvMknC9RGiBa3LhMVGpET4Sxar7Zl56P5/bIfso4VHHlETDvQrvS7mhBCQ qCyi7aTVvKgNDJId+8qgoJaV6LX7G2wv5Q7CdzmuU+7ijmM/KUMxybWlES06fEBOcuOK AueyABwUU4sq4pEeZ3/dkfXjFFsG7tkz6K8XQZTMkrhZCFNi+4UQ3t7b0h6TWIsyjc8r YoAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=rZQVF5vNKcrCN2RJvRzDFDvrF1BI0Fd517nnsUrU9M8=; b=pW6Go5hQPF+jDVy8NuiOv/PT2HIN2YVnDoRGuDmy+e2r5xsr4TN004hd+2ESu+jjQv iqoo5zTYEqbeEGnvNsTRV8M2hCbtdJ4o5iKs+gy2lLtNaxPzqW9ZQY5Wj4arQS9/ig+C fEMqzQ92sGiys3ANxwq/LQU4e1WtlAnp3YUJC5+6iyoRLOWR1xQuaF+8I0tNS9aPL9Sv 7OyAc8T6I2Ln+bMpgny3ZHudOClFhncuuvqnVxixw35xawAJGsKrKxkedFcC0azLUU1l Iqn7OEQRBNIAfGsj8fzQRxHiNwGX+twiUEH4uS3Kesr045L90aRwgKhN68L4CXNQTXrd 4M+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=oXPOj61Q; spf=pass (google.com: domain of binutils-return-101087-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101087-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z12si4473350pgc.195.2018.03.22.07.42.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:42:02 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101087-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 header.s=default header.b=oXPOj61Q; spf=pass (google.com: domain of binutils-return-101087-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101087-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=s1TzpaRj+jZZzXFZsaI9uW/BaT1cDbaN6+ET+0b/Pj8 i1ASNmAoBE4UfjbW+xw/h7+973wqfYQgLxbz98GVt3fQ/JaplA4z8p9Q+CGoGsCg xkaDUqd9S2yVYpBGniupilkVj2D8YsjDudPZi6Mk/Onje8+0oPlQk3paTG5CsWzg = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=EmkJMocE/nrwQZDTQdzpGEtkiCw=; b=oXPOj61QD6z9Hi9Va AybEgXReo4DB3s8+7x5CaZhKyyirgTXboHI8/UaWOI7TPVT/Tm9fX/NG7hMcQrAA ydNewY9CTthEnXYJDF2HuR+khoHDDN6T8/URrCpBdGMX+KDk5aJ63Dp7Xysdt5WR Pl/pyI7Qkb1l7QeyNv+qUWYaLI= Received: (qmail 81949 invoked by alias); 22 Mar 2018 14:41:47 -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 81913 invoked by uid 89); 22 Mar 2018 14:41:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:41:39 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdZim031107 for ; Thu, 22 Mar 2018 15:41:37 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv69ptk7y-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:41:37 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 010AF34 for ; Thu, 22 Mar 2018 14:41:36 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C398D2B12 for ; Thu, 22 Mar 2018 14:41:36 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:41:36 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 08/12] [ARM] FDPIC: Translate R_ARM_TARGET2 relocation into R_ARM_GOT32 relocation for FDPIC platform Date: Thu, 22 Mar 2018 15:38:26 +0100 Message-ID: <20180322143850.1766-9-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * elf32-arm.c (bfd_elf32_arm_set_target_params): Handle FDPIC case for R_ARM_TARGET2. --- bfd/elf32-arm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 6ba4ee4..72d25c8 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -8957,7 +8957,9 @@ bfd_elf32_arm_set_target_params (struct bfd *output_bfd, return; globals->target1_is_rel = params->target1_is_rel; - if (strcmp (params->target2_type, "rel") == 0) + if (globals->fdpic_p) + globals->target2_reloc = R_ARM_GOT32; + else if (strcmp (params->target2_type, "rel") == 0) globals->target2_reloc = R_ARM_REL32; else if (strcmp (params->target2_type, "abs") == 0) globals->target2_reloc = R_ARM_ABS32; From patchwork Thu Mar 22 14:38:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132302 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp932841ljb; Thu, 22 Mar 2018 07:42:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELsCF9kFJZ+DulKy+oF8i+9/zumaPC0UODXZk/VqYAY4RlWuQ/lcr+LcExEWyMYmmBMZF04x X-Received: by 2002:a17:902:4225:: with SMTP id g34-v6mr8707624pld.297.1521729740732; Thu, 22 Mar 2018 07:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729740; cv=none; d=google.com; s=arc-20160816; b=wPKGTwRVJUje9xL/RD35eaLMD82KNd7A6nwQrZo+1hFPeP0H0RIIlCc2QGZvMCvxb1 mg1iSXuXHeiyVCa9KReQ8zRscQAV0ZeMjMzggrGe1pfDl6zQnS5xvICXCbaq8fUjLkJc +cn9mepNcGb6imSWUzn7mqfwINBS4I4KxHlu9hguqZ5WKU+hkJDAmuGHhN+HYq9xJ0Qr 6i+8lFNr9Pfq77HaHzAAC0oro2QFg1qyYkHi3y+6edxiOxEhc4nzK50kyLh5lldSMcP/ djFiKbsMq18EIrKS+9MXJ9UteEn4qncOjIZsapa7vFMGSh/xGIk2k6yFEe+odzIU2fqB paFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=6zzkdNbFcRLJQxdVXPVsnMcAs9BT0X9bzlTmzNHHMLY=; b=eFfYCrdzjmqCihDKKbqYYB4ztaWRhm95/s77ZAAcQzZWKIPbnAmTQM6PhW9HaNlOmG NaFiOZBReAQk3VGUB69AWxW88Gjq5Hj5ftnlEWNagVrMc9hBk9/6+4APxNP0z3A3zTFQ UNy/qwCaIiGKZ73HivKLlIiMqJTTnDUiY1w/O7V93oFKuZ2AF6UIjtJ6eS5dM1BF71vY 1eibWEQEvsrvmJ0ojRAD4MSr4Ctw1ltL2jm/R3jRgiz3zBMQo80WEzfxrQO5yMF9QsC9 TeejBkhKt+4uJiDrMy266rCGjR3dw9alazADjYEGHHCOHqJDHlSbAIS8bNZMAL8lSI1j jQmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=DlNDsn23; spf=pass (google.com: domain of binutils-return-101088-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101088-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id bj11-v6si6921420plb.525.2018.03.22.07.42.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:42:20 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101088-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 header.s=default header.b=DlNDsn23; spf=pass (google.com: domain of binutils-return-101088-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101088-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=OPkH7BG5C40q5mjRO03+3Cs0k9TLwm1NrVRGNyhTzrB zxTaxkzfTCNktLaVitf2BRzf7OcVMpbN81uFAvl2QG1x3D9NgnYmAuDGfkIlaGGx 1dWNxQ2/hOWxtaWo3Yjo2ZCCW5rx6s9jq/KHmZ+A6qh9dFDTLevOBKnnCi8Qn1pY = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=ZrXGPmUusAaShMjK4VInaAT9j9Y=; b=DlNDsn2343V7vOKn6 +tDuJRbAmcGyi3vIQvb855AqZf7HfdpJL28XnAHkKtBz5aLRzWe7AO/XPKkyfYSj X+XMdQYbsplA2kaSuPnf2vTlRgBlu8OnBX3N2Un7eTqeIo93AEdur7NZK1aNKWuj DyUju//ewU/hd+RP9FlwnWOTS4= Received: (qmail 83769 invoked by alias); 22 Mar 2018 14:42:03 -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 83675 invoked by uid 89); 22 Mar 2018 14:42:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1018, HContent-Transfer-Encoding:8bit X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:42:01 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdAvB030982 for ; Thu, 22 Mar 2018 15:41:58 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gvebr816s-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:41:58 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 24A223F for ; Thu, 22 Mar 2018 14:41:57 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0831B2B14 for ; Thu, 22 Mar 2018 14:41:57 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:41:56 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 09/12] [ARM] FDPIC: Make _GLOBAL_OFFSET_TABLE_ a relative symbol Date: Thu, 22 Mar 2018 15:38:27 +0100 Message-ID: <20180322143850.1766-10-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * elf32-arm.c (elf32_arm_finish_dynamic_symbol): Handle _GLOBAL_OFFSET_TABLE_ in FDPIC mode. --- bfd/elf32-arm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 72d25c8..b1beb32 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -17089,10 +17089,10 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks, - the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative - to the ".got" section. */ + and for FDPIC, the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: + it is relative to the ".got" section. */ if (h == htab->root.hdynamic - || (!htab->vxworks_p && h == htab->root.hgot)) + || (!htab->fdpic_p && !htab->vxworks_p && h == htab->root.hgot)) sym->st_shndx = SHN_ABS; return TRUE; From patchwork Thu Mar 22 14:38:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132305 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp934242ljb; Thu, 22 Mar 2018 07:43:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELutCzZJsEXK9F0QOpXCsvn7r62cwz1w/KR2Nxs7OMpIKZ0cN1KtqFcm1MVF3UAoESLE+QZB X-Received: by 2002:a17:902:3f83:: with SMTP id a3-v6mr17318912pld.279.1521729819389; Thu, 22 Mar 2018 07:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729819; cv=none; d=google.com; s=arc-20160816; b=JUpoRdFqTm6q2Bun7lG2KCu5HFvEOJ833XLbOe/ogu7dZdP2gyWyzW+TD0YahD2jL5 h1HdTovwkuill/JT89Nhqrp2CQ8gkaOj8GNEqHXcO9YBp60byG8PpycMn1HWPz9mj/a8 2U5Q8Uf3VDmo5hVYBT2+2Cpoev0b4aICDP0ZSIiKR+Z0X491bpUwDnWH1qfzrxpPQWEs CdE2XbKcu0C/3mDgLbxvVTd5pRGWAZwZXIvIFHK/+h3AFFrhawEhE+vsPKYtkZfab0PB wIQBakNMGtCOwS8XWqiHtPZTKiN05gqMFfeTlhCcPcWp94+5IlpDqrFOAK6QZ3C9FCg6 Gb9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=XimqEPXhcqPxj/QnPXAfSFN/VXgk7cIxyEaGR8+EGtQ=; b=Uhykcy/IRqvdWJr6T6EnEycSAZoig1Nr2zlW+fGfoZegmbjZS0PmpCOts1b/FATdOc zNxeyoQvJJUzxq2tTY2FlJz7fiIukQJTqIP7WlDGvXBzJdEpcWOE3w1LJYo+bi600Qbb 8DF3/hCmLaBfWZbvd+biR6i80xY0Ni+03oO8b64dnSCYkqZ9aYPwxhd/NiBlqezoF0vA Gmkwfgri0ezjJCK9j57BP1+MYXygWQc/V011Lu9o64IMT2aSGZ3UGEyS9oXz6tnWlc2M +4SfKsR6HmUsA/A8LP6CIsqB/xC65DMHDs64kY9qs+iC2afMKHg8HOjrwhjITQnK1JTo 1VSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=gWOiwFs/; spf=pass (google.com: domain of binutils-return-101091-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101091-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o18si5004370pfa.401.2018.03.22.07.43.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101091-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 header.s=default header.b=gWOiwFs/; spf=pass (google.com: domain of binutils-return-101091-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101091-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=XTqqzg+KthPTV6DmQBKbHB2KQEPtzDWbx9XpkpENCA9 ZggR21Xdzg1SDXe/HfXNkXEY3J6C5/wqtXUKnAyiaZlGjb+CJnj74JYi2PahpYP7 csjuLDNQGsQzzWobiDcxb+rS0VcwDaDJwE2P+blDmihqGOUAokEqcEwMv3eJDPT8 = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=6DNbyB/cHmtCGzIp1Qn0Obz7kZU=; b=gWOiwFs/WVnzfj4yw oon5U7/4s02FwMjGm0C7d1sViE/sSr88kYjYxPeHgd3TF8NPlQc1+H1ZEGEN7WpP EWMyypClg3LUkHcngNvXuFzzLKG5UVGesGd1OWe/gNxCEdjq1lff7tCPIsU3HgK2 caqDsYU2pD0/cgGoX9YACxcgc4= Received: (qmail 89682 invoked by alias); 22 Mar 2018 14:43:07 -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 89601 invoked by uid 89); 22 Mar 2018 14:43:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=37, HContent-Transfer-Encoding:8bit X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:43:05 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEcfoP001270 for ; Thu, 22 Mar 2018 15:43:03 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gv9sx1fv1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:43:03 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 48E9449 for ; Thu, 22 Mar 2018 14:42:17 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 36A032B15 for ; Thu, 22 Mar 2018 14:42:17 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:42:16 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 10/12] [ARM] FDPIC: Fix ld testcase not to conflict with uclibc's includes. Date: Thu, 22 Mar 2018 15:38:28 +0100 Message-ID: <20180322143850.1766-11-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes 2018-XX-XX Christophe Lyon Mickaël Guêné ld * testsuite/ld-elf/pr2404b.c (main): Rename time variable into time1. --- ld/testsuite/ld-elf/pr2404b.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.6.3 diff --git a/ld/testsuite/ld-elf/pr2404b.c b/ld/testsuite/ld-elf/pr2404b.c index 5f0f7b4..4bbc2b1 100644 --- a/ld/testsuite/ld-elf/pr2404b.c +++ b/ld/testsuite/ld-elf/pr2404b.c @@ -3,7 +3,7 @@ extern int bar (void); int times = -1; -int time; +int time1; int main () @@ -12,9 +12,9 @@ main () times = 20; printf ("times: %d\n", times); - printf ("time: %d\n", time); - time = 10; - printf ("time: %d\n", time); + printf ("time1: %d\n", time1); + time1 = 10; + printf ("time: %d\n", time1); bar (); return 0; From patchwork Thu Mar 22 14:38:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132303 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp933507ljb; Thu, 22 Mar 2018 07:43:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELu2dwqnnTC8ULBhaC5rH5qD93urGte3uyksbHOx1eeJ111ZedJRPHPfKKcHpdCqVB0Icdn2 X-Received: by 10.99.117.68 with SMTP id f4mr17882009pgn.369.1521729782102; Thu, 22 Mar 2018 07:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729782; cv=none; d=google.com; s=arc-20160816; b=sB5VBOz/cQm231SnYicw2sENKgyicXLxWm4b4ZNNFFhzLv0STXcGCyVYYjGE3B4npR Vw4EJQLYlRr0ud3EhocHOSczXwv8aQKAa8A9OB4iMAoggr61qRZTL+cyyGRKUPhoYxFT Yd+CaORc0FKQyrGuRWne/2c4S5hUpJzffxR8HAwJ4I9VuNdS+igr1hZQBUIoxXo5DxIN yCYCAbFA1JUBOAOA0KFqUAvHYuSPbpf5Ug+hYM1YZcDo6idpXX4gTjp2gfiSukJjXqT0 Ko5NQ2lZbQ2czBh9Kpl1QqTMZtxWqN+Oks22VFtWNAz/qR2L+ThA3vF/8/1FoGVD6l94 ryBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=KB7uiNF+e7iNMP2nV9hVXVtWPASHhCdnSagpfFQ8aqw=; b=PNUk85jjnd/rCpjmO3COgO2dQbbNc3zbTAkFPLZzOOJN700pbvZMJMrHDoioKX8ifV aylu8cSa6zETOLMCUdNW9wOFJztbKYxvyzdSb04+f8b4AWJTk6rBmleoDr2/2pvtXhh0 ovlRi0L7csQiC1hotx492L3F9LydAgn3Am9fQ98IGcdHsaApO1O9WfgT+ynJYeTNDUtT 4KvhtWfKOUs3l/TKuL8tOVdsXxCd0cJ+xrPgnWkFSrXmZe/skLHJnXUccaGT5mDDoZ5a zl6/ex2nstjlyUZG3KRN6A0qps4HoRy3GV+Qso44SJdcIdfABKg9L1rgtJR0pw04ftgY 5rAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ROE8czMa; spf=pass (google.com: domain of binutils-return-101089-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101089-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n29si2350007pgd.778.2018.03.22.07.43.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101089-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 header.s=default header.b=ROE8czMa; spf=pass (google.com: domain of binutils-return-101089-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101089-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=TEC5mFQ3exTdf8Oc3XAc7VFgX0H+1oleIpMiw45Psjz LmA2Yo/O6l+VE4llPme4xd9PAd3ZrBwFk7kSfukwxawyFdE5NkYPi7boGcklbV9W F947bY+NZY82OPUAU+gunxpvkD8Dvcrb128LLmi1zpBbFzKLO7G1rm9eXCoQaWa8 = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=UobzoPjGAnS2wwajQFBpt0W2rkQ=; b=ROE8czMaIJ7tUXnZU F6CtZbel0Dyrn+92Ef4ATU3T6WDYcczyU+yHRaAlCv+vE19Vkuo4VVx1ydY8xYT/ nqEs2/7oFVC8D/x6nvtVdQM2mV/9rO/Zt5i79Kml5jaea3Dx+4DhYyj99brv3woh t0GW5bbVh3Phm6KXcRGn8ew6vs= Received: (qmail 87674 invoked by alias); 22 Mar 2018 14:42:46 -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 87652 invoked by uid 89); 22 Mar 2018 14:42:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=PROVIDE X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:42:41 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEd9H2000351 for ; Thu, 22 Mar 2018 15:42:38 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv6742m67-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:42:38 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D06D45D for ; Thu, 22 Mar 2018 14:42:37 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 74AA826E7 for ; Thu, 22 Mar 2018 14:42:37 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:42:36 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 11/12] [ARM] FDPIC: New tests. Date: Thu, 22 Mar 2018 15:38:29 +0100 Message-ID: <20180322143850.1766-12-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes 2018-XX-XX Christophe Lyon Mickaël Guêné ld/ * testsuite/ld-arm/arm-elf.exp: Execute the new FDPIC tests. * testsuite/ld-arm/fdpic-main.d: New test. * testsuite/ld-arm/fdpic-main.ld: New. * testsuite/ld-arm/fdpic-main.r: New. * testsuite/ld-arm/fdpic-main.s: New. * testsuite/ld-arm/fdpic-main.sym: New. * testsuite/ld-arm/fdpic-shared.d: New test. * testsuite/ld-arm/fdpic-shared.ld: New. * testsuite/ld-arm/fdpic-shared.r: New. * testsuite/ld-arm/fdpic-shared.s: New. * testsuite/ld-arm/fdpic-shared.sym: New. --- ld/testsuite/ld-arm/arm-elf.exp | 25 ++++ ld/testsuite/ld-arm/fdpic-main.d | 72 +++++++++++ ld/testsuite/ld-arm/fdpic-main.ld | 244 +++++++++++++++++++++++++++++++++++ ld/testsuite/ld-arm/fdpic-main.r | 11 ++ ld/testsuite/ld-arm/fdpic-main.s | 86 ++++++++++++ ld/testsuite/ld-arm/fdpic-main.sym | 14 ++ ld/testsuite/ld-arm/fdpic-shared.d | 35 +++++ ld/testsuite/ld-arm/fdpic-shared.ld | 228 ++++++++++++++++++++++++++++++++ ld/testsuite/ld-arm/fdpic-shared.r | 8 ++ ld/testsuite/ld-arm/fdpic-shared.s | 52 ++++++++ ld/testsuite/ld-arm/fdpic-shared.sym | 15 +++ 11 files changed, 790 insertions(+) create mode 100644 ld/testsuite/ld-arm/fdpic-main.d create mode 100644 ld/testsuite/ld-arm/fdpic-main.ld create mode 100644 ld/testsuite/ld-arm/fdpic-main.r create mode 100644 ld/testsuite/ld-arm/fdpic-main.s create mode 100644 ld/testsuite/ld-arm/fdpic-main.sym create mode 100644 ld/testsuite/ld-arm/fdpic-shared.d create mode 100644 ld/testsuite/ld-arm/fdpic-shared.ld create mode 100644 ld/testsuite/ld-arm/fdpic-shared.r create mode 100644 ld/testsuite/ld-arm/fdpic-shared.s create mode 100644 ld/testsuite/ld-arm/fdpic-shared.sym -- 2.6.3 diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index dd15655..c292346 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -1016,6 +1016,31 @@ set armeabitests_nonacl { "" {preempt-app.s} {{readelf -Ds preempt-app.sym}} "preempt-app"} + + {"FDPIC ARM shared library little endian" + "-shared -T fdpic-shared.ld --hash-style=sysv -EL -m armelf_linux_fdpiceabi" "" + "-EL -fdpic" {fdpic-shared.s} + {{objdump -fdw fdpic-shared.d} {objdump -Rw fdpic-shared.r} + {readelf -Ds fdpic-shared.sym}} + "fdpic-shared.so"} + {"FDPIC ARM dynamic executable little endian" + "tmpdir/fdpic-shared.so -T fdpic-main.ld --hash-style=sysv -EL -m armelf_linux_fdpiceabi" "" + "-EL -fdpic" {fdpic-main.s} + {{objdump -fdw fdpic-main.d} {objdump -Rw fdpic-main.r} + {readelf -Ds fdpic-main.sym}} + "fdpic-main"} + {"FDPIC ARM shared library big endian" + "-shared -T fdpic-shared.ld --hash-style=sysv -EB -m armelfb_linux_fdpiceabi" "" + "-EB -fdpic" {fdpic-shared.s} + {{objdump -fdw fdpic-shared.d} {objdump -Rw fdpic-shared.r} + {readelf -Ds fdpic-shared.sym}} + "fdpic-shared.so"} + {"FDPIC ARM dynamic executable big endian" + "tmpdir/fdpic-shared.so -T fdpic-main.ld --hash-style=sysv -EB -m armelfb_linux_fdpiceabi" "" + "-EB -fdpic" {fdpic-main.s} + {{objdump -fdw fdpic-main.d} {objdump -Rw fdpic-main.r} + {readelf -Ds fdpic-main.sym}} + "fdpic-main"} } # Massage the $armeabitests_common list into run_ld_link_tests standard form. diff --git a/ld/testsuite/ld-arm/fdpic-main.d b/ld/testsuite/ld-arm/fdpic-main.d new file mode 100644 index 0000000..cc129c3 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.d @@ -0,0 +1,72 @@ + +tmpdir/fdpic-main: file format elf32-(little|big)arm +architecture: arm.*, flags 0x00000112: +EXEC_P, HAS_SYMS, D_PAGED +start address 0x.* + +Disassembly of section .plt: + +.* <.plt>: + .*: e59fc008 ldr ip, \[pc, #8\] ; .* <.plt\+0x10> + .*: e08cc009 add ip, ip, r9 + .*: e59c9004 ldr r9, \[ip, #4\] + .*: e59cf000 ldr pc, \[ip\] + .*: 0000000c .word 0x0000000c + .*: 00000000 .word 0x00000000 + .*: e51fc00c ldr ip, \[pc, #-12\] ; .* <.plt\+0x14> + .*: e92d1000 stmfd sp!, {ip} + .*: e599c004 ldr ip, \[r9, #4\] + .*: e599f000 ldr pc, \[r9\] + .*: e59fc008 ldr ip, \[pc, #8\] ; .* <.plt\+0x38> + .*: e08cc009 add ip, ip, r9 + .*: e59c9004 ldr r9, \[ip, #4\] + .*: e59cf000 ldr pc, \[ip] + .*: 00000014 .word 0x00000014 + .*: 00000008 .word 0x00000008 + .*: e51fc00c ldr ip, \[pc, #-12\] ; .* <.plt\+0x3c> + .*: e92d1000 stmfd sp!, {ip} + .*: e599c004 ldr ip, \[r9, #4\] + .*: e599f000 ldr pc, \[r9\] + +Disassembly of section .text: + +.* <_start>: + .*: eaffffff b .*
+ +.*
: + .*: e59f206c ldr r2, \[pc, #108\] ; .* + .*: e59f306c ldr r3, \[pc, #108\] ; .* + .*: e92d4070 push {r4, r5, r6, lr} + .*: e7995002 ldr r5, \[r9, r2\] + .*: e1a04009 mov r4, r9 + .*: e7993003 ldr r3, \[r9, r3\] + .*: e5853000 str r3, \[r5\] + .*: ebffffe2 bl .* <.plt> + .*: e1a06000 mov r6, r0 + .*: e1a09004 mov r9, r4 + .*: e5950000 ldr r0, \[r5\] + .*: e1a09004 mov r9, r4 + .*: ebffffe7 bl .* <.plt\+0x28> + .*: e59f3040 ldr r3, \[pc, #64\] ; .* + .*: e1a09004 mov r9, r4 + .*: e0833009 add r3, r3, r9 + .*: e1a00003 mov r0, r3 + .*: e5853000 str r3, \[r5\] + .*: e1a09004 mov r9, r4 + .*: ebffffe0 bl .* <.plt\+0x28> + .*: e59f3028 ldr r3, \[pc, #40\] ; .* + .*: e1a09004 mov r9, r4 + .*: e7993003 ldr r3, \[r9, r3\] + .*: e5930000 ldr r0, \[r3\] + .*: e1a09004 mov r9, r4 + .*: ebffffda bl .* <.plt\+0x28> + .*: e1a00006 mov r0, r6 + .*: e1a09004 mov r9, r4 + .*: e8bd8070 pop {r4, r5, r6, pc} + .*: 0000002c .word 0x0000002c + .*: 00000024 .word 0x00000024 + .*: 0000001c .word 0x0000001c + .*: 00000028 .word 0x00000028 + +.* : + .*: e12fff1e bx lr diff --git a/ld/testsuite/ld-arm/fdpic-main.ld b/ld/testsuite/ld-arm/fdpic-main.ld new file mode 100644 index 0000000..4208c66 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.ld @@ -0,0 +1,244 @@ +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf32-littlearm-fdpic", "elf32-bigarm-fdpic", + "elf32-littlearm-fdpic") +OUTPUT_ARCH(arm) +ENTRY(_start) +SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x00008000)); . = SEGMENT_START("text-segment", 0x00008000) + SIZEOF_HEADERS; + .interp : { *(.interp) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + PROVIDE_HIDDEN (__rel_iplt_start = .); + *(.rel.iplt) + PROVIDE_HIDDEN (__rel_iplt_end = .); + PROVIDE_HIDDEN (__rela_iplt_start = .); + PROVIDE_HIDDEN (__rela_iplt_end = .); + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + PROVIDE_HIDDEN (__rel_iplt_start = .); + PROVIDE_HIDDEN (__rel_iplt_end = .); + PROVIDE_HIDDEN (__rela_iplt_start = .); + *(.rela.iplt) + PROVIDE_HIDDEN (__rela_iplt_end = .); + } + .rel.plt : + { + *(.rel.plt) + } + .rela.plt : + { + *(.rela.plt) + } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + PROVIDE_HIDDEN (__exidx_end = .); + .rofixup : { + __ROFIXUP_LIST__ = .; + *(.rofixup) + __ROFIXUP_END__ = .; +} + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table + .gcc_except_table.*) } + /* These sections are generated by the Sun/Oracle C++ compiler. */ + .exception_ranges : ONLY_IF_RO { *(.exception_ranges + .exception_ranges*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } + /* Thread Local Storage sections */ + .tdata : + { + PROVIDE_HIDDEN (__tdata_start = .); + *(.tdata .tdata.* .gnu.linkonce.td.*) + } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + . = DATA_SEGMENT_RELRO_END (0, .); + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + .data : + { + PROVIDE (__data_start = .); + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/ld/testsuite/ld-arm/fdpic-main.r b/ld/testsuite/ld-arm/fdpic-main.r new file mode 100644 index 0000000..ec012ff --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.r @@ -0,0 +1,11 @@ + +tmpdir/fdpic-main.*: file format elf32-(little|big)arm + +DYNAMIC RELOCATION RECORDS +OFFSET TYPE VALUE +.* R_ARM_FUNCDESC my_shared_func1 +.* R_ARM_FUNCDESC my_shared_func1 +.* R_ARM_FUNCDESC_VALUE my_shared_func1 +.* R_ARM_FUNCDESC_VALUE my_shared_func2 + + diff --git a/ld/testsuite/ld-arm/fdpic-main.s b/ld/testsuite/ld-arm/fdpic-main.s new file mode 100644 index 0000000..7e1ada9 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.s @@ -0,0 +1,86 @@ + .arch armv7-r + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 2 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "hello.c" + .text + .align 2 + .syntax unified + .arm + .fpu softvfp + .type my_local_func, %function +my_local_func: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + bx lr + .size my_local_func, .-my_local_func + .section .text.startup,"ax",%progbits + .align 2 + .global _start + .syntax unified + .arm + .fpu softvfp + .type _start, %function +_start: + b main + + .global main + .syntax unified + .arm + .fpu softvfp + .type main, %function +main: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + ldr r2, .L4 + ldr r3, .L4+4 + push {r4, r5, r6, lr} + ldr r5, [r9, r2] + mov r4, r9 + ldr r3, [r9, r3] + str r3, [r5] + bl my_shared_func1(PLT) + mov r6, r0 + mov r9, r4 + ldr r0, [r5] + mov r9, r4 + bl my_shared_func2(PLT) + ldr r3, .L4+8 + mov r9, r4 + add r3, r3, r9 + mov r0, r3 + str r3, [r5] + mov r9, r4 + bl my_shared_func2(PLT) + ldr r3, .L4+12 + mov r9, r4 + ldr r3, [r9, r3] + ldr r0, [r3] + mov r9, r4 + bl my_shared_func2(PLT) + mov r0, r6 + mov r9, r4 + pop {r4, r5, r6, pc} +.L5: + .align 2 +.L4: + .word funcptr(GOT) + .word my_shared_func1(GOTFUNCDESC) + .word my_local_func(GOTOFFFUNCDESC) + .word funcptr2(GOT) + .size main, .-main + .global funcptr2 + .comm funcptr,4,4 + .section .data.rel,"aw",%progbits + .align 2 + .type funcptr2, %object + .size funcptr2, 4 +funcptr2: + .word my_shared_func1(FUNCDESC) diff --git a/ld/testsuite/ld-arm/fdpic-main.sym b/ld/testsuite/ld-arm/fdpic-main.sym new file mode 100644 index 0000000..9eaf617 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.sym @@ -0,0 +1,14 @@ + +Symbol table for image: + +Num +Buc: +Value +Size +Type +Bind +Vis +Ndx +Name + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 _edata + +.. +..: ........ +0 +FUNC +GLOBAL +DEFAULT +UND my_shared_func2 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 __bss_start__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 _end + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 __bss_end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 __end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT + 9 __ROFIXUP_LIST__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 __bss_start + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT + 9 __ROFIXUP_END__ + +.. +..: ........ +0 +FUNC +GLOBAL +DEFAULT +UND my_shared_func1 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 _bss_end__ diff --git a/ld/testsuite/ld-arm/fdpic-shared.d b/ld/testsuite/ld-arm/fdpic-shared.d new file mode 100644 index 0000000..438c0e9 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.d @@ -0,0 +1,35 @@ + +tmpdir/fdpic-shared.so: file format elf32-(little|big)arm +architecture: arm.*, flags 0x00000150: +HAS_SYMS, DYNAMIC, D_PAGED +start address 0x.* + +Disassembly of section .plt: + +.* <.plt>: + .*: e59fc008 ldr ip, \[pc, #8\] ; .* <.plt\+0x10> + .*: e08cc009 add ip, ip, r9 + .*: e59c9004 ldr r9, \[ip, #4\] + .*: e59cf000 ldr pc, \[ip\] + .*: 0000000c .word 0x0000000c + .*: 00000000 .word 0x00000000 + .*: e51fc00c ldr ip, \[pc, #-12\] ; .* <.plt\+0x14> + .*: e92d1000 stmfd sp!, {ip} + .*: e599c004 ldr ip, \[r9, #4\] + .*: e599f000 ldr pc, \[r9\] + +Disassembly of section .text: + +.* : + .*: e12fff1e bx lr + +.* : + .*: e3a00000 mov r0, #0 + .*: e12fff1e bx lr + +.* : + .*: e92d4010 push {r4, lr} + .*: e1a04009 mov r4, r9 + .*: ebffffef bl .* <.plt> + .*: e1a09004 mov r9, r4 + .*: e8bd8010 pop {r4, pc} diff --git a/ld/testsuite/ld-arm/fdpic-shared.ld b/ld/testsuite/ld-arm/fdpic-shared.ld new file mode 100644 index 0000000..450d6f9 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.ld @@ -0,0 +1,228 @@ +/* Script for --shared -z combreloc: shared library, combine & sort relocs */ +OUTPUT_FORMAT("elf32-littlearm-fdpic", "elf32-bigarm-fdpic", + "elf32-littlearm-fdpic") +OUTPUT_ARCH(arm) +ENTRY(_start) +SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + *(.rel.iplt) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + *(.rela.iplt) + } + .rel.plt : + { + *(.rel.plt) + } + .rela.plt : + { + *(.rela.plt) + } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + PROVIDE_HIDDEN (__exidx_end = .); + .rofixup : { + __ROFIXUP_LIST__ = .; + *(.rofixup) + __ROFIXUP_END__ = .; + } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table + .gcc_except_table.*) } + /* These sections are generated by the Sun/Oracle C++ compiler. */ + .exception_ranges : ONLY_IF_RO { *(.exception_ranges + .exception_ranges*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } + /* Thread Local Storage sections */ + .tdata : + { + *(.tdata .tdata.* .gnu.linkonce.td.*) + } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + KEEP (*(.preinit_array)) + } + .init_array : + { + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + } + .fini_array : + { + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + . = DATA_SEGMENT_RELRO_END (0, .); + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + .data : + { + PROVIDE (__data_start = .); + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/ld/testsuite/ld-arm/fdpic-shared.r b/ld/testsuite/ld-arm/fdpic-shared.r new file mode 100644 index 0000000..22b755e --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.r @@ -0,0 +1,8 @@ + +tmpdir/fdpic-shared.so: file format elf32-(little|big)arm + +DYNAMIC RELOCATION RECORDS +OFFSET TYPE VALUE +.* R_ARM_FUNCDESC_VALUE my_shared_func3 + + diff --git a/ld/testsuite/ld-arm/fdpic-shared.s b/ld/testsuite/ld-arm/fdpic-shared.s new file mode 100644 index 0000000..a5baf3b --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.s @@ -0,0 +1,52 @@ + .arch armv7-r + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 2 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "shared.c" + .text + .align 2 + .global my_shared_func1 + .syntax unified + .arm + .fpu softvfp + .type my_shared_func1, %function +my_shared_func1: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + bx lr + .size my_shared_func1, .-my_shared_func1 + .align 2 + .global my_shared_func3 + .syntax unified + .arm + .fpu softvfp + .type my_shared_func3, %function +my_shared_func3: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + mov r0, #0 + bx lr + .size my_shared_func3, .-my_shared_func3 + .align 2 + .global my_shared_func2 + .syntax unified + .arm + .fpu softvfp + .type my_shared_func2, %function +my_shared_func2: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + push {r4, lr} + mov r4, r9 + bl my_shared_func3(PLT) + mov r9, r4 + pop {r4, pc} + .size my_shared_func2, .-my_shared_func2 diff --git a/ld/testsuite/ld-arm/fdpic-shared.sym b/ld/testsuite/ld-arm/fdpic-shared.sym new file mode 100644 index 0000000..2938b36 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.sym @@ -0,0 +1,15 @@ + +Symbol table for image: + +Num +Buc: +Value +Size +Type +Bind +Vis +Ndx +Name + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _edata + +.. +..: ........ +20 +FUNC +GLOBAL +DEFAULT +6 my_shared_func2 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_start__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _end + +.. +..: ........ +8 +FUNC +GLOBAL +DEFAULT +6 my_shared_func3 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +7 __ROFIXUP_LIST__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_start + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +7 __ROFIXUP_END__ + +.. +..: ........ +4 +FUNC +GLOBAL +DEFAULT +6 my_shared_func1 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _bss_end__ From patchwork Thu Mar 22 14:38:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132304 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp933875ljb; Thu, 22 Mar 2018 07:43:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELt6XpZqBvFY5p8Ezg3qWm35T0Ui2FnCcayjCbqeQmpjgoyHxwmJrYohDD1nWCUg9lbCRM3Q X-Received: by 10.101.83.194 with SMTP id z2mr1436634pgr.133.1521729800342; Thu, 22 Mar 2018 07:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729800; cv=none; d=google.com; s=arc-20160816; b=PC6y/f7kMRnTTPDP3dWJolLVbLlDh5PpesfgFr/boiND4uTP55CdZIh93ay4ymt6EV 0HfXBHVmFWlD0hgwXm3dd8cwwYInqVLYqyvKwy71sscQ7PYmwpa5rmxQ7KwtPt7455/P JYvcLcHEk/t7sr8ghVFURTPVb824rY81j9a8lfTfCsDNNvcbXi5kGXKj3qxdiMvcc+P8 5clkyJYiItxZx6AuE/+/n5Oo2HkrXF8L2z6cbPxHvURcHwr5+A7AjuASOu9NfR7x6z6E or45sViKskNAzbUjWxr5MCY+WqztTJxuEyeBzJ5psfDtfNJY+b0aLQv5jrI8FxlmQp7D p7bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=RQNRfB4UDHfFKjbZWTkS26oL481JAAIcBPHZJibMFsA=; b=AE2Nr9JZhTibY725jiUgSTTjN/FLQP4OjAKzrmFNFvSqt3kCVnvqlJ/Mt02f5qscSI /wJCItoCeI0fxqMa9OQGBNGzjGd0bE31ECHoy8CULDqilLBbLY2b/auHck7hr6WMLmIv 1vFM1WK42qH1LxFewtjiyOLWvqJE7C6Z5Muq53crmkBxLaCkiPkWztFbKyVa001jhU9e DGkOx5I8stHi2shiT1qju7jdy8zupJX726jhjuVGYZLb6Tx11z9kakXwxyRC7F0tCLCL LIl8fhIByzytXR9dhQxgTL7OatR7ahddfw+lt0amswWJloGnX/LlEzMyZxkErGE+TGu5 LdOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=hOadUA22; spf=pass (google.com: domain of binutils-return-101090-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101090-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j4si4467894pgq.119.2018.03.22.07.43.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:43:20 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101090-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 header.s=default header.b=hOadUA22; spf=pass (google.com: domain of binutils-return-101090-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101090-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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=vTVKam7199WfJhtPxoPIGwW3EA4dX6GeosXt1Zr4uRX tkbMqpQjQBU2VFH+J3lLMj/cI93oSaucQO7Eymv3ldmtNbgQOFcvxjI1ETSGsoLY lt2Yy0i5E2U+UUChSeHqJ+jKBkf1zaODIwFXRFEbgubv9QAYchgIcI2cL4Zj/jjo = 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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=9rCRe/jluksGmS5P7wsw2mnvEEo=; b=hOadUA22gN8Z19gh+ eZXqbydwmh6b8kJmjdb7Z+RkMXqR1AkhtGAYD4dgEvUplgkywFTGwKKg7IjIvtIk d6CRftwYaqobFwgbU785ZpugPM/FmZzhVgf1uZq5Dg2wE44MeTncX2a9lzpGUXu7 dQmkLq0kCHrYdRWGs7eTBo5hYU= Received: (qmail 89348 invoked by alias); 22 Mar 2018 14:43:04 -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 89322 invoked by uid 89); 22 Mar 2018 14:43:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=bw X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:43:00 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdPtc030795 for ; Thu, 22 Mar 2018 15:42:58 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv69ptkd1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:42:58 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C3D6284 for ; Thu, 22 Mar 2018 14:42:57 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A311F11B8 for ; Thu, 22 Mar 2018 14:42:57 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:42:57 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 12/12] [ARM] FDPIC: Implement Thumb-only PLT for FDPIC. Date: Thu, 22 Mar 2018 15:38:30 +0100 Message-ID: <20180322143850.1766-13-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes 2018-XX-XX Christophe Lyon Mickaël Guêné bfd/ * elf32-arm.c (elf32_arm_fdpic_thumb_plt_entry): New. (elf32_arm_plt_needs_thumb_stub_p): Handle thumb-only case. (elf32_arm_populate_plt_entry): Likewise. (elf32_arm_output_plt_map_1): Likewise. (elf32_arm_output_arch_local_syms): Likewise. ld/testsuite/ * arm-elf.exp: Execute the new FDPIC Thumb-only tests. * fdpic-main-m.d: New test. * fdpic-main-m.s: New. * fdpic-main-m.sym: New. * fdpic-shared-m.d: New test. * fdpic-shared-m.s: New. * fdpic-shared-m.sym: New. --- bfd/elf32-arm.c | 64 ++++++++++++++++--------- ld/testsuite/ld-arm/arm-elf.exp | 12 +++++ ld/testsuite/ld-arm/fdpic-main-m.d | 73 +++++++++++++++++++++++++++++ ld/testsuite/ld-arm/fdpic-main-m.s | 86 ++++++++++++++++++++++++++++++++++ ld/testsuite/ld-arm/fdpic-main-m.sym | 14 ++++++ ld/testsuite/ld-arm/fdpic-shared-m.d | 37 +++++++++++++++ ld/testsuite/ld-arm/fdpic-shared-m.s | 52 ++++++++++++++++++++ ld/testsuite/ld-arm/fdpic-shared-m.sym | 15 ++++++ 8 files changed, 332 insertions(+), 21 deletions(-) create mode 100644 ld/testsuite/ld-arm/fdpic-main-m.d create mode 100644 ld/testsuite/ld-arm/fdpic-main-m.s create mode 100644 ld/testsuite/ld-arm/fdpic-main-m.sym create mode 100644 ld/testsuite/ld-arm/fdpic-shared-m.d create mode 100644 ld/testsuite/ld-arm/fdpic-shared-m.s create mode 100644 ld/testsuite/ld-arm/fdpic-shared-m.sym -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index b1beb32..216b98b 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2290,6 +2290,22 @@ static const bfd_vma elf32_arm_fdpic_plt_entry [] = 0xe599f000, /* ldr pc, [r9] */ }; +/* Thumb FDPIC PLT entry. */ +/* The last 5 words contain PLT lazy fragment code and data. */ +static const bfd_vma elf32_arm_fdpic_thumb_plt_entry [] = + { + 0xc00cf8df, /* ldr.w r12, .L1 */ + 0x0c09eb0c, /* add.w r12, r12, r9 */ + 0x9004f8dc, /* ldr.w r9, [r12, #4] */ + 0xf000f8dc, /* ldr.w pc, [r12] */ + 0x00000000, /* .L1 .word foo(GOTOFFFUNCDESC) */ + 0x00000000, /* .L2 .word foo(funcdesc_value_reloc_offset) */ + 0xc008f85f, /* ldr.w r12, .L2 */ + 0xcd04f84d, /* push {r12} */ + 0xc004f8d9, /* ldr.w r12, [r9, #4] */ + 0xf000f8d9, /* ldr.w pc, [r9] */ + }; + #ifdef FOUR_WORD_PLT /* The first entry in a procedure linkage table looks like @@ -3620,6 +3636,8 @@ elf32_arm_get_plt_info (bfd *abfd, struct elf32_arm_link_hash_table *globals, return TRUE; } +static bfd_boolean using_thumb_only (struct elf32_arm_link_hash_table *globals); + /* Return true if the PLT described by ARM_PLT requires a Thumb stub before it. */ @@ -3630,8 +3648,9 @@ elf32_arm_plt_needs_thumb_stub_p (struct bfd_link_info *info, struct elf32_arm_link_hash_table *htab; htab = elf32_arm_hash_table (info); - return (arm_plt->thumb_refcount != 0 - || (!htab->use_blx && arm_plt->maybe_thumb_refcount != 0)); + + return (!using_thumb_only(htab) && (arm_plt->thumb_refcount != 0 + || (!htab->use_blx && arm_plt->maybe_thumb_refcount != 0))); } /* Return a pointer to the head of the dynamic reloc list that should @@ -9729,6 +9748,10 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, } else if (htab->fdpic_p) { + const bfd_vma *plt_entry = using_thumb_only(htab) + ? elf32_arm_fdpic_thumb_plt_entry + : elf32_arm_fdpic_plt_entry; + /* Fill-up Thumb stub if needed. */ if (elf32_arm_plt_needs_thumb_stub_p (info, arm_plt)) { @@ -9737,14 +9760,13 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, put_thumb_insn (htab, output_bfd, elf32_arm_plt_thumb_stub[1], ptr - 2); } - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[0], ptr + 0); - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[1], ptr + 4); - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[2], ptr + 8); - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[3], ptr + 12); + /* As we are using 32 bit instructions even for the Thumb + version, we have to use 'put_arm_insn' instead of + 'put_thumb_insn'. */ + put_arm_insn(htab, output_bfd, plt_entry[0], ptr + 0); + put_arm_insn(htab, output_bfd, plt_entry[1], ptr + 4); + put_arm_insn(htab, output_bfd, plt_entry[2], ptr + 8); + put_arm_insn(htab, output_bfd, plt_entry[3], ptr + 12); bfd_put_32 (output_bfd, got_offset, ptr + 16); if (!(info->flags & DF_BIND_NOW)) @@ -9753,14 +9775,10 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, bfd_put_32 (output_bfd, htab->root.srelplt->reloc_count * RELOC_SIZE (htab), ptr + 20); - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[6], ptr + 24); - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[7], ptr + 28); - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[8], ptr + 32); - put_arm_insn(htab, output_bfd, - elf32_arm_fdpic_plt_entry[9], ptr + 36); + put_arm_insn(htab, output_bfd, plt_entry[6], ptr + 24); + put_arm_insn(htab, output_bfd, plt_entry[7], ptr + 28); + put_arm_insn(htab, output_bfd, plt_entry[8], ptr + 32); + put_arm_insn(htab, output_bfd, plt_entry[9], ptr + 36); } } else if (using_thumb_only (htab)) @@ -17770,15 +17788,19 @@ elf32_arm_output_plt_map_1 (output_arch_syminfo *osi, } else if (htab->fdpic_p) { + enum map_symbol_type type = using_thumb_only(htab) + ? ARM_MAP_THUMB + : ARM_MAP_ARM; + if (elf32_arm_plt_needs_thumb_stub_p (osi->info, arm_plt)) if (!elf32_arm_output_map_sym (osi, ARM_MAP_THUMB, addr - 4)) return FALSE; - if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr)) + if (!elf32_arm_output_map_sym (osi, type, addr)) return FALSE; if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 16)) return FALSE; if (htab->plt_entry_size == 4 * ARRAY_SIZE(elf32_arm_fdpic_plt_entry)) - if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr + 24)) + if (!elf32_arm_output_map_sym (osi, type, addr + 24)) return FALSE; } else if (using_thumb_only (htab)) @@ -18137,7 +18159,7 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0)) return FALSE; } - else if (using_thumb_only (htab)) + else if (using_thumb_only (htab) && !htab->fdpic_p) { if (!elf32_arm_output_map_sym (&osi, ARM_MAP_THUMB, 0)) return FALSE; diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index c292346..00960db 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -1041,6 +1041,18 @@ set armeabitests_nonacl { {{objdump -fdw fdpic-main.d} {objdump -Rw fdpic-main.r} {readelf -Ds fdpic-main.sym}} "fdpic-main"} + {"FDPIC ARM shared library little endian M profile" + "-shared -T fdpic-shared.ld --hash-style=sysv -EL -m armelf_linux_fdpiceabi" "" + "-EL -fdpic" {fdpic-shared-m.s} + {{objdump -fdw fdpic-shared-m.d} {objdump -Rw fdpic-shared.r} + {readelf -Ds fdpic-shared-m.sym}} + "fdpic-shared.so"} + {"FDPIC ARM dynamic executable little endian M profile" + "tmpdir/fdpic-shared.so -T fdpic-main.ld --hash-style=sysv -EL -m armelf_linux_fdpiceabi" "" + "-EL -fdpic" {fdpic-main-m.s} + {{objdump -fdw fdpic-main-m.d} {objdump -Rw fdpic-main.r} + {readelf -Ds fdpic-main-m.sym}} + "fdpic-main"} } # Massage the $armeabitests_common list into run_ld_link_tests standard form. diff --git a/ld/testsuite/ld-arm/fdpic-main-m.d b/ld/testsuite/ld-arm/fdpic-main-m.d new file mode 100644 index 0000000..ed0f41a --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main-m.d @@ -0,0 +1,73 @@ + +tmpdir/fdpic-main: file format elf32-(little|big)arm +architecture: arm.*, flags 0x00000112: +EXEC_P, HAS_SYMS, D_PAGED +start address 0x.* + +Disassembly of section .plt: + +.* <.plt>: + .*: f8df c00c ldr.w ip, \[pc, #12\] ; .* <.plt\+0x10> + .*: eb0c 0c09 add.w ip, ip, r9 + .*: f8dc 9004 ldr.w r9, \[ip, #4\] + .*: f8dc f000 ldr.w pc, \[ip\] + .*: 0000000c .word 0x0000000c + .*: 00000000 .word 0x00000000 + .*: f85f c008 ldr.w ip, \[pc, #-8\] ; .* <.plt\+0x14> + .*: f84d cd04 str.w ip, \[sp, #-4\]! + .*: f8d9 c004 ldr.w ip, \[r9, #4\] + .*: f8d9 f000 ldr.w pc, \[r9\] + .*: f8df c00c ldr.w ip, \[pc, #12\] ; .* <.plt\+0x38> + .*: eb0c 0c09 add.w ip, ip, r9 + .*: f8dc 9004 ldr.w r9, \[ip, #4\] + .*: f8dc f000 ldr.w pc, \[ip] + .*: 00000014 .word 0x00000014 + .*: 00000008 .word 0x00000008 + .*: f85f c008 ldr.w ip, \[pc, #-8\] ; .* <.plt\+0x3c> + .*: f84d cd04 str.w ip, \[sp, #-4\]! + .*: f8d9 c004 ldr.w ip, \[r9, #4\] + .*: f8d9 f000 ldr.w pc, \[r9\] + +Disassembly of section .text: + +.* <_start>: + .*: f000 b800 b.w .*
+ +.*
: + .*: 4a11 ldr r2, \[pc, #68\] ; .* .* + .*: 4b12 ldr r3, \[pc, #72\] ; .* .* + .*: b570 push {r4, r5, r6, lr} + .*: f859 5002 ldr.w r5, \[r9, r2\] + .*: 464c mov r4, r9 + .*: f859 3003 ldr.w r3, \[r9, r3\] + .*: 602b str r3, \[r5, #0\] + .*: f7ff ffcb bl .* <.plt> + .*: 4606 mov r6, r0 + .*: 46a1 mov r9, r4 + .*: 6828 ldr r0, \[r5, #0\] + .*: 46a1 mov r9, r4 + .*: f7ff ffd9 bl .* <.plt\+0x28> + .*: 4b0b ldr r3, \[pc, #44\] ; .* .* + .*: 46a1 mov r9, r4 + .*: 444b add r3, r9 + .*: 4618 mov r0, r3 + .*: 602b str r3, \[r5, #0\] + .*: 46a1 mov r9, r4 + .*: f7ff ffd1 bl .* <.plt\+0x28> + .*: 4b08 ldr r3, \[pc, #32\] ; .* .* + .*: 46a1 mov r9, r4 + .*: f859 3003 ldr.w r3, \[r9, r3\] + .*: 6818 ldr r0, \[r3, #0\] + .*: 46a1 mov r9, r4 + .*: f7ff ffc9 bl .* <.plt\+0x28> + .*: 4630 mov r0, r6 + .*: 46a1 mov r9, r4 + .*: bd70 pop {r4, r5, r6, pc} + .*: 0000002c .word 0x0000002c + .*: 00000024 .word 0x00000024 + .*: 0000001c .word 0x0000001c + .*: 00000028 .word 0x00000028 + +.* : + .*: 4770 bx lr + .*: bf00 nop diff --git a/ld/testsuite/ld-arm/fdpic-main-m.s b/ld/testsuite/ld-arm/fdpic-main-m.s new file mode 100644 index 0000000..4fb40ca --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main-m.s @@ -0,0 +1,86 @@ + .arch armv7-m + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 2 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "hello.c" + .text + .align 2 + .syntax unified + .thumb + .fpu softvfp + .type my_local_func, %function +my_local_func: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + bx lr + .size my_local_func, .-my_local_func + .section .text.startup,"ax",%progbits + .align 2 + .global _start + .syntax unified + .thumb + .fpu softvfp + .type _start, %function +_start: + b main + + .global main + .syntax unified + .thumb + .fpu softvfp + .type main, %function +main: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + ldr r2, .L4 + ldr r3, .L4+4 + push {r4, r5, r6, lr} + ldr r5, [r9, r2] + mov r4, r9 + ldr r3, [r9, r3] + str r3, [r5] + bl my_shared_func1(PLT) + mov r6, r0 + mov r9, r4 + ldr r0, [r5] + mov r9, r4 + bl my_shared_func2(PLT) + ldr r3, .L4+8 + mov r9, r4 + add r3, r3, r9 + mov r0, r3 + str r3, [r5] + mov r9, r4 + bl my_shared_func2(PLT) + ldr r3, .L4+12 + mov r9, r4 + ldr r3, [r9, r3] + ldr r0, [r3] + mov r9, r4 + bl my_shared_func2(PLT) + mov r0, r6 + mov r9, r4 + pop {r4, r5, r6, pc} +.L5: + .align 2 +.L4: + .word funcptr(GOT) + .word my_shared_func1(GOTFUNCDESC) + .word my_local_func(GOTOFFFUNCDESC) + .word funcptr2(GOT) + .size main, .-main + .global funcptr2 + .comm funcptr,4,4 + .section .data.rel,"aw",%progbits + .align 2 + .type funcptr2, %object + .size funcptr2, 4 +funcptr2: + .word my_shared_func1(FUNCDESC) diff --git a/ld/testsuite/ld-arm/fdpic-main-m.sym b/ld/testsuite/ld-arm/fdpic-main-m.sym new file mode 100644 index 0000000..9eaf617 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main-m.sym @@ -0,0 +1,14 @@ + +Symbol table for image: + +Num +Buc: +Value +Size +Type +Bind +Vis +Ndx +Name + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 _edata + +.. +..: ........ +0 +FUNC +GLOBAL +DEFAULT +UND my_shared_func2 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 __bss_start__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 _end + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 __bss_end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 __end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT + 9 __ROFIXUP_LIST__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 __bss_start + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT + 9 __ROFIXUP_END__ + +.. +..: ........ +0 +FUNC +GLOBAL +DEFAULT +UND my_shared_func1 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 _bss_end__ diff --git a/ld/testsuite/ld-arm/fdpic-shared-m.d b/ld/testsuite/ld-arm/fdpic-shared-m.d new file mode 100644 index 0000000..49e4d2c --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared-m.d @@ -0,0 +1,37 @@ + +tmpdir/fdpic-shared.so: file format elf32-(little|big)arm +architecture: arm.*, flags 0x00000150: +HAS_SYMS, DYNAMIC, D_PAGED +start address 0x.* + +Disassembly of section .plt: + +.* <.plt>: + .*: f8df c00c ldr.w ip, \[pc, #12\] ; .* <.plt\+0x10> + .*: eb0c 0c09 add.w ip, ip, r9 + .*: f8dc 9004 ldr.w r9, \[ip, #4\] + .*: f8dc f000 ldr.w pc, \[ip\] + .*: 0000000c .word 0x0000000c + .*: 00000000 .word 0x00000000 + .*: f85f c008 ldr.w ip, \[pc, #-8\] ; .* <.plt\+0x14> + .*: f84d cd04 str.w ip, \[sp, #-4\]! + .*: f8d9 c004 ldr.w ip, \[r9, #4\] + .*: f8d9 f000 ldr.w pc, \[r9\] + +Disassembly of section .text: + +.* : + .*: 4770 bx lr + .*: bf00 nop + +.* : + .*: f04f 0000 mov.w r0, #0 + .*: 4770 bx lr + .*: bf00 nop + +.* : + .*: b510 push {r4, lr} + .*: 464c mov r4, r9 + .*: f7ff ffe2 bl .* <.plt> + .*: 46a1 mov r9, r4 + .*: bd10 pop {r4, pc} diff --git a/ld/testsuite/ld-arm/fdpic-shared-m.s b/ld/testsuite/ld-arm/fdpic-shared-m.s new file mode 100644 index 0000000..ab01a08 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared-m.s @@ -0,0 +1,52 @@ + .arch armv7-m + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 2 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "shared.c" + .text + .align 2 + .global my_shared_func1 + .syntax unified + .thumb + .fpu softvfp + .type my_shared_func1, %function +my_shared_func1: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + bx lr + .size my_shared_func1, .-my_shared_func1 + .align 2 + .global my_shared_func3 + .syntax unified + .thumb + .fpu softvfp + .type my_shared_func3, %function +my_shared_func3: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + mov r0, #0 + bx lr + .size my_shared_func3, .-my_shared_func3 + .align 2 + .global my_shared_func2 + .syntax unified + .thumb + .fpu softvfp + .type my_shared_func2, %function +my_shared_func2: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + push {r4, lr} + mov r4, r9 + bl my_shared_func3(PLT) + mov r9, r4 + pop {r4, pc} + .size my_shared_func2, .-my_shared_func2 diff --git a/ld/testsuite/ld-arm/fdpic-shared-m.sym b/ld/testsuite/ld-arm/fdpic-shared-m.sym new file mode 100644 index 0000000..1475370 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared-m.sym @@ -0,0 +1,15 @@ + +Symbol table for image: + +Num +Buc: +Value +Size +Type +Bind +Vis +Ndx +Name + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _edata + +.. +..: ........ +12 +FUNC +GLOBAL +DEFAULT +6 my_shared_func2 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_start__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _end + +.. +..: ........ +6 +FUNC +GLOBAL +DEFAULT +6 my_shared_func3 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +7 __ROFIXUP_LIST__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_start + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +7 __ROFIXUP_END__ + +.. +..: ........ +2 +FUNC +GLOBAL +DEFAULT +6 my_shared_func1 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _bss_end__