]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Constify target name, reloc name, and carsym name
authorAlan Modra <amodra@gmail.com>
Wed, 18 Sep 2019 05:34:27 +0000 (15:04 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 18 Sep 2019 12:02:51 +0000 (21:32 +0930)
bfd/
* bfd-in.h (carsym.name): Make const.
* reloc.c (struct reloc_howto_struct.name): Likewise.
* targets.c (bfd_target.name): Likewise.!
* bfd.c (bfd_get_sign_extend_vma): Make variable const.
* som.c (som_bfd_fill_in_ar_symbols): Use an intermediary variable
when setting carsym.name.
* bfd-in2.h: Regenerate.
gdb/
* amd64-dicos-tdep.c (amd64_dicos_osabi_sniffer): Constify target.
* i386-cygwin-tdep.c (i386_cygwin_init_abi): Likewise.
* i386-dicos-tdep.c (i386_dicos_osabi_sniffer): Likewise.
ld/
* ldlang.c (stricpy, strcut, name_compare): Constify params.
(get_first_input_target): Make return and "target" const.

13 files changed:
bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/bfd.c
bfd/reloc.c
bfd/som.c
bfd/targets.c
gdb/ChangeLog
gdb/amd64-dicos-tdep.c
gdb/i386-cygwin-tdep.c
gdb/i386-dicos-tdep.c
ld/ChangeLog
ld/ldlang.c

index 08605c3a80a8984e6b6dfbdbc32a0067eefb5bbb..8c5ce8b8b2aa452748d4864e5be016d4ebcebbef 100644 (file)
@@ -1,3 +1,13 @@
+2019-09-18  Alan Modra  <amodra@gmail.com>
+
+       * bfd-in.h (carsym.name): Make const.
+       * reloc.c (struct reloc_howto_struct.name): Likewise.
+       * targets.c (bfd_target.name): Likewise.!
+       * bfd.c (bfd_get_sign_extend_vma): Make variable const.
+       * som.c (som_bfd_fill_in_ar_symbols): Use an intermediary variable
+       when setting carsym.name.
+       * bfd-in2.h: Regenerate.
+
 2019-09-18  Alan Modra  <amodra@gmail.com>
 
        * mach-o.c (bfd_mach_o_fat_member_init): Likewise.  Replace
index 6544838a575e40c97e1c2fc07cf8b99e3e291aa1..6c72acb705944e0ff70bbe14c3ed169f766ebc3c 100644 (file)
@@ -257,7 +257,7 @@ typedef unsigned long symindex;
 /* This is a type pun with struct ranlib on purpose!  */
 typedef struct carsym
 {
-  char *name;
+  const char *name;
   file_ptr file_offset;        /* Look here to find the file.  */
 }
 carsym;                        /* To make these you call a carsymogen.  */
index 13445a1de71bd6cc44e13fece30c072fb8967ea9..135c1e5fbc4ca425c39e0333d15b93f1111af1f7 100644 (file)
@@ -264,7 +264,7 @@ typedef unsigned long symindex;
 /* This is a type pun with struct ranlib on purpose!  */
 typedef struct carsym
 {
-  char *name;
+  const char *name;
   file_ptr file_offset;        /* Look here to find the file.  */
 }
 carsym;                        /* To make these you call a carsymogen.  */
@@ -2718,7 +2718,7 @@ struct reloc_howto_struct
      bfd *, char **);
 
   /* The textual name of the relocation type.  */
-  char *name;
+  const char *name;
 };
 
 #define HOWTO(type, right, size, bits, pcrel, left, ovf, func, name,   \
@@ -7634,7 +7634,7 @@ typedef struct flag_info flag_info;
 typedef struct bfd_target
 {
   /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  */
-  char *name;
+  const char *name;
 
  /* The "flavour" of a back end is a general indication about
     the contents of a file.  */
index f14ec253fb795632fec86ec56ede1d72a42349ca..91403508a9a100f94b7689da95d23c5f1241fe35 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1507,7 +1507,7 @@ RETURNS
 int
 bfd_get_sign_extend_vma (bfd *abfd)
 {
-  char *name;
+  const char *name;
 
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     return get_elf_backend_data (abfd)->sign_extend_vma;
index 9ca68ca61dad38bab4fb55fc20f089381fd81a5c..8eac73ddfe588cc96e3e0df91d9d44cce2545093 100644 (file)
@@ -361,7 +361,7 @@ CODE_FRAGMENT
 .     bfd *, char **);
 .
 .  {* The textual name of the relocation type.  *}
-.  char *name;
+.  const char *name;
 .};
 .
 */
index 02a99a336073adfc0242945c1122143df4e30702..cf788434523ca374f3b58851300be2a6f8c82018 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -5995,6 +5995,7 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
       unsigned int hash_val;
       unsigned int len;
       unsigned char ext_len[4];
+      char *name;
 
       /* An empty chain has zero as it's file offset.  */
       hash_val = bfd_getb32 (hash_table + 4 * i);
@@ -6025,13 +6026,14 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
       len = bfd_getb32 (ext_len);
 
       /* Allocate space for the name and null terminate it too.  */
-      set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
-      if (!set->name)
+      name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
+      if (!name)
        goto error_return;
-      if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
+      if (bfd_bread (name, (bfd_size_type) len, abfd) != len)
        goto error_return;
 
-      set->name[len] = 0;
+      name[len] = 0;
+      set->name = name;
 
       /* Fill in the file offset.  Note that the "location" field points
         to the SOM itself, not the ar_hdr in front of it.  */
@@ -6068,13 +6070,14 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
          len = bfd_getb32 (ext_len);
 
          /* Allocate space for the name and null terminate it too.  */
-         set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
-         if (!set->name)
+         name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
+         if (!name)
            goto error_return;
 
-         if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
+         if (bfd_bread (name, (bfd_size_type) len, abfd) != len)
            goto error_return;
-         set->name[len] = 0;
+         name[len] = 0;
+         set->name = name;
 
          /* Fill in the file offset.  Note that the "location" field points
             to the SOM itself, not the ar_hdr in front of it.  */
index 09956994ec9247cb977c2e2f5739e191227eb5cc..b02dfc548474f6b3f9ed7c73ae63d32c257c17e6 100644 (file)
@@ -179,7 +179,7 @@ DESCRIPTION
 .typedef struct bfd_target
 .{
 .  {* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  *}
-.  char *name;
+.  const char *name;
 .
 . {* The "flavour" of a back end is a general indication about
 .    the contents of a file.  *}
index 9ad5000480c20be322b5122c0289d7dcd4087acd..5e0e37bcfaff2e362ebf4ee8dc657c9ea3b9383f 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-18  Alan Modra  <amodra@gmail.com>
+
+       * amd64-dicos-tdep.c (amd64_dicos_osabi_sniffer): Constify target.
+       * i386-cygwin-tdep.c (i386_cygwin_init_abi): Likewise.
+       * i386-dicos-tdep.c (i386_dicos_osabi_sniffer): Likewise.
+
 2019-09-18  Alan Modra  <amodra@gmail.com>
 
        * solib-spu.c (spu_bfd_open): Use bfd_set_filename.
index e797843bc9f514fa6de1fb1d6456b7de85447183..ee91888491b340838601d048b4257dd07641b3ad 100644 (file)
@@ -35,7 +35,7 @@ amd64_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static enum gdb_osabi
 amd64_dicos_osabi_sniffer (bfd *abfd)
 {
-  char *target_name = bfd_get_target (abfd);
+  const char *target_name = bfd_get_target (abfd);
 
   /* On amd64-DICOS, the Load Module's "header" section is 72
      bytes.  */
index 1acd37975ee8c26dfe2873ab76e1909d21394691..0e3ba82b76474f2479da16522fb483cb17467c87 100644 (file)
@@ -229,7 +229,7 @@ i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static enum gdb_osabi
 i386_cygwin_osabi_sniffer (bfd *abfd)
 {
-  char *target_name = bfd_get_target (abfd);
+  const char *target_name = bfd_get_target (abfd);
 
   if (strcmp (target_name, "pei-i386") == 0)
     return GDB_OSABI_CYGWIN;
index 02af91aefd890def117045c5aecf0d5f03b401bc..a8c7c04d1fc5fc74bae5cffd3060bc7c2b42d339 100644 (file)
@@ -31,7 +31,7 @@ i386_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static enum gdb_osabi
 i386_dicos_osabi_sniffer (bfd *abfd)
 {
-  char *target_name = bfd_get_target (abfd);
+  const char *target_name = bfd_get_target (abfd);
 
   /* On x86-DICOS, the Load Module's "header" section is 36 bytes.  */
   if (strcmp (target_name, "elf32-i386") == 0
index 81935a408c582226d4bd7da57914ba249c619402..b863676ccd1a688a23c40a014062115f59204057 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-18  Alan Modra  <amodra@gmail.com>
+
+       * ldlang.c (stricpy, strcut, name_compare): Constify params.
+       (get_first_input_target): Make return and "target" const.
+
 2019-09-18  Alan Modra  <amodra@gmail.com>
 
        * emultempl/pe.em (after_open): Use bfd_set_filename.
index 8beccd373636df55cf8774e05562108b7ca70773..76e862a6409d1d92ef50cc2f507d783ef97c9c05 100644 (file)
@@ -3149,7 +3149,7 @@ get_target (const bfd_target *target, void *data)
 /* Like strcpy() but convert to lower case as well.  */
 
 static void
-stricpy (char *dest, char *src)
+stricpy (char *dest, const char *src)
 {
   char c;
 
@@ -3163,7 +3163,7 @@ stricpy (char *dest, char *src)
    from haystack.  */
 
 static void
-strcut (char *haystack, char *needle)
+strcut (char *haystack, const char *needle)
 {
   haystack = strstr (haystack, needle);
 
@@ -3182,7 +3182,7 @@ strcut (char *haystack, char *needle)
    Return a value indicating how "similar" they are.  */
 
 static int
-name_compare (char *first, char *second)
+name_compare (const char *first, const char *second)
 {
   char *copy1;
   char *copy2;
@@ -3267,10 +3267,10 @@ closest_target_match (const bfd_target *target, void *data)
 
 /* Return the BFD target format of the first input file.  */
 
-static char *
+static const char *
 get_first_input_target (void)
 {
-  char *target = NULL;
+  const char *target = NULL;
 
   LANG_FOR_EACH_INPUT_STATEMENT (s)
     {