]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use 'const' in some gdbarch methods
authorTom Tromey <tromey@adacore.com>
Thu, 6 Mar 2025 17:09:38 +0000 (10:09 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 6 Mar 2025 18:25:45 +0000 (11:25 -0700)
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>
gdb/arm-tdep.c
gdb/gdbarch-gen.c
gdb/gdbarch-gen.h
gdb/gdbarch_components.py
gdb/m68hc11-tdep.c
gdb/mips-tdep.c
gdb/ppc-linux-tdep.c
gdb/ppc64-tdep.c
gdb/ppc64-tdep.h

index bdad0779ca7c5a5b68036b4f989244ef8fc361b9..879f5cf2447488c40360e4d18215f1e496be55f1 100644 (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;
index 8137ece78bcb1aca8a45658c2fbeb99f436903b3..97d7ed9b069d31cb49ed4c6a253748247f431bd7 100644 (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);
index abffcf99fac6c832dc710b702ba4fedb76b9042c..7a52f79d762f169dd7714b7d6defe5f060f62bfb 100644 (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.
index e0fd74e80d145852b43c261548a58a2a1c15e188..cd0a89479486a7611e959fbff3bc9845a9507e68 100644 (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,
 )
 
index 84a44f525c20aa02a4aa7e734863ea90224c03d4..234edcf50bfbfc2f5401f07c4dd36151421a10c3 100644 (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)
index 93f8cd0263ac3f81d034ca4951dd4b06c5c85a27..3613f9bec8d960cfd399ad17e7a5eaf068384fc9 100644 (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)
index 8a5eea765c2885e3d9b0a7d8bc759f39d0fe4862..a9f43c438619b5c1e84d52b803ffe0f4d521cd39 100644 (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
index 79bc4da71e2031b151e021382eebbd0ad5fca4ce..5e758003db97150e2ec3ecdf04d46fa0af1aa5e9 100644 (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);
     }
 }
index 7bea549dda06351cd5642882d5af39846c3010ab..5ad8841166d1e3439d9491527e44146bcd19b989 100644 (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 */