Use 'const' in some gdbarch methods

This changes a couple of gdbarch methods to use 'const' for an
"asymbol *" parameter.  These methods shouldn't be modifying the
underlying symbol in the BFD.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey 2025-03-06 10:09:38 -07:00
parent 8d95753834
commit 78dd36b8f2
9 changed files with 24 additions and 20 deletions

View File

@ -9719,9 +9719,9 @@ coff_sym_is_thumb (int val)
symbol to indicate that it does. */
static void
arm_elf_make_msymbol_special(asymbol *sym, struct minimal_symbol *msym)
arm_elf_make_msymbol_special (const asymbol *sym, struct minimal_symbol *msym)
{
elf_symbol_type *elfsym = (elf_symbol_type *) sym;
const elf_symbol_type *elfsym = (const elf_symbol_type *) sym;
if (ARM_GET_SYM_BRANCH_TYPE (elfsym->internal_elf_sym.st_target_internal)
== ST_BRANCH_TO_THUMB)
@ -9737,7 +9737,7 @@ arm_coff_make_msymbol_special(int val, struct minimal_symbol *msym)
static void
arm_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile,
asymbol *sym)
const asymbol *sym)
{
const char *name = bfd_asymbol_name (sym);
struct arm_per_bfd *data;

View File

@ -3562,7 +3562,7 @@ gdbarch_elf_make_msymbol_special_p (struct gdbarch *gdbarch)
}
void
gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym)
gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, const asymbol *sym, struct minimal_symbol *msym)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->elf_make_msymbol_special != NULL);
@ -4575,7 +4575,7 @@ gdbarch_record_special_symbol_p (struct gdbarch *gdbarch)
}
void
gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym)
gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, const asymbol *sym)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->record_special_symbol != NULL);

View File

@ -867,8 +867,8 @@ extern void set_gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, gdbarc
extern bool gdbarch_elf_make_msymbol_special_p (struct gdbarch *gdbarch);
typedef void (gdbarch_elf_make_msymbol_special_ftype) (asymbol *sym, struct minimal_symbol *msym);
extern void gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym);
typedef void (gdbarch_elf_make_msymbol_special_ftype) (const asymbol *sym, struct minimal_symbol *msym);
extern void gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, const asymbol *sym, struct minimal_symbol *msym);
extern void set_gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special);
typedef void (gdbarch_coff_make_msymbol_special_ftype) (int val, struct minimal_symbol *msym);
@ -1325,8 +1325,8 @@ extern void set_gdbarch_get_siginfo_type (struct gdbarch *gdbarch, gdbarch_get_s
extern bool gdbarch_record_special_symbol_p (struct gdbarch *gdbarch);
typedef void (gdbarch_record_special_symbol_ftype) (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym);
extern void gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym);
typedef void (gdbarch_record_special_symbol_ftype) (struct gdbarch *gdbarch, struct objfile *objfile, const asymbol *sym);
extern void gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, const asymbol *sym);
extern void set_gdbarch_record_special_symbol (struct gdbarch *gdbarch, gdbarch_record_special_symbol_ftype *record_special_symbol);
/* Function for the 'catch syscall' feature.

View File

@ -1506,7 +1506,7 @@ the main symbol table and DWARF-2 records.
""",
type="void",
name="elf_make_msymbol_special",
params=[("asymbol *", "sym"), ("struct minimal_symbol *", "msym")],
params=[("const asymbol *", "sym"), ("struct minimal_symbol *", "msym")],
predicate=True,
)
@ -2126,7 +2126,7 @@ Record architecture-specific information from the symbol table.
""",
type="void",
name="record_special_symbol",
params=[("struct objfile *", "objfile"), ("asymbol *", "sym")],
params=[("struct objfile *", "objfile"), ("const asymbol *", "sym")],
predicate=True,
)

View File

@ -1326,11 +1326,12 @@ m68hc11_return_value (struct gdbarch *gdbarch, struct value *function,
rti to return. */
static void
m68hc11_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
m68hc11_elf_make_msymbol_special (const asymbol *sym,
struct minimal_symbol *msym)
{
unsigned char flags;
flags = ((elf_symbol_type *)sym)->internal_elf_sym.st_other;
flags = ((const elf_symbol_type *) sym)->internal_elf_sym.st_other;
if (flags & STO_M68HC12_FAR)
MSYMBOL_SET_RTC (msym);
if (flags & STO_M68HC12_INTERRUPT)

View File

@ -422,9 +422,10 @@ mips_unmake_compact_addr (CORE_ADDR addr)
in a minimal symbol. */
static void
mips_elf_make_msymbol_special (asymbol * sym, struct minimal_symbol *msym)
mips_elf_make_msymbol_special (const asymbol * sym,
struct minimal_symbol *msym)
{
elf_symbol_type *elfsym = (elf_symbol_type *) sym;
const elf_symbol_type *elfsym = (const elf_symbol_type *) sym;
unsigned char st_other;
if ((sym->flags & BSF_SYNTHETIC) == 0)

View File

@ -1638,14 +1638,15 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch,
gdbarch.h. This implementation is used for the ELFv2 ABI only. */
static void
ppc_elfv2_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
ppc_elfv2_elf_make_msymbol_special (const asymbol *sym,
struct minimal_symbol *msym)
{
if ((sym->flags & BSF_SYNTHETIC) != 0)
/* ELFv2 synthetic symbols (the PLT stubs and the __glink_PLTresolve
trampoline) do not have a local entry point. */
return;
elf_symbol_type *elf_sym = (elf_symbol_type *)sym;
const elf_symbol_type *elf_sym = (const elf_symbol_type *)sym;
/* If the symbol is marked as having a local entry point, set a target
flag in the msymbol. We currently only support local entry point

View File

@ -793,11 +793,12 @@ ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
from that symbol. */
void
ppc64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
ppc64_elf_make_msymbol_special (const asymbol *sym,
struct minimal_symbol *msym)
{
if ((sym->flags & BSF_SYNTHETIC) != 0 && sym->udata.p != NULL)
{
elf_symbol_type *elf_sym = (elf_symbol_type *) sym->udata.p;
const elf_symbol_type *elf_sym = (const elf_symbol_type *) sym->udata.p;
msym->set_size (elf_sym->internal_elf_sym.st_size);
}
}

View File

@ -31,6 +31,6 @@ extern CORE_ADDR ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
CORE_ADDR addr,
struct target_ops *targ);
extern void ppc64_elf_make_msymbol_special (asymbol *,
extern void ppc64_elf_make_msymbol_special (const asymbol *,
struct minimal_symbol *);
#endif /* GDB_PPC64_TDEP_H */