Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/coff-ppc.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for PowerPC Microsoft Portable Executable files.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000, 2001
     3   2000, 2001, 2002, 2003
    44   Free Software Foundation, Inc.
    55
     
    1010   intel backends, and the PE work for the arm.
    1111
    12 This file is part of BFD, the Binary File Descriptor library.
    13 
    14 This program is free software; you can redistribute it and/or modify
    15 it under the terms of the GNU General Public License as published by
    16 the Free Software Foundation; either version 2 of the License, or
    17 (at your option) any later version.
    18 
    19 This program is distributed in the hope that it will be useful,
    20 but WITHOUT ANY WARRANTY; without even the implied warranty of
    21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22 GNU General Public License for more details.
    23 
    24 You should have received a copy of the GNU General Public License
    25 along with this program; if not, write to the Free Software
    26 Foundation, 59 Temple Place - Suite 330,
    27 Boston, MA 02111-1307, USA.  */
     12   This file is part of BFD, the Binary File Descriptor library.
     13
     14   This program is free software; you can redistribute it and/or modify
     15   it under the terms of the GNU General Public License as published by
     16   the Free Software Foundation; either version 2 of the License, or
     17   (at your option) any later version.
     18
     19   This program is distributed in the hope that it will be useful,
     20   but WITHOUT ANY WARRANTY; without even the implied warranty of
     21   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     22   GNU General Public License for more details.
     23
     24   You should have received a copy of the GNU General Public License
     25   along with this program; if not, write to the Free Software
     26   Foundation, 59 Temple Place - Suite 330,
     27   Boston, MA 02111-1307, USA.  */
    2828
    2929/* Current State:
     
    3232   - ld will link files, but they do not run.
    3333   - dlltool will not produce correct output in some .reloc cases, and will
    34      not produce the right glue code for dll function calls.
    35 */
     34     not produce the right glue code for dll function calls.  */
    3635
    3736#include "bfd.h"
     
    5554/* This file is compiled more than once, but we only compile the
    5655   final_link routine once.  */
    57 extern boolean ppc_bfd_coff_final_link
     56extern bfd_boolean ppc_bfd_coff_final_link
    5857  PARAMS ((bfd *, struct bfd_link_info *));
    5958extern void dump_toc PARAMS ((PTR));
    6059
    61 /* The toc is a set of bfd_vma fields. We use the fact that valid         */
    62 /* addresses are even (i.e. the bit representing "1" is off) to allow     */
    63 /* us to encode a little extra information in the field                   */
    64 /* - Unallocated addresses are intialized to 1.                           */
    65 /* - Allocated addresses are even numbers.                                */
    66 /* The first time we actually write a reference to the toc in the bfd,    */
    67 /* we want to record that fact in a fixup file (if it is asked for), so   */
    68 /* we keep track of whether or not an address has been written by marking */
    69 /* the low order bit with a "1" upon writing                              */
     60/* The toc is a set of bfd_vma fields. We use the fact that valid
     61   addresses are even (i.e. the bit representing "1" is off) to allow
     62   us to encode a little extra information in the field
     63   - Unallocated addresses are initialized to 1.
     64   - Allocated addresses are even numbers.
     65   The first time we actually write a reference to the toc in the bfd,
     66   we want to record that fact in a fixup file (if it is asked for), so
     67   we keep track of whether or not an address has been written by marking
     68   the low order bit with a "1" upon writing.  */
    7069
    7170#define SET_UNALLOCATED(x)  ((x) = 1)
     
    7675#define MAKE_ADDR_AGAIN(x)  ((x) &= ~1)
    7776
    78 /* Turn on this check if you suspect something amiss in the hash tables */
     77/* Turn on this check if you suspect something amiss in the hash tables. */
    7978#ifdef DEBUG_HASH
    8079
    81 /* Need a 7 char string for an eye catcher */
     80/* Need a 7 char string for an eye catcher. */
    8281#define EYE "krkjunk"
    8382
     
    102101
    103102/* In order not to add an int to every hash table item for every coff
    104    linker, we define our own hash table, derived from the coff one */
     103   linker, we define our own hash table, derived from the coff one. */
    105104
    106105/* PE linker hash table entries.  */
     
    108107struct ppc_coff_link_hash_entry
    109108{
    110   struct coff_link_hash_entry root; /* First entry, as required  */
     109  struct coff_link_hash_entry root; /* First entry, as required.  */
    111110
    112111  /* As we wonder around the relocs, we'll keep the assigned toc_offset
    113      here */
    114   bfd_vma toc_offset;               /* Our addition, as required */
     112     here. */
     113  bfd_vma toc_offset;               /* Our addition, as required. */
    115114  int symbol_is_glue;
    116115  unsigned long int glue_insn;
     
    123122struct ppc_coff_link_hash_table
    124123{
    125   struct coff_link_hash_table root; /* First entry, as required */
     124  struct coff_link_hash_table root; /* First entry, as required. */
    126125};
    127126
     
    129128  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
    130129           const char *));
    131 static boolean ppc_coff_link_hash_table_init
     130static bfd_boolean ppc_coff_link_hash_table_init
    132131  PARAMS ((struct ppc_coff_link_hash_table *, bfd *,
    133132           struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
     
    136135static struct bfd_link_hash_table *ppc_coff_link_hash_table_create
    137136  PARAMS ((bfd *));
    138 static boolean coff_ppc_relocate_section
     137static bfd_boolean coff_ppc_relocate_section
    139138  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    140139           struct internal_reloc *, struct internal_syment *, asection **));
     
    173172    {
    174173      /* Initialize the local fields.  */
    175       SET_UNALLOCATED(ret->toc_offset);
     174      SET_UNALLOCATED (ret->toc_offset);
    176175      ret->symbol_is_glue = 0;
    177176      ret->glue_insn = 0;
    178177
    179       HASH_CHECK_INIT(ret);
     178      HASH_CHECK_INIT (ret);
    180179    }
    181180
     
    185184/* Initialize a PE linker hash table.  */
    186185
    187 static boolean
     186static bfd_boolean
    188187ppc_coff_link_hash_table_init (table, abfd, newfunc)
    189188     struct ppc_coff_link_hash_table *table;
     
    203202{
    204203  struct ppc_coff_link_hash_table *ret;
    205 
    206   ret = ((struct ppc_coff_link_hash_table *)
    207          bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));
     204  bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table);
     205
     206  ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt);
    208207  if (ret == NULL)
    209208    return NULL;
     
    211210                                        ppc_coff_link_hash_newfunc))
    212211    {
    213       bfd_release (abfd, ret);
     212      free (ret);
    214213      return (struct bfd_link_hash_table *) NULL;
    215214    }
     
    217216}
    218217
    219 /* Now, tailor coffcode.h to use our hash stuff */
     218/* Now, tailor coffcode.h to use our hash stuff. */
    220219
    221220#define coff_bfd_link_hash_table_create ppc_coff_link_hash_table_create
    222221
    223222
    224 /* The nt loader points the toc register to &toc + 32768, in order to */
    225 /* use the complete range of a 16-bit displacement. We have to adjust */
    226 /* for this when we fix up loads displaced off the toc reg.           */
     223/* The nt loader points the toc register to &toc + 32768, in order to
     224   use the complete range of a 16-bit displacement. We have to adjust
     225   for this when we fix up loads displaced off the toc reg.  */
    227226#define TOC_LOAD_ADJUSTMENT (-32768)
    228227#define TOC_SECTION_NAME ".private.toc"
     
    236235#define MINUS_ONE       (((bfd_vma)0) - 1)
    237236
    238 /* these should definitely go in a header file somewhere...  */
     237/* These should definitely go in a header file somewhere...  */
    239238
    240239/* NOP */
     
    286285#define IMAGE_REL_PPC_SECREL16          0x000F
    287286
    288 /* stuff to handle immediate data when the number of bits in the */
    289 /* data is greater than the number of bits in the immediate field */
    290 /* We need to do (usually) 32 bit arithmetic on 16 bit chunks */
     287/* Stuff to handle immediate data when the number of bits in the
     288   data is greater than the number of bits in the immediate field
     289   We need to do (usually) 32 bit arithmetic on 16 bit chunks. */
    291290#define IMAGE_REL_PPC_REFHI             0x0010
    292291#define IMAGE_REL_PPC_REFLO             0x0011
    293292#define IMAGE_REL_PPC_PAIR              0x0012
    294293
    295 /* This is essentially the same as tocrel16, with TOCDEFN assumed */
     294/* This is essentially the same as tocrel16, with TOCDEFN assumed. */
    296295#define IMAGE_REL_PPC_TOCREL16_DEFN     0x0013
    297296
    298 /*  Flag bits in IMAGE_RELOCATION.TYPE */
    299 
    300 /* subtract reloc value rather than adding it */
     297/* Flag bits in IMAGE_RELOCATION.TYPE. */
     298
     299/* Subtract reloc value rather than adding it. */
    301300#define IMAGE_REL_PPC_NEG               0x0100
    302301
    303 /* fix branch prediction bit to predict branch taken */
     302/* Fix branch prediction bit to predict branch taken. */
    304303#define IMAGE_REL_PPC_BRTAKEN           0x0200
    305304
    306 /* fix branch prediction bit to predict branch not taken */
     305/* Fix branch prediction bit to predict branch not taken. */
    307306#define IMAGE_REL_PPC_BRNTAKEN          0x0400
    308307
    309 /* toc slot defined in file (or, data in toc) */
     308/* TOC slot defined in file (or, data in toc). */
    310309#define IMAGE_REL_PPC_TOCDEFN           0x0800
    311310
    312 /* masks to isolate above values in IMAGE_RELOCATION.Type */
     311/* Masks to isolate above values in IMAGE_RELOCATION.Type. */
    313312#define IMAGE_REL_PPC_TYPEMASK          0x00FF
    314313#define IMAGE_REL_PPC_FLAGMASK          0x0F00
     
    320319
    321320
    322 /* static helper functions to make relocation work */
     321/* Static helper functions to make relocation work. */
    323322/* (Work In Progress) */
    324323
     
    389388                                                       char **error));
    390389
    391 static boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));
     390static bfd_boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));
    392391
    393392
    394393/* FIXME: It'll take a while to get through all of these. I only need a few to
    395394   get us started, so those I'll make sure work. Those marked FIXME are either
    396    completely unverified or have a specific unknown marked in the comment */
    397 
    398 /*---------------------------------------------------------------------------*/
    399 /*                                                                           */
    400 /* Relocation entries for Windows/NT on PowerPC.                             */
    401 /*                                                                           */
    402 /* From the document "" we find the following listed as used relocs:         */
    403 /*                                                                           */
    404 /*   ABSOLUTE       : The noop                                               */
    405 /*   ADDR[64|32|16] : fields that hold addresses in data fields or the       */
    406 /*                    16 bit displacement field on a load/store.             */
    407 /*   ADDR[24|14]    : fields that hold addresses in branch and cond          */
    408 /*                    branches. These represent [26|16] bit addresses.       */
    409 /*                    The low order 2 bits are preserved.                    */
    410 /*   REL[24|14]     : branches relative to the Instruction Address           */
    411 /*                    register. These represent [26|16] bit addresses,       */
    412 /*                    as before. The instruction field will be zero, and     */
    413 /*                    the address of the SYM will be inserted at link time.  */
    414 /*   TOCREL16       : 16 bit displacement field referring to a slot in       */
    415 /*                    toc.                                                   */
    416 /*   TOCREL14       : 16 bit displacement field, similar to REL14 or ADDR14.  */
    417 /*   ADDR32NB       : 32 bit address relative to the virtual origin.         */
    418 /*                    (On the alpha, this is always a linker generated thunk)*/
    419 /*                    (i.e. 32bit addr relative to the image base)           */
    420 /*   SECREL         : The value is relative to the start of the section      */
    421 /*                    containing the symbol.                                 */
    422 /*   SECTION        : access to the header containing the item. Supports the */
    423 /*                    codeview debugger.                                     */
    424 /*                                                                           */
    425 /* In particular, note that the document does not indicate that the          */
    426 /* relocations listed in the header file are used.                           */
    427 /*                                                                           */
    428 /*                                                                           */
    429 /*                                                                           */
    430 /*---------------------------------------------------------------------------*/
     395   completely unverified or have a specific unknown marked in the comment.  */
     396
     397/* Relocation entries for Windows/NT on PowerPC.                             
     398
     399   From the document "" we find the following listed as used relocs:
     400
     401     ABSOLUTE       : The noop
     402     ADDR[64|32|16] : fields that hold addresses in data fields or the
     403                      16 bit displacement field on a load/store.
     404     ADDR[24|14]    : fields that hold addresses in branch and cond
     405                      branches. These represent [26|16] bit addresses.
     406                      The low order 2 bits are preserved.
     407     REL[24|14]     : branches relative to the Instruction Address
     408                      register. These represent [26|16] bit addresses,
     409                      as before. The instruction field will be zero, and
     410                      the address of the SYM will be inserted at link time.
     411     TOCREL16       : 16 bit displacement field referring to a slot in
     412                      toc.
     413     TOCREL14       : 16 bit displacement field, similar to REL14 or ADDR14.
     414     ADDR32NB       : 32 bit address relative to the virtual origin.
     415                      (On the alpha, this is always a linker generated thunk)
     416                      (i.e. 32bit addr relative to the image base)
     417     SECREL         : The value is relative to the start of the section
     418                      containing the symbol.
     419     SECTION        : access to the header containing the item. Supports the
     420                      codeview debugger.
     421
     422   In particular, note that the document does not indicate that the
     423   relocations listed in the header file are used.  */
     424
    431425
    432426static reloc_howto_type ppc_coff_howto_table[] =
     
    438432         0,                      /* size (0 = byte, 1 = short, 2 = long) */
    439433         0,                      /* bitsize */
    440          false,                  /* pc_relative */
     434         FALSE,                  /* pc_relative */
    441435         0,                      /* bitpos */
    442436         complain_overflow_dont, /* dont complain_on_overflow */
    443437         0,                      /* special_function */
    444438         "ABSOLUTE",             /* name */
    445          false,                  /* partial_inplace */
     439         FALSE,                  /* partial_inplace */
    446440         0x00,                   /* src_mask */
    447441         0x00,                   /* dst_mask */
    448          false),                 /* pcrel_offset */
     442         FALSE),                 /* pcrel_offset */
    449443
    450444  /* IMAGE_REL_PPC_ADDR64 0x0001  64-bit address */
     
    454448        3,                       /* size (0 = byte, 1 = short, 2 = long) */
    455449        64,                      /* bitsize */
    456         false,                   /* pc_relative */
     450        FALSE,                   /* pc_relative */
    457451        0,                       /* bitpos */
    458452        complain_overflow_bitfield,      /* complain_on_overflow */
    459453        0,                       /* special_function */
    460454        "ADDR64",               /* name */
    461         true,                    /* partial_inplace */
     455        TRUE,                    /* partial_inplace */
    462456        MINUS_ONE,               /* src_mask */
    463457        MINUS_ONE,               /* dst_mask */
    464         false),                 /* pcrel_offset */
     458        FALSE),                 /* pcrel_offset */
    465459
    466460  /* IMAGE_REL_PPC_ADDR32 0x0002  32-bit address */
     
    470464         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    471465         32,                    /* bitsize */
    472          false,                 /* pc_relative */
     466         FALSE,                 /* pc_relative */
    473467         0,                     /* bitpos */
    474468         complain_overflow_bitfield, /* complain_on_overflow */
    475469         0,                     /* special_function */
    476470         "ADDR32",              /* name */
    477          true,                  /* partial_inplace */
     471         TRUE,                  /* partial_inplace */
    478472         0xffffffff,            /* src_mask */
    479473         0xffffffff,            /* dst_mask */
    480          false),                /* pcrel_offset */
     474         FALSE),                /* pcrel_offset */
    481475
    482476  /* IMAGE_REL_PPC_ADDR24 0x0003  26-bit address, shifted left 2 (branch absolute) */
     
    489483         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    490484         26,                    /* bitsize */
    491          false,                 /* pc_relative */
     485         FALSE,                 /* pc_relative */
    492486         0,                     /* bitpos */
    493487         complain_overflow_bitfield, /* complain_on_overflow */
    494488         0,                     /* special_function */
    495489         "ADDR24",              /* name */
    496          true,                  /* partial_inplace */
     490         TRUE,                  /* partial_inplace */
    497491         0x07fffffc,            /* src_mask */
    498492         0x07fffffc,            /* dst_mask */
    499          false),                /* pcrel_offset */
     493         FALSE),                /* pcrel_offset */
    500494
    501495  /* IMAGE_REL_PPC_ADDR16 0x0004  16-bit address */
     
    505499         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    506500         16,                    /* bitsize */
    507          false,                 /* pc_relative */
     501         FALSE,                 /* pc_relative */
    508502         0,                     /* bitpos */
    509503         complain_overflow_signed, /* complain_on_overflow */
    510504         0,                     /* special_function */
    511505         "ADDR16",              /* name */
    512          true,                  /* partial_inplace */
     506         TRUE,                  /* partial_inplace */
    513507         0xffff,                /* src_mask */
    514508         0xffff,                /* dst_mask */
    515          false),                /* pcrel_offset */
     509         FALSE),                /* pcrel_offset */
    516510
    517511  /* IMAGE_REL_PPC_ADDR14 0x0005 */
     
    523517         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    524518         16,                    /* bitsize */
    525          false,                 /* pc_relative */
     519         FALSE,                 /* pc_relative */
    526520         0,                     /* bitpos */
    527521         complain_overflow_signed, /* complain_on_overflow */
    528522         0,                     /* special_function */
    529523         "ADDR16",              /* name */
    530          true,                  /* partial_inplace */
     524         TRUE,                  /* partial_inplace */
    531525         0xffff,                /* src_mask */
    532526         0xffff,                /* dst_mask */
    533          false),                /* pcrel_offset */
     527         FALSE),                /* pcrel_offset */
    534528
    535529  /* IMAGE_REL_PPC_REL24 0x0006 */
     
    540534         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    541535         26,                    /* bitsize */
    542          true,                  /* pc_relative */
     536         TRUE,                  /* pc_relative */
    543537         0,                     /* bitpos */
    544538         complain_overflow_signed, /* complain_on_overflow */
    545539         0,                     /* special_function */
    546540         "REL24",               /* name */
    547          true,                  /* partial_inplace */
     541         TRUE,                  /* partial_inplace */
    548542         0x3fffffc,             /* src_mask */
    549543         0x3fffffc,             /* dst_mask */
    550          false),                /* pcrel_offset */
     544         FALSE),                /* pcrel_offset */
    551545
    552546  /* IMAGE_REL_PPC_REL14 0x0007 */
     
    559553         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    560554         16,                    /* bitsize */
    561          false,                 /* pc_relative */
     555         FALSE,                 /* pc_relative */
    562556         0,                     /* bitpos */
    563557         complain_overflow_signed, /* complain_on_overflow */
    564558         0,                     /* special_function */
    565559         "ADDR16",              /* name */
    566          true,                  /* partial_inplace */
     560         TRUE,                  /* partial_inplace */
    567561         0xffff,                /* src_mask */
    568562         0xffff,                /* dst_mask */
    569          true),                 /* pcrel_offset */
     563         TRUE),                 /* pcrel_offset */
    570564
    571565  /* IMAGE_REL_PPC_TOCREL16 0x0008 */
     
    576570         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    577571         16,                    /* bitsize */
    578          false,                 /* pc_relative */
     572         FALSE,                 /* pc_relative */
    579573         0,                     /* bitpos */
    580574         complain_overflow_dont, /* complain_on_overflow */
    581575         ppc_toc16_reloc,       /* special_function */
    582576         "TOCREL16",            /* name */
    583          false,                 /* partial_inplace */
     577         FALSE,                 /* partial_inplace */
    584578         0xffff,                /* src_mask */
    585579         0xffff,                /* dst_mask */
    586          false),                /* pcrel_offset */
     580         FALSE),                /* pcrel_offset */
    587581
    588582  /* IMAGE_REL_PPC_TOCREL14 0x0009 */
     
    593587         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    594588         16,                    /* bitsize */
    595          false,                 /* pc_relative */
     589         FALSE,                 /* pc_relative */
    596590         0,                     /* bitpos */
    597591         complain_overflow_signed, /* complain_on_overflow */
    598592         0,                     /* special_function */
    599593         "TOCREL14",            /* name */
    600          false,                 /* partial_inplace */
     594         FALSE,                 /* partial_inplace */
    601595         0xffff,                /* src_mask */
    602596         0xffff,                /* dst_mask */
    603          false),                /* pcrel_offset */
     597         FALSE),                /* pcrel_offset */
    604598
    605599  /* IMAGE_REL_PPC_ADDR32NB 0x000A */
     
    610604         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    611605         32,                    /* bitsize */
    612          false,                 /* pc_relative */
     606         FALSE,                 /* pc_relative */
    613607         0,                     /* bitpos */
    614608         complain_overflow_signed, /* complain_on_overflow */
    615609         0,                     /* special_function */
    616610         "ADDR32NB",            /* name */
    617          true,                  /* partial_inplace */
     611         TRUE,                  /* partial_inplace */
    618612         0xffffffff,            /* src_mask */
    619613         0xffffffff,            /* dst_mask */
    620          false),                 /* pcrel_offset */
     614         FALSE),                 /* pcrel_offset */
    621615
    622616  /* IMAGE_REL_PPC_SECREL 0x000B */
     
    627621         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    628622         32,                    /* bitsize */
    629          false,                 /* pc_relative */
     623         FALSE,                 /* pc_relative */
    630624         0,                     /* bitpos */
    631625         complain_overflow_signed, /* complain_on_overflow */
    632626         ppc_secrel_reloc,      /* special_function */
    633627         "SECREL",              /* name */
    634          true,                  /* partial_inplace */
     628         TRUE,                  /* partial_inplace */
    635629         0xffffffff,            /* src_mask */
    636630         0xffffffff,            /* dst_mask */
    637          true),                 /* pcrel_offset */
     631         TRUE),                 /* pcrel_offset */
    638632
    639633  /* IMAGE_REL_PPC_SECTION 0x000C */
     
    644638         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    645639         32,                    /* bitsize */
    646          false,                 /* pc_relative */
     640         FALSE,                 /* pc_relative */
    647641         0,                     /* bitpos */
    648642         complain_overflow_signed, /* complain_on_overflow */
    649643         ppc_section_reloc,     /* special_function */
    650644         "SECTION",             /* name */
    651          true,                  /* partial_inplace */
     645         TRUE,                  /* partial_inplace */
    652646         0xffffffff,            /* src_mask */
    653647         0xffffffff,            /* dst_mask */
    654          true),                 /* pcrel_offset */
     648         TRUE),                 /* pcrel_offset */
    655649
    656650  /* IMAGE_REL_PPC_IFGLUE 0x000D */
     
    661655         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    662656         32,                    /* bitsize */
    663          false,                 /* pc_relative */
     657         FALSE,                 /* pc_relative */
    664658         0,                     /* bitpos */
    665659         complain_overflow_signed, /* complain_on_overflow */
    666660         0,                     /* special_function */
    667661         "IFGLUE",              /* name */
    668          true,                  /* partial_inplace */
     662         TRUE,                  /* partial_inplace */
    669663         0xffffffff,            /* src_mask */
    670664         0xffffffff,            /* dst_mask */
    671          false),                /* pcrel_offset */
     665         FALSE),                /* pcrel_offset */
    672666
    673667  /* IMAGE_REL_PPC_IMGLUE 0x000E */
     
    678672         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    679673         32,                    /* bitsize */
    680          false,                 /* pc_relative */
     674         FALSE,                 /* pc_relative */
    681675         0,                     /* bitpos */
    682676         complain_overflow_dont, /* complain_on_overflow */
    683677         ppc_imglue_reloc,      /* special_function */
    684678         "IMGLUE",              /* name */
    685          false,                 /* partial_inplace */
     679         FALSE,                 /* partial_inplace */
    686680         0xffffffff,            /* src_mask */
    687681         0xffffffff,            /* dst_mask */
    688          false),                 /* pcrel_offset */
     682         FALSE),                 /* pcrel_offset */
    689683
    690684  /* IMAGE_REL_PPC_SECREL16 0x000F */
     
    695689         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    696690         16,                    /* bitsize */
    697          false,                 /* pc_relative */
     691         FALSE,                 /* pc_relative */
    698692         0,                     /* bitpos */
    699693         complain_overflow_signed, /* complain_on_overflow */
    700694         0,                     /* special_function */
    701695         "SECREL16",            /* name */
    702          true,                  /* partial_inplace */
     696         TRUE,                  /* partial_inplace */
    703697         0xffff,                /* src_mask */
    704698         0xffff,                /* dst_mask */
    705          true),                 /* pcrel_offset */
     699         TRUE),                 /* pcrel_offset */
    706700
    707701  /* IMAGE_REL_PPC_REFHI             0x0010 */
     
    711705         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    712706         16,                    /* bitsize */
    713          false,                 /* pc_relative */
     707         FALSE,                 /* pc_relative */
    714708         0,                     /* bitpos */
    715709         complain_overflow_signed, /* complain_on_overflow */
    716710         ppc_refhi_reloc,       /* special_function */
    717711         "REFHI",               /* name */
    718          true,                  /* partial_inplace */
     712         TRUE,                  /* partial_inplace */
    719713         0xffffffff,            /* src_mask */
    720714         0xffffffff,            /* dst_mask */
    721          false),                 /* pcrel_offset */
     715         FALSE),                 /* pcrel_offset */
    722716
    723717  /* IMAGE_REL_PPC_REFLO             0x0011 */
     
    727721         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    728722         16,                    /* bitsize */
    729          false,                 /* pc_relative */
     723         FALSE,                 /* pc_relative */
    730724         0,                     /* bitpos */
    731725         complain_overflow_signed, /* complain_on_overflow */
    732726         ppc_refhi_reloc,       /* special_function */
    733727         "REFLO",               /* name */
    734          true,                  /* partial_inplace */
     728         TRUE,                  /* partial_inplace */
    735729         0xffffffff,            /* src_mask */
    736730         0xffffffff,            /* dst_mask */
    737          false),                /* pcrel_offset */
     731         FALSE),                /* pcrel_offset */
    738732
    739733  /* IMAGE_REL_PPC_PAIR              0x0012 */
     
    743737         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    744738         16,                    /* bitsize */
    745          false,                 /* pc_relative */
     739         FALSE,                 /* pc_relative */
    746740         0,                     /* bitpos */
    747741         complain_overflow_signed, /* complain_on_overflow */
    748742         ppc_pair_reloc,        /* special_function */
    749743         "PAIR",                /* name */
    750          true,                  /* partial_inplace */
     744         TRUE,                  /* partial_inplace */
    751745         0xffffffff,            /* src_mask */
    752746         0xffffffff,            /* dst_mask */
    753          false),                /* pcrel_offset */
     747         FALSE),                /* pcrel_offset */
    754748
    755749  /* IMAGE_REL_PPC_TOCREL16_DEFN 0x0013 */
     
    760754         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    761755         16,                    /* bitsize */
    762          false,                 /* pc_relative */
     756         FALSE,                 /* pc_relative */
    763757         0,                     /* bitpos */
    764758         complain_overflow_dont, /* complain_on_overflow */
    765759         0,                     /* special_function */
    766760         "TOCREL16, TOCDEFN",   /* name */
    767          false,                 /* partial_inplace */
     761         FALSE,                 /* partial_inplace */
    768762         0xffff,                /* src_mask */
    769763         0xffff,                /* dst_mask */
    770          false),                /* pcrel_offset */
     764         FALSE),                /* pcrel_offset */
    771765
    772766};
    773767
    774768
    775 /* Some really cheezy macros that can be turned on to test stderr :-) */
     769/* Some really cheezy macros that can be turned on to test stderr :-)  */
    776770
    777771#ifdef DEBUG_RELOC
     
    798792#define n_name          _n._n_name
    799793#define n_zeroes        _n._n_n._n_zeroes
    800 #define n_offset        _n._n_n._n_offset
    801 
    802 */
    803 
    804 #define DUMP_RELOC2(n,r)                     \
    805 {                                            \
    806    fprintf (stderr,"%s sym %d, r_vaddr %d %s\n", \
    807            n, r->r_symndx, r->r_vaddr,\
     794#define n_offset        _n._n_n._n_offset  */
     795
     796#define DUMP_RELOC2(n,r)                                \
     797{                                                       \
     798   fprintf (stderr,"%s sym %d, r_vaddr %d %s\n",        \
     799           n, r->r_symndx, r->r_vaddr,                  \
    808800           (((r->r_type) & IMAGE_REL_PPC_TOCDEFN) == 0) \
    809            ?" ":" TOCDEFN"  );      \
     801           ?" ":" TOCDEFN"  );                          \
    810802}
    811803
     
    817809
    818810
    819 /* toc construction and management routines */
     811/* TOC construction and management routines. */
    820812
    821813/* This file is compiled twice, and these variables are defined in one
    822814   of the compilations.  FIXME: This is confusing and weird.  Also,
    823815   BFD should not use global variables.  */
    824 extern bfd* bfd_of_toc_owner;
     816extern bfd *    bfd_of_toc_owner;
    825817extern long int global_toc_size;
    826 
    827818extern long int import_table_size;
    828819extern long int first_thunk_address;
     
    840831  priv,
    841832  pub,
    842   data
     833  tocdata
    843834};
    844835
     
    856847
    857848static void record_toc
    858   PARAMS ((asection *, int, enum ref_category, const char *));
     849  PARAMS ((asection *, bfd_signed_vma, enum ref_category, const char *));
    859850
    860851static void
    861852record_toc (toc_section, our_toc_offset, cat, name)
    862853     asection *toc_section;
    863      int our_toc_offset;
     854     bfd_signed_vma our_toc_offset;
    864855     enum ref_category cat;
    865856     const char *name;
    866857{
    867   /* add this entry to our toc addr-offset-name list */
    868   struct list_ele *t;
    869   t = (struct list_ele *) bfd_malloc (sizeof (struct list_ele));
     858  /* Add this entry to our toc addr-offset-name list.  */
     859  bfd_size_type amt = sizeof (struct list_ele);
     860  struct list_ele *t = (struct list_ele *) bfd_malloc (amt);
     861
    870862  if (t == NULL)
    871863    abort ();
     
    890882#ifdef COFF_IMAGE_WITH_PE
    891883
    892 static boolean ppc_record_toc_entry
     884static bfd_boolean ppc_record_toc_entry
    893885  PARAMS ((bfd *, struct bfd_link_info *, asection *, int, enum toc_type));
    894886static void ppc_mark_symbol_as_glue
    895887  PARAMS ((bfd *, int, struct internal_reloc *));
    896888
    897 /* record a toc offset against a symbol */
    898 static boolean
     889/* Record a toc offset against a symbol. */
     890static bfd_boolean
    899891ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
    900892     bfd *abfd;
     
    920912    {
    921913      local_syms = obj_coff_local_toc_table(abfd);
     914
    922915      if (local_syms == 0)
    923916        {
    924917          unsigned int i;
     918          bfd_size_type amt;
     919
    925920          /* allocate a table */
    926           local_syms =
    927             (int *) bfd_zalloc (abfd,
    928                                 obj_raw_syment_count(abfd) * sizeof (int));
     921          amt = (bfd_size_type) obj_raw_syment_count (abfd) * sizeof (int);
     922          local_syms = (int *) bfd_zalloc (abfd, amt);
    929923          if (local_syms == 0)
    930             return false;
    931           obj_coff_local_toc_table(abfd) = local_syms;
    932           for (i = 0; i < obj_raw_syment_count(abfd); ++i)
     924            return FALSE;
     925          obj_coff_local_toc_table (abfd) = local_syms;
     926
     927          for (i = 0; i < obj_raw_syment_count (abfd); ++i)
    933928            {
    934               SET_UNALLOCATED(local_syms[i]);
     929              SET_UNALLOCATED (local_syms[i]);
    935930            }
    936931        }
     
    941936          global_toc_size += 4;
    942937
    943           /* The size must fit in a 16bit displacment */
     938          /* The size must fit in a 16bit displacment. */
    944939          if (global_toc_size > 65535)
    945940            {
    946941              (*_bfd_error_handler) (_("TOC overflow"));
    947942              bfd_set_error (bfd_error_file_too_big);
    948               return false;
     943              return FALSE;
    949944            }
    950945        }
     
    954949      name = h->root.root.root.string;
    955950
    956       /* check to see if there's a toc slot allocated. If not, do it
    957          here. It will be used in relocate_section */
     951      /* Check to see if there's a toc slot allocated. If not, do it
     952         here. It will be used in relocate_section. */
    958953      if (IS_UNALLOCATED(h->toc_offset))
    959954        {
     
    961956          global_toc_size += 4;
    962957
    963           /* The size must fit in a 16bit displacment */
     958          /* The size must fit in a 16bit displacment. */
    964959          if (global_toc_size >= 65535)
    965960            {
    966961              (*_bfd_error_handler) (_("TOC overflow"));
    967962              bfd_set_error (bfd_error_file_too_big);
    968               return false;
     963              return FALSE;
    969964            }
    970965        }
    971966    }
    972967
    973   return true;
    974 }
    975 
    976 /* record a toc offset against a symbol */
     968  return TRUE;
     969}
     970
     971/* Record a toc offset against a symbol. */
    977972static void
    978973ppc_mark_symbol_as_glue(abfd, sym, rel)
     
    996991
    997992
    998 /* Return true if this relocation should
     993/* Return TRUE if this relocation should
    999994   appear in the output .reloc section.  */
    1000995
    1001 static boolean in_reloc_p(abfd, howto)
     996static bfd_boolean in_reloc_p(abfd, howto)
    1002997     bfd * abfd ATTRIBUTE_UNUSED;
    1003998     reloc_howto_type *howto;
     
    10201015#if 0
    10211016
    1022 /* this function is in charge of performing all the ppc PE relocations */
    1023 /* Don't yet know if we want to do this this particular way ... (krk)  */
    1024 /* FIXME: (it is not yet enabled) */
     1017/* This function is in charge of performing all the ppc PE relocations
     1018   Don't yet know if we want to do this this particular way ... (krk).  */
     1019/* FIXME: (it is not yet enabled). */
    10251020
    10261021static bfd_reloc_status_type
     
    10351030     char **error_message;
    10361031{
    1037   /* the consth relocation comes in two parts, we have to remember
    1038      the state between calls, in these variables */
    1039   static boolean part1_consth_active = false;
     1032  /* The consth relocation comes in two parts, we have to remember
     1033     the state between calls, in these variables. */
     1034  static bfd_boolean part1_consth_active = FALSE;
    10401035  static unsigned long part1_consth_value;
    10411036
     
    10481043  if (output_bfd)
    10491044    {
    1050       /* Partial linking - do nothing */
     1045      /* Partial linking - do nothing. */
    10511046      reloc_entry->address += input_section->output_offset;
    10521047      return bfd_reloc_ok;
     
    10561051      && bfd_is_und_section (symbol_in->section))
    10571052    {
    1058       /* Keep the state machine happy in case we're called again */
     1053      /* Keep the state machine happy in case we're called again. */
    10591054      if (r_type == IMAGE_REL_PPC_REFHI)
    10601055        {
    1061           part1_consth_active = true;
     1056          part1_consth_active = TRUE;
    10621057          part1_consth_value  = 0;
    10631058        }
     
    10671062  if ((part1_consth_active) && (r_type != IMAGE_REL_PPC_PAIR))
    10681063    {
    1069       part1_consth_active = false;
     1064      part1_consth_active = FALSE;
    10701065      *error_message = (char *) _("Missing PAIR");
    10711066      return(bfd_reloc_dangerous);
     
    10811076/* The reloc processing routine for the optimized COFF linker.  */
    10821077
    1083 static boolean
     1078static bfd_boolean
    10841079coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
    10851080                           contents, relocs, syms, sections)
     
    10951090  struct internal_reloc *rel;
    10961091  struct internal_reloc *relend;
    1097   boolean hihalf;
     1092  bfd_boolean hihalf;
    10981093  bfd_vma hihalf_val;
    10991094  asection *toc_section = 0;
     
    11051100     addresses and symbol indices.  */
    11061101  if (info->relocateable)
    1107     return true;
    1108 
    1109   hihalf = false;
     1102    return TRUE;
     1103
     1104  hihalf = FALSE;
    11101105  hihalf_val = 0;
    11111106
     
    11581153      val = 0;
    11591154
    1160       /* FIXME: PAIR unsupported in the following code */
     1155      /* FIXME: PAIR unsupported in the following code. */
    11611156      if (h == NULL)
    11621157        {
     
    11891184              if (! ((*info->callbacks->undefined_symbol)
    11901185                     (info, h->root.root.root.string, input_bfd, input_section,
    1191                       rel->r_vaddr - input_section->vma, true)))
    1192                 return false;
     1186                      rel->r_vaddr - input_section->vma, TRUE)))
     1187                return FALSE;
    11931188            }
    11941189        }
     
    11961191      rstat = bfd_reloc_ok;
    11971192
    1198       /* Each case must do its own relocation, setting rstat appropriately */
     1193      /* Each case must do its own relocation, setting rstat appropriately. */
    11991194      switch (r_type)
    12001195        {
     
    12021197          (*_bfd_error_handler)
    12031198            (_("%s: unsupported relocation type 0x%02x"),
    1204              bfd_get_filename (input_bfd), r_type);
     1199             bfd_archive_filename (input_bfd), r_type);
    12051200          bfd_set_error (bfd_error_bad_value);
    1206           return false;
     1201          return FALSE;
    12071202        case IMAGE_REL_PPC_TOCREL16:
    12081203          {
    1209             bfd_vma our_toc_offset;
     1204            bfd_signed_vma our_toc_offset;
    12101205            int fixit;
    12111206
     
    12241219              }
    12251220
    1226             /*
    1227              *  Amazing bit tricks present. As we may have seen earlier, we
    1228              *  use the 1 bit to tell us whether or not a toc offset has been
    1229              *  allocated. Now that they've all been allocated, we will use
    1230              *  the 1 bit to tell us if we've written this particular toc
    1231              *  entry out.
    1232              */
    1233             fixit = false;
     1221            /* Amazing bit tricks present. As we may have seen earlier, we
     1222               use the 1 bit to tell us whether or not a toc offset has been
     1223               allocated. Now that they've all been allocated, we will use
     1224               the 1 bit to tell us if we've written this particular toc
     1225               entry out.  */
     1226            fixit = FALSE;
    12341227            if (h == 0)
    1235               { /* it is a file local symbol */
     1228              {
     1229                /* It is a file local symbol.  */
    12361230                int *local_toc_table;
    12371231                const char *name;
     
    12451239                if (IS_WRITTEN(our_toc_offset))
    12461240                  {
    1247                     /* if it has been written out, it is marked with the
     1241                    /* If it has been written out, it is marked with the
    12481242                       1 bit. Fix up our offset, but do not write it out
    1249                        again.
    1250                      */
     1243                       again.  */
    12511244                    MAKE_ADDR_AGAIN(our_toc_offset);
    12521245                  }
    12531246                else
    12541247                  {
    1255                     /* write out the toc entry */
    1256                     record_toc(toc_section,
    1257                                our_toc_offset,
    1258                                priv,
    1259                                strdup(name));
    1260 
    1261                     bfd_put_32 (output_bfd,
    1262                                val,
     1248                    /* Write out the toc entry.  */
     1249                    record_toc (toc_section, our_toc_offset, priv,
     1250                                strdup (name));
     1251
     1252                    bfd_put_32 (output_bfd, val,
    12631253                               toc_section->contents + our_toc_offset);
    12641254
    12651255                    MARK_AS_WRITTEN(local_toc_table[symndx]);
    1266                     fixit = true;
     1256                    fixit = TRUE;
    12671257                  }
    12681258              }
     
    12871277                       the toc, some trippy library code trying for speed on
    12881278                       dll linkage, takes advantage of that and considers
    1289                        the IAT to be part of the toc, thus saving a load.
    1290                     */
    1291 
    1292                     our_toc_offset = val -
    1293                       (toc_section->output_section->vma +
    1294                        toc_section->output_offset);
    1295 
    1296                     /* The size must still fit in a 16bit displacment */
    1297                     if (our_toc_offset >= 65535)
     1279                       the IAT to be part of the toc, thus saving a load.  */
     1280
     1281                    our_toc_offset = val - (toc_section->output_section->vma
     1282                                            + toc_section->output_offset);
     1283
     1284                    /* The size must still fit in a 16bit displacment.  */
     1285                    if ((bfd_vma) our_toc_offset >= 65535)
    12981286                      {
    12991287                        (*_bfd_error_handler)
    1300                           (_("%s: Relocation for %s of %x exceeds Toc size limit"),
    1301                            bfd_get_filename (input_bfd), name, our_toc_offset);
     1288                          (_("%s: Relocation for %s of %lx exceeds Toc size limit"),
     1289                           bfd_archive_filename (input_bfd), name,
     1290                           (unsigned long) our_toc_offset);
    13021291                        bfd_set_error (bfd_error_bad_value);
    1303                         return false;
     1292                        return FALSE;
    13041293                      }
    13051294
    1306                     record_toc(toc_section, our_toc_offset, pub, strdup(name));
     1295                    record_toc (toc_section, our_toc_offset, pub,
     1296                                strdup (name));
    13071297                  }
    1308                 else if (IS_WRITTEN(our_toc_offset))
     1298                else if (IS_WRITTEN (our_toc_offset))
    13091299                  {
    1310                     /* if it has been written out, it is marked with the
     1300                    /* If it has been written out, it is marked with the
    13111301                       1 bit. Fix up our offset, but do not write it out
    1312                        again.
    1313                      */
     1302                       again.  */
    13141303                    MAKE_ADDR_AGAIN(our_toc_offset);
    13151304                  }
    13161305                else
    13171306                  {
    1318                     record_toc(toc_section, our_toc_offset, pub, strdup(name));
    1319 
    1320                     /* write out the toc entry */
    1321                     bfd_put_32 (output_bfd,
    1322                               val,
     1307                    record_toc(toc_section, our_toc_offset, pub,
     1308                               strdup (name));
     1309
     1310                    /* Write out the toc entry.  */
     1311                    bfd_put_32 (output_bfd, val,
    13231312                               toc_section->contents + our_toc_offset);
    13241313
    13251314                    MARK_AS_WRITTEN(h->toc_offset);
    1326                     /* The tricky part is that this is the address that */
    1327                     /* needs a .reloc entry for it */
    1328                     fixit = true;
     1315                    /* The tricky part is that this is the address that
     1316                       needs a .reloc entry for it. */
     1317                    fixit = TRUE;
    13291318                  }
    13301319              }
     
    13331322              {
    13341323                /* So if this is non pcrelative, and is referenced
    1335                    to a section or a common symbol, then it needs a reloc */
    1336 
    1337                 /* relocation to a symbol in a section which
     1324                   to a section or a common symbol, then it needs a reloc. */
     1325
     1326                /* Relocation to a symbol in a section which
    13381327                   isn't absolute - we output the address here
    1339                    to a file */
    1340 
    1341                 bfd_vma addr =  toc_section->output_section->vma
    1342                   + toc_section->output_offset + our_toc_offset;
    1343 
    1344                 if (coff_data(output_bfd)->pe)
     1328                   to a file.  */
     1329                bfd_vma addr = (toc_section->output_section->vma
     1330                                + toc_section->output_offset + our_toc_offset);
     1331
     1332                if (coff_data (output_bfd)->pe)
    13451333                  addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
    13461334
     
    13481336              }
    13491337
    1350             /* FIXME: this test is conservative */
    1351             if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN &&
    1352                 our_toc_offset > toc_section->_raw_size)
     1338            /* FIXME: this test is conservative. */
     1339            if ((r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN
     1340                && (bfd_vma) our_toc_offset > toc_section->_raw_size)
    13531341              {
    13541342                (*_bfd_error_handler)
    1355                   (_("%s: Relocation exceeds allocated TOC (%x)"),
    1356                    bfd_get_filename (input_bfd),
    1357                    toc_section->_raw_size);
     1343                  (_("%s: Relocation exceeds allocated TOC (%lx)"),
     1344                   bfd_archive_filename (input_bfd),
     1345                   (unsigned long) toc_section->_raw_size);
    13581346                bfd_set_error (bfd_error_bad_value);
    1359                 return false;
     1347                return FALSE;
    13601348              }
    13611349
    1362             /* Now we know the relocation for this toc reference */
     1350            /* Now we know the relocation for this toc reference. */
    13631351            relocation =  our_toc_offset + TOC_LOAD_ADJUSTMENT;
    1364             rstat = _bfd_relocate_contents (howto,
    1365                                             input_bfd,
    1366                                             relocation,
    1367                                             loc);
     1352            rstat = _bfd_relocate_contents (howto, input_bfd, relocation, loc);
    13681353          }
    13691354          break;
    13701355        case IMAGE_REL_PPC_IFGLUE:
    13711356          {
    1372             /* To solve this, we need to know whether or not the symbol */
    1373             /* appearing on the call instruction is a glue function or not.  */
    1374             /* A glue function must announce itself via a IMGLUE reloc, and */
    1375             /* the reloc contains the required toc restore instruction */
    1376 
     1357            /* To solve this, we need to know whether or not the symbol
     1358               appearing on the call instruction is a glue function or not.
     1359               A glue function must announce itself via a IMGLUE reloc, and
     1360               the reloc contains the required toc restore instruction.  */
    13771361            bfd_vma x;
    13781362            const char *my_name;
    1379             DUMP_RELOC2(howto->name, rel);
     1363           
     1364            DUMP_RELOC2 (howto->name, rel);
    13801365
    13811366            if (h != 0)
     
    13851370                  {
    13861371                    x = bfd_get_32 (input_bfd, loc);
    1387                     bfd_put_32 (input_bfd, h->glue_insn, loc);
     1372                    bfd_put_32 (input_bfd, (bfd_vma) h->glue_insn, loc);
    13881373                  }
    13891374              }
     
    13911376          break;
    13921377        case IMAGE_REL_PPC_SECREL:
    1393           /* Unimplemented: codeview debugging information */
     1378          /* Unimplemented: codeview debugging information. */
    13941379          /* For fast access to the header of the section
    13951380             containing the item.  */
    13961381          break;
    13971382        case IMAGE_REL_PPC_SECTION:
    1398           /* Unimplemented: codeview debugging information */
     1383          /* Unimplemented: codeview debugging information. */
    13991384          /* Is used to indicate that the value should be relative
    14001385             to the beginning of the section that contains the
    1401              symbol */
     1386             symbol. */
    14021387          break;
    14031388        case IMAGE_REL_PPC_ABSOLUTE:
    14041389          {
    14051390            const char *my_name;
     1391
    14061392            if (h == 0)
    1407                 my_name = (syms+symndx)->_n._n_name;
     1393              my_name = (syms+symndx)->_n._n_name;
    14081394            else
    1409               {
    1410                 my_name = h->root.root.root.string;
    1411               }
     1395              my_name = h->root.root.root.string;
    14121396
    14131397            fprintf (stderr,
    14141398                    _("Warning: unsupported reloc %s <file %s, section %s>\n"),
    14151399                    howto->name,
    1416                     bfd_get_filename(input_bfd),
     1400                    bfd_archive_filename(input_bfd),
    14171401                    input_section->name);
    14181402
     
    14251409          {
    14261410            /* There is nothing to do now. This reloc was noted in the first
    1427                pass over the relocs, and the glue instruction extracted */
     1411               pass over the relocs, and the glue instruction extracted. */
    14281412            const char *my_name;
     1413
    14291414            if (h->symbol_is_glue == 1)
    14301415              break;
     
    14331418            (*_bfd_error_handler)
    14341419              (_("%s: Out of order IMGLUE reloc for %s"),
    1435                bfd_get_filename (input_bfd), my_name);
     1420               bfd_archive_filename (input_bfd), my_name);
    14361421            bfd_set_error (bfd_error_bad_value);
    1437             return false;
     1422            return FALSE;
    14381423          }
    14391424
    14401425        case IMAGE_REL_PPC_ADDR32NB:
    14411426          {
    1442             struct coff_link_hash_entry *myh = 0;
    14431427            const char *name = 0;
    1444             DUMP_RELOC2(howto->name, rel);
     1428
     1429            DUMP_RELOC2 (howto->name, rel);
    14451430
    14461431            if (strncmp(".idata$2",input_section->name,8) == 0 && first_thunk_address == 0)
    14471432              {
    1448                 /* set magic values */
     1433                /* Set magic values. */
    14491434                int idata5offset;
    1450                 struct coff_link_hash_entry *myh = 0;
     1435                struct coff_link_hash_entry *myh;
     1436
    14511437                myh = coff_link_hash_lookup (coff_hash_table (info),
    14521438                                             "__idata5_magic__",
    1453                                              false, false, true);
     1439                                             FALSE, FALSE, TRUE);
    14541440                first_thunk_address = myh->root.u.def.value +
    14551441                  sec->output_section->vma +
     
    14601446                myh = coff_link_hash_lookup (coff_hash_table (info),
    14611447                                             "__idata6_magic__",
    1462                                              false, false, true);
     1448                                             FALSE, FALSE, TRUE);
    14631449
    14641450                thunk_size = myh->root.u.def.value - idata5offset;
    14651451                myh = coff_link_hash_lookup (coff_hash_table (info),
    14661452                                             "__idata4_magic__",
    1467                                              false, false, true);
     1453                                             FALSE, FALSE, TRUE);
    14681454                import_table_size = myh->root.u.def.value;
    14691455              }
    14701456
    14711457            if (h == 0)
    1472               { /* it is a file local symbol */
     1458              {
     1459                /* It is a file local symbol.  */
    14731460                sym = syms + symndx;
    14741461                name = sym->_n._n_name;
     
    14791466
    14801467                name = h->root.root.root.string;
    1481                 if (strcmp(".idata$2", name) == 0)
     1468                if (strcmp (".idata$2", name) == 0)
    14821469                  target = "__idata2_magic__";
    1483                 else if (strcmp(".idata$4", name) == 0)
     1470                else if (strcmp (".idata$4", name) == 0)
    14841471                  target = "__idata4_magic__";
    1485                 else if (strcmp(".idata$5", name) == 0)
     1472                else if (strcmp (".idata$5", name) == 0)
    14861473                  target = "__idata5_magic__";
    14871474
    14881475                if (target != 0)
    14891476                  {
    1490                     myh = 0;
     1477                    struct coff_link_hash_entry *myh;
    14911478
    14921479                    myh = coff_link_hash_lookup (coff_hash_table (info),
    14931480                                                 target,
    1494                                                  false, false, true);
     1481                                                 FALSE, FALSE, TRUE);
    14951482                    if (myh == 0)
    14961483                      {
     
    15061493                        myh = coff_link_hash_lookup (coff_hash_table (info),
    15071494                                                     "__idata5_magic__",
    1508                                                      false, false, true);
     1495                                                     FALSE, FALSE, TRUE);
    15091496                        first_thunk_address = myh->root.u.def.value +
    15101497                          sec->output_section->vma +
     
    15151502                        myh = coff_link_hash_lookup (coff_hash_table (info),
    15161503                                                     "__idata6_magic__",
    1517                                                      false, false, true);
     1504                                                     FALSE, FALSE, TRUE);
    15181505
    15191506                        thunk_size = myh->root.u.def.value - idata5offset;
    15201507                        myh = coff_link_hash_lookup (coff_hash_table (info),
    15211508                                                     "__idata4_magic__",
    1522                                                      false, false, true);
     1509                                                     FALSE, FALSE, TRUE);
    15231510                        import_table_size = myh->root.u.def.value;
    15241511                      }
     
    15271514
    15281515            rstat = _bfd_relocate_contents (howto,
    1529                               input_bfd,
    1530                               val -
    1531                               pe_data(output_bfd)->pe_opthdr.ImageBase,
    1532                               loc);
     1516                                            input_bfd,
     1517                                            val -
     1518                                            pe_data (output_bfd)->pe_opthdr.ImageBase,
     1519                                            loc);
    15331520          }
    15341521          break;
     
    15551542        }
    15561543
    1557       if ( info->base_file )
     1544      if (info->base_file)
    15581545        {
    15591546          /* So if this is non pcrelative, and is referenced
    1560              to a section or a common symbol, then it needs a reloc */
    1561           if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
     1547             to a section or a common symbol, then it needs a reloc. */
     1548          if (sym && pe_data(output_bfd)->in_reloc_p (output_bfd, howto))
    15621549            {
    1563               /* relocation to a symbol in a section which
     1550              /* Relocation to a symbol in a section which
    15641551                 isn't absolute - we output the address here
    1565                  to a file */
     1552                 to a file. */
    15661553              bfd_vma addr = rel->r_vaddr
    15671554                - input_section->vma
     
    15691556                  + input_section->output_section->vma;
    15701557
    1571               if (coff_data(output_bfd)->pe)
    1572                 {
    1573                   addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
    1574                 }
     1558              if (coff_data (output_bfd)->pe)
     1559                addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
     1560
    15751561              fwrite (&addr, 1,4, (FILE *) info->base_file);
    15761562            }
     
    16081594                    (bfd_vma) 0, input_bfd,
    16091595                    input_section, rel->r_vaddr - input_section->vma)))
    1610               {
    1611                 return false;
    1612               }
     1596              return FALSE;
    16131597          }
    16141598        }
    1615 
    1616     }
    1617 
    1618   return true;
     1599    }
     1600
     1601  return TRUE;
    16191602}
    16201603
     
    16621645      else if (t->cat == pub)
    16631646        cat = _("public        ");
    1664       else if (t->cat == data)
     1647      else if (t->cat == tocdata)
    16651648        cat = _("data-in-toc   ");
    16661649
     
    16731656              fprintf (file,
    16741657                      _("**** global_toc_size %ld(%lx), thunk_size %ld(%lx)\n"),
    1675                       global_toc_size, global_toc_size, thunk_size, thunk_size);
     1658                       global_toc_size, global_toc_size,
     1659                       thunk_size, thunk_size);
    16761660              cat = _("Out of bounds!");
    16771661            }
     
    16891673}
    16901674
    1691 boolean
     1675bfd_boolean
    16921676ppc_allocate_toc_section (info)
    16931677     struct bfd_link_info *info ATTRIBUTE_UNUSED;
     
    16951679  asection *s;
    16961680  bfd_byte *foo;
     1681  bfd_size_type amt;
    16971682  static char test_char = '1';
    16981683
    1699   if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble? */
    1700     return true;
     1684  if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble?  */
     1685    return TRUE;
    17011686
    17021687  if (bfd_of_toc_owner == 0)
    1703     {
    1704       /* No toc owner? Something is very wrong.  */
    1705       abort ();
    1706     }
     1688    /* No toc owner? Something is very wrong.  */
     1689    abort ();
    17071690
    17081691  s = bfd_get_section_by_name ( bfd_of_toc_owner , TOC_SECTION_NAME);
    17091692  if (s == NULL)
    1710     {
    1711       /* No toc section? Something is very wrong.  */
    1712       abort ();
    1713     }
    1714 
    1715   foo = (bfd_byte *) bfd_alloc(bfd_of_toc_owner, global_toc_size);
    1716   memset(foo, test_char, global_toc_size);
     1693    /* No toc section? Something is very wrong.  */
     1694    abort ();
     1695
     1696  amt = global_toc_size;
     1697  foo = (bfd_byte *) bfd_alloc (bfd_of_toc_owner, amt);
     1698  memset(foo, test_char, (size_t) global_toc_size);
    17171699
    17181700  s->_raw_size = s->_cooked_size = global_toc_size;
    17191701  s->contents = foo;
    17201702
    1721   return true;
    1722 }
    1723 
    1724 boolean
     1703  return TRUE;
     1704}
     1705
     1706bfd_boolean
    17251707ppc_process_before_allocation (abfd, info)
    17261708     bfd *abfd;
     
    17301712  struct internal_reloc *i, *rel;
    17311713
    1732   /* here we have a bfd that is to be included on the link. We have a hook
     1714  /* Here we have a bfd that is to be included on the link. We have a hook
    17331715     to do reloc rummaging, before section sizes are nailed down.  */
    1734 
    1735   _bfd_coff_get_external_symbols(abfd);
    1736 
    1737   /* rummage around all the relocs and map the toc */
     1716  _bfd_coff_get_external_symbols (abfd);
     1717
     1718  /* Rummage around all the relocs and map the toc.  */
    17381719  sec = abfd->sections;
    17391720
    17401721  if (sec == 0)
    1741     {
    1742       return true;
    1743     }
     1722    return TRUE;
    17441723
    17451724  for (; sec != 0; sec = sec->next)
    1746   {
    1747     if (sec->reloc_count == 0)
    1748       continue;
    1749 
    1750     /* load the relocs */
    1751     /* FIXME: there may be a storage leak here */
    1752     i=_bfd_coff_read_internal_relocs(abfd,sec,1,0,0,0);
    1753 
    1754     if (i == 0)
    1755       abort ();
    1756 
    1757     for (rel=i;rel<i+sec->reloc_count;++rel)
    1758       {
    1759         unsigned short r_type  = EXTRACT_TYPE (rel->r_type);
    1760         unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
    1761         boolean ok = true;
    1762 
    1763         DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
    1764 
    1765         switch(r_type)
    1766           {
    1767           case IMAGE_REL_PPC_TOCREL16:
    1768             /* if TOCDEFN is on, ignore as someone else has allocated the
    1769                toc entry */
    1770             if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN )
    1771               ok = ppc_record_toc_entry(abfd, info, sec,
    1772                                         rel->r_symndx, default_toc);
    1773             if (!ok)
    1774               return false;
    1775             break;
    1776           case IMAGE_REL_PPC_IMGLUE:
    1777             ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel);
    1778             break;
    1779           default:
    1780             break;
    1781           }
    1782       }
    1783   }
    1784 
    1785   return true;
     1725    {
     1726      if (sec->reloc_count == 0)
     1727        continue;
     1728
     1729      /* load the relocs */
     1730      /* FIXME: there may be a storage leak here */
     1731      i=_bfd_coff_read_internal_relocs(abfd,sec,1,0,0,0);
     1732
     1733      if (i == 0)
     1734        abort ();
     1735
     1736      for (rel = i; rel < i + sec->reloc_count; ++rel)
     1737        {
     1738          unsigned short r_type  = EXTRACT_TYPE (rel->r_type);
     1739          unsigned short r_flags = EXTRACT_FLAGS (rel->r_type);
     1740          bfd_boolean ok = TRUE;
     1741
     1742          DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, rel);
     1743
     1744          switch(r_type)
     1745            {
     1746            case IMAGE_REL_PPC_TOCREL16:
     1747              /* If TOCDEFN is on, ignore as someone else has allocated the
     1748                 toc entry. */
     1749              if ((r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN)
     1750                ok = ppc_record_toc_entry(abfd, info, sec,
     1751                                          rel->r_symndx, default_toc);
     1752              if (!ok)
     1753                return FALSE;
     1754              break;
     1755            case IMAGE_REL_PPC_IMGLUE:
     1756              ppc_mark_symbol_as_glue (abfd, rel->r_symndx, rel);
     1757              break;
     1758            default:
     1759              break;
     1760            }
     1761        }
     1762    }
     1763
     1764  return TRUE;
    17861765}
    17871766
     
    17891768
    17901769static bfd_reloc_status_type
    1791 ppc_refhi_reloc (abfd,
    1792                  reloc_entry,
    1793                  symbol,
    1794                  data,
    1795                  input_section,
    1796                  output_bfd,
    1797                  error_message)
     1770ppc_refhi_reloc (abfd, reloc_entry, symbol, data,
     1771                 input_section, output_bfd, error_message)
    17981772     bfd *abfd ATTRIBUTE_UNUSED;
    17991773     arelent *reloc_entry ATTRIBUTE_UNUSED;
     
    18161790
    18171791static bfd_reloc_status_type
    1818 ppc_reflo_reloc (abfd,
    1819                  reloc_entry,
    1820                  symbol,
    1821                  data,
    1822                  input_section,
    1823                  output_bfd,
    1824                  error_message)
     1792ppc_reflo_reloc (abfd, reloc_entry, symbol, data,
     1793                 input_section, output_bfd, error_message)
    18251794     bfd *abfd;
    18261795     arelent *reloc_entry;
     
    18431812
    18441813static bfd_reloc_status_type
    1845 ppc_pair_reloc (abfd,
    1846                 reloc_entry,
    1847                 symbol,
    1848                 data,
    1849                 input_section,
    1850                 output_bfd,
    1851                 error_message)
     1814ppc_pair_reloc (abfd, reloc_entry, symbol, data,
     1815                input_section, output_bfd, error_message)
    18521816     bfd *abfd ATTRIBUTE_UNUSED;
    18531817     arelent *reloc_entry ATTRIBUTE_UNUSED;
     
    18691833
    18701834static bfd_reloc_status_type
    1871 ppc_toc16_reloc (abfd,
    1872                  reloc_entry,
    1873                  symbol,
    1874                  data,
    1875                  input_section,
    1876                  output_bfd,
    1877                  error_message)
     1835ppc_toc16_reloc (abfd, reloc_entry, symbol, data,
     1836                 input_section, output_bfd, error_message)
    18781837     bfd *abfd ATTRIBUTE_UNUSED;
    18791838     arelent *reloc_entry ATTRIBUTE_UNUSED;
     
    18841843     char **error_message ATTRIBUTE_UNUSED;
    18851844{
    1886   UN_IMPL("TOCREL16");
    1887   DUMP_RELOC("TOCREL16",reloc_entry);
     1845  UN_IMPL ("TOCREL16");
     1846  DUMP_RELOC ("TOCREL16",reloc_entry);
    18881847
    18891848  if (output_bfd == (bfd *) NULL)
    1890     {
    1891       return bfd_reloc_continue;
    1892     }
     1849    return bfd_reloc_continue;
    18931850
    18941851  return bfd_reloc_ok;
     
    18971854#if 0
    18981855
    1899 /* ADDR32NB : 32 bit address relative to the virtual origin.         */
    1900 /*            (On the alpha, this is always a linker generated thunk)*/
    1901 /*            (i.e. 32bit addr relative to the image base)           */
    1902 /*                                                                   */
    1903 /*                                                                   */
     1856/* ADDR32NB : 32 bit address relative to the virtual origin.
     1857              (On the alpha, this is always a linker generated thunk)
     1858              (i.e. 32bit addr relative to the image base).  */
    19041859
    19051860static bfd_reloc_status_type
    1906 ppc_addr32nb_reloc (abfd,
    1907                     reloc_entry,
    1908                     symbol,
    1909                     data,
    1910                     input_section,
    1911                     output_bfd,
    1912                     error_message)
     1861ppc_addr32nb_reloc (abfd, reloc_entry, symbol, data,
     1862                    input_section, output_bfd, error_message)
    19131863     bfd *abfd;
    19141864     arelent *reloc_entry;
     
    19281878
    19291879static bfd_reloc_status_type
    1930 ppc_secrel_reloc (abfd,
    1931                   reloc_entry,
    1932                   symbol,
    1933                   data,
    1934                   input_section,
    1935                   output_bfd,
    1936                   error_message)
     1880ppc_secrel_reloc (abfd, reloc_entry, symbol, data,
     1881                  input_section, output_bfd, error_message)
    19371882     bfd *abfd ATTRIBUTE_UNUSED;
    19381883     arelent *reloc_entry ATTRIBUTE_UNUSED;
     
    19531898
    19541899static bfd_reloc_status_type
    1955 ppc_section_reloc (abfd,
    1956                    reloc_entry,
    1957                    symbol,
    1958                    data,
    1959                    input_section,
    1960                    output_bfd,
    1961                    error_message)
     1900ppc_section_reloc (abfd, reloc_entry, symbol, data,
     1901                   input_section, output_bfd, error_message)
    19621902     bfd *abfd ATTRIBUTE_UNUSED;
    19631903     arelent *reloc_entry ATTRIBUTE_UNUSED;
     
    19781918
    19791919static bfd_reloc_status_type
    1980 ppc_imglue_reloc (abfd,
    1981                   reloc_entry,
    1982                   symbol,
    1983                   data,
    1984                   input_section,
    1985                   output_bfd,
    1986                   error_message)
     1920ppc_imglue_reloc (abfd, reloc_entry, symbol, data,
     1921                  input_section, output_bfd, error_message)
    19871922     bfd *abfd ATTRIBUTE_UNUSED;
    19881923     arelent *reloc_entry ATTRIBUTE_UNUSED;
     
    20081943/* FIXME: There is a possiblity that when we read in a reloc from a file,
    20091944          that there are some bits encoded in the upper portion of the
    2010           type field. Not yet implemented.
    2011 */
    2012 static void ppc_coff_rtype2howto PARAMS ((arelent *relent,
    2013                                           struct internal_reloc *internal));
     1945          type field. Not yet implemented.  */
     1946static void ppc_coff_rtype2howto PARAMS ((arelent *, struct internal_reloc *));
    20141947
    20151948static void
     
    20181951     struct internal_reloc *internal;
    20191952{
    2020 
    20211953  /* We can encode one of three things in the type field, aside from the
    20221954     type:
     
    20271959     3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file
    20281960     For now, we just strip this stuff to find the type, and ignore it other
    2029      than that.
    2030   */
     1961     than that.  */
    20311962  reloc_howto_type *howto;
    20321963  unsigned short r_type  = EXTRACT_TYPE (internal->r_type);
     
    20341965  unsigned short junk    = EXTRACT_JUNK (internal->r_type);
    20351966
    2036   /* the masking process only slices off the bottom byte for r_type.  */
     1967  /* The masking process only slices off the bottom byte for r_type.  */
    20371968  if ( r_type > MAX_RELOC_INDEX )
    20381969    abort ();
    20391970
    2040   /* check for absolute crap */
    2041   if ( junk != 0 )
     1971  /* Check for absolute crap. */
     1972  if (junk != 0)
    20421973    abort ();
    20431974
     
    20521983    case IMAGE_REL_PPC_SECTION:
    20531984    case IMAGE_REL_PPC_SECREL:
    2054       DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
     1985      DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal);
    20551986      howto = ppc_coff_howto_table + r_type;
    20561987      break;
    20571988    case IMAGE_REL_PPC_IMGLUE:
    2058       DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
     1989      DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal);
    20591990      howto = ppc_coff_howto_table + r_type;
    20601991      break;
    20611992    case IMAGE_REL_PPC_TOCREL16:
    2062       DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
     1993      DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal);
    20631994      if (r_flags & IMAGE_REL_PPC_TOCDEFN)
    20641995        howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16_DEFN;
     
    20762007
    20772008  relent->howto = howto;
    2078 
    20792009}
    20802010
     
    20982028     3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file
    20992029     For now, we just strip this stuff to find the type, and ignore it other
    2100      than that.
    2101   */
    2102 
    2103   unsigned short r_type  = EXTRACT_TYPE (rel->r_type);
    2104   unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
    2105   unsigned short junk    = EXTRACT_JUNK (rel->r_type);
    2106 
    2107   /* the masking process only slices off the bottom byte for r_type.  */
    2108   if ( r_type > MAX_RELOC_INDEX )
     2030     than that.  */
     2031
     2032  unsigned short r_type  = EXTRACT_TYPE  (rel->r_type);
     2033  unsigned short r_flags = EXTRACT_FLAGS (rel->r_type);
     2034  unsigned short junk    = EXTRACT_JUNK  (rel->r_type);
     2035
     2036  /* The masking process only slices off the bottom byte for r_type.  */
     2037  if (r_type > MAX_RELOC_INDEX)
    21092038    abort ();
    21102039
    2111   /* check for absolute crap */
    2112   if ( junk != 0 )
     2040  /* Check for absolute crap. */
     2041  if (junk != 0)
    21132042    abort ();
    21142043
     
    21532082}
    21542083
    2155 /* a cheesy little macro to make the code a little more readable */
     2084/* A cheesy little macro to make the code a little more readable. */
    21562085#define HOW2MAP(bfd_rtype,ppc_rtype)  \
    21572086 case bfd_rtype: return &ppc_coff_howto_table[ppc_rtype]
     
    21792108      return NULL;
    21802109    }
    2181   /*NOTREACHED*/
    21822110}
    21832111
     
    21882116
    21892117#define RTYPE2HOWTO(cache_ptr, dst)  ppc_coff_rtype2howto (cache_ptr, dst)
    2190 
    2191 #ifndef COFF_IMAGE_WITH_PE
    2192 static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
    2193 #endif
    21942118
    21952119/* We use the special COFF backend linker, with our own special touch.  */
     
    22022126#ifndef COFF_IMAGE_WITH_PE
    22032127/* FIXME: This no longer works.  */
     2128#if 0
    22042129#define coff_swap_sym_in_hook        ppc_coff_swap_sym_in_hook
     2130#endif
    22052131#endif
    22062132
     
    22322158
    22332159#ifndef COFF_IMAGE_WITH_PE
     2160/* FIXME: This no longer works.  */
     2161#if 0
    22342162/* FIXME:
    22352163   What we're trying to do here is allocate a toc section (early), and attach
     
    22432171      that you are the last bfd closed.
    22442172   3. Doing it on a "swap in" hook depends on when the "swap in" is called,
    2245       and how often, etc. It's not clear to me that there isn't a hole here.
    2246 */
     2173      and how often, etc. It's not clear to me that there isn't a hole here.  */
     2174static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
    22472175
    22482176static void
     
    22522180     PTR in1;
    22532181{
    2254   struct internal_syment      *in = (struct internal_syment *)in1;
    2255 
    2256   if (bfd_of_toc_owner != 0) /* we already have a toc, so go home */
     2182  struct internal_syment * in = (struct internal_syment *)in1;
     2183
     2184  if (bfd_of_toc_owner != 0) /* We already have a toc, so go home. */
    22572185    return;
    22582186
    2259   if (strcmp(in->_n._n_name, ".toc") == 0)
     2187  if (strcmp (in->_n._n_name, ".toc") == 0)
    22602188    {
    22612189      flagword flags;
    22622190      register asection *s;
    22632191
    2264       s = bfd_get_section_by_name ( abfd , TOC_SECTION_NAME);
     2192      s = bfd_get_section_by_name (abfd, TOC_SECTION_NAME);
    22652193      if (s != NULL)
    2266         {
    2267           return;
    2268         }
     2194        return;
    22692195
    22702196      flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ;
     
    22752201          || !bfd_set_section_flags (abfd, s, flags)
    22762202          || !bfd_set_section_alignment (abfd, s, 2))
    2277         {
    2278           /* FIXME: set appropriate bfd error */
    2279           abort ();
    2280         }
    2281 
    2282       /* save the bfd for later allocation */
     2203        /* FIXME: set appropriate bfd error.  */
     2204        abort ();
     2205
     2206      /* Save the bfd for later allocation.  */
    22832207      bfd_of_toc_owner = abfd;
    22842208    }
     
    22872211}
    22882212#endif
     2213#endif
    22892214
    22902215#ifndef COFF_IMAGE_WITH_PE
    22912216
    2292 static boolean ppc_do_last PARAMS ((bfd *));
     2217static bfd_boolean ppc_do_last PARAMS ((bfd *));
    22932218static bfd *ppc_get_last PARAMS ((void));
    22942219
    2295 static boolean
     2220static bfd_boolean
    22962221ppc_do_last (abfd)
    22972222     bfd *abfd;
    22982223{
    22992224  if (abfd == bfd_of_toc_owner)
    2300     return true;
     2225    return TRUE;
    23012226  else
    2302     return false;
     2227    return FALSE;
    23032228}
    23042229
     
    23092234}
    23102235
    2311 /* this piece of machinery exists only to guarantee that the bfd that holds
     2236/* This piece of machinery exists only to guarantee that the bfd that holds
    23122237   the toc section is written last.
    23132238
     
    23182243   cofflink.c:_bfd_coff_final_link(). It is specifically different only
    23192244   where the POWERPC_LE_PE macro modifies the code. It is left in as a
    2320    precise form of comment. krk@cygnus.com
    2321 */
     2245   precise form of comment. krk@cygnus.com  */
    23222246
    23232247/* Do the final link step.  */
    23242248
    2325 boolean
     2249bfd_boolean
    23262250ppc_bfd_coff_final_link (abfd, info)
    23272251     bfd *abfd;
     
    23302254  bfd_size_type symesz;
    23312255  struct coff_final_link_info finfo;
    2332   boolean debug_merge_allocated;
     2256  bfd_boolean debug_merge_allocated;
    23332257  asection *o;
    23342258  struct bfd_link_order *p;
    2335   size_t max_sym_count;
    2336   size_t max_lineno_count;
    2337   size_t max_reloc_count;
    2338   size_t max_output_reloc_count;
    2339   size_t max_contents_size;
     2259  bfd_size_type max_sym_count;
     2260  bfd_size_type max_lineno_count;
     2261  bfd_size_type max_reloc_count;
     2262  bfd_size_type max_output_reloc_count;
     2263  bfd_size_type max_contents_size;
    23402264  file_ptr rel_filepos;
    23412265  unsigned int relsz;
     
    23452269  bfd_byte *external_relocs = NULL;
    23462270  char strbuf[STRING_SIZE_SIZE];
     2271  bfd_size_type amt;
    23472272
    23482273  symesz = bfd_coff_symesz (abfd);
     
    23622287  finfo.external_relocs = NULL;
    23632288  finfo.internal_relocs = NULL;
    2364   debug_merge_allocated = false;
     2289  debug_merge_allocated = FALSE;
    23652290
    23662291  coff_data (abfd)->link_info = info;
     
    23722297  if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
    23732298    goto error_return;
    2374   debug_merge_allocated = true;
     2299  debug_merge_allocated = TRUE;
    23752300
    23762301  /* Compute the file positions for all the sections.  */
     
    23782303    {
    23792304      if (! bfd_coff_compute_section_file_positions (abfd))
    2380         return false;
     2305        return FALSE;
    23812306    }
    23822307
     
    23932318      o->reloc_count = 0;
    23942319      o->lineno_count = 0;
     2320
    23952321      for (p = o->link_order_head; p != NULL; p = p->next)
    23962322        {
    2397 
    23982323          if (p->type == bfd_indirect_link_order)
    23992324            {
     
    24062331                 to do this so that we can identify any sections which
    24072332                 the linker has decided to not include.  */
    2408               sec->linker_mark = true;
     2333              sec->linker_mark = TRUE;
    24092334
    24102335              if (info->strip == strip_none
     
    24452370      /* We use section_count + 1, rather than section_count, because
    24462371         the target_index fields are 1 based.  */
    2447       finfo.section_info =
    2448         ((struct coff_link_section_info *)
    2449          bfd_malloc ((abfd->section_count + 1)
    2450                      * sizeof (struct coff_link_section_info)));
     2372      amt = abfd->section_count + 1;
     2373      amt *= sizeof (struct coff_link_section_info);
     2374      finfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
     2375
    24512376      if (finfo.section_info == NULL)
    24522377        goto error_return;
     2378
    24532379      for (i = 0; i <= abfd->section_count; i++)
    24542380        {
     
    24632389  linesz = bfd_coff_linesz (abfd);
    24642390  max_output_reloc_count = 0;
     2391
    24652392  for (o = abfd->sections; o != NULL; o = o->next)
    24662393    {
     
    24892416             common case.  */
    24902417          BFD_ASSERT (info->relocateable);
     2418          amt = o->reloc_count;
     2419          amt *= sizeof (struct internal_reloc);
    24912420          finfo.section_info[o->target_index].relocs =
    2492             ((struct internal_reloc *)
    2493              bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
     2421            (struct internal_reloc *) bfd_malloc (amt);
     2422          amt = o->reloc_count;
     2423          amt *= sizeof (struct coff_link_hash_entry *);
    24942424          finfo.section_info[o->target_index].rel_hashes =
    2495             ((struct coff_link_hash_entry **)
    2496              bfd_malloc (o->reloc_count
    2497                      * sizeof (struct coff_link_hash_entry *)));
     2425            (struct coff_link_hash_entry **) bfd_malloc (amt);
    24982426          if (finfo.section_info[o->target_index].relocs == NULL
    24992427              || finfo.section_info[o->target_index].rel_hashes == NULL)
     
    25182446  for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
    25192447    {
    2520       size_t sz;
    2521 
    2522       sub->output_has_begun = false;
     2448      bfd_size_type sz;
     2449
     2450      sub->output_has_begun = FALSE;
    25232451      sz = obj_raw_syment_count (sub);
    25242452      if (sz > max_sym_count)
     
    25272455
    25282456  /* Allocate some buffers used while linking.  */
    2529   finfo.internal_syms = ((struct internal_syment *)
    2530                          bfd_malloc (max_sym_count
    2531                                      * sizeof (struct internal_syment)));
    2532   finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
    2533                                              * sizeof (asection *));
    2534   finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
    2535   finfo.outsyms = ((bfd_byte *)
    2536                    bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
    2537   finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
    2538                                        * bfd_coff_linesz (abfd));
     2457  amt = max_sym_count * sizeof (struct internal_syment);
     2458  finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
     2459  amt = max_sym_count * sizeof (asection *);
     2460  finfo.sec_ptrs = (asection **) bfd_malloc (amt);
     2461  amt = max_sym_count * sizeof (long);
     2462  finfo.sym_indices = (long *) bfd_malloc (amt);
     2463  amt = (max_sym_count + 1) * symesz;
     2464  finfo.outsyms = (bfd_byte *) bfd_malloc (amt);
     2465  amt = max_lineno_count * bfd_coff_linesz (abfd);
     2466  finfo.linenos = (bfd_byte *) bfd_malloc (amt);
    25392467  finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
    25402468  finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
    25412469  if (! info->relocateable)
    2542     finfo.internal_relocs = ((struct internal_reloc *)
    2543                              bfd_malloc (max_reloc_count
    2544                                          * sizeof (struct internal_reloc)));
     2470    {
     2471      amt = max_reloc_count * sizeof (struct internal_reloc);
     2472      finfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
     2473    }
    25452474  if ((finfo.internal_syms == NULL && max_sym_count > 0)
    25462475      || (finfo.sec_ptrs == NULL && max_sym_count > 0)
     
    25852514                  if (! _bfd_coff_link_input_bfd (&finfo, sub))
    25862515                    goto error_return;
    2587                   sub->output_has_begun = true;
     2516                  sub->output_has_begun = TRUE;
    25882517                }
    25892518            }
     
    26102539          goto error_return;
    26112540      }
    2612     last_one->output_has_begun = true;
     2541    last_one->output_has_begun = TRUE;
    26132542  }
    26142543#endif
    26152544
    26162545  /* Free up the buffers used by _bfd_coff_link_input_bfd.  */
    2617 
    26182546  coff_debug_merge_hash_table_free (&finfo.debug_merge);
    2619   debug_merge_allocated = false;
     2547  debug_merge_allocated = FALSE;
    26202548
    26212549  if (finfo.internal_syms != NULL)
     
    26612589      && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
    26622590    {
     2591      file_ptr pos;
     2592
    26632593      finfo.last_file.n_value = obj_raw_syment_count (abfd);
    26642594      bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
    26652595                             (PTR) finfo.outsyms);
    2666       if (bfd_seek (abfd,
    2667                     (obj_sym_filepos (abfd)
    2668                      + finfo.last_file_index * symesz),
    2669                     SEEK_SET) != 0
    2670           || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
    2671         return false;
     2596      pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
     2597      if (bfd_seek (abfd, pos, SEEK_SET) != 0
     2598          || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
     2599        return FALSE;
    26722600    }
    26732601
    26742602  /* Write out the global symbols.  */
    2675   finfo.failed = false;
     2603  finfo.failed = FALSE;
    26762604  coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
    26772605                           (PTR) &finfo);
     
    26912619         the symbol indices to use for relocs against them, and we can
    26922620         finally write out the relocs.  */
    2693       external_relocs = ((bfd_byte *)
    2694                          bfd_malloc (max_output_reloc_count * relsz));
     2621      amt = max_output_reloc_count * relsz;
     2622      external_relocs = (bfd_byte *) bfd_malloc (amt);
    26952623      if (external_relocs == NULL)
    26962624        goto error_return;
     
    27202648            }
    27212649
     2650          amt = relsz * o->reloc_count;
    27222651          if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
    2723               || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
    2724                             abfd) != relsz * o->reloc_count)
     2652              || bfd_bwrite ((PTR) external_relocs, amt, abfd) != amt)
    27252653            goto error_return;
    27262654        }
     
    27502678    {
    27512679      if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
    2752         return false;
     2680        return FALSE;
    27532681    }
    27542682
     
    27562684  if (obj_raw_syment_count (abfd) != 0)
    27572685    {
    2758       if (bfd_seek (abfd,
    2759                     (obj_sym_filepos (abfd)
    2760                      + obj_raw_syment_count (abfd) * symesz),
    2761                     SEEK_SET) != 0)
    2762         return false;
     2686      file_ptr pos;
     2687
     2688      pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz;
     2689      if (bfd_seek (abfd, pos, SEEK_SET) != 0)
     2690        return FALSE;
    27632691
    27642692#if STRING_SIZE_SIZE == 4
    2765       bfd_h_put_32 (abfd,
    2766                     _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
    2767                     (bfd_byte *) strbuf);
     2693      H_PUT_32 (abfd,
     2694                _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
     2695                strbuf);
    27682696#else
    2769  #error Change bfd_h_put_32
     2697 #error Change H_PUT_32 above
    27702698#endif
    27712699
    2772       if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
    2773         return false;
     2700      if (bfd_bwrite (strbuf, (bfd_size_type) STRING_SIZE_SIZE, abfd)
     2701          != STRING_SIZE_SIZE)
     2702        return FALSE;
    27742703
    27752704      if (! _bfd_stringtab_emit (abfd, finfo.strtab))
    2776         return false;
     2705        return FALSE;
    27772706    }
    27782707
     
    27832712  bfd_get_symcount (abfd) = 0;
    27842713
    2785   return true;
     2714  return TRUE;
    27862715
    27872716 error_return:
     
    28212750  if (external_relocs != NULL)
    28222751    free (external_relocs);
    2823   return false;
     2752  return FALSE;
    28242753}
    28252754#endif
Note: See TracChangeset for help on using the changeset viewer.