From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2607:f138:0:13::2]) by sourceware.org (Postfix) with ESMTPS id 89A863840C32; Wed, 23 Mar 2022 21:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89A863840C32 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 C7F3E1A84E64; Wed, 23 Mar 2022 17:00:57 -0400 (EDT) From: John Baldwin To: binutils@sourceware.org, gdb-patches@sourceware.org Subject: [PATCH 06/12] Support TLS variables on FreeBSD/arm. Date: Wed, 23 Mar 2022 14:00:45 -0700 Message-Id: <20220323210048.25525-7-jhb@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220323210048.25525-1-jhb@FreeBSD.org> References: <20220323210048.25525-1-jhb@FreeBSD.org> 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]); Wed, 23 Mar 2022 17:00:58 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 21:00:59 -0000 Derive the pointer to the DTV array from the tpidruro register. --- gdb/arm-fbsd-tdep.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c index e11b17664eb..97d41a77f40 100644 --- a/gdb/arm-fbsd-tdep.c +++ b/gdb/arm-fbsd-tdep.c @@ -27,6 +27,7 @@ #include "auxv.h" #include "fbsd-tdep.h" #include "gdbcore.h" +#include "inferior.h" #include "osabi.h" #include "solib-svr4.h" #include "trad-frame.h" @@ -222,6 +223,29 @@ arm_fbsd_core_read_description (struct gdbarch *gdbarch, return arm_fbsd_read_description_auxv (target, tls != nullptr); } +/* Implement the get_thread_local_address gdbarch method. */ + +static CORE_ADDR +arm_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, + CORE_ADDR lm_addr, CORE_ADDR offset) +{ + struct regcache *regcache; + + regcache = get_thread_arch_regcache (current_inferior ()->process_target (), + ptid, gdbarch); + + target_fetch_registers (regcache, ARM_TPIDRURO_REGNUM); + + ULONGEST tpidruro; + if (regcache->cooked_read (ARM_TPIDRURO_REGNUM, &tpidruro) != REG_VALID) + error (_("Unable to fetch %%tpidruro")); + + /* %tpidruro points to the TCB whose first member is the dtv + pointer. */ + CORE_ADDR dtv_addr = tpidruro; + return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset); +} + /* Implement the 'init_osabi' method of struct gdb_osabi_handler. */ static void @@ -247,6 +271,11 @@ arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) (gdbarch, arm_fbsd_iterate_over_regset_sections); set_gdbarch_core_read_description (gdbarch, arm_fbsd_core_read_description); + set_gdbarch_fetch_tls_load_module_address (gdbarch, + svr4_fetch_objfile_link_map); + set_gdbarch_get_thread_local_address (gdbarch, + arm_fbsd_get_thread_local_address); + /* Single stepping. */ set_gdbarch_software_single_step (gdbarch, arm_software_single_step); } -- 2.34.1