From: Simon Marchi Date: Mon, 26 May 2025 20:26:14 +0000 (-0400) Subject: gdb/solib: boolify in_dynsym_resolve_code functions X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d309f4d8a768776c749283c05ff0d3445313ca4e;p=thirdparty%2Fbinutils-gdb.git gdb/solib: boolify in_dynsym_resolve_code functions Change-Id: I66f5986e1a2452e3817f326d908b2e49f99e2fc6 Reviewed-By: Guinevere Larsen --- diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index 46766e40a19..bf3df3697e1 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -666,24 +666,24 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc) return 1; } -/* Return non-zero iff PC belongs to the dynamic linker resolution +/* Return true iff PC belongs to the dynamic linker resolution code, a PLT entry, or a lazy binding stub. */ -static int +static bool mips_linux_in_dynsym_resolve_code (CORE_ADDR pc) { /* Check whether PC is in the dynamic linker. This also checks whether it is in the .plt section, used by non-PIC executables. */ if (svr4_in_dynsym_resolve_code (pc)) - return 1; + return true; /* Likewise for the stubs. They live in the .MIPS.stubs section these days, so we check if the PC is within, than fall back to a pattern match. */ if (mips_linux_in_dynsym_stub (pc)) - return 1; + return true; - return 0; + return false; } /* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c, diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 41aacc372bc..4a3475862a9 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -989,10 +989,10 @@ extern struct obj_section *find_pc_section (CORE_ADDR pc); /* Return true if PC is in a section called NAME. */ extern bool pc_in_section (CORE_ADDR, const char *); -/* Return non-zero if PC is in a SVR4-style procedure linkage table +/* Return true if PC is in a SVR4-style procedure linkage table section. */ -static inline int +static inline bool in_plt_section (CORE_ADDR pc) { return (pc_in_section (pc, ".plt") diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index c998fc2dbe1..b3cc4d5485e 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -310,22 +310,22 @@ static const struct ppc_insn_pattern powerpc32_plt_stub_so_2[] = section. For secure PLT, stub is in .text and we need to check instruction patterns. */ -static int +static bool powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc) { /* Check whether PC is in the dynamic linker. This also checks whether it is in the .plt section, used by non-PIC executables. */ if (svr4_in_dynsym_resolve_code (pc)) - return 1; + return true; /* Check if we are in the resolver. */ bound_minimal_symbol sym = lookup_minimal_symbol_by_pc (pc); - if (sym.minsym != NULL - && (strcmp (sym.minsym->linkage_name (), "__glink") == 0 - || strcmp (sym.minsym->linkage_name (), "__glink_PLTresolve") == 0)) - return 1; - return 0; + if (sym.minsym == nullptr) + return false; + + return (strcmp (sym.minsym->linkage_name (), "__glink") == 0 + || strcmp (sym.minsym->linkage_name (), "__glink_PLTresolve") == 0); } /* Follow PLT stub to actual routine. diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index fb9c781f510..4eb89e9341b 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -499,10 +499,10 @@ solib_aix_open_symbol_file_object (int from_tty) /* Implement the "in_dynsym_resolve_code" solib_ops method. */ -static int +static bool solib_aix_in_dynsym_resolve_code (CORE_ADDR pc) { - return 0; + return false; } /* Implement the "bfd_open" solib_ops method. */ diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index c0c6fb55524..86a71bb2280 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -363,13 +363,13 @@ darwin_read_exec_load_addr_at_init (struct darwin_info *info) return darwin_validate_exec_header (load_addr); } -/* Return 1 if PC lies in the dynamic symbol resolution code of the +/* Return true if PC lies in the dynamic symbol resolution code of the run time loader. */ -static int +static bool darwin_in_dynsym_resolve_code (CORE_ADDR pc) { - return 0; + return false; } /* A wrapper for bfd_mach_o_fat_extract that handles reference diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 0d8b067a20f..ed6580eca0f 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -629,10 +629,10 @@ dsbt_current_sos (void) return sos; } -/* Return 1 if PC lies in the dynamic symbol resolution code of the +/* Return true if PC lies in the dynamic symbol resolution code of the run time loader. */ -static int +static bool dsbt_in_dynsym_resolve_code (CORE_ADDR pc) { dsbt_info *info = get_dsbt_info (current_program_space); diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 124b5eba590..0ccbf903309 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -423,7 +423,7 @@ static CORE_ADDR interp_text_sect_high; static CORE_ADDR interp_plt_sect_low; static CORE_ADDR interp_plt_sect_high; -static int +static bool frv_in_dynsym_resolve_code (CORE_ADDR pc) { return ((pc >= interp_text_sect_low && pc < interp_text_sect_high) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 4aa30858df5..5a8b08edacd 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1802,10 +1802,10 @@ match_main (const char *soname) return (0); } -/* Return 1 if PC lies in the dynamic symbol resolution code of the +/* Return true if PC lies in the dynamic symbol resolution code of the SVR4 run time loader. */ -int +bool svr4_in_dynsym_resolve_code (CORE_ADDR pc) { struct svr4_info *info = get_svr4_info (current_program_space); diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h index 0a04d9c2ee6..1ff9be78a43 100644 --- a/gdb/solib-svr4.h +++ b/gdb/solib-svr4.h @@ -108,9 +108,9 @@ extern CORE_ADDR svr4_fetch_objfile_link_map (struct objfile *objfile); extern struct link_map_offsets *svr4_ilp32_fetch_link_map_offsets (void); extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void); -/* Return 1 if PC lies in the dynamic symbol resolution code of the +/* Return true if PC lies in the dynamic symbol resolution code of the SVR4 run time loader. */ -int svr4_in_dynsym_resolve_code (CORE_ADDR pc); +bool svr4_in_dynsym_resolve_code (CORE_ADDR pc); /* For the MUSL C library, given link map address LM_ADDR, return the corresponding TLS module id, or 0 if not found. */ diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 41a7f8eb68f..7ccb87daa95 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -390,7 +390,7 @@ solib_target_open_symbol_file_object (int from_tty) return 0; } -static int +static bool solib_target_in_dynsym_resolve_code (CORE_ADDR pc) { /* We don't have a range of addresses for the dynamic linker; there diff --git a/gdb/solib.c b/gdb/solib.c index 1a105bd7cb9..8a997a40c22 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1324,9 +1324,8 @@ solib_create_inferior_hook (int from_tty) bool in_solib_dynsym_resolve_code (CORE_ADDR pc) { - const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); - - return ops->in_dynsym_resolve_code (pc) != 0; + return (gdbarch_so_ops (current_inferior ()->arch ()) + ->in_dynsym_resolve_code (pc)); } /* Implements the "sharedlibrary" command. */ diff --git a/gdb/solib.h b/gdb/solib.h index 4955eedd629..f5922aa5f5d 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -150,7 +150,7 @@ struct solib_ops /* Determine if PC lies in the dynamic symbol resolution code of the run time loader. */ - int (*in_dynsym_resolve_code) (CORE_ADDR pc); + bool (*in_dynsym_resolve_code) (CORE_ADDR pc); /* Find and open shared library binary file. */ gdb_bfd_ref_ptr (*bfd_open) (const char *pathname);