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-h8300.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    1 /* BFD back-end for Hitachi H8/300 COFF binaries.
     1/* BFD back-end for Renesas H8/300 COFF binaries.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000
     3   2000, 2001, 2002, 2003
    44   Free Software Foundation, Inc.
    55   Written by Steve Chamberlain, <sac@cygnus.com>.
    66
    7 This file is part of BFD, the Binary File Descriptor library.
    8 
    9 This program is free software; you can redistribute it and/or modify
    10 it under the terms of the GNU General Public License as published by
    11 the Free Software Foundation; either version 2 of the License, or
    12 (at your option) any later version.
    13 
    14 This program is distributed in the hope that it will be useful,
    15 but WITHOUT ANY WARRANTY; without even the implied warranty of
    16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17 GNU General Public License for more details.
    18 
    19 You should have received a copy of the GNU General Public License
    20 along with this program; if not, write to the Free Software
    21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     7   This file is part of BFD, the Binary File Descriptor library.
     8
     9   This program is free software; you can redistribute it and/or modify
     10   it under the terms of the GNU General Public License as published by
     11   the Free Software Foundation; either version 2 of the License, or
     12   (at your option) any later version.
     13
     14   This program is distributed in the hope that it will be useful,
     15   but WITHOUT ANY WARRANTY; without even the implied warranty of
     16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17   GNU General Public License for more details.
     18
     19   You should have received a copy of the GNU General Public License
     20   along with this program; if not, write to the Free Software
     21   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2222
    2323#include "bfd.h"
     
    2929#include "coff/internal.h"
    3030#include "libcoff.h"
     31#include "libiberty.h"
    3132
    3233#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
     
    3940
    4041struct funcvec_hash_entry
    41 {
    42   /* The basic hash table entry.  */
    43   struct bfd_hash_entry root;
    44 
    45   /* The offset within the vectors section where
    46      this entry lives.  */
    47   bfd_vma offset;
    48 };
     42  {
     43    /* The basic hash table entry.  */
     44    struct bfd_hash_entry root;
     45
     46    /* The offset within the vectors section where
     47       this entry lives.  */
     48    bfd_vma offset;
     49  };
    4950
    5051struct funcvec_hash_table
    51 {
    52   /* The basic hash table.  */
    53   struct bfd_hash_table root;
    54 
    55   bfd *abfd;
    56 
    57   /* Offset at which we'll add the next entry.  */
    58   unsigned int offset;
    59 };
     52  {
     53    /* The basic hash table.  */
     54    struct bfd_hash_table root;
     55
     56    bfd *abfd;
     57
     58    /* Offset at which we'll add the next entry.  */
     59    unsigned int offset;
     60  };
    6061
    6162static struct bfd_hash_entry *
     
    6364  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
    6465
    65 static boolean
     66static bfd_boolean
    6667funcvec_hash_table_init
    6768  PARAMS ((struct funcvec_hash_table *, bfd *,
    68            struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *,
    69                                                struct bfd_hash_table *,
    70                                                const char *))));
     69           struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
     70                                       struct bfd_hash_table *,
     71                                       const char *)));
     72
     73static bfd_reloc_status_type special
     74  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
     75static int select_reloc
     76  PARAMS ((reloc_howto_type *));
     77static void rtype2howto
     78  PARAMS ((arelent *, struct internal_reloc *));
     79static void reloc_processing
     80  PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
     81static bfd_boolean h8300_symbol_address_p
     82  PARAMS ((bfd *, asection *, bfd_vma));
     83static int h8300_reloc16_estimate
     84  PARAMS ((bfd *, asection *, arelent *, unsigned int,
     85    struct bfd_link_info *));
     86static void h8300_reloc16_extra_cases
     87  PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
     88    bfd_byte *, unsigned int *, unsigned int *));
     89static bfd_boolean h8300_bfd_link_add_symbols
     90  PARAMS ((bfd *, struct bfd_link_info *));
    7191
    7292/* To lookup a value in the function vector hash table.  */
     
    7999   table!  We use this to attach additional data structures we
    80100   need while linking on the h8300.  */
    81 struct h8300_coff_link_hash_table
    82 {
     101struct h8300_coff_link_hash_table {
    83102  /* The main hash table.  */
    84103  struct generic_link_hash_table root;
     
    120139  if (ret == NULL)
    121140    ret = ((struct funcvec_hash_entry *)
    122            bfd_hash_allocate (gen_table,
    123                               sizeof (struct funcvec_hash_entry)));
     141           bfd_hash_allocate (gen_table,
     142                              sizeof (struct funcvec_hash_entry)));
    124143  if (ret == NULL)
    125144    return NULL;
     
    127146  /* Call the allocation method of the superclass.  */
    128147  ret = ((struct funcvec_hash_entry *)
    129         bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string));
     148        bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string));
    130149
    131150  if (ret == NULL)
     
    152171/* Initialize the function vector hash table.  */
    153172
    154 static boolean
     173static bfd_boolean
    155174funcvec_hash_table_init (table, abfd, newfunc)
    156175     struct funcvec_hash_table *table;
    157176     bfd *abfd;
    158      struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
    159                                                struct bfd_hash_table *,
    160                                                 const char *));
     177     struct bfd_hash_entry *(*newfunc)
     178       PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
     179                const char *));
    161180{
    162181  /* Initialize our local fields, then call the generic initialization
     
    168187
    169188/* Create the derived linker hash table.  We use a derived hash table
    170    basically to hold "static" information during an h8/300 coff link
     189   basically to hold "static" information during an H8/300 coff link
    171190   without using static variables.  */
    172191
     
    176195{
    177196  struct h8300_coff_link_hash_table *ret;
    178   ret = ((struct h8300_coff_link_hash_table *)
    179          bfd_alloc (abfd, sizeof (struct h8300_coff_link_hash_table)));
     197  bfd_size_type amt = sizeof (struct h8300_coff_link_hash_table);
     198
     199  ret = (struct h8300_coff_link_hash_table *) bfd_malloc (amt);
    180200  if (ret == NULL)
    181201    return NULL;
    182   if (!_bfd_link_hash_table_init (&ret->root.root, abfd, _bfd_generic_link_hash_newfunc))
     202  if (!_bfd_link_hash_table_init (&ret->root.root, abfd,
     203                                  _bfd_generic_link_hash_newfunc))
    183204    {
    184       bfd_release (abfd, ret);
     205      free (ret);
    185206      return NULL;
    186207    }
     
    190211  ret->funcvec_hash_table = NULL;
    191212
    192   /* OK.  Everything's intialized, return the base pointer.  */
     213  /* OK.  Everything's initialized, return the base pointer.  */
    193214  return &ret->root.root;
    194215}
     
    222243}
    223244
    224 static reloc_howto_type howto_table[] =
    225 {
    226   HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
    227   HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
    228   HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
    229   HOWTO (R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8", false, 0x000000ff, 0x000000ff, true),
    230   HOWTO (R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, special, "DISP16", false, 0x0000ffff, 0x0000ffff, true),
    231   HOWTO (R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, special, "DISP32", false, 0xffffffff, 0xffffffff, true),
    232   HOWTO (R_MOV16B1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "relaxable mov.b:16", false, 0x0000ffff, 0x0000ffff, false),
    233   HOWTO (R_MOV16B2, 0, 1, 8, false, 0, complain_overflow_bitfield, special, "relaxed mov.b:16", false, 0x000000ff, 0x000000ff, false),
    234   HOWTO (R_JMP1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/pcrel", false, 0x0000ffff, 0x0000ffff, false),
    235   HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pcrecl/16", false, 0x000000ff, 0x000000ff, false),
    236   HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "24/pcrell", false, 0x00ffffff, 0x00ffffff, false),
    237   HOWTO (R_JMPL2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pc8/24", false, 0x000000ff, 0x000000ff, false),
    238   HOWTO (R_MOV24B1, 0, 1, 32, false, 0, complain_overflow_bitfield, special, "relaxable mov.b:24", false, 0xffffffff, 0xffffffff, false),
    239   HOWTO (R_MOV24B2, 0, 1, 8, false, 0, complain_overflow_bitfield, special, "relaxed mov.b:24", false, 0x0000ffff, 0x0000ffff, false),
     245static reloc_howto_type howto_table[] = {
     246  HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "8", FALSE, 0x000000ff, 0x000000ff, FALSE),
     247  HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16", FALSE, 0x0000ffff, 0x0000ffff, FALSE),
     248  HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, special, "32", FALSE, 0xffffffff, 0xffffffff, FALSE),
     249  HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "DISP8", FALSE, 0x000000ff, 0x000000ff, TRUE),
     250  HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, special, "DISP16", FALSE, 0x0000ffff, 0x0000ffff, TRUE),
     251  HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, special, "DISP32", FALSE, 0xffffffff, 0xffffffff, TRUE),
     252  HOWTO (R_MOV16B1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "relaxable mov.b:16", FALSE, 0x0000ffff, 0x0000ffff, FALSE),
     253  HOWTO (R_MOV16B2, 0, 1, 8, FALSE, 0, complain_overflow_bitfield, special, "relaxed mov.b:16", FALSE, 0x000000ff, 0x000000ff, FALSE),
     254  HOWTO (R_JMP1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16/pcrel", FALSE, 0x0000ffff, 0x0000ffff, FALSE),
     255  HOWTO (R_JMP2, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "pcrecl/16", FALSE, 0x000000ff, 0x000000ff, FALSE),
     256  HOWTO (R_JMPL1, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, special, "24/pcrell", FALSE, 0x00ffffff, 0x00ffffff, FALSE),
     257  HOWTO (R_JMPL2, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "pc8/24", FALSE, 0x000000ff, 0x000000ff, FALSE),
     258  HOWTO (R_MOV24B1, 0, 1, 32, FALSE, 0, complain_overflow_bitfield, special, "relaxable mov.b:24", FALSE, 0xffffffff, 0xffffffff, FALSE),
     259  HOWTO (R_MOV24B2, 0, 1, 8, FALSE, 0, complain_overflow_bitfield, special, "relaxed mov.b:24", FALSE, 0x0000ffff, 0x0000ffff, FALSE),
    240260
    241261  /* An indirect reference to a function.  This causes the function's address
    242262     to be added to the function vector in lo-mem and puts the address of
    243263     the function vector's entry in the jsr instruction.  */
    244   HOWTO (R_MEM_INDIRECT, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8/indirect", false, 0x000000ff, 0x000000ff, false),
     264  HOWTO (R_MEM_INDIRECT, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "8/indirect", FALSE, 0x000000ff, 0x000000ff, FALSE),
    245265
    246266  /* Internal reloc for relaxing.  This is created when a 16bit pc-relative
    247267     branch is turned into an 8bit pc-relative branch.  */
    248   HOWTO (R_PCRWORD_B, 0, 0, 8, true, 0, complain_overflow_bitfield, special, "relaxed bCC:16", false, 0x000000ff, 0x000000ff, false),
    249 
    250   HOWTO (R_MOVL1, 0, 2, 32, false, 0, complain_overflow_bitfield,special, "32/24 relaxable move", false, 0xffffffff, 0xffffffff, false),
    251 
    252   HOWTO (R_MOVL2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "32/24 relaxed move", false, 0x0000ffff, 0x0000ffff, false),
    253 
    254   HOWTO (R_BCC_INV, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8 inverted", false, 0x000000ff, 0x000000ff, true),
    255 
    256   HOWTO (R_JMP_DEL, 0, 0, 8, true, 0, complain_overflow_signed, special, "Deleted jump", false, 0x000000ff, 0x000000ff, true),
     268  HOWTO (R_PCRWORD_B, 0, 0, 8, TRUE, 0, complain_overflow_bitfield, special, "relaxed bCC:16", FALSE, 0x000000ff, 0x000000ff, FALSE),
     269
     270  HOWTO (R_MOVL1, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,special, "32/24 relaxable move", FALSE, 0xffffffff, 0xffffffff, FALSE),
     271
     272  HOWTO (R_MOVL2, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "32/24 relaxed move", FALSE, 0x0000ffff, 0x0000ffff, FALSE),
     273
     274  HOWTO (R_BCC_INV, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "DISP8 inverted", FALSE, 0x000000ff, 0x000000ff, TRUE),
     275
     276  HOWTO (R_JMP_DEL, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "Deleted jump", FALSE, 0x000000ff, 0x000000ff, TRUE),
    257277};
    258278
     
    260280
    261281#define SELECT_RELOC(x,howto) \
    262   { x.r_type = select_reloc(howto); }
    263 
    264 #define BADMAG(x) (H8300BADMAG(x) && H8300HBADMAG(x) && H8300SBADMAG(x))
    265 #define H8300 1                 /* Customize coffcode.h */
     282  { x.r_type = select_reloc (howto); }
     283
     284#define BADMAG(x) (H8300BADMAG (x) && H8300HBADMAG (x) && H8300SBADMAG (x) \
     285                                   && H8300HNBADMAG(x) && H8300SNBADMAG(x))
     286#define H8300 1                 /* Customize coffcode.h  */
    266287#define __A_MAGIC_SET__
    267288
    268289/* Code to swap in the reloc.  */
    269 #define SWAP_IN_RELOC_OFFSET   bfd_h_get_32
    270 #define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
     290#define SWAP_IN_RELOC_OFFSET    H_GET_32
     291#define SWAP_OUT_RELOC_OFFSET   H_PUT_32
    271292#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
    272293  dst->r_stuff[0] = 'S'; \
     
    355376}
    356377
    357 #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
     378#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
    358379
    359380/* Perform any necessary magic to the addend in a reloc entry.  */
    360381
    361382#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
    362  cache_ptr->addend =  ext_reloc.r_offset;
     383 cache_ptr->addend = ext_reloc.r_offset;
    363384
    364385#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
    365  reloc_processing(relent, reloc, symbols, abfd, section)
     386 reloc_processing (relent, reloc, symbols, abfd, section)
    366387
    367388static void
     
    377398
    378399  if (((int) reloc->r_symndx) > 0)
    379     {
    380       relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
    381     }
     400    relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
    382401  else
    383     {
    384       relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
    385     }
     402    relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
    386403
    387404  relent->addend = reloc->r_offset;
     
    393410}
    394411
    395 static boolean
     412static bfd_boolean
    396413h8300_symbol_address_p (abfd, input_section, address)
    397414     bfd *abfd;
     
    409426    {
    410427      asymbol *p = *s;
     428
    411429      if (p->section == input_section
    412430          && (input_section->output_section->vma
    413431              + input_section->output_offset
    414432              + p->value) == address)
    415         return true;
     433        return TRUE;
    416434      s++;
    417435    }
    418   return false;
     436  return FALSE;
    419437}
    420438
     
    453471  switch (reloc->howto->type)
    454472    {
    455     /* This is the 16/24 bit absolute branch which could become an 8 bit
    456       pc-relative branch.  */
     473      /* This is the 16/24 bit absolute branch which could become an 8 bit
     474        pc-relative branch.  */
    457475    case R_JMP1:
    458476    case R_JMPL1:
     
    473491         this jump.  +128 is valid since the target will move two bytes
    474492         closer if we do relax this branch.  */
    475       if ((int)gap >= -128 && (int)gap <= 128 )
    476         {
     493      if ((int) gap >= -128 && (int) gap <= 128)
     494        {
     495          bfd_byte code;
     496
     497          if (!bfd_get_section_contents (abfd, input_section, & code,
     498                                         reloc->address, 1))
     499            break;
     500          code = bfd_get_8 (abfd, & code);
     501
    477502          /* It's possible we may be able to eliminate this branch entirely;
    478503             if the previous instruction is a branch around this instruction,
     
    486511
    487512             This saves 4 bytes instead of two, and should be relatively
    488              common.  */
    489 
    490           if (gap <= 126
     513             common.
     514
     515             Only perform this optimisation for jumps (code 0x5a) not
     516             subroutine calls, as otherwise it could transform:
     517
     518                             mov.w   r0,r0
     519                             beq     .L1
     520                             jsr     @_bar
     521                      .L1:   rts
     522                      _bar:  rts
     523             into:
     524                             mov.w   r0,r0
     525                             bne     _bar
     526                             rts
     527                      _bar:  rts
     528
     529             which changes the call (jsr) into a branch (bne).  */
     530          if (code == 0x5a
     531              && gap <= 126
    491532              && last_reloc
    492533              && last_reloc->howto->type == R_PCRBYTE)
     
    523564    case R_PCRWORD:
    524565      /* Get the address of the target of this branch, add one to the value
    525         because the addend field in PCrel jumps is off by -1.  */
     566        because the addend field in PCrel jumps is off by -1.  */
    526567      value = bfd_coff_reloc16_get_value (reloc, link_info, input_section) + 1;
    527568
     
    536577         this jump.  +128 is valid since the target will move two bytes
    537578         closer if we do relax this branch.  */
    538       if ((int)gap >= -128 && (int)gap <= 128 )
     579      if ((int) gap >= -128 && (int) gap <= 128)
    539580        {
    540581          /* Change the reloc type.  */
     
    608649
    609650      /* If this address is in 0x0000..0x7fff inclusive or
    610         0xff8000..0xffffff inclusive, then it can be relaxed.  */
     651        0xff8000..0xffffff inclusive, then it can be relaxed.  */
    611652      if (value <= 0x7fff || value >= 0xff8000)
    612653        {
     
    678719      /* Everything looks OK.  Apply the relocation and update the
    679720         src/dst address appropriately.  */
    680 
    681721      bfd_put_8 (abfd, gap, data + dst_address);
    682722      dst_address++;
     
    710750      /* Everything looks OK.  Apply the relocation and update the
    711751         src/dst address appropriately.  */
    712 
    713       bfd_put_16 (abfd, gap, data + dst_address);
     752      bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
    714753      dst_address += 2;
    715754      src_address += 2;
     
    726765      if (value <= 0xff
    727766          || (value >= 0x0000ff00 && value <= 0x0000ffff)
    728           || (value >= 0x00ffff00 && value <= 0x00ffffff)
     767          || (value >= 0x00ffff00 && value <= 0x00ffffff)
    729768          || (value >= 0xffffff00 && value <= 0xffffffff))
    730769        {
    731770          /* Everything looks OK.  Apply the relocation and update the
    732771             src/dst address appropriately.  */
    733 
    734772          bfd_put_8 (abfd, value & 0xff, data + dst_address);
    735773          dst_address += 1;
     
    794832          /* Fix the opcode.  For all the move insns, we simply
    795833             need to turn off bit 0x20 in the previous byte.  */
    796           data[dst_address - 1] &= ~0x20;
     834          data[dst_address - 1] &= ~0x20;
    797835          dst_address += 2;
    798836          src_address += 4;
     
    805843                  input_section, reloc->address)))
    806844            abort ();
    807         }
     845        }
    808846      break;
    809847
     
    902940        }
    903941
    904         /* Output the target.  */
    905         bfd_put_8 (abfd, gap, data + dst_address - 1);
    906 
    907         /* We don't advance dst_address -- the 8bit reloc is applied at
    908            dst_address - 1, so the next insn should begin at dst_address.  */
    909         src_address += 2;
    910 
    911         break;
     942      /* Output the target.  */
     943      bfd_put_8 (abfd, gap, data + dst_address - 1);
     944
     945      /* We don't advance dst_address -- the 8bit reloc is applied at
     946         dst_address - 1, so the next insn should begin at dst_address.  */
     947      src_address += 2;
     948
     949      break;
    912950
    913951    /* Similarly for a 24bit absolute that is now 8 bits.  */
     
    10471085           address in the function vector table.  */
    10481086        asymbol *symbol;
    1049         bfd_vma value;
    10501087        const char *name;
     1088        struct funcvec_hash_table *ftab;
    10511089        struct funcvec_hash_entry *h;
    1052         asection *vectors_sec = h8300_coff_hash_table (link_info)->vectors_sec;
     1090        struct h8300_coff_link_hash_table *htab;
     1091        asection *vectors_sec;
     1092
     1093        if (link_info->hash->creator != abfd->xvec)
     1094          {
     1095            (*_bfd_error_handler)
     1096              (_("cannot handle R_MEM_INDIRECT reloc when using %s output"),
     1097               link_info->hash->creator->name);
     1098
     1099            /* What else can we do?  This function doesn't allow return
     1100               of an error, and we don't want to call abort as that
     1101               indicates an internal error.  */
     1102#ifndef EXIT_FAILURE
     1103#define EXIT_FAILURE 1
     1104#endif
     1105            xexit (EXIT_FAILURE);
     1106          }
     1107        htab = h8300_coff_hash_table (link_info);
     1108        vectors_sec = htab->vectors_sec;
    10531109
    10541110        /* First see if this is a reloc against the absolute symbol
     
    10891145        if (symbol->flags & BSF_LOCAL)
    10901146          {
    1091             char *new_name = bfd_malloc (strlen (name) + 9);
     1147            char *new_name = bfd_malloc ((bfd_size_type) strlen (name) + 9);
    10921148            if (new_name == NULL)
    10931149              abort ();
     
    10991155          }
    11001156
    1101         h = funcvec_hash_lookup (h8300_coff_hash_table (link_info)->funcvec_hash_table,
    1102                                  name, false, false);
     1157        ftab = htab->funcvec_hash_table;
     1158        h = funcvec_hash_lookup (ftab, name, FALSE, FALSE);
    11031159
    11041160        /* This shouldn't ever happen.  If it does that means we've got
    11051161           data corruption of some kind.  Aborting seems like a reasonable
    1106            think to do here.  */
     1162           thing to do here.  */
    11071163        if (h == NULL || vectors_sec == NULL)
    11081164          abort ();
     
    11391195                                  vectors_sec->output_section,
    11401196                                  vectors_sec->contents,
    1141                                   vectors_sec->output_offset,
     1197                                  (file_ptr) vectors_sec->output_offset,
    11421198                                  vectors_sec->_raw_size);
    11431199        break;
     
    11651221   selected static symbols to the bfd linker hash table.  */
    11661222
    1167 static boolean
     1223static bfd_boolean
    11681224h8300_bfd_link_add_symbols (abfd, info)
    11691225     bfd *abfd;
     
    11721228  asection *sec;
    11731229  struct funcvec_hash_table *funcvec_hash_table;
     1230  bfd_size_type amt;
     1231  struct h8300_coff_link_hash_table *htab;
     1232
     1233  /* Add the symbols using the generic code.  */
     1234  _bfd_generic_link_add_symbols (abfd, info);
     1235
     1236  if (info->hash->creator != abfd->xvec)
     1237    return TRUE;
     1238
     1239  htab = h8300_coff_hash_table (info);
    11741240
    11751241  /* If we haven't created a vectors section, do so now.  */
    1176   if (!h8300_coff_hash_table (info)->vectors_sec)
     1242  if (!htab->vectors_sec)
    11771243    {
    11781244      flagword flags;
     
    11811247      flags = (SEC_ALLOC | SEC_LOAD
    11821248               | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_READONLY);
    1183       h8300_coff_hash_table (info)->vectors_sec = bfd_make_section (abfd,
    1184                                                                     ".vectors");
     1249      htab->vectors_sec = bfd_make_section (abfd, ".vectors");
    11851250
    11861251      /* If the section wasn't created, or we couldn't set the flags,
    1187          quit quickly now, rather than dieing a painful death later.  */
    1188       if (! h8300_coff_hash_table (info)->vectors_sec
    1189           || ! bfd_set_section_flags (abfd,
    1190                                       h8300_coff_hash_table(info)->vectors_sec,
    1191                                       flags))
    1192         return false;
     1252         quit quickly now, rather than dying a painful death later.  */
     1253      if (!htab->vectors_sec
     1254          || !bfd_set_section_flags (abfd, htab->vectors_sec, flags))
     1255        return FALSE;
    11931256
    11941257      /* Also create the vector hash table.  */
    1195       funcvec_hash_table = ((struct funcvec_hash_table *)
    1196         bfd_alloc (abfd, sizeof (struct funcvec_hash_table)));
     1258      amt = sizeof (struct funcvec_hash_table);
     1259      funcvec_hash_table = (struct funcvec_hash_table *) bfd_alloc (abfd, amt);
    11971260
    11981261      if (!funcvec_hash_table)
    1199         return false;
     1262        return FALSE;
    12001263
    12011264      /* And initialize the funcvec hash table.  */
     
    12041267        {
    12051268          bfd_release (abfd, funcvec_hash_table);
    1206           return false;
     1269          return FALSE;
    12071270        }
    12081271
    12091272      /* Store away a pointer to the funcvec hash table.  */
    1210       h8300_coff_hash_table (info)->funcvec_hash_table = funcvec_hash_table;
     1273      htab->funcvec_hash_table = funcvec_hash_table;
    12111274    }
    12121275
    12131276  /* Load up the function vector hash table.  */
    1214   funcvec_hash_table = h8300_coff_hash_table (info)->funcvec_hash_table;
    1215 
    1216   /* Add the symbols using the generic code.  */
    1217   _bfd_generic_link_add_symbols (abfd, info);
     1277  funcvec_hash_table = htab->funcvec_hash_table;
    12181278
    12191279  /* Now scan the relocs for all the sections in this bfd; create
     
    12301290        continue;
    12311291
    1232       relocs = (arelent **) bfd_malloc ((size_t) reloc_size);
     1292      relocs = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
    12331293      if (!relocs)
    1234         return false;
     1294        return FALSE;
    12351295
    12361296      /* The symbols should have been read in by _bfd_generic link_add_symbols
     
    12611321
    12621322            {
     1323              struct funcvec_hash_table *ftab;
    12631324              struct funcvec_hash_entry *h;
    12641325
     
    12661327              if (symbol->flags & BSF_LOCAL)
    12671328                {
    1268                   char *new_name = bfd_malloc (strlen (name) + 9);
    1269 
     1329                  char *new_name;
     1330
     1331                  new_name = bfd_malloc ((bfd_size_type) strlen (name) + 9);
    12701332                  if (new_name == NULL)
    12711333                    abort ();
     
    12781340
    12791341              /* Look this symbol up in the function vector hash table.  */
    1280               h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table,
    1281                                        name, false, false);
     1342              ftab = htab->funcvec_hash_table;
     1343              h = funcvec_hash_lookup (ftab, name, FALSE, FALSE);
    12821344
    12831345              /* If this symbol isn't already in the hash table, add
     
    12851347              if (h == NULL)
    12861348                {
    1287                   h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table,
    1288                                            name, true, true);
     1349                  h = funcvec_hash_lookup (ftab, name, TRUE, TRUE);
    12891350                  if (h == NULL)
    12901351                    {
    12911352                      free (relocs);
    1292                       return false;
     1353                      return FALSE;
    12931354                    }
    12941355
     
    12961357                     takes 2 bytes on the h8300 and 4 bytes on the h8300h.  */
    12971358                  if (bfd_get_mach (abfd) == bfd_mach_h8300)
    1298                     h8300_coff_hash_table (info)->vectors_sec->_raw_size += 2;
     1359                    htab->vectors_sec->_raw_size += 2;
    12991360                  else if (bfd_get_mach (abfd) == bfd_mach_h8300h
    13001361                           || bfd_get_mach (abfd) == bfd_mach_h8300s)
    1301                     h8300_coff_hash_table (info)->vectors_sec->_raw_size += 4;
     1362                    htab->vectors_sec->_raw_size += 4;
    13021363                }
    13031364            }
     
    13101371  /* Now actually allocate some space for the function vector.  It's
    13111372     wasteful to do this more than once, but this is easier.  */
    1312   if (h8300_coff_hash_table (info)->vectors_sec->_raw_size != 0)
     1373  sec = htab->vectors_sec;
     1374  if (sec->_raw_size != 0)
    13131375    {
    13141376      /* Free the old contents.  */
    1315       if (h8300_coff_hash_table (info)->vectors_sec->contents)
    1316         free (h8300_coff_hash_table (info)->vectors_sec->contents);
     1377      if (sec->contents)
     1378        free (sec->contents);
    13171379
    13181380      /* Allocate new contents.  */
    1319       h8300_coff_hash_table (info)->vectors_sec->contents
    1320         = bfd_malloc (h8300_coff_hash_table (info)->vectors_sec->_raw_size);
     1381      sec->contents = bfd_malloc (sec->_raw_size);
    13211382    }
    13221383
    1323   return true;
     1384  return TRUE;
    13241385}
    13251386
Note: See TracChangeset for help on using the changeset viewer.