From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by sourceware.org (Postfix) with ESMTP id 0E46C3857034 for ; Fri, 17 Jul 2020 23:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0E46C3857034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=jhb@FreeBSD.org Received: from ralph.com (unknown [71.198.231.75]) by mail.baldwin.cx (Postfix) with ESMTPSA id 962FB10A760 for ; Fri, 17 Jul 2020 19:00:51 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2] Implement the skip_solib_resolver gdbarch hook for FreeBSD architectures. Date: Fri, 17 Jul 2020 15:59:41 -0700 Message-Id: <20200717225941.82442-1-jhb@FreeBSD.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <4ae8ff57-66bd-0e26-5bdf-46aabf4699a3@FreeBSD.org> References: <4ae8ff57-66bd-0e26-5bdf-46aabf4699a3@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Fri, 17 Jul 2020 19:00:52 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_STOCKGEN, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 17 Jul 2020 23:07:41 -0000 The ELF runtime linker on all FreeBSD architectures uses the "_rtld_bind" entry point for unresolved PTL entries. FreeBSD/mips has an additional entry point called "_mips_rtld_bind". gdb/ChangeLog: * fbsd-tdep.c (fbsd_skip_solib_resolver): New function. (fbsd_init_abi): Install gdbarch "skip_solib_resolver" method. * fbsd-tdep.h (fbsd_skip_solib_resolver): New prototype. * mips-fbsd-tdep.c (mips_fbsd_skip_solib_resolver): New function. (mips_fbsd_init_abi): Install gdbarch "skip_solib_resolver" method. --- gdb/ChangeLog | 9 +++++++++ gdb/fbsd-tdep.c | 14 ++++++++++++++ gdb/fbsd-tdep.h | 5 +++++ gdb/mips-fbsd-tdep.c | 16 ++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1b5bc8b458..ceff8178d7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2020-07-17 John Baldwin + + * fbsd-tdep.c (fbsd_skip_solib_resolver): New function. + (fbsd_init_abi): Install gdbarch "skip_solib_resolver" method. + * fbsd-tdep.h (fbsd_skip_solib_resolver): New prototype. + * mips-fbsd-tdep.c (mips_fbsd_skip_solib_resolver): New function. + (mips_fbsd_init_abi): Install gdbarch "skip_solib_resolver" + method. + 2020-07-17 Tom Tromey * linux-nat.c (linux_nat_target::supports_non_stop) diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 557c5d3d73..ca397fa8e0 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -21,6 +21,7 @@ #include "auxv.h" #include "gdbcore.h" #include "inferior.h" +#include "objfiles.h" #include "regcache.h" #include "regset.h" #include "gdbthread.h" @@ -2071,6 +2072,18 @@ fbsd_get_thread_local_address (struct gdbarch *gdbarch, CORE_ADDR dtv_addr, return addr + offset; } +/* See fbsd-tdep.h. */ + +CORE_ADDR +fbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + struct bound_minimal_symbol msym = lookup_bound_minimal_symbol ("_rtld_bind"); + if (msym.minsym != nullptr && BMSYMBOL_VALUE_ADDRESS (msym) == pc) + return frame_unwind_caller_pc (get_current_frame ()); + + return 0; +} + /* To be called from GDB_OSABI_FREEBSD handlers. */ void @@ -2085,6 +2098,7 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type); set_gdbarch_gdb_signal_from_target (gdbarch, fbsd_gdb_signal_from_target); set_gdbarch_gdb_signal_to_target (gdbarch, fbsd_gdb_signal_to_target); + set_gdbarch_skip_solib_resolver (gdbarch, fbsd_skip_solib_resolver); /* `catch syscall' */ set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml"); diff --git a/gdb/fbsd-tdep.h b/gdb/fbsd-tdep.h index 5dd8203299..e8e49dc25f 100644 --- a/gdb/fbsd-tdep.h +++ b/gdb/fbsd-tdep.h @@ -71,4 +71,9 @@ extern CORE_ADDR fbsd_get_thread_local_address (struct gdbarch *gdbarch, CORE_ADDR lm_addr, CORE_ADDR offset); +/* Implement the "skip_solib_resolver" gdbarch method. */ + +extern CORE_ADDR fbsd_skip_solib_resolver (struct gdbarch *gdbarch, + CORE_ADDR pc); + #endif /* fbsd-tdep.h */ diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c index abaf7f2474..ba666f1dc5 100644 --- a/gdb/mips-fbsd-tdep.c +++ b/gdb/mips-fbsd-tdep.c @@ -462,6 +462,20 @@ static const struct tramp_frame mips64_fbsd_sigframe = /* Shared library support. */ +/* FreeBSD/mips can use an alternate routine in the runtime linker to + resolve functions. */ + +static CORE_ADDR +mips_fbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + struct bound_minimal_symbol msym + = lookup_bound_minimal_symbol ("_mips_rtld_bind"); + if (msym.minsym != nullptr && BMSYMBOL_VALUE_ADDRESS (msym) == pc) + return frame_unwind_caller_pc (get_current_frame ()); + + return fbsd_skip_solib_resolver (gdbarch, pc); +} + /* FreeBSD/mips uses a slightly different `struct link_map' than the other FreeBSD platforms as it includes an additional `l_off' member. */ @@ -546,6 +560,8 @@ mips_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_iterate_over_regset_sections (gdbarch, mips_fbsd_iterate_over_regset_sections); + set_gdbarch_skip_solib_resolver (gdbarch, mips_fbsd_skip_solib_resolver); + /* FreeBSD/mips has SVR4-style shared libraries. */ set_solib_svr4_fetch_link_map_offsets (gdbarch, (gdbarch_ptr_bit (gdbarch) == 32 ? -- 2.25.1