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 <