Message ID | 20231128085109.28422-1-ishitatsuyuki@gmail.com |
---|---|
Headers |
Return-Path: <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3771510vqx; Tue, 28 Nov 2023 00:51:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHva2zTIQlS20hUxRraJVcNz6lgNINFsjkwgq/093klfM0Zm2gbI09GHSVmGhzj8QKsG5JV X-Received: by 2002:a05:620a:6014:b0:779:d143:c1a7 with SMTP id dw20-20020a05620a601400b00779d143c1a7mr17025633qkb.26.1701161509622; Tue, 28 Nov 2023 00:51:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701161509; cv=pass; d=google.com; s=arc-20160816; b=Iwkx0tWAQNxM8SVIezlbRMIIn3D3IGXLvMcshnyEV6LZg6Mi0g/CsfAlP3Kmc3PvQF WjU4hArfc6e5OeGPTs9GDFi3PEBbnWADdomL4ZTDob6pZYnA1cA4bQQmQdWa4Dk1GZD+ Heka4AqaxtzyVGdT4y90Ql2OLh9BiTKJP3ixh4e4SO0ZiwuFzhPZJKlrxYY8+1McN3Iw DCs+dgH2syFUi5HJ/LXd9ZNkXj7dIEbZ/pCqbuqci8x2Ih2lCGMducy2jQ67HKKnIbZ0 4F1Yru+cZYnwcuFjuZ1/06NjWaEQfn7LGVXh9oIgbO6PbADwDyzy6EqKrGNdK2wMoaMZ hZcQ== 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:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=mePxZbsu/BzVxgnqHmw1BJ3s6S0Pd7CQy09k6OD65KM=; fh=YSa8tbAsFM03BU4mjhbbHsdQe1vIF6KegOb6Q0/FrUw=; b=R6nnmlKuyMwC8YlfnYUpOvAEfvSHUOgdBEk2Mj/lm2s/ZdLDlpl0ekJRiTRGURsH3u 4YeuWd36TM56uDV0FpbPs6Cv6WEw4uEe7wZVLTEPKBU57hwvndf72tR5nU1nwfhtoXsc BcIKmpVCmIdtfpa0MkaArcka07vdQSnmyRQSY81sOY34tFSvgepUxsXKdVQeuepLAlwc 4ngas/QQ4+SGNBKFqwbL4SFNnH8HXZeSOI3YFALyRTODY0XiOxLyIAdwZZx7qwEBIoO6 cuWG1WXIm09hgj0hyWPzlrfiCdHGrDLLR9hSjdMBBu236C1gcgcTGhzpNnJo3L501GSU x0bg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=I6dnlCJn; 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"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a11-20020a05620a16cb00b0077d75295408si10036788qkn.737.2023.11.28.00.51.49 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:51:49 -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; dkim=pass header.i=@gmail.com header.s=20230601 header.b=I6dnlCJn; 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"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 65E2C3865C2A for <ouuuleilei@gmail.com>; Tue, 28 Nov 2023 08:51:36 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 2FDE93857B80 for <binutils@sourceware.org>; Tue, 28 Nov 2023 08:51:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FDE93857B80 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 2FDE93857B80 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701161488; cv=none; b=EQ8p9nvOqjQgheU5COik9ZeKGmNwmpdFeZ0W0optnwNdgzNCmkOXZRTTngIOd+WdqItZka2PtFxK4v9z8+slSRgQQMKeFjEOqBXGM1GKPTCQ+Qe+YA6vqGYEFIjgQzTp4foIju7GL1qceAOUrFqnbkuvoaa0nITDqgWhyDzJAHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701161488; c=relaxed/simple; bh=gmZx/jC6cvA+tge+bZmaz5/lESO+G7/aZwRtozHil5c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MMIeRun4F4IrAifUL1KcyHJS3qJ47NcmQ7c/n60QVG4IVfGEk2RsqW9xm8MUZOuwbWFnjhLHi0ijTDwhsuCpTCCww1QVyUfTiG9Wl/8bgBKpzI7mfq+dYtIb9ZBqPxaB/wuxEjN42w3KRR+5x+sypgIMfT2OV2B+wljcDiJND04= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1cf876eab03so8971035ad.0 for <binutils@sourceware.org>; Tue, 28 Nov 2023 00:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701161485; x=1701766285; 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=mePxZbsu/BzVxgnqHmw1BJ3s6S0Pd7CQy09k6OD65KM=; b=I6dnlCJn23rTsVZbaw4G2Rdls/bQGpwbrkf1dS586HCLO0UqWPB2P17nKwTIqC99/h XerCr3zVonyB+qZ4dp93/XI+j2RnccHUPhhUKrlIrZtv7yRJs5uPiYLyqtZQePhFJ7C9 7lrNKMigk5V5wvfKGpHhOD0+sFijZ/HRqsYmnPQ8xEavKoJlIivBFR9UrPPt+HwgNeVQ gKat1tlLvrAWEjtHG/BP/Vd/9PjMyOlw/JRR+6o/C+brUkIheTyngvypTT4T9S+Sh9py 4sNS+PP4tOO+lA8FTwuWxie9YdMQwW7vfGwR27TdVolW9KmZ69evXN+15osm71a6dybF LSRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701161485; x=1701766285; 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=mePxZbsu/BzVxgnqHmw1BJ3s6S0Pd7CQy09k6OD65KM=; b=bCn74GF6GWIkKtwhGtEP/GWqlALzL/gpftDKFuQNn3JmqhSwgH4qX2q/qBAYarLCwN Y0NHvFHRVOhGhY8QLbc0DboXodKqC7TDXFXUKzgh26GhmpTs0T10MSC7zDx1lLbNZfnp 9wEjPmbJiknQreaveKyFaF1R9qnGyoN6QPVgo3nnhuAfOTn8an6uw7sLSUer1XNmf/aT 3H4gnayYc2w7jCr3uejx6JVSyYHUfypUPDnLya/dTy2WuV7a2SSajW5sbVNMbMe2zdrY XKRKkvurTwtgpaESnk2vDrWkLNzD2tJ+Yu+1p370WC7uMjpezV7u/QNeaq0RwBWlhmHW J23Q== X-Gm-Message-State: AOJu0Yxbv8CfW2Sp0xWUp4rLtbe8fFQgoXs/y1wODf1u/LmUsa9m3MxW DbBH2gExrjdnTMPzHSOogoGs/Rr1RcqBOmnS X-Received: by 2002:a17:902:9f96:b0:1cc:27fa:1fb7 with SMTP id g22-20020a1709029f9600b001cc27fa1fb7mr16881983plq.5.1701161485090; Tue, 28 Nov 2023 00:51:25 -0800 (PST) Received: from localhost (zz20184013906F627101.userreverse.dion.ne.jp. [111.98.113.1]) by smtp.gmail.com with ESMTPSA id ik20-20020a170902ab1400b001cc56354cc8sm9941178plb.62.2023.11.28.00.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:51:24 -0800 (PST) From: Tatsuyuki Ishi <ishitatsuyuki@gmail.com> To: binutils@sourceware.org Cc: i@maskray.me, nelson@rivosinc.com, rui314@gmail.com, ruiu@bluewhale.systems, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> Subject: [PATCH v3 0/9] RISC-V: Implement TLS Descriptors. Date: Tue, 28 Nov 2023 17:51:00 +0900 Message-ID: <20231128085109.28422-1-ishitatsuyuki@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20230817180852.121628-2-ishitatsuyuki@gmail.com> References: <20230817180852.121628-2-ishitatsuyuki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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 <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774500727943734784 X-GMAIL-MSGID: 1783797131124778537 |
Series | RISC-V: Implement TLS Descriptors. | |
Message
Tatsuyuki Ishi
Nov. 28, 2023, 8:51 a.m. UTC
This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per the specification (merged) at [1]. Tested on rv64gc for: - No regression (& passing new tests) in binutils - No regression in gcc - No regression in glibc for subdirs=elf With both -mtls-dialect=desc and trad. This contribution is made on behalf of Blue Whale Systems, which has copyright assignment on file with the FSF. [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 v2: Add changelogs and tests. Minor fixes described in patch messages. v3: Add relaxation support. This fixes tst-tls1-static in glibc. Tatsuyuki Ishi (9): RISC-V: Fix local GOT and reloc size calculation for TLS. RISC-V: Add TLSDESC reloc definitions. RISC-V: Add assembly support for TLSDESC. RISC-V: Define and use GOT entry size constants for TLS. RISC-V: Initial ld.bfd support for TLSDESC. RISC-V: Move STATIC_TLS handling into record_tls_type. RISC-V: Unify TLS handling in check_relocs. RISC-V: Add elf_link_hash_entry to relax_func args. RISC-V: Introduce TLSDESC relaxation. bfd/bfd-in2.h | 4 + bfd/elfnn-riscv.c | 341 ++++++++++++++++++--- bfd/elfxx-riscv.c | 130 +++++++- bfd/libbfd.h | 4 + bfd/reloc.c | 8 + gas/config/tc-riscv.c | 18 +- gas/testsuite/gas/riscv/tlsdesc.d | 22 ++ gas/testsuite/gas/riscv/tlsdesc.s | 24 ++ include/elf/riscv.h | 21 +- include/opcode/riscv.h | 1 + ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 8 + ld/testsuite/ld-riscv-elf/tls.d | 17 + ld/testsuite/ld-riscv-elf/tls.s | 42 +++ ld/testsuite/ld-riscv-elf/tlsbin.d | 7 + ld/testsuite/ld-riscv-elf/tlslib.s | 6 + opcodes/riscv-opc.c | 1 + 16 files changed, 601 insertions(+), 53 deletions(-) create mode 100644 gas/testsuite/gas/riscv/tlsdesc.d create mode 100644 gas/testsuite/gas/riscv/tlsdesc.s create mode 100644 ld/testsuite/ld-riscv-elf/tls.d create mode 100644 ld/testsuite/ld-riscv-elf/tls.s create mode 100644 ld/testsuite/ld-riscv-elf/tlsbin.d create mode 100644 ld/testsuite/ld-riscv-elf/tlslib.s
Comments
> On Nov 28, 2023, at 17:51, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: > > This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per > the specification (merged) at [1]. > > Tested on rv64gc for: > - No regression (& passing new tests) in binutils > - No regression in gcc > - No regression in glibc for subdirs=elf > With both -mtls-dialect=desc and trad. > > This contribution is made on behalf of Blue Whale Systems, which has > copyright assignment on file with the FSF. > > [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 > > v2: Add changelogs and tests. Minor fixes described in patch messages. > v3: Add relaxation support. This fixes tst-tls1-static in glibc. Would anyone like to review this? This is a prerequisite for the GCC-side implementation to be useful (especially the gas part). I can split up the series into bug fix / refactors and actual changes if desired. > Tatsuyuki Ishi (9): > RISC-V: Fix local GOT and reloc size calculation for TLS. > RISC-V: Add TLSDESC reloc definitions. > RISC-V: Add assembly support for TLSDESC. > RISC-V: Define and use GOT entry size constants for TLS. > RISC-V: Initial ld.bfd support for TLSDESC. > RISC-V: Move STATIC_TLS handling into record_tls_type. > RISC-V: Unify TLS handling in check_relocs. > RISC-V: Add elf_link_hash_entry to relax_func args. > RISC-V: Introduce TLSDESC relaxation. > > bfd/bfd-in2.h | 4 + > bfd/elfnn-riscv.c | 341 ++++++++++++++++++--- > bfd/elfxx-riscv.c | 130 +++++++- > bfd/libbfd.h | 4 + > bfd/reloc.c | 8 + > gas/config/tc-riscv.c | 18 +- > gas/testsuite/gas/riscv/tlsdesc.d | 22 ++ > gas/testsuite/gas/riscv/tlsdesc.s | 24 ++ > include/elf/riscv.h | 21 +- > include/opcode/riscv.h | 1 + > ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 8 + > ld/testsuite/ld-riscv-elf/tls.d | 17 + > ld/testsuite/ld-riscv-elf/tls.s | 42 +++ > ld/testsuite/ld-riscv-elf/tlsbin.d | 7 + > ld/testsuite/ld-riscv-elf/tlslib.s | 6 + > opcodes/riscv-opc.c | 1 + > 16 files changed, 601 insertions(+), 53 deletions(-) > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.d > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.s > create mode 100644 ld/testsuite/ld-riscv-elf/tls.d > create mode 100644 ld/testsuite/ld-riscv-elf/tls.s > create mode 100644 ld/testsuite/ld-riscv-elf/tlsbin.d > create mode 100644 ld/testsuite/ld-riscv-elf/tlslib.s > > -- > 2.43.0 >
Sorry that I don't familiar with the TLS stuff and TLS descriptor, so I will need more time to figure these out if other maintainers are all busy. Since there are other patches which are also being reviewed, if someone thinks this is an urgent matter, please feel free to let us know, so we can switch to see these first. On Wed, Dec 6, 2023 at 12:44 AM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: > > On Nov 28, 2023, at 17:51, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> > wrote: > > > > This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, > per > > the specification (merged) at [1]. > > > > Tested on rv64gc for: > > - No regression (& passing new tests) in binutils > > - No regression in gcc > > - No regression in glibc for subdirs=elf > > With both -mtls-dialect=desc and trad. > > > > This contribution is made on behalf of Blue Whale Systems, which has > > copyright assignment on file with the FSF. > > > > [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 > > > > v2: Add changelogs and tests. Minor fixes described in patch messages. > > v3: Add relaxation support. This fixes tst-tls1-static in glibc. > > Would anyone like to review this? This is a prerequisite for the GCC-side > implementation to be useful (especially the gas part). > For these huge features, gcc/binutils/glibc should be reviewed at the same time, since all the stuff should be bound and tested together, so "prerequisite" shouldn't apply here ;) Thanks Nelson > > I can split up the series into bug fix / refactors and actual changes if > desired. > > > Tatsuyuki Ishi (9): > > RISC-V: Fix local GOT and reloc size calculation for TLS. > > RISC-V: Add TLSDESC reloc definitions. > > RISC-V: Add assembly support for TLSDESC. > > RISC-V: Define and use GOT entry size constants for TLS. > > RISC-V: Initial ld.bfd support for TLSDESC. > > RISC-V: Move STATIC_TLS handling into record_tls_type. > > RISC-V: Unify TLS handling in check_relocs. > > RISC-V: Add elf_link_hash_entry to relax_func args. > > RISC-V: Introduce TLSDESC relaxation. > > > > bfd/bfd-in2.h | 4 + > > bfd/elfnn-riscv.c | 341 ++++++++++++++++++--- > > bfd/elfxx-riscv.c | 130 +++++++- > > bfd/libbfd.h | 4 + > > bfd/reloc.c | 8 + > > gas/config/tc-riscv.c | 18 +- > > gas/testsuite/gas/riscv/tlsdesc.d | 22 ++ > > gas/testsuite/gas/riscv/tlsdesc.s | 24 ++ > > include/elf/riscv.h | 21 +- > > include/opcode/riscv.h | 1 + > > ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 8 + > > ld/testsuite/ld-riscv-elf/tls.d | 17 + > > ld/testsuite/ld-riscv-elf/tls.s | 42 +++ > > ld/testsuite/ld-riscv-elf/tlsbin.d | 7 + > > ld/testsuite/ld-riscv-elf/tlslib.s | 6 + > > opcodes/riscv-opc.c | 1 + > > 16 files changed, 601 insertions(+), 53 deletions(-) > > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.d > > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.s > > create mode 100644 ld/testsuite/ld-riscv-elf/tls.d > > create mode 100644 ld/testsuite/ld-riscv-elf/tls.s > > create mode 100644 ld/testsuite/ld-riscv-elf/tlsbin.d > > create mode 100644 ld/testsuite/ld-riscv-elf/tlslib.s > > > > -- > > 2.43.0 > > > >
On Tue, Dec 5, 2023 at 4:33 PM Nelson Chu <nelson@rivosinc.com> wrote: > > Sorry that I don't familiar with the TLS stuff and TLS descriptor, so I will need more time to figure these out if other maintainers are all busy. Since there are other patches which are also being reviewed, if someone thinks this is an urgent matter, please feel free to let us know, so we can switch to see these first. I know that Android wants TLSDESC and having TLSDESC in gcc/binutils helps check LLVM feature parity... If we have TLSDESC earlier, an OS with a new RISC-V port can make TLSDESC part of the baseline ABI... > On Wed, Dec 6, 2023 at 12:44 AM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: >> >> > On Nov 28, 2023, at 17:51, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: >> > >> > This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per >> > the specification (merged) at [1]. >> > >> > Tested on rv64gc for: >> > - No regression (& passing new tests) in binutils >> > - No regression in gcc >> > - No regression in glibc for subdirs=elf >> > With both -mtls-dialect=desc and trad. >> > >> > This contribution is made on behalf of Blue Whale Systems, which has >> > copyright assignment on file with the FSF. >> > >> > [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 >> > >> > v2: Add changelogs and tests. Minor fixes described in patch messages. >> > v3: Add relaxation support. This fixes tst-tls1-static in glibc. >> >> Would anyone like to review this? This is a prerequisite for the GCC-side >> implementation to be useful (especially the gas part). > > > For these huge features, gcc/binutils/glibc should be reviewed at the same time, since all the stuff should be bound and tested together, so "prerequisite" shouldn't apply here ;) > > Thanks > Nelson Agreed. I wonder whether Wei can find someone to test gcc/binutils/glibc patches... and some packages using TLS (e.g. https://codesearch.debian.net/search?q=__thread&literal=1). >> >> >> I can split up the series into bug fix / refactors and actual changes if >> desired. >> >> > Tatsuyuki Ishi (9): >> > RISC-V: Fix local GOT and reloc size calculation for TLS. >> > RISC-V: Add TLSDESC reloc definitions. >> > RISC-V: Add assembly support for TLSDESC. >> > RISC-V: Define and use GOT entry size constants for TLS. >> > RISC-V: Initial ld.bfd support for TLSDESC. >> > RISC-V: Move STATIC_TLS handling into record_tls_type. >> > RISC-V: Unify TLS handling in check_relocs. >> > RISC-V: Add elf_link_hash_entry to relax_func args. >> > RISC-V: Introduce TLSDESC relaxation. >> > >> > bfd/bfd-in2.h | 4 + >> > bfd/elfnn-riscv.c | 341 ++++++++++++++++++--- >> > bfd/elfxx-riscv.c | 130 +++++++- >> > bfd/libbfd.h | 4 + >> > bfd/reloc.c | 8 + >> > gas/config/tc-riscv.c | 18 +- >> > gas/testsuite/gas/riscv/tlsdesc.d | 22 ++ >> > gas/testsuite/gas/riscv/tlsdesc.s | 24 ++ >> > include/elf/riscv.h | 21 +- >> > include/opcode/riscv.h | 1 + >> > ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 8 + >> > ld/testsuite/ld-riscv-elf/tls.d | 17 + >> > ld/testsuite/ld-riscv-elf/tls.s | 42 +++ >> > ld/testsuite/ld-riscv-elf/tlsbin.d | 7 + >> > ld/testsuite/ld-riscv-elf/tlslib.s | 6 + >> > opcodes/riscv-opc.c | 1 + >> > 16 files changed, 601 insertions(+), 53 deletions(-) >> > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.d >> > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.s >> > create mode 100644 ld/testsuite/ld-riscv-elf/tls.d >> > create mode 100644 ld/testsuite/ld-riscv-elf/tls.s >> > create mode 100644 ld/testsuite/ld-riscv-elf/tlsbin.d >> > create mode 100644 ld/testsuite/ld-riscv-elf/tlslib.s >> > >> > -- >> > 2.43.0 >> > >>
On Wed, 06 Dec 2023 19:35:00 PST (-0800), i@maskray.me wrote: > On Tue, Dec 5, 2023 at 4:33 PM Nelson Chu <nelson@rivosinc.com> wrote: >> >> Sorry that I don't familiar with the TLS stuff and TLS descriptor, so I will need more time to figure these out if other maintainers are all busy. Since there are other patches which are also being reviewed, if someone thinks this is an urgent matter, please feel free to let us know, so we can switch to see these first. > > I know that Android wants TLSDESC and having TLSDESC in gcc/binutils > helps check LLVM feature parity... > If we have TLSDESC earlier, an OS with a new RISC-V port can make > TLSDESC part of the baseline ABI... > >> On Wed, Dec 6, 2023 at 12:44 AM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: >>> >>> > On Nov 28, 2023, at 17:51, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: >>> > >>> > This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per >>> > the specification (merged) at [1]. >>> > >>> > Tested on rv64gc for: >>> > - No regression (& passing new tests) in binutils >>> > - No regression in gcc >>> > - No regression in glibc for subdirs=elf >>> > With both -mtls-dialect=desc and trad. >>> > >>> > This contribution is made on behalf of Blue Whale Systems, which has >>> > copyright assignment on file with the FSF. >>> > >>> > [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 >>> > >>> > v2: Add changelogs and tests. Minor fixes described in patch messages. >>> > v3: Add relaxation support. This fixes tst-tls1-static in glibc. >>> >>> Would anyone like to review this? This is a prerequisite for the GCC-side >>> implementation to be useful (especially the gas part). >> >> >> For these huge features, gcc/binutils/glibc should be reviewed at the same time, since all the stuff should be bound and tested together, so "prerequisite" shouldn't apply here ;) Ya, I agree. It's super hard to review stuff like this without seeing all the code, doubly so now that the psABI has turned into a wasteland for discussions. >> >> Thanks >> Nelson > > Agreed. I wonder whether Wei can find someone to test > gcc/binutils/glibc patches... and some packages using TLS (e.g. > https://codesearch.debian.net/search?q=__thread&literal=1). Do you guys have a pointer to the glibc code? I can't find it, but I'm happy to poke it (or maybe find someone else who to poke it...). > >>> >>> >>> I can split up the series into bug fix / refactors and actual changes if >>> desired. >>> >>> > Tatsuyuki Ishi (9): >>> > RISC-V: Fix local GOT and reloc size calculation for TLS. >>> > RISC-V: Add TLSDESC reloc definitions. >>> > RISC-V: Add assembly support for TLSDESC. >>> > RISC-V: Define and use GOT entry size constants for TLS. >>> > RISC-V: Initial ld.bfd support for TLSDESC. >>> > RISC-V: Move STATIC_TLS handling into record_tls_type. >>> > RISC-V: Unify TLS handling in check_relocs. >>> > RISC-V: Add elf_link_hash_entry to relax_func args. >>> > RISC-V: Introduce TLSDESC relaxation. >>> > >>> > bfd/bfd-in2.h | 4 + >>> > bfd/elfnn-riscv.c | 341 ++++++++++++++++++--- >>> > bfd/elfxx-riscv.c | 130 +++++++- >>> > bfd/libbfd.h | 4 + >>> > bfd/reloc.c | 8 + >>> > gas/config/tc-riscv.c | 18 +- >>> > gas/testsuite/gas/riscv/tlsdesc.d | 22 ++ >>> > gas/testsuite/gas/riscv/tlsdesc.s | 24 ++ >>> > include/elf/riscv.h | 21 +- >>> > include/opcode/riscv.h | 1 + >>> > ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 8 + >>> > ld/testsuite/ld-riscv-elf/tls.d | 17 + >>> > ld/testsuite/ld-riscv-elf/tls.s | 42 +++ >>> > ld/testsuite/ld-riscv-elf/tlsbin.d | 7 + >>> > ld/testsuite/ld-riscv-elf/tlslib.s | 6 + >>> > opcodes/riscv-opc.c | 1 + >>> > 16 files changed, 601 insertions(+), 53 deletions(-) >>> > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.d >>> > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.s >>> > create mode 100644 ld/testsuite/ld-riscv-elf/tls.d >>> > create mode 100644 ld/testsuite/ld-riscv-elf/tls.s >>> > create mode 100644 ld/testsuite/ld-riscv-elf/tlsbin.d >>> > create mode 100644 ld/testsuite/ld-riscv-elf/tlslib.s >>> > >>> > -- >>> > 2.43.0 >>> > >>>
> On Dec 13, 2023, at 9:27, Palmer Dabbelt <palmer@dabbelt.com> wrote: > > On Wed, 06 Dec 2023 19:35:00 PST (-0800), i@maskray.me wrote: >> On Tue, Dec 5, 2023 at 4:33 PM Nelson Chu <nelson@rivosinc.com> wrote: >>> >>> Sorry that I don't familiar with the TLS stuff and TLS descriptor, so I will need more time to figure these out if other maintainers are all busy. Since there are other patches which are also being reviewed, if someone thinks this is an urgent matter, please feel free to let us know, so we can switch to see these first. >> >> I know that Android wants TLSDESC and having TLSDESC in gcc/binutils >> helps check LLVM feature parity... >> If we have TLSDESC earlier, an OS with a new RISC-V port can make >> TLSDESC part of the baseline ABI... >> >>> On Wed, Dec 6, 2023 at 12:44 AM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: >>>> >>>> > On Nov 28, 2023, at 17:51, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: >>>> > >>>> > This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per >>>> > the specification (merged) at [1]. >>>> > >>>> > Tested on rv64gc for: >>>> > - No regression (& passing new tests) in binutils >>>> > - No regression in gcc >>>> > - No regression in glibc for subdirs=elf >>>> > With both -mtls-dialect=desc and trad. >>>> > >>>> > This contribution is made on behalf of Blue Whale Systems, which has >>>> > copyright assignment on file with the FSF. >>>> > >>>> > [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 >>>> > >>>> > v2: Add changelogs and tests. Minor fixes described in patch messages. >>>> > v3: Add relaxation support. This fixes tst-tls1-static in glibc. >>>> >>>> Would anyone like to review this? This is a prerequisite for the GCC-side >>>> implementation to be useful (especially the gas part). >>> >>> >>> For these huge features, gcc/binutils/glibc should be reviewed at the same time, since all the stuff should be bound and tested together, so "prerequisite" shouldn't apply here ;) > > Ya, I agree. It's super hard to review stuff like this without seeing all the code, doubly so now that the psABI has turned into a wasteland for discussions. > >>> >>> Thanks >>> Nelson >> >> Agreed. I wonder whether Wei can find someone to test >> gcc/binutils/glibc patches... and some packages using TLS (e.g. >> https://codesearch.debian.net/search?q=__thread&literal=1). > > Do you guys have a pointer to the glibc code? I can't find it, but I'm happy to poke it (or maybe find someone else who to poke it...). Hi, The glibc and gcc patches are available at [1] and [2] respectively. For glibc, I still need to implement save/restore stubs for vector ABI, but apart from that it should be functional. [1]: https://inbox.sourceware.org/libc-alpha/20230914084033.222120-1-ishitatsuyuki@gmail.com/ [2]: https://inbox.sourceware.org/gcc-patches/20231205070152.38360-1-ishitatsuyuki@gmail.com/ Tatsuyuki. >> >>>> >>>> >>>> I can split up the series into bug fix / refactors and actual changes if >>>> desired. >>>> >>>> > Tatsuyuki Ishi (9): >>>> > RISC-V: Fix local GOT and reloc size calculation for TLS. >>>> > RISC-V: Add TLSDESC reloc definitions. >>>> > RISC-V: Add assembly support for TLSDESC. >>>> > RISC-V: Define and use GOT entry size constants for TLS. >>>> > RISC-V: Initial ld.bfd support for TLSDESC. >>>> > RISC-V: Move STATIC_TLS handling into record_tls_type. >>>> > RISC-V: Unify TLS handling in check_relocs. >>>> > RISC-V: Add elf_link_hash_entry to relax_func args. >>>> > RISC-V: Introduce TLSDESC relaxation. >>>> > >>>> > bfd/bfd-in2.h | 4 + >>>> > bfd/elfnn-riscv.c | 341 ++++++++++++++++++--- >>>> > bfd/elfxx-riscv.c | 130 +++++++- >>>> > bfd/libbfd.h | 4 + >>>> > bfd/reloc.c | 8 + >>>> > gas/config/tc-riscv.c | 18 +- >>>> > gas/testsuite/gas/riscv/tlsdesc.d | 22 ++ >>>> > gas/testsuite/gas/riscv/tlsdesc.s | 24 ++ >>>> > include/elf/riscv.h | 21 +- >>>> > include/opcode/riscv.h | 1 + >>>> > ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 8 + >>>> > ld/testsuite/ld-riscv-elf/tls.d | 17 + >>>> > ld/testsuite/ld-riscv-elf/tls.s | 42 +++ >>>> > ld/testsuite/ld-riscv-elf/tlsbin.d | 7 + >>>> > ld/testsuite/ld-riscv-elf/tlslib.s | 6 + >>>> > opcodes/riscv-opc.c | 1 + >>>> > 16 files changed, 601 insertions(+), 53 deletions(-) >>>> > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.d >>>> > create mode 100644 gas/testsuite/gas/riscv/tlsdesc.s >>>> > create mode 100644 ld/testsuite/ld-riscv-elf/tls.d >>>> > create mode 100644 ld/testsuite/ld-riscv-elf/tls.s >>>> > create mode 100644 ld/testsuite/ld-riscv-elf/tlsbin.d >>>> > create mode 100644 ld/testsuite/ld-riscv-elf/tlslib.s >>>> > >>>> > -- >>>> > 2.43.0 >>>> > >>>>
On Tue, Dec 12, 2023 at 5:53 PM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: > > On Dec 13, 2023, at 9:27, Palmer Dabbelt <palmer@dabbelt.com> wrote: > > On Wed, 06 Dec 2023 19:35:00 PST (-0800), i@maskray.me wrote: > > On Tue, Dec 5, 2023 at 4:33 PM Nelson Chu <nelson@rivosinc.com> wrote: > > > Sorry that I don't familiar with the TLS stuff and TLS descriptor, so I will need more time to figure these out if other maintainers are all busy. Since there are other patches which are also being reviewed, if someone thinks this is an urgent matter, please feel free to let us know, so we can switch to see these first. > > > I know that Android wants TLSDESC and having TLSDESC in gcc/binutils > helps check LLVM feature parity... > If we have TLSDESC earlier, an OS with a new RISC-V port can make > TLSDESC part of the baseline ABI... > > On Wed, Dec 6, 2023 at 12:44 AM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: > > > > On Nov 28, 2023, at 17:51, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote: > > > > This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per > > the specification (merged) at [1]. > > > > Tested on rv64gc for: > > - No regression (& passing new tests) in binutils > > - No regression in gcc > > - No regression in glibc for subdirs=elf > > With both -mtls-dialect=desc and trad. > > > > This contribution is made on behalf of Blue Whale Systems, which has > > copyright assignment on file with the FSF. > > > > [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 > > > > v2: Add changelogs and tests. Minor fixes described in patch messages. > > v3: Add relaxation support. This fixes tst-tls1-static in glibc. > > Would anyone like to review this? This is a prerequisite for the GCC-side > implementation to be useful (especially the gas part). > > > > For these huge features, gcc/binutils/glibc should be reviewed at the same time, since all the stuff should be bound and tested together, so "prerequisite" shouldn't apply here ;) > > > Ya, I agree. It's super hard to review stuff like this without seeing all the code, doubly so now that the psABI has turned into a wasteland for discussions. > > > Thanks > Nelson > > > Agreed. I wonder whether Wei can find someone to test > gcc/binutils/glibc patches... and some packages using TLS (e.g. > https://codesearch.debian.net/search?q=__thread&literal=1). > > > Do you guys have a pointer to the glibc code? I can't find it, but I'm happy to poke it (or maybe find someone else who to poke it...). > > > Hi, > The glibc and gcc patches are available at [1] and [2] respectively. > For glibc, I still need to implement save/restore stubs for vector ABI, but apart from that it should be functional. > > [1]: https://inbox.sourceware.org/libc-alpha/20230914084033.222120-1-ishitatsuyuki@gmail.com/ > [2]: https://inbox.sourceware.org/gcc-patches/20231205070152.38360-1-ishitatsuyuki@gmail.com/ > > Tatsuyuki. > > > > > I can split up the series into bug fix / refactors and actual changes if > desired. On the LLVM side, the RISC-V TLSDESC work (LLVM, Clang, lld) has been completed today. (I will frequently update https://maskray.me/blog/2024-01-23-riscv-tlsdesc-works to track the status.) I filed cherry-pick requests into the upcoming 18.1 release. We postponed the LLVM change to add R_RISCV_RELAX when relaxation is in effect. That one will not go to the 18.x releases for safety. If the gas patch is to add one R_RISCV_RELAX to each of the 4 instructions. Perhaps it can be adjusted to add just one per https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/421 ? I haven't checked, but for the ld patch, you probably want to consider TLSDESC to LE/IE optimization regardless of R_RISCV_RELAX. TLSDESC to LE optimization is essential if a libc doesn't implement R_RISCV_TLSDESC in its resolocation resolver for a statically linkeded executable. It seems that musl will merge the RISC-V TLSDESC patch soon (https://www.openwall.com/lists/musl/2024/01/27/1 , CCed Tatsuyuki there). So even if glibc will take some time to be ready, we will still have a testable libc :)