From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 034C3385801E for ; Tue, 12 Apr 2022 23:48:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 034C3385801E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.com (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 447AE1A84C82 for ; Tue, 12 Apr 2022 19:48:07 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2 00/14] Support for Thread Local Storage (TLS) variables on FreeBSD arm and aarch64 architectures. Date: Tue, 12 Apr 2022 16:46:33 -0700 Message-Id: <20220412234647.84595-1-jhb@FreeBSD.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Tue, 12 Apr 2022 19:48:07 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 23:48:09 -0000 Changes since V1: - I changed the register number for TPIDR on Aarch64 to a fixed value locally in GDB itself. (I had misparsed Luis's original reply to using a fixed register on 32-bit ARM.) This does work in my testing on both FreeBSD and Linux, but it is a debatable point if new extensions should use fixed register numbers (as on amd64/i386) or variable register numbers with base register numbers in the per-arch tdep class (as Aarch64 has done more recently). An advantage of fixed register numbers is that regcache_map_entry arrays used with regsets can be const globals and shared between *-tdep.c and *-nat.c files. A disadvantage is that fixed numbers leave gaps in some of the internal arrays stored in a tdesc. I'm also not sure that they can be used as easily in gdbserver. At least for TPIDR on on Linux Aarch64 I had to lookup gdbserver's register number dynmically vs using the constant. - I added support for TPIDR on Linux Aarch64. There are some XXX comments as I didn't add any tests to see if NT_ARM_TLS is supported or not but just assume it is always present (since other places that use NT_ARM_TLS seem to assume it is always present). The Linux changes do not try to change TLS variable resolution, but simply report the register's value. I did do light testing on a RPi both for core dumps, native, and gdbserver showing that $tpidr showed a sensible value for all three cases for a simple test program which prints out the address of a TLS variable in the main executable (and verified that the tpidr register value was "close" to the printed address). John Baldwin (14): fbsd-nat: Add helper routines for register sets using PT_[G]SETREGSET. Create pseudo sections for NT_ARM_TLS notes on FreeBSD. Add an arm-tls feature which includes the tpidruro register from CP15. Read the tpidruro register from NT_ARM_TLS core dump notes on FreeBSD/arm. Support TLS variables on FreeBSD/arm. Fetch the NT_ARM_TLS register set for native FreeBSD/arm processes. Add an aarch64-tls feature which includes the tpidr register. Read the tpidr register from NT_ARM_TLS core dump notes on FreeBSD/Aarch64. Support TLS variables on FreeBSD/Aarch64. Fetch the NT_ARM_TLS register set for native FreeBSD/Aarch64 processes. NEWS: Add a note for TLS support on FreeBSD/arm and FreeBSD/Aarch64. Read the tpidr register from NT_ARM_TLS core dump notes on Linux Aarch64. gdbserver: Read the tpidr register from NT_ARM_TLS on Linux. Read the tpidr register from NT_ARM_TLS on Linux. bfd/ChangeLog | 4 ++ bfd/elf.c | 3 ++ gdb/NEWS | 3 ++ gdb/aarch64-fbsd-nat.c | 26 +++++++++++ gdb/aarch64-fbsd-tdep.c | 61 ++++++++++++++++++++++++++ gdb/aarch64-fbsd-tdep.h | 4 ++ gdb/aarch64-linux-nat.c | 57 +++++++++++++++++++++++- gdb/aarch64-linux-tdep.c | 20 ++++++++- gdb/aarch64-linux-tdep.h | 4 ++ gdb/aarch64-tdep.c | 30 ++++++++++--- gdb/aarch64-tdep.h | 10 ++++- gdb/arch/aarch32.c | 2 + gdb/arch/aarch64.c | 7 ++- gdb/arch/aarch64.h | 9 +++- gdb/arch/arm.c | 6 ++- gdb/arch/arm.h | 7 +-- gdb/arm-fbsd-nat.c | 15 ++++++- gdb/arm-fbsd-tdep.c | 57 +++++++++++++++++++++--- gdb/arm-fbsd-tdep.h | 6 ++- gdb/arm-linux-nat.c | 6 +-- gdb/arm-linux-tdep.c | 4 +- gdb/arm-netbsd-nat.c | 4 +- gdb/arm-tdep.c | 20 ++++++--- gdb/arm-tdep.h | 2 +- gdb/fbsd-nat.c | 75 ++++++++++++++++++++++++++++++++ gdb/fbsd-nat.h | 38 ++++++++++++++++ gdb/features/Makefile | 2 + gdb/features/aarch64-tls.c | 14 ++++++ gdb/features/aarch64-tls.xml | 11 +++++ gdb/features/arm/arm-tls.c | 14 ++++++ gdb/features/arm/arm-tls.xml | 11 +++++ gdbserver/linux-aarch64-ipa.cc | 8 ++-- gdbserver/linux-aarch64-low.cc | 28 +++++++++++- gdbserver/linux-aarch64-tdesc.cc | 11 ++--- gdbserver/linux-aarch64-tdesc.h | 2 +- gdbserver/netbsd-aarch64-low.cc | 2 +- 36 files changed, 533 insertions(+), 50 deletions(-) create mode 100644 gdb/features/aarch64-tls.c create mode 100644 gdb/features/aarch64-tls.xml create mode 100644 gdb/features/arm/arm-tls.c create mode 100644 gdb/features/arm/arm-tls.xml -- 2.34.1