From patchwork Tue Feb 20 17:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tatsuyuki Ishi X-Patchwork-Id: 86059 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE5E33857BB7 for ; Tue, 20 Feb 2024 17:59:41 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id ED9633858D35 for ; Tue, 20 Feb 2024 17:56:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED9633858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED9633858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708451789; cv=none; b=gl2mAWqeB+hzzMo5egmTOYpM9C1iSrFZtSCjtAv0Ebi8GZFFo66htUZmdXkS9FeBiq6FcNBGYyjUq8iRLXAGKYa0ap7+WUJvvxq041RBIczbgy/+P+ODD+BY4/79oU6i90/VcG9IyUnIskYjvQgSo+a8ef5CWDTGFcMnzNUnK+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708451789; c=relaxed/simple; bh=kNw6ZApoHx1cgnvBpnvDaejw1EUSw0LwX4x44Wv0XOU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=d8Vtesh4rSjLggqNlRL2bEEozIfDNKdfVzKzKqK7XgGq/fEUpDZxF2jvS6xzNaamzSJK0rNaNmy4JA4rUXfWPIn3fyV2XDUSsRkAE1k4pbEUctEBek2VEpC+fS2mTEEASdj3/ZWELL0u9Cavqe7x4gK4zizoxWMWrTYlaDaakt0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-29964f5c904so268836a91.0 for ; Tue, 20 Feb 2024 09:56:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708451785; x=1709056585; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pwdLL4zB7NO4bYN7Of7Jrm9zCz3qMIfhcZcBmDy5/pc=; b=k1yDnRbWqDhYIvFDu/J4hHgASPPj3pZ/p6/aOwlx9uT38Nh1JE+w59iRN8UfyAWqwE aG8x5TGbhypBTpq2sB8M2i7AA10puox/k3iO+mZapJcBAu5gd80aVdvE4IEevaVrlJk9 74+8n4tbVnPGSxhIUF9yIQbfrvvov7vth8z/O++N9uaboa3CbZpuLIEyLjgdCBKdW4pu SYmXnc+2VYL+qqnurPTwAWAuUV+72QR1/V8wSGOt6EMH1zVL/WUcQE08KRPugnSvgv/i xFecN2xSRf5itJwq54H7kpFrEfEPabJL1bOUvniaZTdxBfMW3IGZILePYjBqW+adLtFP a+Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708451785; x=1709056585; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pwdLL4zB7NO4bYN7Of7Jrm9zCz3qMIfhcZcBmDy5/pc=; b=gVpd2K3T58o1QZ6+RGpD9D9UJY/QxnX8kF95uoNTlxVyfiLlHtJPKeKxqPJrcQQLxU ETzsEVGquyyidB411KPGTShk4o6YPnElzWGYOPg98/3s8cqylwm42yI44oe20ZSEcOQU wbGSszMAjz1vVXg+0e5jqzeU3qrgIWpyQ7q2jP8i7NOKnfPfhQFBhT7JeWilWXijBpLk WfFT++jnAecU3rVAAvU0gfi0oW+waCZR1WrN190VfJ+cjV0xA2BLoclWRrIzraBa9jOk pltqkIvxAuTR/5hynZ/L9xW4bjqiHEkp/9Sjbc3iFPtVWhMP4jXpXMMtFrRdUXqvcAuH nh7A== X-Gm-Message-State: AOJu0YyvfljiO3UmzYpmGhzupbiXiBzxIg4LISuLuBmvoZcFmb890oes u3CZr1xSqAOxTY610TaOpVFk/90FSy9m8x+720gbCGpaNb56HC7GV92aopPCjELP4g== X-Google-Smtp-Source: AGHT+IF8Gw53TdN0uYDcM1F/RpBKEg3liedqwNzswmz+ZdlF7I5H9AkAG+9knkaMxCD+wRxN4bkxSw== X-Received: by 2002:a17:90a:9903:b0:299:1ae1:51ae with SMTP id b3-20020a17090a990300b002991ae151aemr12329687pjp.3.1708451785346; Tue, 20 Feb 2024 09:56:25 -0800 (PST) Received: from localhost (zz20184013906F627101.userreverse.dion.ne.jp. [111.98.113.1]) by smtp.gmail.com with ESMTPSA id qn11-20020a17090b3d4b00b00298f88c3e48sm7661885pjb.11.2024.02.20.09.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 09:56:24 -0800 (PST) From: Tatsuyuki Ishi To: binutils@sourceware.org Cc: i@maskray.me, nelson@rivosinc.com, rui314@gmail.com, ruiu@bluewhale.systems, Tatsuyuki Ishi Subject: [PATCH v4 2/9] RISC-V: Add TLSDESC reloc definitions. Date: Wed, 21 Feb 2024 02:55:49 +0900 Message-ID: <20240220175556.304692-3-ishitatsuyuki@gmail.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220175556.304692-1-ishitatsuyuki@gmail.com> References: <20230817180852.121628-2-ishitatsuyuki@gmail.com> <20240220175556.304692-1-ishitatsuyuki@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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+patchwork=sourceware.org@sourceware.org bfd/ * elfxx-riscv.c: Add 5 TLSDESC reloc descriptions. * reloc.c: Likewise. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. include/ * elf/riscv.h: Add 5 TLSDESC reloc descriptions. --- v4: Fix complain_on_overflow and use complain_overflow_dont. bfd/bfd-in2.h | 4 +++ bfd/elfxx-riscv.c | 75 ++++++++++++++++++++++++++++++++++++++++++++- bfd/libbfd.h | 4 +++ bfd/reloc.c | 8 +++++ include/elf/riscv.h | 5 +++ 5 files changed, 95 insertions(+), 1 deletion(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 37917845cf5..a335df522d2 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -5420,6 +5420,10 @@ enum bfd_reloc_code_real BFD_RELOC_RISCV_TLS_DTPREL64, BFD_RELOC_RISCV_TLS_TPREL32, BFD_RELOC_RISCV_TLS_TPREL64, + BFD_RELOC_RISCV_TLSDESC_HI20, + BFD_RELOC_RISCV_TLSDESC_LOAD_LO12, + BFD_RELOC_RISCV_TLSDESC_ADD_LO12, + BFD_RELOC_RISCV_TLSDESC_CALL, BFD_RELOC_RISCV_ALIGN, BFD_RELOC_RISCV_RVC_BRANCH, BFD_RELOC_RISCV_RVC_JUMP, diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 9a121b47121..a4aa71fd809 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -218,7 +218,20 @@ static reloc_howto_type howto_table[] = MINUS_ONE, /* dst_mask */ false), /* pcrel_offset */ - EMPTY_HOWTO (12), + HOWTO (R_RISCV_TLSDESC, /* type */ + 0, /* rightshift */ + 0, /* size is handled by dynamic linker */ + 0, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_RISCV_TLSDESC", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + MINUS_ONE, /* dst_mask */ + false), /* pcrel_offset */ + EMPTY_HOWTO (13), EMPTY_HOWTO (14), EMPTY_HOWTO (15), @@ -808,6 +821,62 @@ static reloc_howto_type howto_table[] = 0, /* src_mask */ 0, /* dst_mask */ false), /* pcrel_offset */ + + HOWTO (R_RISCV_TLSDESC_HI20, /* type */ + 0, /* rightshift */ + 4, /* size */ + 32, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_RISCV_TLSDESC_HI20", /* name */ + true, /* partial_inplace */ + 0, /* src_mask */ + ENCODE_UTYPE_IMM (-1U), /* dst_mask */ + false), /* pcrel_offset */ + + HOWTO (R_RISCV_TLSDESC_LOAD_LO12, /* type */ + 0, /* rightshift */ + 4, /* size */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_RISCV_TLSDESC_LOAD_LO12", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + ENCODE_ITYPE_IMM (-1U), /* dst_mask */ + false), /* pcrel_offset */ + + HOWTO (R_RISCV_TLSDESC_ADD_LO12, /* type */ + 0, /* rightshift */ + 4, /* size */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_RISCV_TLSDESC_ADD_LO12", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + ENCODE_ITYPE_IMM (-1U), /* dst_mask */ + false), /* pcrel_offset */ + + HOWTO (R_RISCV_TLSDESC_CALL, /* type */ + 0, /* rightshift */ + 0, /* size */ + 0, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_RISCV_TLSDESC_CALL", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + ENCODE_ITYPE_IMM (-1U), /* dst_mask */ + false) /* pcrel_offset */ }; static reloc_howto_type howto_table_internal[] = @@ -935,6 +1004,10 @@ static const struct elf_reloc_map riscv_reloc_map[] = { BFD_RELOC_RISCV_TPREL_LO12_I, R_RISCV_TPREL_LO12_I }, { BFD_RELOC_RISCV_TLS_GOT_HI20, R_RISCV_TLS_GOT_HI20 }, { BFD_RELOC_RISCV_TLS_GD_HI20, R_RISCV_TLS_GD_HI20 }, + { BFD_RELOC_RISCV_TLSDESC_HI20, R_RISCV_TLSDESC_HI20 }, + { BFD_RELOC_RISCV_TLSDESC_LOAD_LO12, R_RISCV_TLSDESC_LOAD_LO12 }, + { BFD_RELOC_RISCV_TLSDESC_ADD_LO12, R_RISCV_TLSDESC_ADD_LO12 }, + { BFD_RELOC_RISCV_TLSDESC_CALL, R_RISCV_TLSDESC_CALL }, { BFD_RELOC_RISCV_ALIGN, R_RISCV_ALIGN }, { BFD_RELOC_RISCV_RVC_BRANCH, R_RISCV_RVC_BRANCH }, { BFD_RELOC_RISCV_RVC_JUMP, R_RISCV_RVC_JUMP }, diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 40bbe6a3886..49f63a0b8e5 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -2409,6 +2409,10 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_RISCV_TLS_DTPREL64", "BFD_RELOC_RISCV_TLS_TPREL32", "BFD_RELOC_RISCV_TLS_TPREL64", + "BFD_RELOC_RISCV_TLSDESC_HI20", + "BFD_RELOC_RISCV_TLSDESC_LOAD_LO12", + "BFD_RELOC_RISCV_TLSDESC_ADD_LO12", + "BFD_RELOC_RISCV_TLSDESC_CALL", "BFD_RELOC_RISCV_ALIGN", "BFD_RELOC_RISCV_RVC_BRANCH", "BFD_RELOC_RISCV_RVC_JUMP", diff --git a/bfd/reloc.c b/bfd/reloc.c index 7583b7fd552..a187afe9b56 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -5002,6 +5002,14 @@ ENUMX BFD_RELOC_RISCV_TLS_TPREL32 ENUMX BFD_RELOC_RISCV_TLS_TPREL64 +ENUMX + BFD_RELOC_RISCV_TLSDESC_HI20 +ENUMX + BFD_RELOC_RISCV_TLSDESC_LOAD_LO12 +ENUMX + BFD_RELOC_RISCV_TLSDESC_ADD_LO12 +ENUMX + BFD_RELOC_RISCV_TLSDESC_CALL ENUMX BFD_RELOC_RISCV_ALIGN ENUMX diff --git a/include/elf/riscv.h b/include/elf/riscv.h index 2000cf21b9d..c1e73f7f5c0 100644 --- a/include/elf/riscv.h +++ b/include/elf/riscv.h @@ -44,6 +44,7 @@ START_RELOC_NUMBERS (elf_riscv_reloc_type) RELOC_NUMBER (R_RISCV_TLS_DTPREL64, 9) RELOC_NUMBER (R_RISCV_TLS_TPREL32, 10) RELOC_NUMBER (R_RISCV_TLS_TPREL64, 11) + RELOC_NUMBER (R_RISCV_TLSDESC, 12) /* Relocation types not used by the dynamic linker. */ RELOC_NUMBER (R_RISCV_BRANCH, 16) @@ -90,6 +91,10 @@ START_RELOC_NUMBERS (elf_riscv_reloc_type) /* Reserved 59 for R_RISCV_PLT32. */ RELOC_NUMBER (R_RISCV_SET_ULEB128, 60) RELOC_NUMBER (R_RISCV_SUB_ULEB128, 61) + RELOC_NUMBER (R_RISCV_TLSDESC_HI20, 62) + RELOC_NUMBER (R_RISCV_TLSDESC_LOAD_LO12, 63) + RELOC_NUMBER (R_RISCV_TLSDESC_ADD_LO12, 64) + RELOC_NUMBER (R_RISCV_TLSDESC_CALL, 65) END_RELOC_NUMBERS (R_RISCV_max) /* Internal relocations used exclusively by the relaxation pass. */