]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
XCOFF constify
authorAlan Modra <amodra@gmail.com>
Tue, 15 Dec 2020 11:40:27 +0000 (22:10 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 16 Dec 2020 04:47:53 +0000 (15:17 +1030)
There are occasions where it is reasonable to use a macro defining
function parameters, but this isn't one of them.  Use typedefs
instead, which also simplifies declaring a const array of function
pointers.

* libxcoff.h (struct xcoff_backend_data_rec): Constify
_xcoff_glink_code.
(XCOFF_RELOC_FUNCTION_ARGS, XCOFF_COMPLAIN_FUNCTION_ARGS): Delete.
(xcoff_reloc_function, xcoff_complain_function): New typedef.
(xcoff_calculate_relocation, xcoff_complain_overflow),
(xcoff_reloc_type_noop, xcoff_reloc_type_fail),
(xcoff_reloc_type_pos, xcoff_reloc_type_neg),
(xcoff_reloc_type_rel, xcoff_reloc_type_toc),
(xcoff_reloc_type_ba, xcoff_reloc_type_crel): Update declaration.
* coff-rs6000.c (xcoff_reloc_type_br): Declare using typedef.
(xcoff_complain_overflow_dont_func): Likewise.
(xcoff_complain_overflow_bitfield_func): Likewise.
(xcoff_complain_overflow_signed_func): Likewise.
(xcoff_complain_overflow_unsigned_func): Likewise.
(xcoff_calculate_relocation, xcoff_complain_overflow): Constify.
(xcoff_glink_code): Constify.
* coff64-rs6000.c (xcoff64_reloc_type_br): Declare using typedef.
(xcoff64_calculate_relocation, xcoff64_glink_code): Constify.

bfd/ChangeLog
bfd/coff-rs6000.c
bfd/coff64-rs6000.c
bfd/libxcoff.h

index fd9a99ccf9d6439c6c72877e4408ea432564d7cf..ebbf970631859ba669665702d14ab267b3558690 100644 (file)
@@ -1,3 +1,24 @@
+2020-12-16  Alan Modra  <amodra@gmail.com>
+
+       * libxcoff.h (struct xcoff_backend_data_rec): Constify
+       _xcoff_glink_code.
+       (XCOFF_RELOC_FUNCTION_ARGS, XCOFF_COMPLAIN_FUNCTION_ARGS): Delete.
+       (xcoff_reloc_function, xcoff_complain_function): New typedef.
+       (xcoff_calculate_relocation, xcoff_complain_overflow),
+       (xcoff_reloc_type_noop, xcoff_reloc_type_fail),
+       (xcoff_reloc_type_pos, xcoff_reloc_type_neg),
+       (xcoff_reloc_type_rel, xcoff_reloc_type_toc),
+       (xcoff_reloc_type_ba, xcoff_reloc_type_crel): Update declaration.
+       * coff-rs6000.c (xcoff_reloc_type_br): Declare using typedef.
+       (xcoff_complain_overflow_dont_func): Likewise.
+       (xcoff_complain_overflow_bitfield_func): Likewise.
+       (xcoff_complain_overflow_signed_func): Likewise.
+       (xcoff_complain_overflow_unsigned_func): Likewise.
+       (xcoff_calculate_relocation, xcoff_complain_overflow): Constify.
+       (xcoff_glink_code): Constify.
+       * coff64-rs6000.c (xcoff64_reloc_type_br): Declare using typedef.
+       (xcoff64_calculate_relocation, xcoff64_glink_code): Constify.
+
 2020-12-16  Alan Modra  <amodra@gmail.com>
 
        * elf32-xtensa.c (narrowable, widenable): Constify.
index 5e5b182da9c0b5ae0bc65254f335429ccd35e992..2854f928dbecfc874010af18e0a0ce26b55159f3 100644 (file)
@@ -148,19 +148,15 @@ static bfd_boolean do_pad (bfd *, unsigned int);
 static bfd_boolean do_copy (bfd *, bfd *);
 
 /* Relocation functions */
-static bfd_boolean xcoff_reloc_type_br (XCOFF_RELOC_FUNCTION_ARGS);
-
-static bfd_boolean xcoff_complain_overflow_dont_func
-  (XCOFF_COMPLAIN_FUNCTION_ARGS);
-static bfd_boolean xcoff_complain_overflow_bitfield_func
-  (XCOFF_COMPLAIN_FUNCTION_ARGS);
-static bfd_boolean xcoff_complain_overflow_signed_func
-  (XCOFF_COMPLAIN_FUNCTION_ARGS);
-static bfd_boolean xcoff_complain_overflow_unsigned_func
-  (XCOFF_COMPLAIN_FUNCTION_ARGS);
-
-bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
-  (XCOFF_RELOC_FUNCTION_ARGS) =
+static xcoff_reloc_function xcoff_reloc_type_br;
+
+static xcoff_complain_function xcoff_complain_overflow_dont_func;
+static xcoff_complain_function xcoff_complain_overflow_bitfield_func;
+static xcoff_complain_function xcoff_complain_overflow_signed_func;
+static xcoff_complain_function xcoff_complain_overflow_unsigned_func;
+
+xcoff_reloc_function *const
+xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION] =
 {
   xcoff_reloc_type_pos,         /* R_POS   (0x00) */
   xcoff_reloc_type_neg,         /* R_NEG   (0x01) */
@@ -192,8 +188,8 @@ bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
   xcoff_reloc_type_ba,  /* R_RBRC  (0x1b) */
 };
 
-bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
-  (XCOFF_COMPLAIN_FUNCTION_ARGS) =
+xcoff_complain_function *const
+xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW] =
 {
   xcoff_complain_overflow_dont_func,
   xcoff_complain_overflow_bitfield_func,
@@ -3981,7 +3977,7 @@ HOWTO (0,                 /* type */
    The first word of global linkage code must be modified by filling in
    the correct TOC offset.  */
 
-static unsigned long xcoff_glink_code[9] =
+static const unsigned long xcoff_glink_code[9] =
   {
     0x81820000,        /* lwz r12,0(r2) */
     0x90410014,        /* stw r2,20(r1) */
index 7185232ce14b6d140354cdf095efb0a8b0b9cd02..6b7cd34b333833bb61a3c539657f611bf46aaa4f 100644 (file)
@@ -177,11 +177,10 @@ static bfd_boolean xcoff64_bad_format_hook
   (bfd *, void *);
 
 /* Relocation functions */
-static bfd_boolean xcoff64_reloc_type_br
-  (XCOFF_RELOC_FUNCTION_ARGS);
+static xcoff_reloc_function xcoff64_reloc_type_br;
 
-bfd_boolean (*xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
-  (XCOFF_RELOC_FUNCTION_ARGS) =
+xcoff_reloc_function *const
+xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION] =
 {
   xcoff_reloc_type_pos,         /* R_POS   (0x00) */
   xcoff_reloc_type_neg,         /* R_NEG   (0x01) */
@@ -2539,7 +2538,7 @@ HOWTO (0,                 /* type */
        MINUS_ONE,              /* dst_mask */
        FALSE);                 /* pcrel_offset */
 
-static unsigned long xcoff64_glink_code[10] =
+static const unsigned long xcoff64_glink_code[10] =
 {
   0xe9820000,  /* ld r12,0(r2) */
   0xf8410028,  /* std r2,40(r1) */
index cba9afd3e56565472d8d3976468f3a813111a6eb..c4b69ac1b7dc12b6c5817d64b1b68cdbb8df920f 100644 (file)
@@ -90,7 +90,7 @@ struct xcoff_backend_data_rec
 
   /* Global linkage.  The first word of global linkage code must be be
      modified by filling in the correct TOC offset.  */
-  unsigned long *_xcoff_glink_code;
+  const unsigned long *_xcoff_glink_code;
 
   /* Size of the global link code in bytes of the xcoff_glink_code table.  */
   unsigned long _xcoff_glink_size;
@@ -210,30 +210,30 @@ struct xcoff_backend_data_rec
 #endif
 #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
 
-#define XCOFF_RELOC_FUNCTION_ARGS \
-  bfd *, asection *, bfd *, struct internal_reloc *, \
-  struct internal_syment *, struct reloc_howto_struct *, bfd_vma, bfd_vma, \
-  bfd_vma *relocation, bfd_byte *contents
+typedef bfd_boolean xcoff_reloc_function (bfd *, asection *, bfd *,
+                                         struct internal_reloc *,
+                                         struct internal_syment *,
+                                         struct reloc_howto_struct *,
+                                         bfd_vma, bfd_vma,
+                                         bfd_vma *, bfd_byte *);
 
-#define XCOFF_COMPLAIN_FUNCTION_ARGS \
-  bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto
+typedef bfd_boolean xcoff_complain_function (bfd *, bfd_vma, bfd_vma,
+                                            struct reloc_howto_struct *);
 
-extern bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
-  (XCOFF_RELOC_FUNCTION_ARGS);
-extern bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
-  (XCOFF_COMPLAIN_FUNCTION_ARGS);
+extern xcoff_reloc_function *const xcoff_calculate_relocation[];
+extern xcoff_complain_function *const xcoff_complain_overflow[];
 
 #define XCOFF_NO_LONG_SECTION_NAMES  (FALSE), bfd_coff_set_long_section_names_disallowed
 
 /* Relocation functions */
-bfd_boolean xcoff_reloc_type_noop (XCOFF_RELOC_FUNCTION_ARGS);
-bfd_boolean xcoff_reloc_type_fail (XCOFF_RELOC_FUNCTION_ARGS);
-bfd_boolean xcoff_reloc_type_pos  (XCOFF_RELOC_FUNCTION_ARGS);
-bfd_boolean xcoff_reloc_type_neg  (XCOFF_RELOC_FUNCTION_ARGS);
-bfd_boolean xcoff_reloc_type_rel  (XCOFF_RELOC_FUNCTION_ARGS);
-bfd_boolean xcoff_reloc_type_toc  (XCOFF_RELOC_FUNCTION_ARGS);
-bfd_boolean xcoff_reloc_type_ba   (XCOFF_RELOC_FUNCTION_ARGS);
-bfd_boolean xcoff_reloc_type_crel (XCOFF_RELOC_FUNCTION_ARGS);
+extern xcoff_reloc_function xcoff_reloc_type_noop;
+extern xcoff_reloc_function xcoff_reloc_type_fail;
+extern xcoff_reloc_function xcoff_reloc_type_pos;
+extern xcoff_reloc_function xcoff_reloc_type_neg;
+extern xcoff_reloc_function xcoff_reloc_type_rel;
+extern xcoff_reloc_function xcoff_reloc_type_toc;
+extern xcoff_reloc_function xcoff_reloc_type_ba;
+extern xcoff_reloc_function xcoff_reloc_type_crel;
 
 /* Structure to describe dwarf sections.
    Useful to convert from XCOFF section name to flag and vice-versa.