From patchwork Thu Dec 14 02:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 178424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8283995dys; Wed, 13 Dec 2023 18:51:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgFCrQvzXIttZwxr4gOsU+wzf6rGANT2tRRBvlXP5sRFYI7Nnw/zuiUcijc8w5z1ETJqMt X-Received: by 2002:a05:622a:1822:b0:425:8fb6:5f74 with SMTP id t34-20020a05622a182200b004258fb65f74mr12109566qtc.34.1702522307941; Wed, 13 Dec 2023 18:51:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702522307; cv=pass; d=google.com; s=arc-20160816; b=xDE8JWfMRUHK10T4IFVp9wfVSdD9s8SRV9cPKIRk9804SXbF5wQJxuT6pTTWdMffBm Hku1lml+orCM55PpNChp9RvwrlTNtfThffu6XRerbNtDG+ajtxBGAZfR/ChtPcyqj0ui vvgNDL/ae9scd9aqIFzc4Z/+LS2t5UMMK4WYgjwnDiM2o/MXXFe+xZUuFhijsVhnnyOD lXOXkIu7JALkvV+XIJM5BQ1XRFeS+YY9ltOhzDJEdxD1AW1zwp7E28DfuW3MnPTgRm4j lPG4CfeyuF/Fb0wtce3WTrG3jH1ufNFgke5QmH2s9RNp3x31gCs/+Bow5jHVL2QiO5cr AJ7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=olNEPz8BBiVA0n15vNIVK2MWIzBFaPpO/J1J+0Dr1U4=; fh=FvlVQEmCpm5H8oBXQswexzCupeeQXnbssobXN+3R2Wg=; b=RlCIHlHKp7m6J4kuaCvMa4MYDL10q4XcfztsAldVOJUeg+IXWJkGvWh1Zxd+phdvSd d22CjhPZHHZzLwUjegVXyQzfIBwiVV2Ljt959uNYJu+Q0Oqa+ebRDMCDhqHmmt33qkgP VyfbhkIJvJfXqANo2/XGgLQ6ESwfOUm/cKDKd0Q0GtWH59zuYyAHDLY02n7zhM8+Jk2B z+lrqIsDBiRXQpNnOVr22qQOik3sC7OtBRMrB1yidATQuqchd4FqnEIDsvfVgkIyJUpF +mOgKazC4LpiFnFyA/iJd1U9ptJHEX3jaC9YZb9RQ1bZGS/0t7+Ir9YjR0g55YcDG2I7 sFsw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id cn11-20020a05622a248b00b004255308a476si15310246qtb.564.2023.12.13.18.51.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 18:51:47 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 669923860C0B for ; Thu, 14 Dec 2023 02:51:47 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 64152385E02E for ; Thu, 14 Dec 2023 02:51:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 64152385E02E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 64152385E02E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522283; cv=none; b=c3IPPILBw+T952fpj09rkp1WJlfMSYJ4NusaLdfUZBVVygNlxRMFY428fV5YEggAsWiy9i9O/xpWt13IsqcSwlk6CnbJCuCGHSwE30HhvbqRf0c7mSU+HPcvekP6hUBVTMv9l6Uu6mRFW2iFWah5/f9d9Q4KoVSe84K88AuiqmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522283; c=relaxed/simple; bh=iW1x9upy1vQuJU/60qCjX2umpoNDV19UL+3/Q1q8QzE=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=RTtGrWsPRcYVo9uOhAtjsGXXTB5DYmDdANQ4cpUXsfDjRpEJpIW5tWsl7dIlJDTFGobJuzZ2QcR6/k+q7pQm7/Qzgjcu9W7agWteafDHSRTVh0Ouq2pIm9tbKxd9vojo4jSfdQgsGu7bgXeu9LIvlV8O/jNLMl+qLQ5mbV5WLqE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8Bx6uikbXplTOYAAA--.5189S3; Thu, 14 Dec 2023 10:51:16 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxOXOYbXplPIQDAA--.4894S5; Thu, 14 Dec 2023 10:51:15 +0800 (CST) From: Lulu Cai To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, mengqinggang@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lulu Cai Subject: [PATCH v3 1/5] LoongArch: Add new relocs and macro for TLSDESC. Date: Thu, 14 Dec 2023 10:50:45 +0800 Message-Id: <20231214025049.1629419-2-cailulu@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231214025049.1629419-1-cailulu@loongson.cn> References: <20231214025049.1629419-1-cailulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxOXOYbXplPIQDAA--.4894S5 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAFB2V6Zi0A4AAAs3 X-Coremail-Antispam: 1Uk129KBj9fXoW3KFWrGryDZF18urW5JryxWFX_yoW8Ary8Wo WxZFy8Xr48KFW7A3ySq3W7WF1xKryrGa15Ca45u3ySga48Kr15tFyIyw12vr4xG34DW34r ZFy3KFWDAr48Xrnrl-sFpf9Il3svdjkaLaAFLSUrUUUU0b8apTn2vfkv8UJUUUU8wcxFpf 9Il3svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3 UjIYCTnIWjp_UUUYy7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI 8IcIk0rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4j6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAaw2AFwI0_JF0_Jw1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2 xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ JF0_Jw1lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwCY1x0262kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVF xhVjvjDU0xZFpf9x07je4EiUUUUU= X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785224031611166859 X-GMAIL-MSGID: 1785224031611166859 --- bfd/bfd-in2.h | 12 +++ bfd/elfxx-loongarch.c | 211 +++++++++++++++++++++++++++++++++++++- bfd/libbfd.h | 12 +++ bfd/reloc.c | 29 ++++++ gas/config/tc-loongarch.c | 14 ++- include/elf/loongarch.h | 22 +++- opcodes/loongarch-opc.c | 54 ++++++++++ 7 files changed, 350 insertions(+), 4 deletions(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 040d5560cdf..d3557a4fd74 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7377,6 +7377,8 @@ enum bfd_reloc_code_real BFD_RELOC_LARCH_TLS_DTPREL64, BFD_RELOC_LARCH_TLS_TPREL32, BFD_RELOC_LARCH_TLS_TPREL64, + BFD_RELOC_LARCH_TLS_DESC32, + BFD_RELOC_LARCH_TLS_DESC64, BFD_RELOC_LARCH_MARK_LA, BFD_RELOC_LARCH_MARK_PCREL, BFD_RELOC_LARCH_SOP_PUSH_PCREL, @@ -7460,6 +7462,16 @@ enum bfd_reloc_code_real BFD_RELOC_LARCH_ADD_ULEB128, BFD_RELOC_LARCH_SUB_ULEB128, BFD_RELOC_LARCH_64_PCREL, + BFD_RELOC_LARCH_TLS_DESC_PC_HI20, + BFD_RELOC_LARCH_TLS_DESC_ADD_PC_LO12, + BFD_RELOC_LARCH_TLS_DESC_LD, + BFD_RELOC_LARCH_TLS_DESC64_PC_LO20, + BFD_RELOC_LARCH_TLS_DESC64_PC_HI12, + BFD_RELOC_LARCH_TLS_DESC_HI20, + BFD_RELOC_LARCH_TLS_DESC_LO12, + BFD_RELOC_LARCH_TLS_DESC64_LO20, + BFD_RELOC_LARCH_TLS_DESC64_HI12, + BFD_RELOC_LARCH_TLS_DESC_CALL, BFD_RELOC_UNUSED }; typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c index 7f298c08fd3..819c4849ef5 100644 --- a/bfd/elfxx-loongarch.c +++ b/bfd/elfxx-loongarch.c @@ -293,8 +293,40 @@ static loongarch_reloc_howto_type loongarch_howto_table[] = NULL, /* adjust_reloc_bits */ NULL), /* larch_reloc_type_name */ - LOONGARCH_EMPTY_HOWTO (13), - LOONGARCH_EMPTY_HOWTO (14), + LOONGARCH_HOWTO (R_LARCH_TLS_DESC32, /* type (13). */ + 0, /* rightshift. */ + 4, /* size. */ + 32, /* bitsize. */ + false, /* pc_relative. */ + 0, /* bitpos. */ + complain_overflow_dont, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC32", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + ALL_ONES, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC32, /* bfd_reloc_code_real_type. */ + NULL, /* adjust_reloc_bits. */ + NULL), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_DESC64, /* type (14). */ + 0, /* rightshift. */ + 4, /* size. */ + 64, /* bitsize. */ + false, /* pc_relative. */ + 0, /* bitpos. */ + complain_overflow_dont, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC64", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + ALL_ONES, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC64, /* bfd_reloc_code_real_type. */ + NULL, /* adjust_reloc_bits. */ + NULL), /* larch_reloc_type_name. */ + LOONGARCH_EMPTY_HOWTO (15), LOONGARCH_EMPTY_HOWTO (16), LOONGARCH_EMPTY_HOWTO (17), @@ -1547,6 +1579,181 @@ static loongarch_reloc_howto_type loongarch_howto_table[] = NULL, /* adjust_reloc_bits */ NULL), /* larch_reloc_type_name */ + LOONGARCH_EMPTY_HOWTO (110), + + /* TLS_DESC PCREL. */ + LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PC_HI20, /* type (111). */ + 12, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + true, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC_PC_HI20", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC_PC_HI20, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc_pc_hi20"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_DESC_ADD_PC_LO12,/* type (112). */ + 0, /* rightshift. */ + 4, /* size. */ + 12, /* bitsize. */ + true, /* pc_relative. */ + 10, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC_ADD_PC_LO12", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x3ffc00, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC_ADD_PC_LO12, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc_add_pc_lo12"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LD, /* type (113). */ + 0, /* rightshift. */ + 4, /* size. */ + 0, /* bitsize. */ + true, /* pc_relative. */ + 0, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC_LD", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC_LD, /* bfd_reloc_code_real_type. */ + NULL, /* adjust_reloc_bits. */ + "desc_ld"), /* larch_reloc_type_name. */ + + /* TLS_DESC64 LARGE PCREL. */ + LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_LO20, /* type (114). */ + 32, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + true, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC64_PC_LO20", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC64_PC_LO20, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc64_pc_lo20"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_HI12, /* type (115). */ + 52, /* rightshift. */ + 4, /* size. */ + 12, /* bitsize. */ + true, /* pc_relative. */ + 10, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC64_PC_HI12", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x3ffc00, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC64_PC_HI12, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc64_pc_hi12"), /* larch_reloc_type_name. */ + + /* TLS_DESC ABS. */ + LOONGARCH_HOWTO (R_LARCH_TLS_DESC_HI20, /* type (116). */ + 12, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + false, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC_HI20", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC_HI20, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc_hi20"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LO12, /* type (117). */ + 0, /* rightshift. */ + 4, /* size. */ + 12, /* bitsize. */ + false, /* pc_relative. */ + 10, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC_LO12", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x3ffc00, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC_LO12, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc_lo12"), /* larch_reloc_type_name. */ + + /* TLS_DESC64 LARGE ABS. */ + LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_LO20, /* type (118). */ + 32, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + false, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC64_LO20", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC64_LO20, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc64_lo20"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_HI12, /* type (119). */ + 52, /* rightshift. */ + 4, /* size. */ + 12, /* bitsize. */ + false, /* pc_relative. */ + 10, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC64_HI12", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x3ffc00, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC64_HI12, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "desc64_hi12"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_DESC_CALL, /* type (120). */ + 0, /* rightshift. */ + 4, /* size. */ + 0, /* bitsize. */ + false, /* pc_relative. */ + 0, /* bitpos. */ + complain_overflow_dont, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC_CALL", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC_CALL, /* bfd_reloc_code_real_type. */ + NULL, /* adjust_reloc_bits. */ + "desc_call"), /* larch_reloc_type_name. */ }; reloc_howto_type * diff --git a/bfd/libbfd.h b/bfd/libbfd.h index cc432677a81..6ee021e84b5 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -3516,6 +3516,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_LARCH_TLS_DTPREL64", "BFD_RELOC_LARCH_TLS_TPREL32", "BFD_RELOC_LARCH_TLS_TPREL64", + "BFD_RELOC_LARCH_TLS_DESC32", + "BFD_RELOC_LARCH_TLS_DESC64", "BFD_RELOC_LARCH_MARK_LA", "BFD_RELOC_LARCH_MARK_PCREL", "BFD_RELOC_LARCH_SOP_PUSH_PCREL", @@ -3599,6 +3601,16 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_LARCH_ADD_ULEB128", "BFD_RELOC_LARCH_SUB_ULEB128", "BFD_RELOC_LARCH_64_PCREL", + "BFD_RELOC_LARCH_TLS_DESC_PC_HI20", + "BFD_RELOC_LARCH_TLS_DESC_ADD_PC_LO12", + "BFD_RELOC_LARCH_TLS_DESC_LD", + "BFD_RELOC_LARCH_TLS_DESC64_PC_LO20", + "BFD_RELOC_LARCH_TLS_DESC64_PC_HI12", + "BFD_RELOC_LARCH_TLS_DESC_HI20", + "BFD_RELOC_LARCH_TLS_DESC_LO12", + "BFD_RELOC_LARCH_TLS_DESC64_LO20", + "BFD_RELOC_LARCH_TLS_DESC64_HI12", + "BFD_RELOC_LARCH_TLS_DESC_CALL", "@@overflow: BFD_RELOC_UNUSED@@", }; #endif diff --git a/bfd/reloc.c b/bfd/reloc.c index 93ebad879e0..0e354ef4b80 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -8111,6 +8111,10 @@ ENUMX BFD_RELOC_LARCH_TLS_TPREL32 ENUMX BFD_RELOC_LARCH_TLS_TPREL64 +ENUMX + BFD_RELOC_LARCH_TLS_DESC32 +ENUMX + BFD_RELOC_LARCH_TLS_DESC64 ENUMX BFD_RELOC_LARCH_MARK_LA ENUMX @@ -8292,6 +8296,31 @@ ENUMX ENUMX BFD_RELOC_LARCH_64_PCREL +ENUMX + BFD_RELOC_LARCH_TLS_DESC_PC_HI20 +ENUMX + BFD_RELOC_LARCH_TLS_DESC_ADD_PC_LO12 +ENUMX + BFD_RELOC_LARCH_TLS_DESC_LD + +ENUMX + BFD_RELOC_LARCH_TLS_DESC64_PC_LO20 +ENUMX + BFD_RELOC_LARCH_TLS_DESC64_PC_HI12 + +ENUMX + BFD_RELOC_LARCH_TLS_DESC_HI20 +ENUMX + BFD_RELOC_LARCH_TLS_DESC_LO12 + +ENUMX + BFD_RELOC_LARCH_TLS_DESC64_LO20 +ENUMX + BFD_RELOC_LARCH_TLS_DESC64_HI12 + +ENUMX + BFD_RELOC_LARCH_TLS_DESC_CALL + ENUMDOC LARCH relocations. diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index 59232832cf7..e1d5453b14f 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -682,7 +682,7 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2, esc_ch1, esc_ch2, bit_field, arg); if (ip->reloc_info[0].type >= BFD_RELOC_LARCH_B16 - && ip->reloc_info[0].type < BFD_RELOC_LARCH_64_PCREL) + && ip->reloc_info[0].type <= BFD_RELOC_LARCH_TLS_DESC_CALL) { /* As we compact stack-relocs, it is no need for pop operation. But break out until here in order to check the imm field. @@ -1270,6 +1270,14 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_LARCH_TLS_LD_HI20: case BFD_RELOC_LARCH_TLS_GD_PC_HI20: case BFD_RELOC_LARCH_TLS_GD_HI20: + case BFD_RELOC_LARCH_TLS_DESC_PC_HI20: + case BFD_RELOC_LARCH_TLS_DESC_ADD_PC_LO12: + case BFD_RELOC_LARCH_TLS_DESC64_PC_LO20: + case BFD_RELOC_LARCH_TLS_DESC64_PC_HI12: + case BFD_RELOC_LARCH_TLS_DESC_HI20: + case BFD_RELOC_LARCH_TLS_DESC_LO12: + case BFD_RELOC_LARCH_TLS_DESC64_LO20: + case BFD_RELOC_LARCH_TLS_DESC64_HI12: /* Add tls lo (got_lo reloc type). */ if (fixP->fx_addsy == NULL) as_bad_where (fixP->fx_file, fixP->fx_line, @@ -1290,6 +1298,10 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) stack_top = 0; break; + case BFD_RELOC_LARCH_TLS_DESC_LD: + case BFD_RELOC_LARCH_TLS_DESC_CALL: + break; + case BFD_RELOC_LARCH_SOP_POP_32_S_10_5: case BFD_RELOC_LARCH_SOP_POP_32_S_10_12: case BFD_RELOC_LARCH_SOP_POP_32_U_10_12: diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h index e31395e13d5..da2fd119181 100644 --- a/include/elf/loongarch.h +++ b/include/elf/loongarch.h @@ -38,7 +38,8 @@ RELOC_NUMBER (R_LARCH_TLS_DTPREL64, 9) RELOC_NUMBER (R_LARCH_TLS_TPREL32, 10) RELOC_NUMBER (R_LARCH_TLS_TPREL64, 11) RELOC_NUMBER (R_LARCH_IRELATIVE, 12) - +RELOC_NUMBER (R_LARCH_TLS_DESC32, 13) +RELOC_NUMBER (R_LARCH_TLS_DESC64, 14) /* Reserved for future relocs that the dynamic linker must understand. */ /* Used by the static linker for relocating .text. */ @@ -251,6 +252,25 @@ RELOC_NUMBER (R_LARCH_SUB_ULEB128, 108) RELOC_NUMBER (R_LARCH_64_PCREL, 109) +/* TLS_DESC PCREL. */ +RELOC_NUMBER (R_LARCH_TLS_DESC_PC_HI20, 111) +RELOC_NUMBER (R_LARCH_TLS_DESC_ADD_PC_LO12, 112) +RELOC_NUMBER (R_LARCH_TLS_DESC_LD, 113) + +/* TLS_DESC LARGE PCREL. */ +RELOC_NUMBER (R_LARCH_TLS_DESC64_PC_LO20, 114) +RELOC_NUMBER (R_LARCH_TLS_DESC64_PC_HI12, 115) + +/* TLS_DESC ABS. */ +RELOC_NUMBER (R_LARCH_TLS_DESC_HI20, 116) +RELOC_NUMBER (R_LARCH_TLS_DESC_LO12, 117) + +/* TLSDESC LARGE ABS. */ +RELOC_NUMBER (R_LARCH_TLS_DESC64_LO20, 118) +RELOC_NUMBER (R_LARCH_TLS_DESC64_HI12, 119) + +RELOC_NUMBER (R_LARCH_TLS_DESC_CALL, 120) + END_RELOC_NUMBERS (R_LARCH_count) /* Processor specific flags for the ELF header e_flags field. */ diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c index 15c7da6340c..3adcb380e0e 100644 --- a/opcodes/loongarch-opc.c +++ b/opcodes/loongarch-opc.c @@ -293,6 +293,55 @@ const char *const loongarch_x_normal_name[32] = &LARCH_opts.ase_lp64, \ &LARCH_opts.ase_gpcr +/* For TLS_DESC32 pcrel. */ +#define INSN_LA_TLS_DESC32 \ + "pcalau12i $r4,%%desc_pc_hi20(%2);" \ + "addi.w $r4,$r4,%%desc_add_pc_lo12(%2);"\ + "ld.w $r1,$r4,%%desc_ld(%2);" \ + "jirl $r1,$r1,%%desc_call(%2);", \ + &LARCH_opts.ase_ilp32, \ + &LARCH_opts.ase_lp64 + +/* For TLS_DESC32 abs. */ +#define INSN_LA_TLS_DESC32_ABS \ + "lu12i.w $r4,%%desc_hi20(%2);" \ + "ori $r4,$r4,%%desc_lo12(%2);" \ + "ld.w $r1,$r4,0;" \ + "jirl $r1,$r1,%%desc_call(%2);", \ + &LARCH_opts.ase_gabs, \ + &LARCH_opts.ase_lp64 + +/* For TLS_DESC64 pcrel. */ +#define INSN_LA_TLS_DESC64 \ + "pcalau12i $r4,%%desc_pc_hi20(%2);" \ + "addi.d $r4,$r4,%%desc_add_pc_lo12(%2);"\ + "ld.d $r1,$r4,%%desc_ld(%2);" \ + "jirl $r1,$r1,%%desc_call(%2);", \ + &LARCH_opts.ase_lp64, 0 + +/* For TLS_DESC64 large pcrel. */ +#define INSN_LA_TLS_DESC64_LARGE_PCREL \ + "pcalau12i $r4,%%desc_pc_hi20(%3);" \ + "addi.d %2,$r0,%%desc_add_pc_lo12(%3);"\ + "lu32i.d %2,%%desc64_pc_lo20(%3);" \ + "lu52i.d %2,%2,%%desc64_pc_hi12(%3);" \ + "add.d $r4,$r4,%2;" \ + "ld.d $r1,$r4,0;" \ + "jirl $r1,$r1,%%desc_call(%3);", \ + &LARCH_opts.ase_lp64, \ + &LARCH_opts.ase_gabs + +/* For TLS_DESC64 large abs. */ +#define INSN_LA_TLS_DESC64_LARGE_ABS \ + "lu12i.w $r4,%%desc_hi20(%2);" \ + "ori $r4,$r4,%%desc_lo12(%2);" \ + "lu32i.d $r4,%%desc64_lo20(%2);" \ + "lu52i.d $r4,$r4,%%desc64_hi12(%2);"\ + "ld.d $r1,$r4,0;" \ + "jirl $r1,$r1,%%desc_call(%2);", \ + &LARCH_opts.ase_lp64, \ + &LARCH_opts.ase_gpcr + static struct loongarch_opcode loongarch_macro_opcodes[] = { @@ -341,6 +390,11 @@ static struct loongarch_opcode loongarch_macro_opcodes[] = { 0, 0, "la.tls.gd", "r,l", INSN_LA_TLS_GD64_LARGE_ABS, 0 }, { 0, 0, "la.tls.gd", "r,r,l", INSN_LA_TLS_GD64_LARGE_PCREL, 0 }, { 0, 0, "pcaddi", "r,la", "pcaddi %1, %%pcrel_20(%2)", &LARCH_opts.ase_ilp32, 0, 0 }, + { 0, 0, "la.tls.desc", "r,l", INSN_LA_TLS_DESC32, 0 }, + { 0, 0, "la.tls.desc", "r,l", INSN_LA_TLS_DESC32_ABS, 0 }, + { 0, 0, "la.tls.desc", "r,l", INSN_LA_TLS_DESC64, 0 }, + { 0, 0, "la.tls.desc", "r,l", INSN_LA_TLS_DESC64_LARGE_ABS, 0 }, + { 0, 0, "la.tls.desc", "r,r,l", INSN_LA_TLS_DESC64_LARGE_PCREL, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0 } /* Terminate the list. */ }; From patchwork Thu Dec 14 02:50:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 178423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8283961dys; Wed, 13 Dec 2023 18:51:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHv9y92PwmDLDQ8/s3OU1XwdLQ8fXvdrwkZxtqD4jSdHjLZlWbqPkGkjMzumqmO6On3aeKw X-Received: by 2002:ad4:5ecb:0:b0:67f:b1a:64a with SMTP id jm11-20020ad45ecb000000b0067f0b1a064amr283785qvb.54.1702522302373; Wed, 13 Dec 2023 18:51:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702522302; cv=pass; d=google.com; s=arc-20160816; b=uU8Bcbkr9wVnjLHBlv0+gKklZmYjnLUD5Z0/Ub+DYqvwL2wa1aEu8fPkoaHh4DSkRt gk456spsgTKBex7BbZUgXOajviK7hlEvjrrCDHGhvJ78QctdES95xQb2XjY2WPCdKR4D XROS2b3DBJSjneG7Q9ZnysjY5/1d7gxegJGc5Isa0AR+mD3X2gBXrPQyeD41ZfTKzlAz Op426KB/MzBqVZ7jQ3KGFsOOu855/BIGuQ2wLmk85RqZ1+XBYnC94vawvs1srB9bRat6 vF6d1+93IZMZ5pkC9gmk/i7n636rWaK0c5D1gK7pUFULs/vJgLJ4yXxtbn8n3p9EmX9x 8hVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=6sQpeo/j5JPq9zyl47/8DXbu/tyiltKix7y4SDU43Y8=; fh=FvlVQEmCpm5H8oBXQswexzCupeeQXnbssobXN+3R2Wg=; b=gcXIZXfviuuG9ESoMYwGqqaULR5p7Un0qfnKpadZ35017WT5KU/nrvQnlN+04TeHRZ 5TW12aWsIz8nqyyACvYiOKjFQaObxiQ05jag8kHKfvWhf3y6c0E1veHZwZX60OeESTkD Q6LasIQ2z2VNbn+P3/NLnxyQpWEeHPco8D54GjffT2UEkjV8uPJghKv1bZHw7CwiYw4i vu/lR1+NBjpx8S1wiz8NgJXT/U8ZqEQXAtDi29Emx86WHbQeYz9i9gHM52tYaxq5vQ9X SIsVYpGx5cV1tArVSoQpDZv/n9e4s4UKqZ843Bt2d/8/3WXXS7btvJ/nJqb1Vox9UnUu bv3g== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f10-20020a05620a280a00b0077f8920f2b7si4791404qkp.712.2023.12.13.18.51.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 18:51:42 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14D423861805 for ; Thu, 14 Dec 2023 02:51:42 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 73D493860753 for ; Thu, 14 Dec 2023 02:51:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73D493860753 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 73D493860753 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522297; cv=none; b=uW+87XyR5azwCOHvvZ9mJKNy+Y7sGaZXFJJIWGDKVpGl7OhQXu50G72XYLecFT/BPt53DgQFmEzV73XqN373H543k1BOrsK0qB3zo3ano4f9Fa6R6MG9olveXprUVN0NnWV7HUYzkGX3Cu45vNO1WxrchIh+BhLY6+3hnUdvY/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522297; c=relaxed/simple; bh=WCHNalZMsnTPrIU7NmLuOZ/k7RBPt/jsC3bYh7Iwuto=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=ZZ7LY3Jdyf5ZyeVt7+cYuOArHMjokGMYPs9Cvj/S9yoE4Hs5Z4UZ40LLh92o3yWF2kaw0uZTpAtPIzQqSXNgAbLOicxlMWM0G7H+O3fJkQ0OaT/9ybZD48E9YMGZ97J7NgUHZSaov/Yfn9xc0Cgd4em71mdrQVK+jYkeQag8BlQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8Cxuei0bXplUuYAAA--.5252S3; Thu, 14 Dec 2023 10:51:32 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxOXOYbXplPIQDAA--.4894S6; Thu, 14 Dec 2023 10:51:31 +0800 (CST) From: Lulu Cai To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, mengqinggang@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lulu Cai Subject: [PATCH v3 2/5] LoongArch: Add support for TLSDESC in ld. Date: Thu, 14 Dec 2023 10:50:46 +0800 Message-Id: <20231214025049.1629419-3-cailulu@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231214025049.1629419-1-cailulu@loongson.cn> References: <20231214025049.1629419-1-cailulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxOXOYbXplPIQDAA--.4894S6 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAFB2V6Zi0A-gAAsp X-Coremail-Antispam: 1Uk129KBj93XoW3KFW5tF17tFWrXr48XF45XFc_yoWDXrW5pr ZxAr4UKw48urW7W34aq3WrZa1Fg3y8ury2qr9xt3909Fn3Xr95WF47Xr15ZFW5KF4qyw42 v3sY93W8Za48A3XCm3ZEXasCq-sJn29KB7ZKAUJUUUUx529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxkF7I0En4kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY 6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU8g6pPUUUUU== X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785224025557055523 X-GMAIL-MSGID: 1785224025557055523 --- bfd/elfnn-loongarch.c | 168 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 146 insertions(+), 22 deletions(-) diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 024c5d4cd96..b63f42bb6a7 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -48,6 +48,12 @@ struct loongarch_elf_link_hash_entry #define GOT_TLS_GD 2 #define GOT_TLS_IE 4 #define GOT_TLS_LE 8 +#define GOT_TLS_GDESC 16 + +#define GOT_TLS_GD_BOTH_P(tls_type) \ + ((tls_type & GOT_TLS_GD) && (tls_type & GOT_TLS_GDESC)) +#define GOT_TLS_GD_ANY_P(tls_type) \ + ((tls_type & GOT_TLS_GD) || (tls_type & GOT_TLS_GDESC)) char tls_type; }; @@ -563,6 +569,7 @@ loongarch_elf_record_tls_and_got_reference (bfd *abfd, case GOT_NORMAL: case GOT_TLS_GD: case GOT_TLS_IE: + case GOT_TLS_GDESC: /* Need GOT. */ if (htab->elf.sgot == NULL && !loongarch_elf_create_got_section (htab->elf.dynobj, info)) @@ -750,6 +757,14 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, return false; break; + case R_LARCH_TLS_DESC_PC_HI20: + case R_LARCH_TLS_DESC_HI20: + if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h, + r_symndx, + GOT_TLS_GDESC)) + return false; + break; + case R_LARCH_ABS_HI20: case R_LARCH_SOP_PUSH_ABSOLUTE: if (h != NULL) @@ -1129,7 +1144,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) s = htab->elf.sgot; h->got.offset = s->size; - if (tls_type & (GOT_TLS_GD | GOT_TLS_IE)) + if (tls_type & (GOT_TLS_GD | GOT_TLS_IE | GOT_TLS_GDESC)) { /* TLS_GD needs two dynamic relocs and two GOT slots. */ if (tls_type & GOT_TLS_GD) @@ -1166,7 +1181,15 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) htab->elf.srelgot->size += sizeof (ElfNN_External_Rela); } } + + /* TLS_DESC needs one dynamic reloc and two GOT slot. */ + if (tls_type & GOT_TLS_GDESC) + { + s->size += GOT_ENTRY_SIZE * 2; + htab->elf.srelgot->size += sizeof (ElfNN_External_Rela); + } } + else { s->size += GOT_ENTRY_SIZE; @@ -1669,19 +1692,34 @@ loongarch_elf_size_dynamic_sections (bfd *output_bfd, if (0 < *local_got) { *local_got = s->size; + if (*local_tls_type & (GOT_TLS_GD | GOT_TLS_IE | GOT_TLS_GDESC)) + { + /* TLS gd use two got. */ + if (*local_tls_type & GOT_TLS_GD) + { + s->size += 2 * GOT_ENTRY_SIZE; + if (!bfd_link_executable (info)) + srel->size += sizeof (ElfNN_External_Rela); + } - /* TLS gd use two got. */ - if (*local_tls_type & GOT_TLS_GD) - s->size += GOT_ENTRY_SIZE * 2; - else - /* Normal got, tls ie/ld use one got. */ - s->size += GOT_ENTRY_SIZE; + /* TLS_DESC use two got. */ + if (*local_tls_type & GOT_TLS_GDESC) + { + s->size += 2 * GOT_ENTRY_SIZE; + srel->size += sizeof (ElfNN_External_Rela); + } - if (bfd_link_executable (info) - && (*local_tls_type & (GOT_TLS_GD| GOT_TLS_IE))) - ;/* Do nothing. */ + /* TLS ie and use one got. */ + if (*local_tls_type & GOT_TLS_IE) + { + s->size += GOT_ENTRY_SIZE; + if (!bfd_link_executable (info)) + srel->size += sizeof (ElfNN_External_Rela); + } + } else { + s->size += GOT_ENTRY_SIZE; srel->size += sizeof (ElfNN_External_Rela); } } @@ -2120,6 +2158,15 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section, case R_LARCH_TLS_GD_PC_HI20: case R_LARCH_TLS_GD_HI20: case R_LARCH_PCREL20_S2: + case R_LARCH_TLS_DESC_PC_HI20: + case R_LARCH_TLS_DESC_ADD_PC_LO12: + case R_LARCH_TLS_DESC64_PC_LO20: + case R_LARCH_TLS_DESC64_PC_HI12: + case R_LARCH_TLS_DESC_HI20: + case R_LARCH_TLS_DESC_LO12: + case R_LARCH_TLS_DESC64_LO20: + case R_LARCH_TLS_DESC64_HI12: + r = loongarch_check_offset (rel, input_section); if (r != bfd_reloc_ok) break; @@ -2129,6 +2176,11 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section, contents, value); break; + case R_LARCH_TLS_DESC_LD: + case R_LARCH_TLS_DESC_CALL: + r = bfd_reloc_ok; + break; + case R_LARCH_RELAX: break; @@ -2377,10 +2429,10 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, struct elf_link_hash_entry *h = NULL; const char *name; bfd_reloc_status_type r = bfd_reloc_ok; - bool is_ie, is_undefweak, unresolved_reloc, defined_local; + bool is_ie, is_desc, is_undefweak, unresolved_reloc, defined_local; bool resolved_local, resolved_dynly, resolved_to_const; char tls_type; - bfd_vma relocation, off, ie_off; + bfd_vma relocation, off, ie_off, desc_off; int i, j; howto = loongarch_elf_rtype_to_howto (input_bfd, r_type); @@ -2509,6 +2561,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (!resolved_local || defined_local); + is_desc = false; is_ie = false; switch (r_type) { @@ -3398,6 +3451,8 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, case R_LARCH_TLS_LD_HI20: case R_LARCH_TLS_GD_PC_HI20: case R_LARCH_TLS_GD_HI20: + case R_LARCH_TLS_DESC_PC_HI20: + case R_LARCH_TLS_DESC_HI20: BFD_ASSERT (rel->r_addend == 0); unresolved_reloc = false; @@ -3405,6 +3460,10 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, || r_type == R_LARCH_TLS_IE_HI20) is_ie = true; + if (r_type == R_LARCH_TLS_DESC_PC_HI20 + || r_type == R_LARCH_TLS_DESC_HI20) + is_desc = true; + bfd_vma got_off = 0; if (h != NULL) { @@ -3419,9 +3478,19 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (got_off != MINUS_ONE); - ie_off = 0; tls_type = _bfd_loongarch_elf_tls_type (input_bfd, h, r_symndx); - if ((tls_type & GOT_TLS_GD) && (tls_type & GOT_TLS_IE)) + + /* If a tls variable is accessed in multiple ways, GD uses + the first two slots of GOT, desc follows with two slots, + and IE uses one slot at the end. */ + desc_off = 0; + if (GOT_TLS_GD_BOTH_P (tls_type)) + desc_off = 2 * GOT_ENTRY_SIZE; + + ie_off = 0; + if (GOT_TLS_GD_BOTH_P (tls_type) && (tls_type & GOT_TLS_IE)) + ie_off = 4 * GOT_ENTRY_SIZE; + else if (GOT_TLS_GD_ANY_P (tls_type) && (tls_type & GOT_TLS_IE)) ie_off = 2 * GOT_ENTRY_SIZE; if ((got_off & 1) == 0) @@ -3470,6 +3539,21 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, loongarch_elf_append_rela (output_bfd, relgot, &rela); } } + if (tls_type & GOT_TLS_GDESC) + { + /* Unless it is a static link, DESC always emits a + dynamic relocation. */ + int indx = h && h->dynindx != -1 ? h->dynindx : 0; + rela.r_offset = sec_addr (got) + got_off + desc_off; + rela.r_addend = 0; + if (indx == 0) + rela.r_addend = relocation - elf_hash_table (info)->tls_sec->vma; + + rela.r_info = ELFNN_R_INFO (indx, R_LARCH_TLS_DESCNN); + loongarch_elf_append_rela (output_bfd, relgot, &rela); + bfd_put_NN (output_bfd, 0, + got->contents + got_off + desc_off); + } if (tls_type & GOT_TLS_IE) { rela.r_offset = sec_addr (got) + got_off + ie_off; @@ -3497,16 +3581,52 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, } } } - relocation = (got_off & (~(bfd_vma)1)) + sec_addr (got) - + (is_ie ? ie_off : 0); + relocation = (got_off & (~(bfd_vma)1)) + sec_addr (got); + if (is_desc) + relocation += desc_off; + else if (is_ie) + relocation += ie_off; if (r_type == R_LARCH_TLS_LD_PC_HI20 || r_type == R_LARCH_TLS_GD_PC_HI20 - || r_type == R_LARCH_TLS_IE_PC_HI20) + || r_type == R_LARCH_TLS_IE_PC_HI20 + || r_type == R_LARCH_TLS_DESC_PC_HI20) RELOCATE_CALC_PC32_HI20 (relocation, pc); break; + case R_LARCH_TLS_DESC_ADD_PC_LO12: + case R_LARCH_TLS_DESC64_PC_LO20: + case R_LARCH_TLS_DESC64_PC_HI12: + case R_LARCH_TLS_DESC_LO12: + case R_LARCH_TLS_DESC64_LO20: + case R_LARCH_TLS_DESC64_HI12: + { + unresolved_reloc = false; + + if (h) + relocation = sec_addr (got) + (h->got.offset & (~(bfd_vma)1)); + else + relocation = sec_addr (got) + + (local_got_offsets[r_symndx] & (~(bfd_vma)1)); + + tls_type = _bfd_loongarch_elf_tls_type (input_bfd, h, r_symndx); + /* Use both TLS_GD and TLS_DESC. */ + if ((tls_type & GOT_TLS_GD) && (tls_type & GOT_TLS_GDESC)) + relocation += 2 * GOT_ENTRY_SIZE; + } + + if (r_type == R_LARCH_TLS_DESC64_PC_LO20 + || r_type == R_LARCH_TLS_DESC64_PC_HI12) + RELOCATE_CALC_PC64_HI32 (relocation, pc); + + break; + + case R_LARCH_TLS_DESC_LD: + case R_LARCH_TLS_DESC_CALL: + unresolved_reloc = false; + break; + case R_LARCH_TLS_IE_PC_LO12: case R_LARCH_TLS_IE64_PC_LO20: case R_LARCH_TLS_IE64_PC_HI12: @@ -3516,14 +3636,17 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, unresolved_reloc = false; if (h) - relocation = sec_addr (got) + (h->got.offset & (~(bfd_vma)3)); + relocation = sec_addr (got) + (h->got.offset & (~(bfd_vma)1)); else relocation = sec_addr (got) - + (local_got_offsets[r_symndx] & (~(bfd_vma)3)); + + (local_got_offsets[r_symndx] & (~(bfd_vma)1)); tls_type = _bfd_loongarch_elf_tls_type (input_bfd, h, r_symndx); - /* Use both TLS_GD and TLS_IE. */ - if ((tls_type & GOT_TLS_GD) && (tls_type & GOT_TLS_IE)) + /* Use TLS_GD TLS_DESC and TLS_IE. */ + if (GOT_TLS_GD_BOTH_P (tls_type) && (tls_type & GOT_TLS_IE)) + relocation += 4 * GOT_ENTRY_SIZE; + /* Use GOT_TLS_GD_ANY_P (tls_type) and TLS_IE. */ + else if (GOT_TLS_GD_ANY_P (tls_type) && (tls_type & GOT_TLS_IE)) relocation += 2 * GOT_ENTRY_SIZE; if (r_type == R_LARCH_TLS_IE64_PC_LO20 @@ -4149,7 +4272,8 @@ loongarch_elf_finish_dynamic_symbol (bfd *output_bfd, if (h->got.offset != MINUS_ONE /* TLS got entry have been handled in elf_relocate_section. */ - && !(loongarch_elf_hash_entry (h)->tls_type & (GOT_TLS_GD | GOT_TLS_IE)) + && !(loongarch_elf_hash_entry (h)->tls_type + & (GOT_TLS_GD | GOT_TLS_IE | GOT_TLS_GDESC)) /* Have allocated got entry but not allocated rela before. */ && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) { From patchwork Thu Dec 14 02:50:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 178425 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8284008dys; Wed, 13 Dec 2023 18:51:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuZEfOFOPjHnl/gRrBU18ZucLDi4lOjZ/KxnXkg5lZ/juNq+leDBHXW1qHc0V2vzkQRkU0 X-Received: by 2002:a05:620a:27c9:b0:76c:af30:3281 with SMTP id i9-20020a05620a27c900b0076caf303281mr10528790qkp.10.1702522308669; Wed, 13 Dec 2023 18:51:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702522308; cv=pass; d=google.com; s=arc-20160816; b=dLecU730xymWTdgdSc7nRp/FhgwMCmGetJnLPL0etHgo1KVm4hUxQm0osgh/Qaj7Dk Kr7b0L/reEBxtLLAHYQK3IIjwxVzv7Pt0w4ih0BnsHr+gx0zjzeUQn1TaJL6Vwt0vO/g X0ELGbvZAMSwU7Yhd/1kr4NsmUsLxzRZO4v+TMHnNSk+94nsrEd2AipQfxwqPy5GtHCu xDzSiSms03el0V8hFoMgbmVR4RjFj5ZYA4z0pfRkjj8TVvt2a7lUoFu0c+4YK0JoLwr0 PfyxgmQArILjFlWJTMRsdqjMMrnxP95cHhiNt0XDP0LZbClvPATzRGporL6VbIh9aIsR A6tA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=aGU+NP4U2+QeLX/BPLeD0ahg6nh8OXUYFT4lLi9zSNE=; fh=FvlVQEmCpm5H8oBXQswexzCupeeQXnbssobXN+3R2Wg=; b=cVhc8Efq6bkldwSWHigVLgU/zDvW5gKIjth11easbJAz0ItN3jYM0swqmy82y2RTih Ech2vs058EZvq2Q4XkI6dv/TlZiD7JSl+UzSEGKej18wyGOTh04IbTtYo3EC9CCY+axO QHtisNETxNDr3voS2kPPW4f15T/0ZTqtNzqwYI5NHx2rCZMCn3mJg5QE9tTL3vjn0Meh rU3f1WLmMh/QobexGUAMTymFIo1gCZrHcobMq34Ail9DZtSal2aJSShj4WV6VNGYjxR2 gv8ZDfoKyrziIUCW4T2pq7ipDvp6LrQvEnA0yR+vMnAtsiRu5lwdBnv3+w5B1NroPKOV UmCQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u7-20020a05620a454700b0077f957ee61fsi2771509qkp.753.2023.12.13.18.51.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 18:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EAB7D386181A for ; Thu, 14 Dec 2023 02:51:47 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 4769B385841F for ; Thu, 14 Dec 2023 02:51:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4769B385841F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4769B385841F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522302; cv=none; b=Je6jF0kEh9Z01cOyIlpPzIWz1QBxk41fu6tooNPonSbPnC/cq2bHbfUqHj631TDrXQq3UKY9oa3QKzS1dHHvQ68N1qQwU9x2e/K/06Yw8pKmPaRSlRP2ZZGWq5SEXV6TRviOwamGja1U0rHRRnwot0QG23ksGQaCFvLCvJCfmZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522302; c=relaxed/simple; bh=ZPMkFI8kPXcFY7G/Pls7MPZidK7atE6HDwlsXzckWE0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=VF3lxdqVp9PRNlcGysfvlVOCpkqtASqHU2YFJnqHd2CcCzGmhmZoHSZ6KrB5FJsgTCyXS2hcxRtWMzTMrZmIQeJn4JC5ILSWICG9Nek7VfxORMKUeeL+Vv67nFp7nocEjAuN1XYGivVozhRvCd2xgsMsnes2wxfN6pNPjv74rk8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8AxXOm5bXplV+YAAA--.5427S3; Thu, 14 Dec 2023 10:51:37 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxOXOYbXplPIQDAA--.4894S7; Thu, 14 Dec 2023 10:51:37 +0800 (CST) From: Lulu Cai To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, mengqinggang@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lulu Cai Subject: [PATCH v3 3/5] LoongArch: Add tls transition support. Transitions between DESC->IE/LE and IE->LE are supported now. Date: Thu, 14 Dec 2023 10:50:47 +0800 Message-Id: <20231214025049.1629419-4-cailulu@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231214025049.1629419-1-cailulu@loongson.cn> References: <20231214025049.1629419-1-cailulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxOXOYbXplPIQDAA--.4894S7 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAFB2V6Zi0BAAAAsW X-Coremail-Antispam: 1Uk129KBj93XoW3JryUAFykAr4kJw1xWFy8Zwc_yoWfXrWkpr W5Z3yUKF4j9F47W348Ja45Z3WYqrWxWrWxta43trZ0krs7XryrXFsrtr12ya1rGw4vgr9a vrWF9a1Uu3W8A3XCm3ZEXasCq-sJn29KB7ZKAUJUUUUx529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxkF7I0En4kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY 6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6ryUMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU8g6pPUUUUU== X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_STOCKGEN, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785224032711862228 X-GMAIL-MSGID: 1785224032711862228 --- bfd/elfnn-loongarch.c | 216 ++++++++++++++++++++++++++++++++++++- include/opcode/loongarch.h | 6 ++ 2 files changed, 221 insertions(+), 1 deletion(-) diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index b63f42bb6a7..ad94a2a7835 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -145,6 +145,16 @@ struct loongarch_elf_link_hash_table #define elf_backend_rela_normal 1 #define elf_backend_default_execstack 0 +#define IS_LOONGARCH_TLS_DESC_RELOC(R_TYPE) \ + ((R_TYPE) == R_LARCH_TLS_DESC_PC_HI20 \ + || (R_TYPE) == R_LARCH_TLS_DESC_ADD_PC_LO12 \ + || (R_TYPE) == R_LARCH_TLS_DESC_LD \ + || (R_TYPE) == R_LARCH_TLS_DESC_CALL) + +#define IS_LOONGARCH_TLS_IE_RELOC(R_TYPE) \ + ((R_TYPE) == R_LARCH_TLS_IE_PC_HI20 \ + || (R_TYPE) == R_LARCH_TLS_IE_PC_LO12) + /* Generate a PLT header. */ static bool @@ -593,6 +603,10 @@ loongarch_elf_record_tls_and_got_reference (bfd *abfd, char *new_tls_type = &_bfd_loongarch_elf_tls_type (abfd, h, symndx); *new_tls_type |= tls_type; + + /* If a symbol is accessed by both IE and DESC, relax DESC to IE. */ + if ((*new_tls_type & GOT_TLS_IE) && (*new_tls_type & GOT_TLS_GDESC)) + *new_tls_type &= ~ (GOT_TLS_GDESC); if ((*new_tls_type & GOT_NORMAL) && (*new_tls_type & ~GOT_NORMAL)) { _bfd_error_handler (_("%pB: `%s' accessed both as normal and " @@ -605,6 +619,104 @@ loongarch_elf_record_tls_and_got_reference (bfd *abfd, return true; } +static unsigned int +loongarch_reloc_got_type (unsigned int r_type) +{ + switch (r_type) + { + case R_LARCH_TLS_DESC_PC_HI20: + case R_LARCH_TLS_DESC_ADD_PC_LO12: + case R_LARCH_TLS_DESC_LD: + case R_LARCH_TLS_DESC_CALL: + return GOT_TLS_GDESC; + + case R_LARCH_TLS_IE_PC_HI20: + case R_LARCH_TLS_IE_PC_LO12: + return GOT_TLS_IE; + + default: + break; + } + return GOT_UNKNOWN; +} + +/* Return true if tls type transition can be performed. */ +static bool +loongarch_can_relax_tls (struct bfd_link_info *info, unsigned int r_type, + struct elf_link_hash_entry *h, bfd *input_bfd, + unsigned long r_symndx) +{ + char symbol_tls_type; + unsigned int reloc_got_type; + + if (! (IS_LOONGARCH_TLS_DESC_RELOC (r_type) + || IS_LOONGARCH_TLS_IE_RELOC (r_type))) + return false; + + symbol_tls_type = _bfd_loongarch_elf_tls_type (input_bfd, h, r_symndx); + reloc_got_type = loongarch_reloc_got_type (r_type); + + if (symbol_tls_type == GOT_TLS_IE && GOT_TLS_GD_ANY_P (reloc_got_type)) + return true; + + if (! bfd_link_executable (info)) + return false; + + if (h && h->root.type == bfd_link_hash_undefweak) + return false; + + return true; +} + +/* The type of relocation that can be transitioned. */ +static unsigned int +loongarch_tls_transition_without_check (struct bfd_link_info *info, + unsigned int r_type, + struct elf_link_hash_entry *h) +{ + bool local_exec = bfd_link_executable (info) + && SYMBOL_REFERENCES_LOCAL (info, h); + + switch (r_type) + { + case R_LARCH_TLS_DESC_PC_HI20: + return (local_exec + ? R_LARCH_TLS_LE_HI20 + : R_LARCH_TLS_IE_PC_HI20); + + case R_LARCH_TLS_DESC_ADD_PC_LO12: + return (local_exec + ? R_LARCH_TLS_LE_LO12 + : R_LARCH_TLS_IE_PC_LO12); + + case R_LARCH_TLS_DESC_LD: + case R_LARCH_TLS_DESC_CALL: + return R_LARCH_NONE; + + case R_LARCH_TLS_IE_PC_HI20: + return local_exec ? R_LARCH_TLS_LE_HI20 : r_type; + + case R_LARCH_TLS_IE_PC_LO12: + return local_exec ? R_LARCH_TLS_LE_LO12 : r_type; + + default: + break; + } + + return r_type; +} + +static unsigned int +loongarch_tls_transition (struct bfd_link_info *info, unsigned int r_type, + struct elf_link_hash_entry *h, bfd *input_bfd, + unsigned long r_symndx) +{ + if (! loongarch_can_relax_tls (info, r_type, h, input_bfd,r_symndx)) + return r_type; + + return loongarch_tls_transition_without_check (info, r_type, h); +} + /* Look through the relocs for a section during the first phase, and allocate space in the global offset table or procedure linkage table. */ @@ -706,6 +818,7 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, int need_dynreloc = 0; int only_need_pcrel = 0; + r_type = loongarch_tls_transition (info, r_type, h, abfd, r_symndx); switch (r_type) { case R_LARCH_GOT_PC_HI20: @@ -2397,6 +2510,96 @@ loongarch_reloc_is_fatal (struct bfd_link_info *info, relocation += 0x100000000; \ }) +/* Transition instruction sequence to relax instruction sequence. */ +static bool +loongarch_tls_relax (bfd *abfd, asection *sec, Elf_Internal_Rela *rel, + int r_type, struct elf_link_hash_entry *h, + struct bfd_link_info *info) +{ + bool local_exec = bfd_link_executable (info) + && SYMBOL_REFERENCES_LOCAL (info, h); + bfd_byte *contents = elf_section_data (sec)->this_hdr.contents; + unsigned long insn; + + switch (r_type) + { + case R_LARCH_TLS_DESC_PC_HI20: + if (local_exec) + /* DESC -> LE relaxation: + pcalalau12i $a0,%desc_pc_hi20(var) => + lu12i.w $a0,%le_hi20(var) + */ + bfd_put (32, abfd, LARCH_LU12I_W | LARCH_RD_A0, + contents + rel->r_offset); + + /* DESC -> IE relaxation: + pcalalau12i $a0,%desc_pc_hi20(var) => + pcalalau12i $a0,%ie_pc_hi20(var) + */ + return true; + + case R_LARCH_TLS_DESC_ADD_PC_LO12: + if (local_exec) + { + /* DESC -> LE relaxation: + addi.d $a0,$a0,%desc_add_pc_lo12(var) => + ori $a0,$a0,le_lo12(var) + */ + insn = LARCH_ORI | LARCH_RD_RJ_A0; + bfd_put (32, abfd, LARCH_ORI | LARCH_RD_RJ_A0, + contents + rel->r_offset); + } + else + { + /* DESC -> IE relaxation: + addi.d $a0,$a0,%desc_add_pc_lo12(var) => + ld.d $a0,$a0,%%ie_pc_lo12 + */ + bfd_put (32, abfd, LARCH_LD_D | LARCH_RD_RJ_A0, + contents + rel->r_offset); + } + return true; + + case R_LARCH_TLS_DESC_LD: + case R_LARCH_TLS_DESC_CALL: + /* DESC -> LE/IE relaxation: + ld.d $ra,$a0,%desc_ld_pc_lo12(var) => NOP + jirl $ra,$ra,%desc_call(var) => NOP + */ + bfd_put (32, abfd, LARCH_NOP, contents + rel->r_offset); + return true; + + case R_LARCH_TLS_IE_PC_HI20: + if (local_exec) + { + /* IE -> LE relaxation: + pcalalau12i $rd,%ie_pc_hi20(var) => + lu12i.w $rd,%le_hi20(var) + */ + insn = bfd_getl32 (contents + rel->r_offset); + bfd_put (32, abfd, LARCH_LU12I_W | (insn & 0x1f), + contents + rel->r_offset); + } + return true; + + case R_LARCH_TLS_IE_PC_LO12: + if (local_exec) + { + /* IE -> LE relaxation: + ld.d $rd,$rj,%%ie_pc_lo12 => + ori $rd,$rj,le_lo12(var) + */ + insn = bfd_getl32 (contents + rel->r_offset); + bfd_put (32, abfd, LARCH_ORI | (insn & 0x3ff), + contents + rel->r_offset); + } + return true; + } + + return false; +} + + static int loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd, asection *input_section, @@ -2420,7 +2623,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, relend = relocs + input_section->reloc_count; for (rel = relocs; rel < relend; rel++) { - int r_type = ELFNN_R_TYPE (rel->r_info); + unsigned int r_type = ELFNN_R_TYPE (rel->r_info); unsigned long r_symndx = ELFNN_R_SYM (rel->r_info); bfd_vma pc = sec_addr (input_section) + rel->r_offset; reloc_howto_type *howto = NULL; @@ -2430,6 +2633,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, const char *name; bfd_reloc_status_type r = bfd_reloc_ok; bool is_ie, is_desc, is_undefweak, unresolved_reloc, defined_local; + unsigned int relaxed_r_type; bool resolved_local, resolved_dynly, resolved_to_const; char tls_type; bfd_vma relocation, off, ie_off, desc_off; @@ -2561,6 +2765,16 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (!resolved_local || defined_local); + relaxed_r_type = loongarch_tls_transition (info, r_type, h, input_bfd, r_symndx); + if (relaxed_r_type != r_type) + { + howto = loongarch_elf_rtype_to_howto (input_bfd, relaxed_r_type); + BFD_ASSERT (howto != NULL); + + if (loongarch_tls_relax (input_bfd, input_section, rel, r_type, h, info)) + r_type = relaxed_r_type; + } + is_desc = false; is_ie = false; switch (r_type) diff --git a/include/opcode/loongarch.h b/include/opcode/loongarch.h index da936f7945a..32ff4d8a0f1 100644 --- a/include/opcode/loongarch.h +++ b/include/opcode/loongarch.h @@ -42,6 +42,12 @@ extern "C" ((value) < (-(1 << ((bits) - 1) << align)) \ || (value) > ((((1 << ((bits) - 1)) - 1) << align))) + #define LARCH_LU12I_W 0x14000000 + #define LARCH_ORI 0x03800000 + #define LARCH_LD_D 0x28c00000 + #define LARCH_RD_A0 0x04 + #define LARCH_RD_RJ_A0 0x084 + typedef uint32_t insn_t; struct loongarch_opcode From patchwork Thu Dec 14 02:50:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 178426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8284161dys; Wed, 13 Dec 2023 18:52:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IG21Tho5fTbtRBuLiR6wUel+DhI295QMVfY1nSahTVf1fUt5R2bZeWyfgkgQqpNKYSSLj6+ X-Received: by 2002:a05:622a:199e:b0:425:4043:7627 with SMTP id u30-20020a05622a199e00b0042540437627mr12818062qtc.79.1702522344075; Wed, 13 Dec 2023 18:52:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702522344; cv=pass; d=google.com; s=arc-20160816; b=W75PWinQD3vERUdz5ZzYpmJwTlao08146SvFU/iVzBpouO44nhf7DK7xX/Y5g/R78v XjRTfV8STF9p1NBjUjLx2oohKNsnhez0paHQ+65H0iJXXNqSA/JzGfSVdHa+tzpHqkWW 0fv4VJ5ndzN8VXFQwjTkse5ZyNUWL+QhjLBat/GKpHD2iiQ7YG8rfyVxozLD34WeMHaL 7B3BWzgOyGb+iw3IaVZHuqHNQ4wBlFBtPWhW/yZ73k5jVIl1UffW+ngt5e4iIha9kFmC 7DkXITGhp66f1oFF8RMrg+O3Eq/yEuHyzaj+wwDqeWgl5CrQnupkrVGbEu8RTAwDxJPH YBvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=1VsUgtEZgXqdJetXHMDwfRQPscuREgVB3X5Wc5xNyKg=; fh=JHv3E1Q5HC5uFNK+VPYvNdVIokGesZsLfQWJnKT1x3E=; b=Xx0stwNU/PzJByEHPL/XY+P/GyGNnheLh3Fo/GsZaRA6XDTA1nvWfnJ29uRWfBKCRp eS1BhT0il25TuQulUx7mzC+UZbQglRYoVnvdfhyYgS98dEkNHLMBm245pf9I2idBYBtx 9mSRPjMO12pXplYyEx6sadWNMeVygCd8H5rqRgevfcdRonRlwd2TlI83PMebKyB49XRv XMBoqy3ipMmtm9Cnf1Lq2znOKQ5XVWOhXer5Qm+1dFnmUhOfBStPLpB1rpqp5KExSm97 msEH9TvMHABSYR8li8XMG0QW0W2q5czC74NcLO6G188yjDpVI1Dcz5xh4MKi4x5vxI8T SMeA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bs24-20020ac86f18000000b0042378c526a8si15291805qtb.569.2023.12.13.18.52.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 18:52:24 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B6B143861853 for ; Thu, 14 Dec 2023 02:52:20 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 33A6B386181F for ; Thu, 14 Dec 2023 02:51:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33A6B386181F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33A6B386181F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522310; cv=none; b=q21QsSqmJc4TsW9hHh7UDjAxp7yXuVGloURq01tVZzYkTJ1pOmCrzP3EWAOfNB0xfi71CgKfgEFUO0T+r+EwhURYsko4yS2bROsuOyHsJwyJlN5/xo6wphkIfQ6emB3NZ+FHqd8Pws2bnwVF4xOJ5+nzgQiGhKsCkeP2f1zf8Fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522310; c=relaxed/simple; bh=YASdrt4Z0LnyWsDEibbi+k5T/swY15pCVcxC/KEFW8o=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=vfVI+cPmJ7LDAvg4r3nVMiojO7F8JEqjJptFcdp2Gg7DKEPSGjT719oPTbogFdpETDFr02ifTr2zy2YYd8HgEkEyYxw5bVo2OfJPMSrertB6QittfXqvCHcbg+5X5hadjZ1rVPu6jiIrhppoZ/smV1yT7QezzulwJU/6szP9gzM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8BxbOm9bXplXOYAAA--.5171S3; Thu, 14 Dec 2023 10:51:41 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxOXOYbXplPIQDAA--.4894S8; Thu, 14 Dec 2023 10:51:41 +0800 (CST) From: Lulu Cai To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, mengqinggang@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn Subject: [PATCH v3 4/5] LoongArch: TLS LD/GD/DESC relaxation. Date: Thu, 14 Dec 2023 10:50:48 +0800 Message-Id: <20231214025049.1629419-5-cailulu@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231214025049.1629419-1-cailulu@loongson.cn> References: <20231214025049.1629419-1-cailulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxOXOYbXplPIQDAA--.4894S8 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAFB2V6Zi0BAgAAsU X-Coremail-Antispam: 1Uk129KBj9fXoWDWF1fWw1UJF4UAF1xCF43XFc_yoW7ZFWrAo W8Za40y3Z3Ka9rt39xJF17X3WDAryDGFySkFnagw1Utw1UKw1Fqr4ayF4SyFs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ATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785224069412944136 X-GMAIL-MSGID: 1785224069412944136 From: mengqinggang --- bfd/bfd-in2.h | 3 + bfd/elfnn-loongarch.c | 131 +++++- bfd/elfxx-loongarch.c | 54 +++ bfd/libbfd.h | 3 + bfd/reloc.c | 7 + gas/config/tc-loongarch.c | 6 +- gas/testsuite/gas/loongarch/macro_op.d | 128 +++--- gas/testsuite/gas/loongarch/macro_op_32.d | 120 +++--- .../gas/loongarch/macro_op_large_abs.d | 160 +++---- .../gas/loongarch/macro_op_large_pc.d | 160 +++---- include/elf/loongarch.h | 4 + ld/testsuite/ld-loongarch-elf/macro_op.d | 391 +++++++++--------- ld/testsuite/ld-loongarch-elf/macro_op_32.d | 120 +++--- 13 files changed, 748 insertions(+), 539 deletions(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index d3557a4fd74..6d666ac2b1c 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7472,6 +7472,9 @@ enum bfd_reloc_code_real BFD_RELOC_LARCH_TLS_DESC64_LO20, BFD_RELOC_LARCH_TLS_DESC64_HI12, BFD_RELOC_LARCH_TLS_DESC_CALL, + BFD_RELOC_LARCH_TLS_LD_PCREL20_S2, + BFD_RELOC_LARCH_TLS_GD_PCREL20_S2, + BFD_RELOC_LARCH_TLS_DESC_PCREL20_S2, BFD_RELOC_UNUSED }; typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index ad94a2a7835..dba2d151501 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -2279,7 +2279,9 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section, case R_LARCH_TLS_DESC_LO12: case R_LARCH_TLS_DESC64_LO20: case R_LARCH_TLS_DESC64_HI12: - + case R_LARCH_TLS_LD_PCREL20_S2: + case R_LARCH_TLS_GD_PCREL20_S2: + case R_LARCH_TLS_DESC_PCREL20_S2: r = loongarch_check_offset (rel, input_section); if (r != bfd_reloc_ok) break; @@ -3667,6 +3669,9 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, case R_LARCH_TLS_GD_HI20: case R_LARCH_TLS_DESC_PC_HI20: case R_LARCH_TLS_DESC_HI20: + case R_LARCH_TLS_LD_PCREL20_S2: + case R_LARCH_TLS_GD_PCREL20_S2: + case R_LARCH_TLS_DESC_PCREL20_S2: BFD_ASSERT (rel->r_addend == 0); unresolved_reloc = false; @@ -3675,7 +3680,8 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, is_ie = true; if (r_type == R_LARCH_TLS_DESC_PC_HI20 - || r_type == R_LARCH_TLS_DESC_HI20) + || r_type == R_LARCH_TLS_DESC_HI20 + || r_type == R_LARCH_TLS_DESC_PCREL20_S2) is_desc = true; bfd_vma got_off = 0; @@ -3806,7 +3812,11 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, || r_type == R_LARCH_TLS_IE_PC_HI20 || r_type == R_LARCH_TLS_DESC_PC_HI20) RELOCATE_CALC_PC32_HI20 (relocation, pc); - + else if (r_type == R_LARCH_TLS_LD_PCREL20_S2 + || r_type == R_LARCH_TLS_GD_PCREL20_S2 + || r_type == R_LARCH_TLS_DESC_PCREL20_S2) + relocation -= pc; + /*else {} ABS relocations. */ break; case R_LARCH_TLS_DESC_ADD_PC_LO12: @@ -4228,6 +4238,84 @@ loongarch_relax_align (bfd *abfd, asection *sec, rel->r_addend - nop_bytes, link_info); } +static bool +loongarch_relax_tls_ld_gd_desc (bfd *abfd, asection *sec, asection *sym_sec, + Elf_Internal_Rela *rel_hi, bfd_vma symval, + struct bfd_link_info *info, bool *again) +{ + bfd_byte *contents = elf_section_data (sec)->this_hdr.contents; + Elf_Internal_Rela *rel_lo = rel_hi + 2; + uint32_t pca = bfd_get (32, abfd, contents + rel_hi->r_offset); + uint32_t add = bfd_get (32, abfd, contents + rel_lo->r_offset); + uint32_t rd = pca & 0x1f; + + /* This section's output_offset need to subtract the bytes of instructions + relaxed by the previous sections, so it needs to be updated beforehand. + size_input_section already took care of updating it after relaxation, + so we additionally update once here. */ + sec->output_offset = sec->output_section->size; + bfd_vma pc = sec_addr (sec) + rel_hi->r_offset; + + /* If pc and symbol not in the same segment, add/sub segment alignment. + FIXME: if there are multiple readonly segments? */ + if (!(sym_sec->flags & SEC_READONLY)) + { + if (symval > pc) + pc -= info->maxpagesize; + else if (symval < pc) + pc += info->maxpagesize; + } + + const uint32_t addi_d = 0x02c00000; + const uint32_t pcaddi = 0x18000000; + + /* Is pcalau12i + addi.d insns? */ + if ((ELFNN_R_TYPE (rel_lo->r_info) != R_LARCH_GOT_PC_LO12 + && ELFNN_R_TYPE (rel_lo->r_info) != R_LARCH_TLS_DESC_ADD_PC_LO12) + || (ELFNN_R_TYPE ((rel_lo + 1)->r_info) != R_LARCH_RELAX) + || (ELFNN_R_TYPE ((rel_hi + 1)->r_info) != R_LARCH_RELAX) + || (rel_hi->r_offset + 4 != rel_lo->r_offset) + || ((add & addi_d) != addi_d) + /* Is pcalau12i $rd + addi.d $rd,$rd? */ + || ((add & 0x1f) != rd) + || (((add >> 5) & 0x1f) != rd) + /* Can be relaxed to pcaddi? */ + || (symval & 0x3) /* 4 bytes align. */ + || ((bfd_signed_vma)(symval - pc) < (bfd_signed_vma)(int32_t)0xffe00000) + || ((bfd_signed_vma)(symval - pc) > (bfd_signed_vma)(int32_t)0x1ffffc)) + return false; + + /* Continue next relax trip. */ + *again = true; + + pca = pcaddi | rd; + bfd_put (32, abfd, pca, contents + rel_hi->r_offset); + + /* Adjust relocations. */ + switch (ELFNN_R_TYPE (rel_hi->r_info)) + { + case R_LARCH_TLS_LD_PC_HI20: + rel_hi->r_info = ELFNN_R_INFO (ELFNN_R_SYM (rel_hi->r_info), + R_LARCH_TLS_LD_PCREL20_S2); + break; + case R_LARCH_TLS_GD_PC_HI20: + rel_hi->r_info = ELFNN_R_INFO (ELFNN_R_SYM (rel_hi->r_info), + R_LARCH_TLS_GD_PCREL20_S2); + break; + case R_LARCH_TLS_DESC_PC_HI20: + rel_hi->r_info = ELFNN_R_INFO (ELFNN_R_SYM (rel_hi->r_info), + R_LARCH_TLS_DESC_PCREL20_S2); + break; + default: + break; + } + rel_lo->r_info = ELFNN_R_INFO (0, R_LARCH_NONE); + + loongarch_relax_delete_bytes (abfd, sec, rel_lo->r_offset, 4, info); + + return true; +} + static bool loongarch_elf_relax_section (bfd *abfd, asection *sec, struct bfd_link_info *info, @@ -4272,13 +4360,14 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec, for (unsigned int i = 0; i < sec->reloc_count; i++) { - Elf_Internal_Rela *rel = relocs + i; - asection *sym_sec; + char symtype; bfd_vma symval; - unsigned long r_symndx = ELFNN_R_SYM (rel->r_info); + asection *sym_sec; bool local_got = false; - char symtype; + Elf_Internal_Rela *rel = relocs + i; struct elf_link_hash_entry *h = NULL; + unsigned long r_type = ELFNN_R_TYPE (rel->r_info); + unsigned long r_symndx = ELFNN_R_SYM (rel->r_info); if (r_symndx < symtab_hdr->sh_info) { @@ -4347,7 +4436,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec, symval += sec_addr (sym_sec); - switch (ELFNN_R_TYPE (rel->r_info)) + switch (r_type) { case R_LARCH_ALIGN: if (1 == info->relax_pass) @@ -4374,6 +4463,32 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec, info, again); } break; + + case R_LARCH_TLS_LD_PC_HI20: + if (0 == info->relax_pass && (i + 4) <= sec->reloc_count) + loongarch_relax_tls_ld_gd_desc (abfd, sec, sym_sec, rel, symval, + info, again); + break; + + case R_LARCH_TLS_GD_PC_HI20: + if (0 == info->relax_pass && (i + 4) <= sec->reloc_count) + loongarch_relax_tls_ld_gd_desc (abfd, sec, sym_sec, rel, symval, + info, again); + break; + + case R_LARCH_TLS_DESC_PC_HI20: + if (0 == info->relax_pass + && (i + 4) <= sec->reloc_count + && !loongarch_can_relax_tls (info, r_type, h, abfd, r_symndx)) + { + char tls_type = _bfd_loongarch_elf_tls_type (abfd, h, r_symndx); + if (GOT_TLS_GD_BOTH_P (tls_type)) + symval += 2 * GOT_ENTRY_SIZE; + loongarch_relax_tls_ld_gd_desc (abfd, sec, sym_sec, rel, symval, + info, again); + } + break; + default: break; } diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c index 819c4849ef5..ab930e58aec 100644 --- a/bfd/elfxx-loongarch.c +++ b/bfd/elfxx-loongarch.c @@ -1754,6 +1754,60 @@ static loongarch_reloc_howto_type loongarch_howto_table[] = BFD_RELOC_LARCH_TLS_DESC_CALL, /* bfd_reloc_code_real_type. */ NULL, /* adjust_reloc_bits. */ "desc_call"), /* larch_reloc_type_name. */ + + /* For pcaddi, ld_pc_hi20 + ld_pc_lo12 can relax to ld_pcrel20_s2. */ + LOONGARCH_HOWTO (R_LARCH_TLS_LD_PCREL20_S2, /* type (121). */ + 2, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + false, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_LD_PCREL20_S2", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_LD_PCREL20_S2, /* bfd_reloc_code_real_type. */ + reloc_sign_bits, /* adjust_reloc_bits. */ + "ld_pcrel_20"), /* larch_reloc_type_name. */ + + /* For pcaddi, gd_pc_hi20 + gd_pc_lo12 can relax to gd_pcrel20_s2. */ + LOONGARCH_HOWTO (R_LARCH_TLS_GD_PCREL20_S2, /* type (122). */ + 2, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + false, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_GD_PCREL20_S2", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_GD_PCREL20_S2, /* bfd_reloc_code_real_type. */ + reloc_sign_bits, /* adjust_reloc_bits. */ + "gd_pcrel_20"), /* larch_reloc_type_name. */ + + /* For pcaddi, desc_pc_hi20 + desc_pc_lo12 can relax to desc_pcrel20_s2. */ + LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PCREL20_S2, /* type (123). */ + 2, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + false, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_DESC_PCREL20_S2", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_DESC_PCREL20_S2, /* bfd_reloc_code_real_type. */ + reloc_sign_bits, /* adjust_reloc_bits. */ + "desc_pcrel_20"), /* larch_reloc_type_name. */ }; reloc_howto_type * diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 6ee021e84b5..6151eec50a2 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -3611,6 +3611,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_LARCH_TLS_DESC64_LO20", "BFD_RELOC_LARCH_TLS_DESC64_HI12", "BFD_RELOC_LARCH_TLS_DESC_CALL", + "BFD_RELOC_LARCH_TLS_LD_PCREL20_S2", + "BFD_RELOC_LARCH_TLS_GD_PCREL20_S2", + "BFD_RELOC_LARCH_TLS_DESC_PCREL20_S2", "@@overflow: BFD_RELOC_UNUSED@@", }; #endif diff --git a/bfd/reloc.c b/bfd/reloc.c index 0e354ef4b80..aa0575ad839 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -8321,6 +8321,13 @@ ENUMX ENUMX BFD_RELOC_LARCH_TLS_DESC_CALL +ENUMX + BFD_RELOC_LARCH_TLS_LD_PCREL20_S2 +ENUMX + BFD_RELOC_LARCH_TLS_GD_PCREL20_S2 +ENUMX + BFD_RELOC_LARCH_TLS_DESC_PCREL20_S2 + ENUMDOC LARCH relocations. diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index e1d5453b14f..a14c23fb45b 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -694,7 +694,11 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2, && (BFD_RELOC_LARCH_PCALA_HI20 == reloc_type || BFD_RELOC_LARCH_PCALA_LO12 == reloc_type || BFD_RELOC_LARCH_GOT_PC_HI20 == reloc_type - || BFD_RELOC_LARCH_GOT_PC_LO12 == reloc_type)) + || BFD_RELOC_LARCH_GOT_PC_LO12 == reloc_type + || BFD_RELOC_LARCH_TLS_LD_PC_HI20 == reloc_type + || BFD_RELOC_LARCH_TLS_GD_PC_HI20 == reloc_type + || BFD_RELOC_LARCH_TLS_DESC_PC_HI20 == reloc_type + || BFD_RELOC_LARCH_TLS_DESC_ADD_PC_LO12 == reloc_type)) { ip->reloc_info[ip->reloc_num].type = BFD_RELOC_LARCH_RELAX; ip->reloc_info[ip->reloc_num].value = const_0; diff --git a/gas/testsuite/gas/loongarch/macro_op.d b/gas/testsuite/gas/loongarch/macro_op.d index 32860864704..47f8f45c663 100644 --- a/gas/testsuite/gas/loongarch/macro_op.d +++ b/gas/testsuite/gas/loongarch/macro_op.d @@ -2,70 +2,72 @@ #objdump: -dr #skip: loongarch32-*-* -.*:[ ]+file format .* +.*: file format .* Disassembly of section .text: -00000000.* <.text>: -[ ]+0:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+4:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+8:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+c:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+10:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+10:[ ]+R_LARCH_GOT_PC_HI20[ ]+\.L1 -[ ]+10:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+14:[ ]+28c00084[ ]+ld\.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+14:[ ]+R_LARCH_GOT_PC_LO12[ ]+\.L1 -[ ]+14:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+18:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+18:[ ]+R_LARCH_GOT_PC_HI20[ ]+\.L1 -[ ]+18:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+1c:[ ]+28c00084[ ]+ld\.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+1c:[ ]+R_LARCH_GOT_PC_LO12[ ]+\.L1 -[ ]+1c:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+20:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+20:[ ]+R_LARCH_PCALA_HI20[ ]+\.L1 -[ ]+20:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+24:[ ]+02c00084[ ]+addi\.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+24:[ ]+R_LARCH_PCALA_LO12[ ]+\.L1 -[ ]+24:[ ]+R_LARCH_RELAX[ ]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,[ ]+0x0 -[ ]+4c:[ ]+R_LARCH_TLS_LE_LO12[ ]+TLS1 -[ ]+50:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+50:[ ]+R_LARCH_TLS_IE_PC_HI20[ ]+TLS1 -[ ]+54:[ ]+28c00084[ ]+ld\.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+54:[ ]+R_LARCH_TLS_IE_PC_LO12[ ]+TLS1 -[ ]+58:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+58:[ ]+R_LARCH_TLS_LD_PC_HI20[ ]+TLS1 -[ ]+5c:[ ]+02c00084[ ]+addi\.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+5c:[ ]+R_LARCH_GOT_PC_LO12[ ]+TLS1 -[ ]+5c:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+60:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+60:[ ]+R_LARCH_TLS_GD_PC_HI20[ ]+TLS1 -[ ]+64:[ ]+02c00084[ ]+addi\.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+64:[ ]+R_LARCH_GOT_PC_LO12[ ]+TLS1 -[ ]+64:[ ]+R_LARCH_RELAX[ ]+\*ABS\* +0+ <.*>: + 0: 00150004 move \$a0, \$zero + 4: 02bffc04 li.w \$a0, -1 + 8: 00150004 move \$a0, \$zero + c: 02bffc04 li.w \$a0, -1 + 10: 1a000004 pcalau12i \$a0, 0 + 10: R_LARCH_GOT_PC_HI20 .L1 + 10: R_LARCH_RELAX \*ABS\* + 14: 28c00084 ld.d \$a0, \$a0, 0 + 14: R_LARCH_GOT_PC_LO12 .L1 + 14: R_LARCH_RELAX \*ABS\* + 18: 1a000004 pcalau12i \$a0, 0 + 18: R_LARCH_GOT_PC_HI20 .L1 + 18: R_LARCH_RELAX \*ABS\* + 1c: 28c00084 ld.d \$a0, \$a0, 0 + 1c: R_LARCH_GOT_PC_LO12 .L1 + 1c: R_LARCH_RELAX \*ABS\* + 20: 1a000004 pcalau12i \$a0, 0 + 20: R_LARCH_PCALA_HI20 .L1 + 20: R_LARCH_RELAX \*ABS\* + 24: 02c00084 addi.d \$a0, \$a0, 0 + 24: R_LARCH_PCALA_LO12 .L1 + 24: R_LARCH_RELAX \*ABS\* + 28: 14000004 lu12i.w \$a0, 0 + 28: R_LARCH_MARK_LA \*ABS\* + 28: R_LARCH_ABS_HI20 .L1 + 2c: 03800084 ori \$a0, \$a0, 0x0 + 2c: R_LARCH_ABS_LO12 .L1 + 30: 16000004 lu32i.d \$a0, 0 + 30: R_LARCH_ABS64_LO20 .L1 + 34: 03000084 lu52i.d \$a0, \$a0, 0 + 34: R_LARCH_ABS64_HI12 .L1 + 38: 1a000004 pcalau12i \$a0, 0 + 38: R_LARCH_PCALA_HI20 .L1 + 38: R_LARCH_RELAX \*ABS\* + 3c: 02c00084 addi.d \$a0, \$a0, 0 + 3c: R_LARCH_PCALA_LO12 .L1 + 3c: R_LARCH_RELAX \*ABS\* + 40: 1a000004 pcalau12i \$a0, 0 + 40: R_LARCH_GOT_PC_HI20 .L1 + 40: R_LARCH_RELAX \*ABS\* + 44: 28c00084 ld.d \$a0, \$a0, 0 + 44: R_LARCH_GOT_PC_LO12 .L1 + 44: R_LARCH_RELAX \*ABS\* + 48: 14000004 lu12i.w \$a0, 0 + 48: R_LARCH_TLS_LE_HI20 TLS1 + 4c: 03800084 ori \$a0, \$a0, 0x0 + 4c: R_LARCH_TLS_LE_LO12 TLS1 + 50: 1a000004 pcalau12i \$a0, 0 + 50: R_LARCH_TLS_IE_PC_HI20 TLS1 + 54: 28c00084 ld.d \$a0, \$a0, 0 + 54: R_LARCH_TLS_IE_PC_LO12 TLS1 + 58: 1a000004 pcalau12i \$a0, 0 + 58: R_LARCH_TLS_LD_PC_HI20 TLS1 + 58: R_LARCH_RELAX \*ABS\* + 5c: 02c00084 addi.d \$a0, \$a0, 0 + 5c: R_LARCH_GOT_PC_LO12 TLS1 + 5c: R_LARCH_RELAX \*ABS\* + 60: 1a000004 pcalau12i \$a0, 0 + 60: R_LARCH_TLS_GD_PC_HI20 TLS1 + 60: R_LARCH_RELAX \*ABS\* + 64: 02c00084 addi.d \$a0, \$a0, 0 + 64: R_LARCH_GOT_PC_LO12 TLS1 + 64: R_LARCH_RELAX \*ABS\* diff --git a/gas/testsuite/gas/loongarch/macro_op_32.d b/gas/testsuite/gas/loongarch/macro_op_32.d index 188026a5780..a7349aa8dc0 100644 --- a/gas/testsuite/gas/loongarch/macro_op_32.d +++ b/gas/testsuite/gas/loongarch/macro_op_32.d @@ -2,66 +2,68 @@ #objdump: -dr #skip: loongarch64-*-* -.*:[ ]+file format .* +.*: file format .* Disassembly of section .text: -00000000.* <.L1>: -[ ]+0:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+4:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+8:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+c:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+10:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+10:[ ]+R_LARCH_GOT_PC_HI20[ ]+.L1 -[ ]+10:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+14:[ ]+28800084[ ]+ld.w[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+14:[ ]+R_LARCH_GOT_PC_LO12[ ]+.L1 -[ ]+14:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+18:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+18:[ ]+R_LARCH_GOT_PC_HI20[ ]+.L1 -[ ]+18:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+1c:[ ]+28800084[ ]+ld.w[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+1c:[ ]+R_LARCH_GOT_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0, 0 + 18: R_LARCH_GOT_PC_HI20 .L1 + 18: R_LARCH_RELAX \*ABS\* + 1c: 28800084 ld.w \$a0, \$a0, 0 + 1c: R_LARCH_GOT_PC_LO12 .L1 + 1c: R_LARCH_RELAX \*ABS\* + 20: 1a000004 pcalau12i \$a0, 0 + 20: R_LARCH_PCALA_HI20 .L1 + 20: R_LARCH_RELAX \*ABS\* + 24: 02800084 addi.w \$a0, \$a0, 0 + 24: R_LARCH_PCALA_LO12 .L1 + 24: R_LARCH_RELAX \*ABS\* + 28: 14000004 lu12i.w \$a0, 0 + 28: R_LARCH_MARK_LA \*ABS\* + 28: R_LARCH_ABS_HI20 .L1 + 2c: 03800084 ori \$a0, \$a0, 0x0 + 2c: R_LARCH_ABS_LO12 .L1 + 30: 1a000004 pcalau12i \$a0, 0 + 30: R_LARCH_PCALA_HI20 .L1 + 30: R_LARCH_RELAX \*ABS\* + 34: 02800084 addi.w \$a0, \$a0, 0 + 34: R_LARCH_PCALA_LO12 .L1 + 34: R_LARCH_RELAX \*ABS\* + 38: 1a000004 pcalau12i \$a0, 0 + 38: R_LARCH_GOT_PC_HI20 .L1 + 38: R_LARCH_RELAX \*ABS\* + 3c: 28800084 ld.w \$a0, \$a0, 0 + 3c: R_LARCH_GOT_PC_LO12 .L1 + 3c: R_LARCH_RELAX \*ABS\* + 40: 14000004 lu12i.w \$a0, 0 + 40: R_LARCH_TLS_LE_HI20 TLS1 + 44: 03800084 ori \$a0, \$a0, 0x0 + 44: R_LARCH_TLS_LE_LO12 TLS1 + 48: 1a000004 pcalau12i \$a0, 0 + 48: R_LARCH_TLS_IE_PC_HI20 TLS1 + 4c: 28800084 ld.w \$a0, \$a0, 0 + 4c: R_LARCH_TLS_IE_PC_LO12 TLS1 + 50: 1a000004 pcalau12i \$a0, 0 + 50: R_LARCH_TLS_LD_PC_HI20 TLS1 + 50: R_LARCH_RELAX \*ABS\* + 54: 02800084 addi.w \$a0, \$a0, 0 + 54: R_LARCH_GOT_PC_LO12 TLS1 + 54: R_LARCH_RELAX \*ABS\* + 58: 1a000004 pcalau12i \$a0, 0 + 58: R_LARCH_TLS_GD_PC_HI20 TLS1 + 58: R_LARCH_RELAX \*ABS\* + 5c: 02800084 addi.w \$a0, \$a0, 0 + 5c: R_LARCH_GOT_PC_LO12 TLS1 + 5c: R_LARCH_RELAX \*ABS\* diff --git a/gas/testsuite/gas/loongarch/macro_op_large_abs.d b/gas/testsuite/gas/loongarch/macro_op_large_abs.d index 0c49f68e2ab..729e878ffb8 100644 --- a/gas/testsuite/gas/loongarch/macro_op_large_abs.d +++ b/gas/testsuite/gas/loongarch/macro_op_large_abs.d @@ -1,85 +1,89 @@ -#as: -mla-global-with-abs +#as: #objdump: -dr #skip: loongarch32-*-* -.*:[ ]+file format .* +.*: file format .* Disassembly of section .text: -00000000.* <.L1>: -[ ]+0:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+0:[ ]+R_LARCH_PCALA_HI20[ ]+.L1 -[ ]+0:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+4:[ ]+02c00005[ ]+li\.d[ ]+\$a1,[ ]+0 -[ ]+4:[ ]+R_LARCH_PCALA_LO12[ ]+.L1 -[ ]+4:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+8:[ ]+16000005[ ]+lu32i.d[ ]+\$a1,[ ]+0 -[ ]+8:[ ]+R_LARCH_PCALA64_LO20[ ]+.L1 -[ ]+c:[ ]+030000a5[ ]+lu52i.d[ ]+\$a1,[ ]+\$a1,[ ]+0 -[ ]+c:[ ]+R_LARCH_PCALA64_HI12[ ]+.L1 -[ ]+10:[ ]+00109484[ ]+add.d[ ]+\$a0,[ ]+\$a0,[ ]+\$a1 -[ ]+14:[ ]+14000004[ ]+lu12i.w[ ]+\$a0,[ ]+0 -[ ]+14:[ ]+R_LARCH_MARK_LA[ ]+\*ABS\* -[ ]+14:[ ]+R_LARCH_ABS_HI20[ ]+.L1 -[ ]+18:[ ]+03800084[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 ]+R_LARCH_GOT64_PC_LO20[ ]+TLS1 -[ ]+74:[ ]+030000a5[ ]+lu52i.d[ ]+\$a1,[ ]+\$a1,[ ]+0 -[ ]+74:[ ]+R_LARCH_GOT64_PC_HI12[ ]+TLS1 -[ ]+78:[ ]+00109484[ ]+add.d[ ]+\$a0,[ ]+\$a0,[ ]+\$a1 -[ ]+7c:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+7c:[ ]+R_LARCH_TLS_GD_PC_HI20[ ]+TLS1 -[ ]+80:[ ]+02c00005[ ]+li\.d[ ]+\$a1,[ ]+0 -[ ]+80:[ ]+R_LARCH_GOT_PC_LO12[ ]+TLS1 -[ ]+80:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+84:[ ]+16000005[ ]+lu32i.d[ ]+\$a1,[ ]+0 -[ ]+84:[ ]+R_LARCH_GOT64_PC_LO20[ ]+TLS1 -[ ]+88:[ ]+030000a5[ ]+lu52i.d[ ]+\$a1,[ ]+\$a1,[ ]+0 -[ ]+88:[ ]+R_LARCH_GOT64_PC_HI12[ ]+TLS1 -[ ]+8c:[ ]+00109484[ ]+add.d[ ]+\$a0,[ ]+\$a0,[ ]+\$a1 +0+ <.L1>: + 0: 1a000004 pcalau12i \$a0, 0 + 0: R_LARCH_PCALA_HI20 .L1 + 0: R_LARCH_RELAX \*ABS\* + 4: 02c00005 li.d \$a1, 0 + 4: R_LARCH_PCALA_LO12 .L1 + 4: R_LARCH_RELAX \*ABS\* + 8: 16000005 lu32i.d \$a1, 0 + 8: R_LARCH_PCALA64_LO20 .L1 + c: 030000a5 lu52i.d \$a1, \$a1, 0 + c: R_LARCH_PCALA64_HI12 .L1 + 10: 00109484 add.d \$a0, \$a0, \$a1 + 14: 1a000004 pcalau12i \$a0, 0 + 14: R_LARCH_GOT_PC_HI20 .L1 + 14: R_LARCH_RELAX \*ABS\* + 18: 02c00005 li.d \$a1, 0 + 18: R_LARCH_GOT_PC_LO12 .L1 + 18: R_LARCH_RELAX \*ABS\* + 1c: 16000005 lu32i.d \$a1, 0 + 1c: R_LARCH_GOT64_PC_LO20 .L1 + 20: 030000a5 lu52i.d \$a1, \$a1, 0 + 20: R_LARCH_GOT64_PC_HI12 .L1 + 24: 380c1484 ldx.d \$a0, \$a0, \$a1 + 28: 1a000004 pcalau12i \$a0, 0 + 28: R_LARCH_PCALA_HI20 .L1 + 28: R_LARCH_RELAX \*ABS\* + 2c: 02c00005 li.d \$a1, 0 + 2c: R_LARCH_PCALA_LO12 .L1 + 2c: R_LARCH_RELAX \*ABS\* + 30: 16000005 lu32i.d \$a1, 0 + 30: R_LARCH_PCALA64_LO20 .L1 + 34: 030000a5 lu52i.d \$a1, \$a1, 0 + 34: R_LARCH_PCALA64_HI12 .L1 + 38: 00109484 add.d \$a0, \$a0, \$a1 + 3c: 1a000004 pcalau12i \$a0, 0 + 3c: R_LARCH_GOT_PC_HI20 .L1 + 3c: R_LARCH_RELAX \*ABS\* + 40: 02c00005 li.d \$a1, 0 + 40: R_LARCH_GOT_PC_LO12 .L1 + 40: R_LARCH_RELAX \*ABS\* + 44: 16000005 lu32i.d \$a1, 0 + 44: R_LARCH_GOT64_PC_LO20 .L1 + 48: 030000a5 lu52i.d \$a1, \$a1, 0 + 48: R_LARCH_GOT64_PC_HI12 .L1 + 4c: 380c1484 ldx.d \$a0, \$a0, \$a1 + 50: 14000004 lu12i.w \$a0, 0 + 50: R_LARCH_TLS_LE_HI20 TLS1 + 54: 03800084 ori \$a0, \$a0, 0x0 + 54: R_LARCH_TLS_LE_LO12 TLS1 + 58: 1a000004 pcalau12i \$a0, 0 + 58: R_LARCH_TLS_IE_PC_HI20 TLS1 + 5c: 02c00005 li.d \$a1, 0 + 5c: R_LARCH_TLS_IE_PC_LO12 TLS1 + 60: 16000005 lu32i.d \$a1, 0 + 60: R_LARCH_TLS_IE64_PC_LO20 TLS1 + 64: 030000a5 lu52i.d \$a1, \$a1, 0 + 64: R_LARCH_TLS_IE64_PC_HI12 TLS1 + 68: 380c1484 ldx.d \$a0, \$a0, \$a1 + 6c: 1a000004 pcalau12i \$a0, 0 + 6c: R_LARCH_TLS_LD_PC_HI20 TLS1 + 6c: R_LARCH_RELAX \*ABS\* + 70: 02c00005 li.d \$a1, 0 + 70: R_LARCH_GOT_PC_LO12 TLS1 + 70: R_LARCH_RELAX \*ABS\* + 74: 16000005 lu32i.d \$a1, 0 + 74: R_LARCH_GOT64_PC_LO20 TLS1 + 78: 030000a5 lu52i.d \$a1, \$a1, 0 + 78: R_LARCH_GOT64_PC_HI12 TLS1 + 7c: 00109484 add.d \$a0, \$a0, \$a1 + 80: 1a000004 pcalau12i \$a0, 0 + 80: R_LARCH_TLS_GD_PC_HI20 TLS1 + 80: R_LARCH_RELAX \*ABS\* + 84: 02c00005 li.d \$a1, 0 + 84: R_LARCH_GOT_PC_LO12 TLS1 + 84: R_LARCH_RELAX \*ABS\* + 88: 16000005 lu32i.d \$a1, 0 + 88: R_LARCH_GOT64_PC_LO20 TLS1 + 8c: 030000a5 lu52i.d \$a1, \$a1, 0 + 8c: R_LARCH_GOT64_PC_HI12 TLS1 + 90: 00109484 add.d \$a0, \$a0, \$a1 diff --git a/gas/testsuite/gas/loongarch/macro_op_large_pc.d b/gas/testsuite/gas/loongarch/macro_op_large_pc.d index 0c49f68e2ab..729e878ffb8 100644 --- a/gas/testsuite/gas/loongarch/macro_op_large_pc.d +++ b/gas/testsuite/gas/loongarch/macro_op_large_pc.d @@ -1,85 +1,89 @@ -#as: -mla-global-with-abs +#as: #objdump: -dr #skip: loongarch32-*-* -.*:[ ]+file format .* +.*: file format .* Disassembly of section .text: -00000000.* <.L1>: -[ ]+0:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+0:[ ]+R_LARCH_PCALA_HI20[ ]+.L1 -[ ]+0:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+4:[ ]+02c00005[ ]+li\.d[ ]+\$a1,[ ]+0 -[ ]+4:[ ]+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]+\$a0,[ ]+\$a0,[ ]+\$a1 +0+ <.L1>: + 0: 1a000004 pcalau12i \$a0, 0 + 0: R_LARCH_PCALA_HI20 .L1 + 0: R_LARCH_RELAX \*ABS\* + 4: 02c00005 li.d \$a1, 0 + 4: R_LARCH_PCALA_LO12 .L1 + 4: R_LARCH_RELAX \*ABS\* + 8: 16000005 lu32i.d \$a1, 0 + 8: R_LARCH_PCALA64_LO20 .L1 + c: 030000a5 lu52i.d \$a1, \$a1, 0 + c: R_LARCH_PCALA64_HI12 .L1 + 10: 00109484 add.d \$a0, \$a0, \$a1 + 14: 1a000004 pcalau12i \$a0, 0 + 14: R_LARCH_GOT_PC_HI20 .L1 + 14: R_LARCH_RELAX \*ABS\* + 18: 02c00005 li.d \$a1, 0 + 18: R_LARCH_GOT_PC_LO12 .L1 + 18: R_LARCH_RELAX \*ABS\* + 1c: 16000005 lu32i.d \$a1, 0 + 1c: R_LARCH_GOT64_PC_LO20 .L1 + 20: 030000a5 lu52i.d \$a1, \$a1, 0 + 20: R_LARCH_GOT64_PC_HI12 .L1 + 24: 380c1484 ldx.d \$a0, \$a0, \$a1 + 28: 1a000004 pcalau12i \$a0, 0 + 28: R_LARCH_PCALA_HI20 .L1 + 28: R_LARCH_RELAX \*ABS\* + 2c: 02c00005 li.d \$a1, 0 + 2c: R_LARCH_PCALA_LO12 .L1 + 2c: R_LARCH_RELAX \*ABS\* + 30: 16000005 lu32i.d \$a1, 0 + 30: R_LARCH_PCALA64_LO20 .L1 + 34: 030000a5 lu52i.d \$a1, \$a1, 0 + 34: R_LARCH_PCALA64_HI12 .L1 + 38: 00109484 add.d \$a0, \$a0, \$a1 + 3c: 1a000004 pcalau12i \$a0, 0 + 3c: R_LARCH_GOT_PC_HI20 .L1 + 3c: R_LARCH_RELAX \*ABS\* + 40: 02c00005 li.d \$a1, 0 + 40: R_LARCH_GOT_PC_LO12 .L1 + 40: R_LARCH_RELAX \*ABS\* + 44: 16000005 lu32i.d \$a1, 0 + 44: R_LARCH_GOT64_PC_LO20 .L1 + 48: 030000a5 lu52i.d \$a1, \$a1, 0 + 48: R_LARCH_GOT64_PC_HI12 .L1 + 4c: 380c1484 ldx.d \$a0, \$a0, \$a1 + 50: 14000004 lu12i.w \$a0, 0 + 50: R_LARCH_TLS_LE_HI20 TLS1 + 54: 03800084 ori \$a0, \$a0, 0x0 + 54: R_LARCH_TLS_LE_LO12 TLS1 + 58: 1a000004 pcalau12i \$a0, 0 + 58: R_LARCH_TLS_IE_PC_HI20 TLS1 + 5c: 02c00005 li.d \$a1, 0 + 5c: R_LARCH_TLS_IE_PC_LO12 TLS1 + 60: 16000005 lu32i.d \$a1, 0 + 60: R_LARCH_TLS_IE64_PC_LO20 TLS1 + 64: 030000a5 lu52i.d \$a1, \$a1, 0 + 64: R_LARCH_TLS_IE64_PC_HI12 TLS1 + 68: 380c1484 ldx.d \$a0, \$a0, \$a1 + 6c: 1a000004 pcalau12i \$a0, 0 + 6c: R_LARCH_TLS_LD_PC_HI20 TLS1 + 6c: R_LARCH_RELAX \*ABS\* + 70: 02c00005 li.d \$a1, 0 + 70: R_LARCH_GOT_PC_LO12 TLS1 + 70: R_LARCH_RELAX \*ABS\* + 74: 16000005 lu32i.d \$a1, 0 + 74: R_LARCH_GOT64_PC_LO20 TLS1 + 78: 030000a5 lu52i.d \$a1, \$a1, 0 + 78: R_LARCH_GOT64_PC_HI12 TLS1 + 7c: 00109484 add.d \$a0, \$a0, \$a1 + 80: 1a000004 pcalau12i \$a0, 0 + 80: R_LARCH_TLS_GD_PC_HI20 TLS1 + 80: R_LARCH_RELAX \*ABS\* + 84: 02c00005 li.d \$a1, 0 + 84: R_LARCH_GOT_PC_LO12 TLS1 + 84: R_LARCH_RELAX \*ABS\* + 88: 16000005 lu32i.d \$a1, 0 + 88: R_LARCH_GOT64_PC_LO20 TLS1 + 8c: 030000a5 lu52i.d \$a1, \$a1, 0 + 8c: R_LARCH_GOT64_PC_HI12 TLS1 + 90: 00109484 add.d \$a0, \$a0, \$a1 diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h index da2fd119181..66a47c6c3f2 100644 --- a/include/elf/loongarch.h +++ b/include/elf/loongarch.h @@ -271,6 +271,10 @@ RELOC_NUMBER (R_LARCH_TLS_DESC64_HI12, 119) RELOC_NUMBER (R_LARCH_TLS_DESC_CALL, 120) +RELOC_NUMBER (R_LARCH_TLS_LD_PCREL20_S2, 121) +RELOC_NUMBER (R_LARCH_TLS_GD_PCREL20_S2, 122) +RELOC_NUMBER (R_LARCH_TLS_DESC_PCREL20_S2, 123) + END_RELOC_NUMBERS (R_LARCH_count) /* Processor specific flags for the ELF header e_flags field. */ diff --git a/ld/testsuite/ld-loongarch-elf/macro_op.d b/ld/testsuite/ld-loongarch-elf/macro_op.d index edc71bc0dbf..f0d87c03802 100644 --- a/ld/testsuite/ld-loongarch-elf/macro_op.d +++ b/ld/testsuite/ld-loongarch-elf/macro_op.d @@ -1,200 +1,205 @@ #as: #objdump: -dr +#skip: loongarch32-*-* -.*:[ ]+file format .* +.*: file format .* Disassembly of section .text: -00000000.* <.L1>: -[ ]+0:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+4:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+8:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+c:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+10:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+10:[ ]+R_LARCH_GOT_PC_HI20[ ]+.L1 -[ ]+10:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+14:[ ]+28c00084[ ]+ld.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+14:[ ]+R_LARCH_GOT_PC_LO12[ ]+.L1 -[ ]+14:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+18:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]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TLS_GD_PC_HI20[ ]+TLS1 -[ ]+138:[ ]+02c00084[ ]+addi.d[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+138:[ ]+R_LARCH_GOT_PC_LO12[ ]+TLS1 -[ ]+138:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+13c:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+13c:[ ]+R_LARCH_TLS_GD_PC_HI20[ ]+TLS1 -[ ]+140:[ ]+02c00005[ ]+li\.d[ ]+\$a1,[ ]+0 -[ ]+140:[ ]+R_LARCH_GOT_PC_LO12[ ]+TLS1 -[ ]+140:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+144:[ ]+16000005[ ]+lu32i.d[ ]+\$a1,[ ]+0 -[ ]+144:[ ]+R_LARCH_GOT64_PC_LO20[ ]+TLS1 -[ ]+148:[ ]+030000a5[ ]+lu52i.d[ ]+\$a1,[ ]+\$a1,[ ]+0 -[ ]+148:[ ]+R_LARCH_GOT64_PC_HI12[ ]+TLS1 -[ ]+14c:[ ]+00109484[ ]+add.d[ ]+\$a0,[ ]+\$a0,[ ]+\$a1 +0+ <.L1>: + 0: 00150004 move \$a0, \$zero + 4: 02bffc04 li.w \$a0, -1 + 8: 00150004 move \$a0, \$zero + c: 02bffc04 li.w \$a0, -1 + 10: 1a000004 pcalau12i \$a0, 0 + 10: R_LARCH_GOT_PC_HI20 .L1 + 10: R_LARCH_RELAX \*ABS\* + 14: 28c00084 ld.d \$a0, \$a0, 0 + 14: R_LARCH_GOT_PC_LO12 .L1 + 14: R_LARCH_RELAX \*ABS\* + 18: 1a000004 pcalau12i \$a0, 0 + 18: R_LARCH_GOT_PC_HI20 .L1 + 18: R_LARCH_RELAX \*ABS\* + 1c: 28c00084 ld.d \$a0, \$a0, 0 + 1c: R_LARCH_GOT_PC_LO12 .L1 + 1c: R_LARCH_RELAX \*ABS\* + 20: 1a000004 pcalau12i \$a0, 0 + 20: R_LARCH_GOT_PC_HI20 .L1 + 20: R_LARCH_RELAX \*ABS\* + 24: 02c00005 li.d \$a1, 0 + 24: R_LARCH_GOT_PC_LO12 .L1 + 24: R_LARCH_RELAX \*ABS\* + 28: 16000005 lu32i.d \$a1, 0 + 28: R_LARCH_GOT64_PC_LO20 .L1 + 2c: 030000a5 lu52i.d \$a1, \$a1, 0 + 2c: R_LARCH_GOT64_PC_HI12 .L1 + 30: 380c1484 ldx.d \$a0, \$a0, \$a1 + 34: 1a000004 pcalau12i \$a0, 0 + 34: R_LARCH_GOT_PC_HI20 .L1 + 34: R_LARCH_RELAX \*ABS\* + 38: 28c00084 ld.d \$a0, \$a0, 0 + 38: R_LARCH_GOT_PC_LO12 .L1 + 38: R_LARCH_RELAX \*ABS\* + 3c: 1a000004 pcalau12i \$a0, 0 + 3c: R_LARCH_GOT_PC_HI20 .L1 + 3c: R_LARCH_RELAX \*ABS\* + 40: 02c00005 li.d \$a1, 0 + 40: R_LARCH_GOT_PC_LO12 .L1 + 40: R_LARCH_RELAX \*ABS\* + 44: 16000005 lu32i.d \$a1, 0 + 44: R_LARCH_GOT64_PC_LO20 .L1 + 48: 030000a5 lu52i.d \$a1, \$a1, 0 + 48: R_LARCH_GOT64_PC_HI12 .L1 + 4c: 380c1484 ldx.d \$a0, \$a0, \$a1 + 50: 1a000004 pcalau12i \$a0, 0 + 50: R_LARCH_GOT_PC_HI20 .L1 + 50: R_LARCH_RELAX \*ABS\* + 54: 28c00084 ld.d \$a0, \$a0, 0 + 54: R_LARCH_GOT_PC_LO12 .L1 + 54: R_LARCH_RELAX \*ABS\* + 58: 1a000004 pcalau12i \$a0, 0 + 58: R_LARCH_GOT_PC_HI20 .L1 + 58: R_LARCH_RELAX \*ABS\* + 5c: 02c00005 li.d \$a1, 0 + 5c: R_LARCH_GOT_PC_LO12 .L1 + 5c: R_LARCH_RELAX \*ABS\* + 60: 16000005 lu32i.d \$a1, 0 + 60: R_LARCH_GOT64_PC_LO20 .L1 + 64: 030000a5 lu52i.d \$a1, \$a1, 0 + 64: R_LARCH_GOT64_PC_HI12 .L1 + 68: 380c1484 ldx.d \$a0, \$a0, \$a1 + 6c: 1a000004 pcalau12i \$a0, 0 + 6c: R_LARCH_PCALA_HI20 .L1 + 6c: R_LARCH_RELAX \*ABS\* + 70: 02c00084 addi.d \$a0, \$a0, 0 + 70: R_LARCH_PCALA_LO12 .L1 + 70: R_LARCH_RELAX \*ABS\* + 74: 1a000004 pcalau12i \$a0, 0 + 74: R_LARCH_PCALA_HI20 .L1 + 74: R_LARCH_RELAX \*ABS\* + 78: 02c00005 li.d \$a1, 0 + 78: R_LARCH_PCALA_LO12 .L1 + 78: R_LARCH_RELAX \*ABS\* + 7c: 16000005 lu32i.d \$a1, 0 + 7c: R_LARCH_PCALA64_LO20 .L1 + 80: 030000a5 lu52i.d \$a1, \$a1, 0 + 80: R_LARCH_PCALA64_HI12 .L1 + 84: 00109484 add.d \$a0, \$a0, \$a1 + 88: 1a000004 pcalau12i \$a0, 0 + 88: R_LARCH_PCALA_HI20 .L1 + 88: R_LARCH_RELAX \*ABS\* + 8c: 02c00084 addi.d \$a0, \$a0, 0 + 8c: R_LARCH_PCALA_LO12 .L1 + 8c: R_LARCH_RELAX \*ABS\* + 90: 1a000004 pcalau12i \$a0, 0 + 90: R_LARCH_PCALA_HI20 .L1 + 90: R_LARCH_RELAX \*ABS\* + 94: 02c00005 li.d \$a1, 0 + 94: R_LARCH_PCALA_LO12 .L1 + 94: R_LARCH_RELAX \*ABS\* + 98: 16000005 lu32i.d \$a1, 0 + 98: R_LARCH_PCALA64_LO20 .L1 + 9c: 030000a5 lu52i.d \$a1, \$a1, 0 + 9c: R_LARCH_PCALA64_HI12 .L1 + a0: 00109484 add.d \$a0, \$a0, \$a1 + a4: 14000004 lu12i.w \$a0, 0 + a4: R_LARCH_MARK_LA \*ABS\* + a4: R_LARCH_ABS_HI20 .L1 + a8: 03800084 ori \$a0, \$a0, 0x0 + a8: R_LARCH_ABS_LO12 .L1 + ac: 16000004 lu32i.d \$a0, 0 + ac: R_LARCH_ABS64_LO20 .L1 + b0: 03000084 lu52i.d \$a0, \$a0, 0 + b0: R_LARCH_ABS64_HI12 .L1 + b4: 1a000004 pcalau12i \$a0, 0 + b4: R_LARCH_PCALA_HI20 .L1 + b4: R_LARCH_RELAX \*ABS\* + b8: 02c00084 addi.d \$a0, \$a0, 0 + b8: R_LARCH_PCALA_LO12 .L1 + b8: R_LARCH_RELAX \*ABS\* + bc: 1a000004 pcalau12i \$a0, 0 + bc: R_LARCH_PCALA_HI20 .L1 + bc: R_LARCH_RELAX \*ABS\* + c0: 02c00084 addi.d \$a0, \$a0, 0 + c0: R_LARCH_PCALA_LO12 .L1 + c0: R_LARCH_RELAX \*ABS\* + c4: 1a000004 pcalau12i \$a0, 0 + c4: R_LARCH_PCALA_HI20 .L1 + c4: R_LARCH_RELAX \*ABS\* + c8: 02c00005 li.d \$a1, 0 + c8: R_LARCH_PCALA_LO12 .L1 + c8: R_LARCH_RELAX \*ABS\* + cc: 16000005 lu32i.d \$a1, 0 + cc: R_LARCH_PCALA64_LO20 .L1 + d0: 030000a5 lu52i.d \$a1, \$a1, 0 + d0: R_LARCH_PCALA64_HI12 .L1 + d4: 00109484 add.d \$a0, \$a0, \$a1 + d8: 1a000004 pcalau12i \$a0, 0 + d8: R_LARCH_GOT_PC_HI20 .L1 + d8: R_LARCH_RELAX \*ABS\* + dc: 28c00084 ld.d \$a0, \$a0, 0 + dc: R_LARCH_GOT_PC_LO12 .L1 + dc: R_LARCH_RELAX \*ABS\* + e0: 1a000004 pcalau12i \$a0, 0 + e0: R_LARCH_GOT_PC_HI20 .L1 + e0: R_LARCH_RELAX \*ABS\* + e4: 02c00005 li.d \$a1, 0 + e4: R_LARCH_GOT_PC_LO12 .L1 + e4: R_LARCH_RELAX \*ABS\* + e8: 16000005 lu32i.d \$a1, 0 + e8: R_LARCH_GOT64_PC_LO20 .L1 + ec: 030000a5 lu52i.d \$a1, \$a1, 0 + ec: R_LARCH_GOT64_PC_HI12 .L1 + f0: 380c1484 ldx.d \$a0, \$a0, \$a1 + f4: 14000004 lu12i.w \$a0, 0 + f4: R_LARCH_TLS_LE_HI20 TLS1 + f8: 03800084 ori \$a0, \$a0, 0x0 + f8: R_LARCH_TLS_LE_LO12 TLS1 + fc: 1a000004 pcalau12i \$a0, 0 + fc: R_LARCH_TLS_IE_PC_HI20 TLS1 + 100: 28c00084 ld.d \$a0, \$a0, 0 + 100: R_LARCH_TLS_IE_PC_LO12 TLS1 + 104: 1a000004 pcalau12i \$a0, 0 + 104: R_LARCH_TLS_IE_PC_HI20 TLS1 + 108: 02c00005 li.d \$a1, 0 + 108: R_LARCH_TLS_IE_PC_LO12 TLS1 + 10c: 16000005 lu32i.d \$a1, 0 + 10c: R_LARCH_TLS_IE64_PC_LO20 TLS1 + 110: 030000a5 lu52i.d \$a1, \$a1, 0 + 110: R_LARCH_TLS_IE64_PC_HI12 TLS1 + 114: 380c1484 ldx.d \$a0, \$a0, \$a1 + 118: 1a000004 pcalau12i \$a0, 0 + 118: R_LARCH_TLS_LD_PC_HI20 TLS1 + 118: R_LARCH_RELAX \*ABS\* + 11c: 02c00084 addi.d \$a0, \$a0, 0 + 11c: R_LARCH_GOT_PC_LO12 TLS1 + 11c: R_LARCH_RELAX \*ABS\* + 120: 1a000004 pcalau12i \$a0, 0 + 120: R_LARCH_TLS_LD_PC_HI20 TLS1 + 120: R_LARCH_RELAX \*ABS\* + 124: 02c00005 li.d \$a1, 0 + 124: R_LARCH_GOT_PC_LO12 TLS1 + 124: R_LARCH_RELAX \*ABS\* + 128: 16000005 lu32i.d \$a1, 0 + 128: R_LARCH_GOT64_PC_LO20 TLS1 + 12c: 030000a5 lu52i.d \$a1, \$a1, 0 + 12c: R_LARCH_GOT64_PC_HI12 TLS1 + 130: 00109484 add.d \$a0, \$a0, \$a1 + 134: 1a000004 pcalau12i \$a0, 0 + 134: R_LARCH_TLS_GD_PC_HI20 TLS1 + 134: R_LARCH_RELAX \*ABS\* + 138: 02c00084 addi.d \$a0, \$a0, 0 + 138: R_LARCH_GOT_PC_LO12 TLS1 + 138: R_LARCH_RELAX \*ABS\* + 13c: 1a000004 pcalau12i \$a0, 0 + 13c: R_LARCH_TLS_GD_PC_HI20 TLS1 + 13c: R_LARCH_RELAX \*ABS\* + 140: 02c00005 li.d \$a1, 0 + 140: R_LARCH_GOT_PC_LO12 TLS1 + 140: R_LARCH_RELAX \*ABS\* + 144: 16000005 lu32i.d \$a1, 0 + 144: R_LARCH_GOT64_PC_LO20 TLS1 + 148: 030000a5 lu52i.d \$a1, \$a1, 0 + 148: R_LARCH_GOT64_PC_HI12 TLS1 + 14c: 00109484 add.d \$a0, \$a0, \$a1 diff --git a/ld/testsuite/ld-loongarch-elf/macro_op_32.d b/ld/testsuite/ld-loongarch-elf/macro_op_32.d index 188026a5780..a7349aa8dc0 100644 --- a/ld/testsuite/ld-loongarch-elf/macro_op_32.d +++ b/ld/testsuite/ld-loongarch-elf/macro_op_32.d @@ -2,66 +2,68 @@ #objdump: -dr #skip: loongarch64-*-* -.*:[ ]+file format .* +.*: file format .* Disassembly of section .text: -00000000.* <.L1>: -[ ]+0:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+4:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+8:[ ]+00150004[ ]+move[ ]+\$a0,[ ]+\$zero -[ ]+c:[ ]+02bffc04[ ]+li\.w[ ]+\$a0,[ ]+-1 -[ ]+10:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0,[ ]+0 -[ ]+10:[ ]+R_LARCH_GOT_PC_HI20[ ]+.L1 -[ ]+10:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+14:[ ]+28800084[ ]+ld.w[ ]+\$a0,[ ]+\$a0,[ ]+0 -[ ]+14:[ ]+R_LARCH_GOT_PC_LO12[ ]+.L1 -[ ]+14:[ ]+R_LARCH_RELAX[ ]+\*ABS\* -[ ]+18:[ ]+1a000004[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ffc04 li.w \$a0, -1 + 10: 1a000004 pcalau12i \$a0, 0 + 10: R_LARCH_GOT_PC_HI20 .L1 + 10: R_LARCH_RELAX \*ABS\* + 14: 28800084 ld.w \$a0, \$a0, 0 + 14: R_LARCH_GOT_PC_LO12 .L1 + 14: R_LARCH_RELAX \*ABS\* + 18: 1a000004 pcalau12i \$a0, 0 + 18: R_LARCH_GOT_PC_HI20 .L1 + 18: R_LARCH_RELAX \*ABS\* + 1c: 28800084 ld.w \$a0, \$a0, 0 + 1c: R_LARCH_GOT_PC_LO12 .L1 + 1c: R_LARCH_RELAX \*ABS\* + 20: 1a000004 pcalau12i \$a0, 0 + 20: R_LARCH_PCALA_HI20 .L1 + 20: R_LARCH_RELAX \*ABS\* + 24: 02800084 addi.w \$a0, \$a0, 0 + 24: R_LARCH_PCALA_LO12 .L1 + 24: R_LARCH_RELAX \*ABS\* + 28: 14000004 lu12i.w \$a0, 0 + 28: R_LARCH_MARK_LA \*ABS\* + 28: R_LARCH_ABS_HI20 .L1 + 2c: 03800084 ori \$a0, \$a0, 0x0 + 2c: R_LARCH_ABS_LO12 .L1 + 30: 1a000004 pcalau12i \$a0, 0 + 30: R_LARCH_PCALA_HI20 .L1 + 30: R_LARCH_RELAX \*ABS\* + 34: 02800084 addi.w \$a0, \$a0, 0 + 34: R_LARCH_PCALA_LO12 .L1 + 34: R_LARCH_RELAX \*ABS\* + 38: 1a000004 pcalau12i \$a0, 0 + 38: R_LARCH_GOT_PC_HI20 .L1 + 38: R_LARCH_RELAX \*ABS\* + 3c: 28800084 ld.w \$a0, \$a0, 0 + 3c: R_LARCH_GOT_PC_LO12 .L1 + 3c: R_LARCH_RELAX \*ABS\* + 40: 14000004 lu12i.w \$a0, 0 + 40: R_LARCH_TLS_LE_HI20 TLS1 + 44: 03800084 ori \$a0, \$a0, 0x0 + 44: R_LARCH_TLS_LE_LO12 TLS1 + 48: 1a000004 pcalau12i \$a0, 0 + 48: R_LARCH_TLS_IE_PC_HI20 TLS1 + 4c: 28800084 ld.w \$a0, \$a0, 0 + 4c: R_LARCH_TLS_IE_PC_LO12 TLS1 + 50: 1a000004 pcalau12i \$a0, 0 + 50: R_LARCH_TLS_LD_PC_HI20 TLS1 + 50: R_LARCH_RELAX \*ABS\* + 54: 02800084 addi.w \$a0, \$a0, 0 + 54: R_LARCH_GOT_PC_LO12 TLS1 + 54: R_LARCH_RELAX \*ABS\* + 58: 1a000004 pcalau12i \$a0, 0 + 58: R_LARCH_TLS_GD_PC_HI20 TLS1 + 58: R_LARCH_RELAX \*ABS\* + 5c: 02800084 addi.w \$a0, \$a0, 0 + 5c: R_LARCH_GOT_PC_LO12 TLS1 + 5c: R_LARCH_RELAX \*ABS\* From patchwork Thu Dec 14 02:58:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 178429 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8286025dys; Wed, 13 Dec 2023 18:59:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWN3L037RullETs1vD7scuDHrDhizSN4Ch2d54v/RTjRBfPQcPqwqneGRFEoVDDudW1mDl X-Received: by 2002:a05:620a:1452:b0:776:fba6:da64 with SMTP id i18-20020a05620a145200b00776fba6da64mr9566406qkl.22.1702522748593; Wed, 13 Dec 2023 18:59:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702522748; cv=pass; d=google.com; s=arc-20160816; b=bI8RykXpN6iqT9e2u3qpwCfA4W4zgc/ungaFULzeLrDZs8+6luR2cXW0u/lo3F7yDt XWKXvpq2Wflb4y0Ri7i/0G2UZOKgVoVhVIHNxx1pXLmllpEcIQfn6q0Bg5ugRPtht71E 74cBznl6eIIAHDHJGgnYzuiP3gfOum3KKBpRryd5OpwOj/N6dhV28gNbql5WBJhDA82f +HqYvuuBRUbc5Z28/7Dw7lsXl2bOenBQyYds5bG7OW39WL4tpzu3/6df+6EO/J2lVxZs cAiTO1JkqmoY6bVry7nK58pU4FMeb5OEivTw2PXMaY9huSAiNOE8QNgpCQogQhbJRTZR feXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=I8ozcKshJBjgKiWgCkM1hzvH+cfS1R7Iw1hkQFlir4M=; fh=FvlVQEmCpm5H8oBXQswexzCupeeQXnbssobXN+3R2Wg=; b=YDAxoYX8feYIWDWDmgopfASPgpNRocJodDyAR4nUUbDnkQ7A7Lup8K9xlD01xsy7dm dBAuowZZDm9xKd5xZbj9bry3n/OO32J/seduuSxjjPvdnX0jQXyWfzEut1pliCvlBFMe zuMDm30j8voF9MvLTMhPRH2KQxW5+aBFT3BglXh54F28MTd3fjQpcbyoC5g+ouxKKEwa Pf/EEmmGpaMtI4ZLj5spEu7lt8JY58hyv1p20gpWatWH224z+vMlaX3lsDv0az52x08J +L7gYjFGuGWfEjgadVFtJB29vSWTdWmDXmeNfRIYRNxR0Vz5kGQDEtXvCJhoqxJxbRlh ZLjg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i8-20020ad44108000000b0067eeb5d03f7si4732281qvp.563.2023.12.13.18.59.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 18:59:08 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A92F385C6F2 for ; Thu, 14 Dec 2023 02:59:08 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id C1E00385B524 for ; Thu, 14 Dec 2023 02:58:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1E00385B524 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C1E00385B524 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522743; cv=none; b=Fwp9mvWyWzy9GdMPdidicgVrX+aFXjdlJuvPDJdR3k1IA9SmKeVTtN/Z63kTfMbyBn9m9OSfc774mVyxXFzncEOESfLmrGcu1J6FDflGmKHMYkMdQBWcp+cT/5QRY+SCxLWYR2O1ph8SktbTTN10jGeSxP0WrVqK21d9sQbenxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702522743; c=relaxed/simple; bh=C+mJBGoqhCr9mHHi3G7/O9yZt8rED7S1YamDnztR7cg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=NLt5+Zem1wz4Yd96V2M3NFao1/hijqkCfdP1xx/RPJAHR5ZXwAOgG9rBzvobSV9MtSs4BkKr/pmiy3DTeTcZiytOcLlO+zaYxxxyweq0zImC5Nj6tiuqWIkNKava+RGkxspPbBvEgqy595qrSDZsBT5mWcSF78zCN8AnxS6WcvI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8CxRPBvb3plAecAAA--.5205S3; Thu, 14 Dec 2023 10:58:55 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx3+Fub3plUocDAA--.20789S4; Thu, 14 Dec 2023 10:58:54 +0800 (CST) From: Lulu Cai To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, mengqinggang@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lulu Cai Subject: [PATCH v3 5/5] LoongArch: Add testsuit for DESC and tls transition and tls relaxation. Date: Thu, 14 Dec 2023 10:58:52 +0800 Message-Id: <20231214025852.1657496-1-cailulu@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cx3+Fub3plUocDAA--.20789S4 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAFB2V6Zi0BKgAAs8 X-Coremail-Antispam: 1Uk129KBj9fXoW3Zry5XrW7AF45XryfGF1ktFc_yoW8XF48Wo Z5AFyagan7CFW2yr13trWrXr9FgrWxCF4fJr9xuw17Aa1jg345GasFkw1rZws3Xrykt3Z8 ua4DG34DZa4xJr1kl-sFpf9Il3svdjkaLaAFLSUrUUUU8b8apTn2vfkv8UJUUUU8wcxFpf 9Il3svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3 UjIYCTnIWjp_UUUY97kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI 8IcIk0rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26F4j6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E 14v26r4UJVWxJr1ln4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6x kI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v2 6rWY6Fy7McIj6I8E87Iv67AKxVWxJVW8Jr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48Icx kI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E 14v26r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4 CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26ryj6F1U MIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Cr0_Gr1UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBI daVFxhVjvjDU0xZFpf9x07jF_M-UUUUU= X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785224493546393962 X-GMAIL-MSGID: 1785224493546393962 --- gas/testsuite/gas/loongarch/tlsdesc_32.d | 28 ++++++++ gas/testsuite/gas/loongarch/tlsdesc_32.s | 12 ++++ gas/testsuite/gas/loongarch/tlsdesc_64.d | 28 ++++++++ gas/testsuite/gas/loongarch/tlsdesc_64.s | 12 ++++ .../gas/loongarch/tlsdesc_large_abs.d | 21 ++++++ .../gas/loongarch/tlsdesc_large_abs.s | 9 +++ .../gas/loongarch/tlsdesc_large_pc.d | 22 +++++++ .../gas/loongarch/tlsdesc_large_pc.s | 13 ++++ ld/testsuite/ld-loongarch-elf/desc-ie.d | 17 +++++ ld/testsuite/ld-loongarch-elf/desc-ie.s | 18 +++++ ld/testsuite/ld-loongarch-elf/desc-le.d | 15 +++++ ld/testsuite/ld-loongarch-elf/desc-le.s | 14 ++++ ld/testsuite/ld-loongarch-elf/ie-le.d | 13 ++++ ld/testsuite/ld-loongarch-elf/ie-le.s | 11 ++++ .../ld-loongarch-elf/ld-loongarch-elf.exp | 7 ++ ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d | 57 ++++++++++++++++ ld/testsuite/ld-loongarch-elf/tlsdesc-dso.s | 66 +++++++++++++++++++ 17 files changed, 363 insertions(+) create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_32.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_32.s create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_64.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_64.s create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_abs.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_abs.s create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_pc.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_pc.s create mode 100644 ld/testsuite/ld-loongarch-elf/desc-ie.d create mode 100644 ld/testsuite/ld-loongarch-elf/desc-ie.s create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le.d create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le.s create mode 100644 ld/testsuite/ld-loongarch-elf/ie-le.d create mode 100644 ld/testsuite/ld-loongarch-elf/ie-le.s create mode 100644 ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d create mode 100644 ld/testsuite/ld-loongarch-elf/tlsdesc-dso.s diff --git a/gas/testsuite/gas/loongarch/tlsdesc_32.d b/gas/testsuite/gas/loongarch/tlsdesc_32.d new file mode 100644 index 00000000000..d621fcd41ab --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_32.d @@ -0,0 +1,28 @@ +#as: +#objdump: -dr +#skip: loongarch64-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+ <.*>: + 0: 1a000004 pcalau12i \$a0, 0 + 0: R_LARCH_TLS_DESC_PC_HI20 var + 4: 02c00084 addi.w \$a0, \$a0, 0 + 4: R_LARCH_TLS_DESC_ADD_PC_LO12 var + 8: 28c00081 ld.w \$ra, \$a0, 0 + 8: R_LARCH_TLS_DESC_LD var + c: 4c000021 jirl \$ra, \$ra, 0 + c: R_LARCH_TLS_DESC_CALL var + 10: 1a000004 pcalau12i \$a0, 0 + 10: R_LARCH_TLS_DESC_PC_HI20 var + 10: R_LARCH_RELAX \*ABS\* + 14: 02c00084 addi.w \$a0, \$a0, 0 + 14: R_LARCH_TLS_DESC_ADD_PC_LO12 var + 14: R_LARCH_RELAX \*ABS\* + 18: 28c00081 ld.w \$ra, \$a0, 0 + 18: R_LARCH_TLS_DESC_LD var + 1c: 4c000021 jirl \$ra, \$ra, 0 + 1c: R_LARCH_TLS_DESC_CALL var diff --git a/gas/testsuite/gas/loongarch/tlsdesc_32.s b/gas/testsuite/gas/loongarch/tlsdesc_32.s new file mode 100644 index 00000000000..e0b51330a77 --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_32.s @@ -0,0 +1,12 @@ +.L1: + # R_LARCH_TLSDESC_HI20 var + pcalau12i $a0,%desc_pc_hi20(var) + # R_LARCH_TLSDESC_ADD_PC_LO12 var + addi.w $a0,$a0,%desc_add_pc_lo12(var) + # R_LARCH_TLSDESC_LD var + ld.w $ra,$a0,%desc_ld(var) + # R_LARCH_TLSDESC_CALL var + jirl $ra,$ra,%desc_call(var) + + # test macro, pcalau12i + addi.w => pcaddi + la.tls.desc $a0,var diff --git a/gas/testsuite/gas/loongarch/tlsdesc_64.d b/gas/testsuite/gas/loongarch/tlsdesc_64.d new file mode 100644 index 00000000000..f907605c0a1 --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_64.d @@ -0,0 +1,28 @@ +#as: +#objdump: -dr +#skip: loongarch32-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+ <.*>: + 0: 1a000004 pcalau12i \$a0, 0 + 0: R_LARCH_TLS_DESC_PC_HI20 var + 4: 02c00084 addi.d \$a0, \$a0, 0 + 4: R_LARCH_TLS_DESC_ADD_PC_LO12 var + 8: 28c00081 ld.d \$ra, \$a0, 0 + 8: R_LARCH_TLS_DESC_LD var + c: 4c000021 jirl \$ra, \$ra, 0 + c: R_LARCH_TLS_DESC_CALL var + 10: 1a000004 pcalau12i \$a0, 0 + 10: R_LARCH_TLS_DESC_PC_HI20 var + 10: R_LARCH_RELAX \*ABS\* + 14: 02c00084 addi.d \$a0, \$a0, 0 + 14: R_LARCH_TLS_DESC_ADD_PC_LO12 var + 14: R_LARCH_RELAX \*ABS\* + 18: 28c00081 ld.d \$ra, \$a0, 0 + 18: R_LARCH_TLS_DESC_LD var + 1c: 4c000021 jirl \$ra, \$ra, 0 + 1c: R_LARCH_TLS_DESC_CALL var diff --git a/gas/testsuite/gas/loongarch/tlsdesc_64.s b/gas/testsuite/gas/loongarch/tlsdesc_64.s new file mode 100644 index 00000000000..6d16c52eb96 --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_64.s @@ -0,0 +1,12 @@ +.L1: + # R_LARCH_TLSDESC_HI20 var + pcalau12i $a0,%desc_pc_hi20(var) + # R_LARCH_TLSDESC_ADD_PC_LO12 var + addi.d $a0,$a0,%desc_add_pc_lo12(var) + # R_LARCH_TLSDESC_LD var + ld.d $ra,$a0,%desc_ld(var) + # R_LARCH_TLSDESC_CALL var + jirl $ra,$ra,%desc_call(var) + + # test macro, pcalau12i + addi.d => pcaddi + la.tls.desc $a0,var diff --git a/gas/testsuite/gas/loongarch/tlsdesc_large_abs.d b/gas/testsuite/gas/loongarch/tlsdesc_large_abs.d new file mode 100644 index 00000000000..41bb1833e0e --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_large_abs.d @@ -0,0 +1,21 @@ +#as: +#objdump: -dr +#skip: loongarch32-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+ <.*>: + 0: 14000004 lu12i.w \$a0, 0 + 0: R_LARCH_TLS_DESC_HI20 var + 4: 03800084 ori \$a0, \$a0, 0x0 + 4: R_LARCH_TLS_DESC_LO12 var + 8: 16000004 lu32i.d \$a0, 0 + 8: R_LARCH_TLS_DESC64_LO20 var + c: 03000084 lu52i.d \$a0, \$a0, 0 + c: R_LARCH_TLS_DESC64_HI12 var + 10: 28c00081 ld.d \$ra, \$a0, 0 + 14: 4c000021 jirl \$ra, \$ra, 0 + 14: R_LARCH_TLS_DESC_CALL var diff --git a/gas/testsuite/gas/loongarch/tlsdesc_large_abs.s b/gas/testsuite/gas/loongarch/tlsdesc_large_abs.s new file mode 100644 index 00000000000..01a374cf983 --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_large_abs.s @@ -0,0 +1,9 @@ +.L1: + .global var + #TLSDESC large abs + lu12i.w $a0,%desc_hi20(var) + ori $a0,$a0,%desc_lo12(var) + lu32i.d $a0,%desc64_lo20(var) + lu52i.d $a0,$a0,%desc64_hi12(var) + ld.d $ra,$a0,0 + jirl $ra,$ra,%desc_call(var) diff --git a/gas/testsuite/gas/loongarch/tlsdesc_large_pc.d b/gas/testsuite/gas/loongarch/tlsdesc_large_pc.d new file mode 100644 index 00000000000..751847647f3 --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_large_pc.d @@ -0,0 +1,22 @@ +#as: +#objdump: -dr +#skip: loongarch32-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+ <.*>: + 0: 1a000004 pcalau12i \$a0, 0 + 0: R_LARCH_TLS_DESC_PC_HI20 var + 4: 02c00005 li.d \$a1, 0 + 4: R_LARCH_TLS_DESC_ADD_PC_LO12 var + 8: 16000005 lu32i.d \$a1, 0 + 8: R_LARCH_TLS_DESC64_PC_LO20 var + c: 030000a5 lu52i.d \$a1, \$a1, 0 + c: R_LARCH_TLS_DESC64_PC_HI12 var + 10: 00109484 add.d \$a0, \$a0, \$a1 + 14: 28c00081 ld.d \$ra, \$a0, 0 + 18: 4c000021 jirl \$ra, \$ra, 0 + 18: R_LARCH_TLS_DESC_CALL var diff --git a/gas/testsuite/gas/loongarch/tlsdesc_large_pc.s b/gas/testsuite/gas/loongarch/tlsdesc_large_pc.s new file mode 100644 index 00000000000..bf7e92864a0 --- /dev/null +++ b/gas/testsuite/gas/loongarch/tlsdesc_large_pc.s @@ -0,0 +1,13 @@ +.L1: + # R_LARCH_TLS_DESC_PC_HI20 var + pcalau12i $a0,%desc_pc_hi20(var) + # R_LARCH_TLS_DESC_ADD_PC_LO12 + addi.d $a1,$zero,%desc_add_pc_lo12(var) + # R_LARCH_TLS_DESC64_PC_LO20 + lu32i.d $a1,%desc64_pc_lo20(var) + # R_LARCH_TLS_DESC64_PC_HI12 + lu52i.d $a1,$a1,%desc64_pc_hi12(var) + add.d $a0,$a0,$a1 + ld.d $ra,$a0,0 + # R_LARCH_TLS_DESC + jirl $ra,$ra,%desc_call(var) diff --git a/ld/testsuite/ld-loongarch-elf/desc-ie.d b/ld/testsuite/ld-loongarch-elf/desc-ie.d new file mode 100644 index 00000000000..66026e843a2 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/desc-ie.d @@ -0,0 +1,17 @@ +#as: +#ld: -shared -z norelro -e 0x0 +#objdump: -dr +#skip: loongarch32-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+230 : + 230: 1a000084 pcalau12i \$a0, 4 + 234: 28cd6084 ld.d \$a0, \$a0, 856 + 238: 03400000 nop + 23c: 03400000 nop + 240: 1a000084 pcalau12i \$a0, 4 + 244: 28cd6081 ld.d \$ra, \$a0, 856 diff --git a/ld/testsuite/ld-loongarch-elf/desc-ie.s b/ld/testsuite/ld-loongarch-elf/desc-ie.s new file mode 100644 index 00000000000..39b23f29550 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/desc-ie.s @@ -0,0 +1,18 @@ + .global v1 + .section .tdata,"awT",@progbits +v1: + .word 1 + .text + .global fn1 + .type fn1,@function +fn1: + + # Use DESC and IE to access the same symbol, + # DESC will relax to IE. + pcalau12i $a0,%desc_pc_hi20(var) + addi.d $a0,$a0,%desc_add_pc_lo12(var) + ld.d $ra,$a0,%desc_ld(var) + jirl $ra,$ra,%desc_call(var) + + pcalau12i $a0,%ie_pc_hi20(var) + ld.d $ra,$a0,%ie_pc_lo12(var) diff --git a/ld/testsuite/ld-loongarch-elf/desc-le.d b/ld/testsuite/ld-loongarch-elf/desc-le.d new file mode 100644 index 00000000000..6a9c5eac296 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/desc-le.d @@ -0,0 +1,15 @@ +#as: +#ld: -z norelro -e 0x0 +#objdump: -dr +#skip: loongarch32-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+1200000e8 : + 1200000e8: 14000004 lu12i.w \$a0, 0 + 1200000ec: 03800084 ori \$a0, \$a0, 0x0 + 1200000f0: 03400000 nop + 1200000f4: 03400000 nop diff --git a/ld/testsuite/ld-loongarch-elf/desc-le.s b/ld/testsuite/ld-loongarch-elf/desc-le.s new file mode 100644 index 00000000000..9c88c0311f6 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/desc-le.s @@ -0,0 +1,14 @@ + .global var + .section .tdata,"awT",@progbits +var: + .word 1 + .text + .global fn1 + .type fn1,@function +fn1: + + # DESC will relax to LE. + pcalau12i $a0,%desc_pc_hi20(var) + addi.d $a0,$a0,%desc_add_pc_lo12(var) + ld.d $ra,$a0,%desc_ld(var) + jirl $ra,$ra,%desc_call(var) diff --git a/ld/testsuite/ld-loongarch-elf/ie-le.d b/ld/testsuite/ld-loongarch-elf/ie-le.d new file mode 100644 index 00000000000..42694d7f9f0 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/ie-le.d @@ -0,0 +1,13 @@ +#as: +#ld: -z norelro -e 0x0 +#objdump: -dr +#skip: loongarch32-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+1200000e8 : + 1200000e8: 14000004 lu12i.w \$a0, 0 + 1200000ec: 03800084 ori \$a0, \$a0, 0x0 diff --git a/ld/testsuite/ld-loongarch-elf/ie-le.s b/ld/testsuite/ld-loongarch-elf/ie-le.s new file mode 100644 index 00000000000..795c7ce49cf --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/ie-le.s @@ -0,0 +1,11 @@ + .data + .section .tdata,"awT",@progbits +var: + .word 1 + .text + .global fn1 + .type gn1,@function +fn1: + # expect IE to relax LE. + pcalau12i $a0,%ie_pc_hi20(var) + ld.d $a0,$a0,%ie_pc_lo12(var) diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp index b95cc53e597..98913ea1184 100644 --- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp +++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp @@ -56,3 +56,10 @@ if [istarget "loongarch64-*-*"] { ] \ ] } + +if [istarget "loongarch64-*-*"] { + run_dump_test "desc-ie" + run_dump_test "desc-le" + run_dump_test "ie-le" + run_dump_test "tlsdesc-dso" +} diff --git a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d new file mode 100644 index 00000000000..7fd9d7a6285 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d @@ -0,0 +1,57 @@ +#as: +#ld: -shared -z norelro +#objdump: -dr +#skip: loongarch32-*-* + +.*: file format .* + + +Disassembly of section .text: + +0+418 : + 418: 180214c4 pcaddi \$a0, 4262 + 41c: 1a000084 pcalau12i \$a0, 4 + 420: 28db0084 ld.d \$a0, \$a0, 1728 + 424: 180212a4 pcaddi \$a0, 4245 + 428: 18021304 pcaddi \$a0, 4248 + 42c: 28c00081 ld.d \$ra, \$a0, 0 + 430: 4c000021 jirl \$ra, \$ra, 0 + 434: 1a000084 pcalau12i \$a0, 4 + 438: 28d9c084 ld.d \$a0, \$a0, 1648 + 43c: 03400000 nop + 440: 03400000 nop + 444: 1a000084 pcalau12i \$a0, 4 + 448: 28d9c084 ld.d \$a0, \$a0, 1648 + 44c: 18021264 pcaddi \$a0, 4243 + 450: 18021244 pcaddi \$a0, 4242 + 454: 28c00081 ld.d \$ra, \$a0, 0 + 458: 4c000021 jirl \$ra, \$ra, 0 + 45c: 1a000084 pcalau12i \$a0, 4 + 460: 28daa084 ld.d \$a0, \$a0, 1704 + +0+464 : + 464: 1a000084 pcalau12i \$a0, 4 + 468: 28d86084 ld.d \$a0, \$a0, 1560 + 46c: 18020ce4 pcaddi \$a0, 4199 + 470: 18020e04 pcaddi \$a0, 4208 + 474: 28c00081 ld.d \$ra, \$a0, 0 + 478: 4c000021 jirl \$ra, \$ra, 0 + 47c: 18020d24 pcaddi \$a0, 4201 + 480: 1a000084 pcalau12i \$a0, 4 + 484: 28d90084 ld.d \$a0, \$a0, 1600 + 488: 03400000 nop + 48c: 03400000 nop + 490: 1a000084 pcalau12i \$a0, 4 + 494: 28d90084 ld.d \$a0, \$a0, 1600 + 498: 18020d84 pcaddi \$a0, 4204 + 49c: 28c00081 ld.d \$ra, \$a0, 0 + 4a0: 4c000021 jirl \$ra, \$ra, 0 + 4a4: 18020d24 pcaddi \$a0, 4201 + 4a8: 1a000084 pcalau12i \$a0, 4 + 4ac: 28d96084 ld.d \$a0, \$a0, 1624 + +0+4b0 : + 4b0: 1a000084 pcalau12i \$a0, 4 + 4b4: 02d98084 addi.d \$a0, \$a0, 1632 + 4b8: 28c00081 ld.d \$ra, \$a0, 0 + 4bc: 4c000021 jirl \$ra, \$ra, 0 diff --git a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.s b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.s new file mode 100644 index 00000000000..41bbe5cf8b4 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.s @@ -0,0 +1,66 @@ + .data + .section .tdata,"awT",@progbits + .global gl1, gl2, gl3, gl4 +gl1: .dword 1 +gl2: .dword 2 +gl3: .dword 3 +gl4: .dword 4 +lo1: .dword 10 +lo2: .dword 20 +lo3: .dword 30 +lo4: .dword 40 + .text +# Access global symbol +fun_gl1: + # GD + IE + # GD: pcaddi + addi.d => pcaddi + la.tls.gd $a0, gl1 + la.tls.ie $a0, gl1 + + # GD + DESC + # GD: pcaddi + addi.d => pcaddi + la.tls.gd $a0, gl2 + # DESC: pcaddi + addi.d => pcaddi + la.tls.desc $a0, gl2 + + # DESC + IE + # DESC -> IE + la.tls.desc $a0, gl3 + la.tls.ie $a0, gl3 + + # GD + DESC + IE + # GD: pcaddi + addi.d => pcaddi + la.tls.gd $a0, gl4 + # DESC: pcaddi + addi.d => pcaddi + la.tls.desc $a0, gl4 + la.tls.ie $a0, gl4 + +# Access local symbol +fun_lo: + # IE + GD + la.tls.ie $a0, lo1 + # GD: pcaddi + addi.d => pcaddi + la.tls.gd $a0, lo1 + + # DESC + GD + # DESC: pcaddi + addi.d => pcaddi + la.tls.desc $a0, lo2 + # GD: pcaddi + addi.d => pcaddi + la.tls.gd $a0, lo2 + + # DESC + IE + # DESC: DESC -> IE + la.tls.desc $a0, lo3 + la.tls.ie $a0, lo3 + + # DESC + GD + IE + # DESC: pcaddi + addi.d => pcaddi + la.tls.desc $a0, lo4 + # GD: pcaddi + addi.d => pcaddi + la.tls.gd $a0, lo4 + la.tls.ie $a0, lo4 + +# Access external undef symbol +fun_external: + # UND symbol do not relax. + la.tls.desc $a0, sH1