* elf32-s390.c (elf_s390_size_dynamic_sections): Set relocs to TRUE
[binutils-gdb.git] / bfd / coff-ppc.c
index 64371626fd97a8eeafd9950639ad286faf802ae7..f0c82a6dfa3dc19fb905791350b12ae709a5ca1d 100644 (file)
@@ -1,5 +1,6 @@
 /* BFD back-end for PowerPC Microsoft Portable Executable files.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+   2000, 2001, 2002
    Free Software Foundation, Inc.
 
    Original version pieced together by Kim Knuttila (krk@cygnus.com)
@@ -53,7 +54,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* This file is compiled more than once, but we only compile the
    final_link routine once.  */
-extern boolean ppc_bfd_coff_final_link
+extern bfd_boolean ppc_bfd_coff_final_link
   PARAMS ((bfd *, struct bfd_link_info *));
 extern void dump_toc PARAMS ((PTR));
 
@@ -85,10 +86,10 @@ extern void dump_toc PARAMS ((PTR));
 #define HASH_CHECK(addr) \
  if (strcmp(addr->eye_catcher, EYE) != 0) \
   { \
-    fprintf(stderr,\
+    fprintf (stderr,\
     _("File %s, line %d, Hash check failure, bad eye %8s\n"), \
     __FILE__, __LINE__, addr->eye_catcher); \
-    abort(); \
+    abort (); \
  }
 
 #else
@@ -127,14 +128,14 @@ struct ppc_coff_link_hash_table
 static struct bfd_hash_entry *ppc_coff_link_hash_newfunc
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
           const char *));
-static boolean ppc_coff_link_hash_table_init
+static bfd_boolean ppc_coff_link_hash_table_init
   PARAMS ((struct ppc_coff_link_hash_table *, bfd *,
           struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                                       struct bfd_hash_table *,
                                       const char *)));
 static struct bfd_link_hash_table *ppc_coff_link_hash_table_create
   PARAMS ((bfd *));
-static boolean coff_ppc_relocate_section
+static bfd_boolean coff_ppc_relocate_section
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
           struct internal_reloc *, struct internal_syment *, asection **));
 static reloc_howto_type *coff_ppc_rtype_to_howto
@@ -183,7 +184,7 @@ ppc_coff_link_hash_newfunc (entry, table, string)
 
 /* Initialize a PE linker hash table.  */
 
-static boolean
+static bfd_boolean
 ppc_coff_link_hash_table_init (table, abfd, newfunc)
      struct ppc_coff_link_hash_table *table;
      bfd *abfd;
@@ -201,15 +202,15 @@ ppc_coff_link_hash_table_create (abfd)
      bfd *abfd;
 {
   struct ppc_coff_link_hash_table *ret;
+  bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table);
 
-  ret = ((struct ppc_coff_link_hash_table *)
-        bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));
+  ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
   if (! ppc_coff_link_hash_table_init (ret, abfd,
                                        ppc_coff_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
   return &ret->root.root;
@@ -218,7 +219,6 @@ ppc_coff_link_hash_table_create (abfd)
 /* Now, tailor coffcode.h to use our hash stuff */
 
 #define coff_bfd_link_hash_table_create ppc_coff_link_hash_table_create
-
 \f
 /* The nt loader points the toc register to &toc + 32768, in order to */
 /* use the complete range of a 16-bit displacement. We have to adjust */
@@ -316,7 +316,6 @@ ppc_coff_link_hash_table_create (abfd)
 #define EXTRACT_FLAGS(x) ((x) & IMAGE_REL_PPC_FLAGMASK)
 #define EXTRACT_JUNK(x)  \
            ((x) & ~(IMAGE_REL_PPC_TYPEMASK | IMAGE_REL_PPC_FLAGMASK))
-
 \f
 /* static helper functions to make relocation work */
 /* (Work In Progress) */
@@ -344,7 +343,6 @@ static bfd_reloc_status_type ppc_pair_reloc PARAMS ((bfd *abfd,
                                                     asection *section,
                                                     bfd *output_bfd,
                                                     char **error));
-
 \f
 static bfd_reloc_status_type ppc_toc16_reloc PARAMS ((bfd *abfd,
                                                      arelent *reloc,
@@ -387,8 +385,7 @@ static bfd_reloc_status_type ppc_imglue_reloc PARAMS ((bfd *abfd,
                                                       bfd *output_bfd,
                                                       char **error));
 
-static boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));
-
+static bfd_boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));
 \f
 /* FIXME: It'll take a while to get through all of these. I only need a few to
    get us started, so those I'll make sure work. Those marked FIXME are either
@@ -436,15 +433,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                      /* rightshift */
         0,                      /* size (0 = byte, 1 = short, 2 = long) */
         0,                      /* bitsize */
-        false,                  /* pc_relative */
+        FALSE,                  /* pc_relative */
         0,                      /* bitpos */
         complain_overflow_dont, /* dont complain_on_overflow */
         0,                      /* special_function */
         "ABSOLUTE",             /* name */
-        false,                  /* partial_inplace */
+        FALSE,                  /* partial_inplace */
         0x00,                   /* src_mask */
         0x00,                   /* dst_mask */
-        false),                 /* pcrel_offset */
+        FALSE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_ADDR64 0x0001  64-bit address */
   /* Unused: */
@@ -452,15 +449,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
        0,                       /* rightshift */
        3,                       /* size (0 = byte, 1 = short, 2 = long) */
        64,                      /* bitsize */
-       false,                   /* pc_relative */
+       FALSE,                   /* pc_relative */
        0,                       /* bitpos */
        complain_overflow_bitfield,      /* complain_on_overflow */
        0,                       /* special_function */
        "ADDR64",               /* name */
-       true,                    /* partial_inplace */
+       TRUE,                    /* partial_inplace */
        MINUS_ONE,               /* src_mask */
        MINUS_ONE,               /* dst_mask */
-       false),                 /* pcrel_offset */
+       FALSE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_ADDR32 0x0002  32-bit address */
   /* Used: */
@@ -468,15 +465,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         0,                     /* special_function */
         "ADDR32",              /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_ADDR24 0x0003  26-bit address, shifted left 2 (branch absolute) */
   /* the LI field is in bit 6 through bit 29 is 24 bits, + 2 for the shift */
@@ -487,15 +484,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         26,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         0,                     /* special_function */
         "ADDR24",              /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0x07fffffc,            /* src_mask */
         0x07fffffc,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_ADDR16 0x0004  16-bit address */
   /* Used: */
@@ -503,15 +500,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "ADDR16",              /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_ADDR14 0x0005 */
   /*  16-bit address, shifted left 2 (load doubleword) */
@@ -521,15 +518,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "ADDR16",              /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_REL24 0x0006 */
   /*   26-bit PC-relative offset, shifted left 2 (branch relative) */
@@ -538,15 +535,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         26,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "REL24",               /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0x3fffffc,             /* src_mask */
         0x3fffffc,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_REL14 0x0007 */
   /*   16-bit PC-relative offset, shifted left 2 (br cond relative) */
@@ -557,15 +554,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "ADDR16",              /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_TOCREL16 0x0008 */
   /*   16-bit offset from TOC base */
@@ -574,15 +571,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         ppc_toc16_reloc,       /* special_function */
         "TOCREL16",            /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_TOCREL14 0x0009 */
   /*   16-bit offset from TOC base, shifted left 2 (load doubleword) */
@@ -591,15 +588,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "TOCREL14",            /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_ADDR32NB 0x000A */
   /*   32-bit addr w/ image base */
@@ -608,15 +605,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "ADDR32NB",            /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                 /* pcrel_offset */
+        FALSE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_SECREL 0x000B */
   /*   va of containing section (as in an image sectionhdr) */
@@ -625,15 +622,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         ppc_secrel_reloc,      /* special_function */
         "SECREL",              /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_SECTION 0x000C */
   /*   sectionheader number */
@@ -642,15 +639,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         ppc_section_reloc,     /* special_function */
         "SECTION",             /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_IFGLUE 0x000D */
   /*   substitute TOC restore instruction iff symbol is glue code */
@@ -659,15 +656,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "IFGLUE",              /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_IMGLUE 0x000E */
   /*   symbol is glue code; virtual address is TOC restore instruction */
@@ -676,15 +673,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         ppc_imglue_reloc,      /* special_function */
         "IMGLUE",              /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                 /* pcrel_offset */
+        FALSE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_SECREL16 0x000F */
   /*   va of containing section (limited to 16 bits) */
@@ -693,15 +690,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         0,                     /* special_function */
         "SECREL16",            /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_REFHI             0x0010 */
   /* Unused: */
@@ -709,15 +706,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         ppc_refhi_reloc,       /* special_function */
         "REFHI",               /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                 /* pcrel_offset */
+        FALSE),                 /* pcrel_offset */
 
   /* IMAGE_REL_PPC_REFLO             0x0011 */
   /* Unused: */
@@ -725,15 +722,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         ppc_refhi_reloc,       /* special_function */
         "REFLO",               /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_PAIR              0x0012 */
   /* Unused: */
@@ -741,15 +738,15 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         ppc_pair_reloc,        /* special_function */
         "PAIR",                /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* IMAGE_REL_PPC_TOCREL16_DEFN 0x0013 */
   /*   16-bit offset from TOC base, without causing a definition */
@@ -758,20 +755,18 @@ static reloc_howto_type ppc_coff_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         0,                     /* special_function */
         "TOCREL16, TOCDEFN",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
 };
-
 \f
-
 /* Some really cheezy macros that can be turned on to test stderr :-) */
 
 #ifdef DEBUG_RELOC
@@ -781,13 +776,13 @@ static reloc_howto_type ppc_coff_howto_table[] =
    if (i == 0)                                               \
      {                                                       \
        i = 1;                                                \
-       fprintf(stderr,_("Unimplemented Relocation -- %s\n"),x); \
+       fprintf (stderr,_("Unimplemented Relocation -- %s\n"),x); \
      }                                                       \
 }
 
 #define DUMP_RELOC(n,r)                              \
 {                                                    \
-   fprintf(stderr,"%s sym %d, addr %d, addend %d\n", \
+   fprintf (stderr,"%s sym %d, addr %d, addend %d\n", \
           n, (*(r->sym_ptr_ptr))->name,             \
           r->address, r->addend);                   \
 }
@@ -803,7 +798,7 @@ static reloc_howto_type ppc_coff_howto_table[] =
 
 #define DUMP_RELOC2(n,r)                     \
 {                                            \
-   fprintf(stderr,"%s sym %d, r_vaddr %d %s\n", \
+   fprintf (stderr,"%s sym %d, r_vaddr %d %s\n", \
           n, r->r_symndx, r->r_vaddr,\
           (((r->r_type) & IMAGE_REL_PPC_TOCDEFN) == 0) \
           ?" ":" TOCDEFN"  );      \
@@ -814,7 +809,6 @@ static reloc_howto_type ppc_coff_howto_table[] =
 #define DUMP_RELOC(n,r)
 #define DUMP_RELOC2(n,r)
 #endif
-
 \f
 /* toc construction and management routines */
 
@@ -839,7 +833,7 @@ enum ref_category
 {
   priv,
   pub,
-  data
+  tocdata
 };
 
 struct list_ele
@@ -855,18 +849,19 @@ extern struct list_ele *head;
 extern struct list_ele *tail;
 
 static void record_toc
-  PARAMS ((asection *, int, enum ref_category, const char *));
+  PARAMS ((asection *, bfd_signed_vma, enum ref_category, const char *));
 
 static void
 record_toc (toc_section, our_toc_offset, cat, name)
      asection *toc_section;
-     int our_toc_offset;
+     bfd_signed_vma our_toc_offset;
      enum ref_category cat;
      const char *name;
 {
   /* add this entry to our toc addr-offset-name list */
-  struct list_ele *t;
-  t = (struct list_ele *) bfd_malloc (sizeof (struct list_ele));
+  bfd_size_type amt = sizeof (struct list_ele);
+  struct list_ele *t = (struct list_ele *) bfd_malloc (amt);
+
   if (t == NULL)
     abort ();
   t->next = 0;
@@ -889,13 +884,13 @@ record_toc (toc_section, our_toc_offset, cat, name)
 
 #ifdef COFF_IMAGE_WITH_PE
 
-static boolean ppc_record_toc_entry
+static bfd_boolean ppc_record_toc_entry
   PARAMS ((bfd *, struct bfd_link_info *, asection *, int, enum toc_type));
 static void ppc_mark_symbol_as_glue
   PARAMS ((bfd *, int, struct internal_reloc *));
 
 /* record a toc offset against a symbol */
-static boolean
+static bfd_boolean
 ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
      bfd *abfd;
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
@@ -922,16 +917,16 @@ ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
       if (local_syms == 0)
        {
          unsigned int i;
+         bfd_size_type amt;
          /* allocate a table */
-         local_syms =
-           (int *) bfd_zalloc (abfd,
-                               obj_raw_syment_count(abfd) * sizeof(int));
+         amt = (bfd_size_type) obj_raw_syment_count (abfd) * sizeof (int);
+         local_syms = (int *) bfd_zalloc (abfd, amt);
          if (local_syms == 0)
-           return false;
-         obj_coff_local_toc_table(abfd) = local_syms;
-         for (i = 0; i < obj_raw_syment_count(abfd); ++i)
+           return FALSE;
+         obj_coff_local_toc_table (abfd) = local_syms;
+         for (i = 0; i < obj_raw_syment_count (abfd); ++i)
            {
-             SET_UNALLOCATED(local_syms[i]);
+             SET_UNALLOCATED (local_syms[i]);
            }
        }
 
@@ -945,7 +940,7 @@ ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
            {
              (*_bfd_error_handler) (_("TOC overflow"));
              bfd_set_error (bfd_error_file_too_big);
-             return false;
+             return FALSE;
            }
        }
     }
@@ -965,12 +960,12 @@ ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
            {
              (*_bfd_error_handler) (_("TOC overflow"));
              bfd_set_error (bfd_error_file_too_big);
-             return false;
+             return FALSE;
            }
        }
     }
 
-  return true;
+  return TRUE;
 }
 
 /* record a toc offset against a symbol */
@@ -994,11 +989,10 @@ ppc_mark_symbol_as_glue(abfd, sym, rel)
 
 #endif /* COFF_IMAGE_WITH_PE */
 \f
-
-/* Return true if this relocation should
+/* Return TRUE if this relocation should
    appear in the output .reloc section.  */
 
-static boolean in_reloc_p(abfd, howto)
+static bfd_boolean in_reloc_p(abfd, howto)
      bfd * abfd ATTRIBUTE_UNUSED;
      reloc_howto_type *howto;
 {
@@ -1036,7 +1030,7 @@ pe_ppc_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
 {
   /* the consth relocation comes in two parts, we have to remember
      the state between calls, in these variables */
-  static boolean part1_consth_active = false;
+  static bfd_boolean part1_consth_active = FALSE;
   static unsigned long part1_consth_value;
 
   unsigned long sym_value;
@@ -1058,7 +1052,7 @@ pe_ppc_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
       /* Keep the state machine happy in case we're called again */
       if (r_type == IMAGE_REL_PPC_REFHI)
        {
-         part1_consth_active = true;
+         part1_consth_active = TRUE;
          part1_consth_value  = 0;
        }
       return(bfd_reloc_undefined);
@@ -1066,7 +1060,7 @@ pe_ppc_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
 
   if ((part1_consth_active) && (r_type != IMAGE_REL_PPC_PAIR))
     {
-      part1_consth_active = false;
+      part1_consth_active = FALSE;
       *error_message = (char *) _("Missing PAIR");
       return(bfd_reloc_dangerous);
     }
@@ -1080,7 +1074,7 @@ pe_ppc_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
 
 /* The reloc processing routine for the optimized COFF linker.  */
 
-static boolean
+static bfd_boolean
 coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                           contents, relocs, syms, sections)
      bfd *output_bfd;
@@ -1094,7 +1088,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
 {
   struct internal_reloc *rel;
   struct internal_reloc *relend;
-  boolean hihalf;
+  bfd_boolean hihalf;
   bfd_vma hihalf_val;
   asection *toc_section = 0;
   bfd_vma relocation;
@@ -1104,9 +1098,9 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
      thing.  The caller will take care of adjusting the reloc
      addresses and symbol indices.  */
   if (info->relocateable)
-    return true;
+    return TRUE;
 
-  hihalf = false;
+  hihalf = FALSE;
   hihalf_val = 0;
 
   rel = relocs;
@@ -1151,7 +1145,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
       if (r_type == IMAGE_REL_PPC_IMGLUE && h == 0)
        {
          /* An IMGLUE reloc must have a name. Something is very wrong.  */
-         abort();
+         abort ();
        }
 
       sec = NULL;
@@ -1188,8 +1182,8 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
            {
              if (! ((*info->callbacks->undefined_symbol)
                     (info, h->root.root.root.string, input_bfd, input_section,
-                     rel->r_vaddr - input_section->vma, true)))
-               return false;
+                     rel->r_vaddr - input_section->vma, TRUE)))
+               return FALSE;
            }
        }
 
@@ -1201,12 +1195,12 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
        default:
          (*_bfd_error_handler)
            (_("%s: unsupported relocation type 0x%02x"),
-            bfd_get_filename (input_bfd), r_type);
+            bfd_archive_filename (input_bfd), r_type);
          bfd_set_error (bfd_error_bad_value);
-         return false;
+         return FALSE;
        case IMAGE_REL_PPC_TOCREL16:
          {
-           bfd_vma our_toc_offset;
+           bfd_signed_vma our_toc_offset;
            int fixit;
 
            DUMP_RELOC2(howto->name, rel);
@@ -1219,7 +1213,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                if ( toc_section == NULL )
                  {
                    /* There is no toc section. Something is very wrong.  */
-                   abort();
+                   abort ();
                  }
              }
 
@@ -1230,7 +1224,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
             *  the 1 bit to tell us if we've written this particular toc
             *  entry out.
             */
-           fixit = false;
+           fixit = FALSE;
            if (h == 0)
              { /* it is a file local symbol */
                int *local_toc_table;
@@ -1253,17 +1247,14 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                else
                  {
                    /* write out the toc entry */
-                   record_toc(toc_section,
-                              our_toc_offset,
-                              priv,
-                              strdup(name));
+                   record_toc (toc_section, our_toc_offset, priv,
+                               strdup (name));
 
-                   bfd_put_32(output_bfd,
-                              val,
+                   bfd_put_32 (output_bfd, val,
                               toc_section->contents + our_toc_offset);
 
                    MARK_AS_WRITTEN(local_toc_table[symndx]);
-                   fixit = true;
+                   fixit = TRUE;
                  }
              }
            else
@@ -1289,21 +1280,22 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                       the IAT to be part of the toc, thus saving a load.
                    */
 
-                   our_toc_offset = val -
-                     (toc_section->output_section->vma +
-                      toc_section->output_offset);
+                   our_toc_offset = val - (toc_section->output_section->vma
+                                           + toc_section->output_offset);
 
                    /* The size must still fit in a 16bit displacment */
-                   if (our_toc_offset >= 65535)
+                   if ((bfd_vma) our_toc_offset >= 65535)
                      {
                        (*_bfd_error_handler)
-                         (_("%s: Relocation for %s of %x exceeds Toc size limit"),
-                          bfd_get_filename (input_bfd), name, our_toc_offset);
+                         (_("%s: Relocation for %s of %lx exceeds Toc size limit"),
+                          bfd_archive_filename (input_bfd), name,
+                          (unsigned long) our_toc_offset);
                        bfd_set_error (bfd_error_bad_value);
-                       return false;
+                       return FALSE;
                      }
 
-                   record_toc(toc_section, our_toc_offset, pub, strdup(name));
+                   record_toc (toc_section, our_toc_offset, pub,
+                               strdup (name));
                  }
                else if (IS_WRITTEN(our_toc_offset))
                  {
@@ -1315,17 +1307,17 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                  }
                else
                  {
-                   record_toc(toc_section, our_toc_offset, pub, strdup(name));
+                   record_toc(toc_section, our_toc_offset, pub,
+                              strdup (name));
 
                    /* write out the toc entry */
-                   bfd_put_32(output_bfd,
-                              val,
+                   bfd_put_32 (output_bfd, val,
                               toc_section->contents + our_toc_offset);
 
                    MARK_AS_WRITTEN(h->toc_offset);
                    /* The tricky part is that this is the address that */
                    /* needs a .reloc entry for it */
-                   fixit = true;
+                   fixit = TRUE;
                  }
              }
 
@@ -1338,8 +1330,8 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                   isn't absolute - we output the address here
                   to a file */
 
-               bfd_vma addr =  toc_section->output_section->vma
-                 + toc_section->output_offset + our_toc_offset;
+               bfd_vma addr = (toc_section->output_section->vma
+                               + toc_section->output_offset + our_toc_offset);
 
                if (coff_data(output_bfd)->pe)
                  addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
@@ -1348,23 +1340,20 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
              }
 
            /* FIXME: this test is conservative */
-           if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN &&
-               our_toc_offset > toc_section->_raw_size)
+           if ((r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN
+               && (bfd_vma) our_toc_offset > toc_section->_raw_size)
              {
                (*_bfd_error_handler)
-                 (_("%s: Relocation exceeds allocated TOC (%x)"),
-                  bfd_get_filename (input_bfd),
-                  toc_section->_raw_size);
+                 (_("%s: Relocation exceeds allocated TOC (%lx)"),
+                  bfd_archive_filename (input_bfd),
+                  (unsigned long) toc_section->_raw_size);
                bfd_set_error (bfd_error_bad_value);
-               return false;
+               return FALSE;
              }
 
            /* Now we know the relocation for this toc reference */
            relocation =  our_toc_offset + TOC_LOAD_ADJUSTMENT;
-           rstat = _bfd_relocate_contents (howto,
-                                           input_bfd,
-                                           relocation,
-                                           loc);
+           rstat = _bfd_relocate_contents (howto, input_bfd, relocation, loc);
          }
          break;
        case IMAGE_REL_PPC_IFGLUE:
@@ -1383,8 +1372,8 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                my_name = h->root.root.root.string;
                if (h->symbol_is_glue == 1)
                  {
-                   x = bfd_get_32(input_bfd, loc);
-                   bfd_put_32(input_bfd, h->glue_insn, loc);
+                   x = bfd_get_32 (input_bfd, loc);
+                   bfd_put_32 (input_bfd, (bfd_vma) h->glue_insn, loc);
                  }
              }
          }
@@ -1410,13 +1399,13 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                my_name = h->root.root.root.string;
              }
 
-           fprintf(stderr,
+           fprintf (stderr,
                    _("Warning: unsupported reloc %s <file %s, section %s>\n"),
                    howto->name,
-                   bfd_get_filename(input_bfd),
+                   bfd_archive_filename(input_bfd),
                    input_section->name);
 
-           fprintf(stderr,"sym %ld (%s), r_vaddr %ld (%lx)\n",
+           fprintf (stderr,"sym %ld (%s), r_vaddr %ld (%lx)\n",
                    rel->r_symndx, my_name, (long) rel->r_vaddr,
                    (unsigned long) rel->r_vaddr);
          }
@@ -1432,14 +1421,13 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
 
            (*_bfd_error_handler)
              (_("%s: Out of order IMGLUE reloc for %s"),
-              bfd_get_filename (input_bfd), my_name);
+              bfd_archive_filename (input_bfd), my_name);
            bfd_set_error (bfd_error_bad_value);
-           return false;
+           return FALSE;
          }
 
        case IMAGE_REL_PPC_ADDR32NB:
          {
-           struct coff_link_hash_entry *myh = 0;
            const char *name = 0;
            DUMP_RELOC2(howto->name, rel);
 
@@ -1447,10 +1435,10 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
              {
                /* set magic values */
                int idata5offset;
-               struct coff_link_hash_entry *myh = 0;
+               struct coff_link_hash_entry *myh;
                myh = coff_link_hash_lookup (coff_hash_table (info),
                                             "__idata5_magic__",
-                                            false, false, true);
+                                            FALSE, FALSE, TRUE);
                first_thunk_address = myh->root.u.def.value +
                  sec->output_section->vma +
                    sec->output_offset -
@@ -1459,12 +1447,12 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                idata5offset = myh->root.u.def.value;
                myh = coff_link_hash_lookup (coff_hash_table (info),
                                             "__idata6_magic__",
-                                            false, false, true);
+                                            FALSE, FALSE, TRUE);
 
                thunk_size = myh->root.u.def.value - idata5offset;
                myh = coff_link_hash_lookup (coff_hash_table (info),
                                             "__idata4_magic__",
-                                            false, false, true);
+                                            FALSE, FALSE, TRUE);
                import_table_size = myh->root.u.def.value;
              }
 
@@ -1487,15 +1475,15 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
 
                if (target != 0)
                  {
-                   myh = 0;
+                   struct coff_link_hash_entry *myh;
 
                    myh = coff_link_hash_lookup (coff_hash_table (info),
                                                 target,
-                                                false, false, true);
+                                                FALSE, FALSE, TRUE);
                    if (myh == 0)
                      {
                        /* Missing magic cookies. Something is very wrong.  */
-                       abort();
+                       abort ();
                      }
 
                    val = myh->root.u.def.value +
@@ -1505,7 +1493,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                        int idata5offset;
                        myh = coff_link_hash_lookup (coff_hash_table (info),
                                                     "__idata5_magic__",
-                                                    false, false, true);
+                                                    FALSE, FALSE, TRUE);
                        first_thunk_address = myh->root.u.def.value +
                          sec->output_section->vma +
                            sec->output_offset -
@@ -1514,12 +1502,12 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                        idata5offset = myh->root.u.def.value;
                        myh = coff_link_hash_lookup (coff_hash_table (info),
                                                     "__idata6_magic__",
-                                                    false, false, true);
+                                                    FALSE, FALSE, TRUE);
 
                        thunk_size = myh->root.u.def.value - idata5offset;
                        myh = coff_link_hash_lookup (coff_hash_table (info),
                                                     "__idata4_magic__",
-                                                    false, false, true);
+                                                    FALSE, FALSE, TRUE);
                        import_table_size = myh->root.u.def.value;
                      }
                  }
@@ -1608,14 +1596,14 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                    (bfd_vma) 0, input_bfd,
                    input_section, rel->r_vaddr - input_section->vma)))
              {
-               return false;
+               return FALSE;
              }
          }
        }
 
     }
 
-  return true;
+  return TRUE;
 }
 
 #ifdef COFF_IMAGE_WITH_PE
@@ -1649,11 +1637,11 @@ dump_toc (vfile)
   FILE *file = (FILE *) vfile;
   struct list_ele *t;
 
-  fprintf(file, _(h1));
-  fprintf(file, _(h2));
-  fprintf(file, _(h3));
+  fprintf (file, _(h1));
+  fprintf (file, _(h2));
+  fprintf (file, _(h3));
 
-  for(t = head; t != 0; t=t->next)
+  for (t = head; t != 0; t=t->next)
     {
       const char *cat = "";
 
@@ -1661,7 +1649,7 @@ dump_toc (vfile)
        cat = _("private       ");
       else if (t->cat == pub)
        cat = _("public        ");
-      else if (t->cat == data)
+      else if (t->cat == tocdata)
        cat = _("data-in-toc   ");
 
       if (t->offset > global_toc_size)
@@ -1670,58 +1658,61 @@ dump_toc (vfile)
            cat = _("IAT reference ");
          else
            {
-             fprintf(file,
+             fprintf (file,
                      _("**** global_toc_size %ld(%lx), thunk_size %ld(%lx)\n"),
-                     global_toc_size, global_toc_size, thunk_size, thunk_size);
+                      global_toc_size, global_toc_size,
+                      thunk_size, thunk_size);
              cat = _("Out of bounds!");
            }
        }
 
-      fprintf(file,
+      fprintf (file,
              " %04lx    (%d)", (unsigned long) t->offset, t->offset - 32768);
-      fprintf(file,
+      fprintf (file,
              "    %s %s\n",
              cat, t->name);
 
     }
 
-  fprintf(file, "\n");
+  fprintf (file, "\n");
 }
 
-boolean
+bfd_boolean
 ppc_allocate_toc_section (info)
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
 {
   asection *s;
   bfd_byte *foo;
+  bfd_size_type amt;
   static char test_char = '1';
 
   if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble? */
-    return true;
+    return TRUE;
 
   if (bfd_of_toc_owner == 0)
     {
       /* No toc owner? Something is very wrong.  */
-      abort();
+      abort ();
     }
 
   s = bfd_get_section_by_name ( bfd_of_toc_owner , TOC_SECTION_NAME);
   if (s == NULL)
     {
       /* No toc section? Something is very wrong.  */
-      abort();
+      abort ();
     }
 
-  foo = (bfd_byte *) bfd_alloc(bfd_of_toc_owner, global_toc_size);
-  memset(foo, test_char, global_toc_size);
+  amt = global_toc_size;
+  foo = (bfd_byte *) bfd_alloc (bfd_of_toc_owner, amt);
+  memset(foo, test_char, (size_t) global_toc_size);
 
   s->_raw_size = s->_cooked_size = global_toc_size;
   s->contents = foo;
 
-  return true;
+  return TRUE;
 }
 
-boolean
+bfd_boolean
 ppc_process_before_allocation (abfd, info)
      bfd *abfd;
      struct bfd_link_info *info;
@@ -1739,7 +1730,7 @@ ppc_process_before_allocation (abfd, info)
 
   if (sec == 0)
     {
-      return true;
+      return TRUE;
     }
 
   for (; sec != 0; sec = sec->next)
@@ -1752,13 +1743,13 @@ ppc_process_before_allocation (abfd, info)
     i=_bfd_coff_read_internal_relocs(abfd,sec,1,0,0,0);
 
     if (i == 0)
-      abort();
+      abort ();
 
     for (rel=i;rel<i+sec->reloc_count;++rel)
       {
        unsigned short r_type  = EXTRACT_TYPE (rel->r_type);
        unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
-       boolean ok = true;
+       bfd_boolean ok = TRUE;
 
        DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
 
@@ -1771,7 +1762,7 @@ ppc_process_before_allocation (abfd, info)
              ok = ppc_record_toc_entry(abfd, info, sec,
                                        rel->r_symndx, default_toc);
            if (!ok)
-             return false;
+             return FALSE;
            break;
          case IMAGE_REL_PPC_IMGLUE:
            ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel);
@@ -1782,7 +1773,7 @@ ppc_process_before_allocation (abfd, info)
       }
   }
 
-  return true;
+  return TRUE;
 }
 
 #endif
@@ -1865,7 +1856,6 @@ ppc_pair_reloc (abfd,
 
   return bfd_reloc_undefined;
 }
-
 \f
 static bfd_reloc_status_type
 ppc_toc16_reloc (abfd,
@@ -2000,11 +1990,9 @@ ppc_imglue_reloc (abfd,
 
   return bfd_reloc_ok;
 }
-
 \f
-
 #define MAX_RELOC_INDEX  \
-      (sizeof(ppc_coff_howto_table) / sizeof(ppc_coff_howto_table[0]) - 1)
+      (sizeof (ppc_coff_howto_table) / sizeof (ppc_coff_howto_table[0]) - 1)
 
 /* FIXME: There is a possiblity that when we read in a reloc from a file,
           that there are some bits encoded in the upper portion of the
@@ -2036,11 +2024,11 @@ ppc_coff_rtype2howto (relent, internal)
 
   /* the masking process only slices off the bottom byte for r_type.  */
   if ( r_type > MAX_RELOC_INDEX )
-    abort();
+    abort ();
 
   /* check for absolute crap */
   if ( junk != 0 )
-    abort();
+    abort ();
 
   switch(r_type)
     {
@@ -2067,7 +2055,7 @@ ppc_coff_rtype2howto (relent, internal)
        howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16;
       break;
     default:
-      fprintf(stderr,
+      fprintf (stderr,
              _("Warning: Unsupported reloc %s [%d] used -- it may not work.\n"),
              ppc_coff_howto_table[r_type].name,
              r_type);
@@ -2107,11 +2095,11 @@ coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
 
   /* the masking process only slices off the bottom byte for r_type.  */
   if ( r_type > MAX_RELOC_INDEX )
-    abort();
+    abort ();
 
   /* check for absolute crap */
   if ( junk != 0 )
-    abort();
+    abort ();
 
   switch(r_type)
     {
@@ -2142,7 +2130,7 @@ coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
       howto = ppc_coff_howto_table + r_type;
       break;
     default:
-      fprintf(stderr,
+      fprintf (stderr,
              _("Warning: Unsupported reloc %s [%d] used -- it may not work.\n"),
              ppc_coff_howto_table[r_type].name,
              r_type);
@@ -2183,16 +2171,11 @@ ppc_coff_reloc_type_lookup (abfd, code)
 }
 
 #undef HOW2MAP
-
 \f
 /* Tailor coffcode.h -- macro heaven.  */
 
 #define RTYPE2HOWTO(cache_ptr, dst)  ppc_coff_rtype2howto (cache_ptr, dst)
 
-#ifndef COFF_IMAGE_WITH_PE
-static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
-#endif
-
 /* We use the special COFF backend linker, with our own special touch.  */
 
 #define coff_bfd_reloc_type_lookup   ppc_coff_reloc_type_lookup
@@ -2202,8 +2185,10 @@ static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
 
 #ifndef COFF_IMAGE_WITH_PE
 /* FIXME: This no longer works.  */
+#if 0
 #define coff_swap_sym_in_hook        ppc_coff_swap_sym_in_hook
 #endif
+#endif
 
 #define SELECT_RELOC(internal, howto) {internal.r_type=howto->type;}
 
@@ -2229,10 +2214,10 @@ static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 1 }
 
 #include "coffcode.h"
-
 \f
-
 #ifndef COFF_IMAGE_WITH_PE
+/* FIXME: This no longer works.  */
+#if 0
 /* FIXME:
    What we're trying to do here is allocate a toc section (early), and attach
    it to the last bfd to be processed. This avoids the problem of having a toc
@@ -2246,6 +2231,7 @@ static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
    3. Doing it on a "swap in" hook depends on when the "swap in" is called,
       and how often, etc. It's not clear to me that there isn't a hole here.
 */
+static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
 
 static void
 ppc_coff_swap_sym_in_hook (abfd, ext1, in1)
@@ -2278,7 +2264,7 @@ ppc_coff_swap_sym_in_hook (abfd, ext1, in1)
          || !bfd_set_section_alignment (abfd, s, 2))
        {
          /* FIXME: set appropriate bfd error */
-         abort();
+         abort ();
        }
 
       /* save the bfd for later allocation */
@@ -2288,20 +2274,21 @@ ppc_coff_swap_sym_in_hook (abfd, ext1, in1)
   return;
 }
 #endif
+#endif
 
 #ifndef COFF_IMAGE_WITH_PE
 
-static boolean ppc_do_last PARAMS ((bfd *));
+static bfd_boolean ppc_do_last PARAMS ((bfd *));
 static bfd *ppc_get_last PARAMS ((void));
 
-static boolean
+static bfd_boolean
 ppc_do_last (abfd)
      bfd *abfd;
 {
   if (abfd == bfd_of_toc_owner)
-    return true;
+    return TRUE;
   else
-    return false;
+    return FALSE;
 }
 
 static bfd *
@@ -2324,21 +2311,21 @@ ppc_get_last()
 
 /* Do the final link step.  */
 
-boolean
+bfd_boolean
 ppc_bfd_coff_final_link (abfd, info)
      bfd *abfd;
      struct bfd_link_info *info;
 {
   bfd_size_type symesz;
   struct coff_final_link_info finfo;
-  boolean debug_merge_allocated;
+  bfd_boolean debug_merge_allocated;
   asection *o;
   struct bfd_link_order *p;
-  size_t max_sym_count;
-  size_t max_lineno_count;
-  size_t max_reloc_count;
-  size_t max_output_reloc_count;
-  size_t max_contents_size;
+  bfd_size_type max_sym_count;
+  bfd_size_type max_lineno_count;
+  bfd_size_type max_reloc_count;
+  bfd_size_type max_output_reloc_count;
+  bfd_size_type max_contents_size;
   file_ptr rel_filepos;
   unsigned int relsz;
   file_ptr line_filepos;
@@ -2346,6 +2333,7 @@ ppc_bfd_coff_final_link (abfd, info)
   bfd *sub;
   bfd_byte *external_relocs = NULL;
   char strbuf[STRING_SIZE_SIZE];
+  bfd_size_type amt;
 
   symesz = bfd_coff_symesz (abfd);
 
@@ -2363,7 +2351,7 @@ ppc_bfd_coff_final_link (abfd, info)
   finfo.contents = NULL;
   finfo.external_relocs = NULL;
   finfo.internal_relocs = NULL;
-  debug_merge_allocated = false;
+  debug_merge_allocated = FALSE;
 
   coff_data (abfd)->link_info = info;
 
@@ -2373,13 +2361,13 @@ ppc_bfd_coff_final_link (abfd, info)
 
   if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
     goto error_return;
-  debug_merge_allocated = true;
+  debug_merge_allocated = TRUE;
 
   /* Compute the file positions for all the sections.  */
   if (! abfd->output_has_begun)
     {
       if (! bfd_coff_compute_section_file_positions (abfd))
-       return false;
+       return FALSE;
     }
 
   /* Count the line numbers and relocation entries required for the
@@ -2407,7 +2395,7 @@ ppc_bfd_coff_final_link (abfd, info)
                 link.  This will normally be every section.  We need
                 to do this so that we can identify any sections which
                 the linker has decided to not include.  */
-             sec->linker_mark = true;
+             sec->linker_mark = TRUE;
 
              if (info->strip == strip_none
                  || info->strip == strip_some)
@@ -2446,10 +2434,9 @@ ppc_bfd_coff_final_link (abfd, info)
 
       /* We use section_count + 1, rather than section_count, because
          the target_index fields are 1 based.  */
-      finfo.section_info =
-       ((struct coff_link_section_info *)
-        bfd_malloc ((abfd->section_count + 1)
-                    * sizeof (struct coff_link_section_info)));
+      amt = abfd->section_count + 1;
+      amt *= sizeof (struct coff_link_section_info);
+      finfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
       if (finfo.section_info == NULL)
        goto error_return;
       for (i = 0; i <= abfd->section_count; i++)
@@ -2490,13 +2477,14 @@ ppc_bfd_coff_final_link (abfd, info)
             but only when doing a relocateable link, which is not the
             common case.  */
          BFD_ASSERT (info->relocateable);
+         amt = o->reloc_count;
+         amt *= sizeof (struct internal_reloc);
          finfo.section_info[o->target_index].relocs =
-           ((struct internal_reloc *)
-            bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
+           (struct internal_reloc *) bfd_malloc (amt);
+         amt = o->reloc_count;
+         amt *= sizeof (struct coff_link_hash_entry *);
          finfo.section_info[o->target_index].rel_hashes =
-           ((struct coff_link_hash_entry **)
-            bfd_malloc (o->reloc_count
-                    * sizeof (struct coff_link_hash_entry *)));
+           (struct coff_link_hash_entry **) bfd_malloc (amt);
          if (finfo.section_info[o->target_index].relocs == NULL
              || finfo.section_info[o->target_index].rel_hashes == NULL)
            goto error_return;
@@ -2519,31 +2507,32 @@ ppc_bfd_coff_final_link (abfd, info)
   max_sym_count = 0;
   for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
     {
-      size_t sz;
+      bfd_size_type sz;
 
-      sub->output_has_begun = false;
+      sub->output_has_begun = FALSE;
       sz = obj_raw_syment_count (sub);
       if (sz > max_sym_count)
        max_sym_count = sz;
     }
 
   /* Allocate some buffers used while linking.  */
-  finfo.internal_syms = ((struct internal_syment *)
-                        bfd_malloc (max_sym_count
-                                    * sizeof (struct internal_syment)));
-  finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
-                                            * sizeof (asection *));
-  finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
-  finfo.outsyms = ((bfd_byte *)
-                  bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
-  finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
-                                      * bfd_coff_linesz (abfd));
+  amt = max_sym_count * sizeof (struct internal_syment);
+  finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
+  amt = max_sym_count * sizeof (asection *);
+  finfo.sec_ptrs = (asection **) bfd_malloc (amt);
+  amt = max_sym_count * sizeof (long);
+  finfo.sym_indices = (long *) bfd_malloc (amt);
+  amt = (max_sym_count + 1) * symesz;
+  finfo.outsyms = (bfd_byte *) bfd_malloc (amt);
+  amt = max_lineno_count * bfd_coff_linesz (abfd);
+  finfo.linenos = (bfd_byte *) bfd_malloc (amt);
   finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
   finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
   if (! info->relocateable)
-    finfo.internal_relocs = ((struct internal_reloc *)
-                            bfd_malloc (max_reloc_count
-                                        * sizeof (struct internal_reloc)));
+    {
+      amt = max_reloc_count * sizeof (struct internal_reloc);
+      finfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
+    }
   if ((finfo.internal_syms == NULL && max_sym_count > 0)
       || (finfo.sec_ptrs == NULL && max_sym_count > 0)
       || (finfo.sym_indices == NULL && max_sym_count > 0)
@@ -2586,7 +2575,7 @@ ppc_bfd_coff_final_link (abfd, info)
                {
                  if (! _bfd_coff_link_input_bfd (&finfo, sub))
                    goto error_return;
-                 sub->output_has_begun = true;
+                 sub->output_has_begun = TRUE;
                }
            }
          else if (p->type == bfd_section_reloc_link_order
@@ -2611,14 +2600,14 @@ ppc_bfd_coff_final_link (abfd, info)
        if (! _bfd_coff_link_input_bfd (&finfo, last_one))
          goto error_return;
       }
-    last_one->output_has_begun = true;
+    last_one->output_has_begun = TRUE;
   }
 #endif
 
   /* Free up the buffers used by _bfd_coff_link_input_bfd.  */
 
   coff_debug_merge_hash_table_free (&finfo.debug_merge);
-  debug_merge_allocated = false;
+  debug_merge_allocated = FALSE;
 
   if (finfo.internal_syms != NULL)
     {
@@ -2662,19 +2651,19 @@ ppc_bfd_coff_final_link (abfd, info)
   if (finfo.last_file_index != -1
       && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
     {
+      file_ptr pos;
+
       finfo.last_file.n_value = obj_raw_syment_count (abfd);
       bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
                             (PTR) finfo.outsyms);
-      if (bfd_seek (abfd,
-                   (obj_sym_filepos (abfd)
-                    + finfo.last_file_index * symesz),
-                   SEEK_SET) != 0
-         || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
-       return false;
+      pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
+      if (bfd_seek (abfd, pos, SEEK_SET) != 0
+         || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
+       return FALSE;
     }
 
   /* Write out the global symbols.  */
-  finfo.failed = false;
+  finfo.failed = FALSE;
   coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
                           (PTR) &finfo);
   if (finfo.failed)
@@ -2692,8 +2681,8 @@ ppc_bfd_coff_final_link (abfd, info)
       /* Now that we have written out all the global symbols, we know
         the symbol indices to use for relocs against them, and we can
         finally write out the relocs.  */
-      external_relocs = ((bfd_byte *)
-                        bfd_malloc (max_output_reloc_count * relsz));
+      amt = max_output_reloc_count * relsz;
+      external_relocs = (bfd_byte *) bfd_malloc (amt);
       if (external_relocs == NULL)
        goto error_return;
 
@@ -2721,9 +2710,9 @@ ppc_bfd_coff_final_link (abfd, info)
              bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
            }
 
+         amt = relsz * o->reloc_count;
          if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
-             || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
-                           abfd) != relsz * o->reloc_count)
+             || bfd_bwrite ((PTR) external_relocs, amt, abfd) != amt)
            goto error_return;
        }
 
@@ -2751,31 +2740,32 @@ ppc_bfd_coff_final_link (abfd, info)
   if (coff_hash_table (info)->stab_info != NULL)
     {
       if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
-       return false;
+       return FALSE;
     }
 
   /* Write out the string table.  */
   if (obj_raw_syment_count (abfd) != 0)
     {
-      if (bfd_seek (abfd,
-                   (obj_sym_filepos (abfd)
-                    + obj_raw_syment_count (abfd) * symesz),
-                   SEEK_SET) != 0)
-       return false;
+      file_ptr pos;
+
+      pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz;
+      if (bfd_seek (abfd, pos, SEEK_SET) != 0)
+       return FALSE;
 
 #if STRING_SIZE_SIZE == 4
-      bfd_h_put_32 (abfd,
-                   _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
-                   (bfd_byte *) strbuf);
+      H_PUT_32 (abfd,
+               _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+               strbuf);
 #else
- #error Change bfd_h_put_32
+ #error Change H_PUT_32 above
 #endif
 
-      if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
-       return false;
+      if (bfd_bwrite (strbuf, (bfd_size_type) STRING_SIZE_SIZE, abfd)
+         != STRING_SIZE_SIZE)
+       return FALSE;
 
       if (! _bfd_stringtab_emit (abfd, finfo.strtab))
-       return false;
+       return FALSE;
     }
 
   _bfd_stringtab_free (finfo.strtab);
@@ -2784,7 +2774,7 @@ ppc_bfd_coff_final_link (abfd, info)
      not try to write out the symbols.  */
   bfd_get_symcount (abfd) = 0;
 
-  return true;
+  return TRUE;
 
  error_return:
   if (debug_merge_allocated)
@@ -2822,11 +2812,10 @@ ppc_bfd_coff_final_link (abfd, info)
     free (finfo.internal_relocs);
   if (external_relocs != NULL)
     free (external_relocs);
-  return false;
+  return FALSE;
 }
 #endif
 \f
-
 /* Forward declaration for use by alternative_target field.  */
 #ifdef TARGET_BIG_SYM
 extern const bfd_target TARGET_BIG_SYM;