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/pe-mips.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for MIPS PE COFF files.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000, 2001 Free Software Foundation, Inc.
     3   2000, 2001, 2002 Free Software Foundation, Inc.
    44   Modified from coff-i386.c by DJ Delorie, dj@cygnus.com
    55
     
    2222#define COFF_WITH_PE
    2323#define COFF_LONG_SECTION_NAMES
    24 #define PCRELOFFSET true
     24#define PCRELOFFSET TRUE
    2525
    2626#include "bfd.h"
     
    4141  PARAMS ((bfd *, asection *, struct internal_reloc *,
    4242           struct coff_link_hash_entry *, struct internal_syment *,
    43 
    4443           bfd_vma *));
    4544#if 0
    46 static void mips_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
    47                                               struct internal_reloc *));
    48 static void mips_ecoff_swap_reloc_out PARAMS ((bfd *,
    49                                                const struct internal_reloc *,
    50                                                PTR));
    51 static void mips_adjust_reloc_in PARAMS ((bfd *,
    52                                           const struct internal_reloc *,
    53                                           arelent *));
    54 static void mips_adjust_reloc_out PARAMS ((bfd *, const arelent *,
    55                                            struct internal_reloc *));
    56 #endif
     45static void mips_ecoff_swap_reloc_in
     46  PARAMS ((bfd *, PTR, struct internal_reloc *));
     47static void mips_ecoff_swap_reloc_out
     48  PARAMS ((bfd *, const struct internal_reloc *, PTR));
     49static void mips_adjust_reloc_in
     50  PARAMS ((bfd *, const struct internal_reloc *, arelent *));
     51static void mips_adjust_reloc_out
     52  PARAMS ((bfd *, const arelent *, struct internal_reloc *));
     53#endif
     54
     55static bfd_boolean in_reloc_p
     56  PARAMS ((bfd *, reloc_howto_type *));
     57static reloc_howto_type * coff_mips_reloc_type_lookup
     58  PARAMS ((bfd *, bfd_reloc_code_real_type));
     59static void mips_swap_reloc_in
     60  PARAMS ((bfd *, PTR, PTR));
     61static unsigned int mips_swap_reloc_out
     62  PARAMS ((bfd *, PTR, PTR));
     63static bfd_boolean coff_pe_mips_relocate_section
     64  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
     65           struct internal_reloc *, struct internal_syment *, asection **));
     66
    5767#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
    5868/* The page size is a guess based on ELF.  */
     
    145155              short x = bfd_get_16 (abfd, addr);
    146156              DOIT (x);
    147               bfd_put_16 (abfd, x, addr);
     157              bfd_put_16 (abfd, (bfd_vma) x, addr);
    148158            }
    149159            break;
     
    153163              long x = bfd_get_32 (abfd, addr);
    154164              DOIT (x);
    155               bfd_put_32 (abfd, x, addr);
     165              bfd_put_32 (abfd, (bfd_vma) x, addr);
    156166            }
    157167            break;
     
    167177
    168178#ifdef COFF_WITH_PE
    169 /* Return true if this relocation should
     179/* Return TRUE if this relocation should
    170180   appear in the output .reloc section.  */
    171181
    172 static boolean in_reloc_p(abfd, howto)
     182static bfd_boolean
     183in_reloc_p (abfd, howto)
    173184     bfd * abfd ATTRIBUTE_UNUSED;
    174185     reloc_howto_type *howto;
     
    179190
    180191#ifndef PCRELOFFSET
    181 #define PCRELOFFSET false
     192#define PCRELOFFSET FALSE
    182193#endif
    183194
     
    191202         0,                     /* size (0 = byte, 1 = short, 2 = long) */
    192203         8,                     /* bitsize */
    193          false,                 /* pc_relative */
     204         FALSE,                 /* pc_relative */
    194205         0,                     /* bitpos */
    195206         complain_overflow_dont, /* complain_on_overflow */
    196207         0,                     /* special_function */
    197208         "IGNORE",              /* name */
    198          false,                 /* partial_inplace */
     209         FALSE,                 /* partial_inplace */
    199210         0,                     /* src_mask */
    200211         0,                     /* dst_mask */
    201          false),                /* pcrel_offset */
     212         FALSE),                /* pcrel_offset */
    202213
    203214  /* A 16 bit reference to a symbol, normally from a data section.  */
     
    206217         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    207218         16,                    /* bitsize */
    208          false,                 /* pc_relative */
     219         FALSE,                 /* pc_relative */
    209220         0,                     /* bitpos */
    210221         complain_overflow_bitfield, /* complain_on_overflow */
    211222         coff_mips_reloc,       /* special_function */
    212223         "REFHALF",             /* name */
    213          true,                  /* partial_inplace */
     224         TRUE,                  /* partial_inplace */
    214225         0xffff,                /* src_mask */
    215226         0xffff,                /* dst_mask */
    216          false),                /* pcrel_offset */
     227         FALSE),                /* pcrel_offset */
    217228
    218229  /* A 32 bit reference to a symbol, normally from a data section.  */
     
    221232         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    222233         32,                    /* bitsize */
    223          false,                 /* pc_relative */
     234         FALSE,                 /* pc_relative */
    224235         0,                     /* bitpos */
    225236         complain_overflow_bitfield, /* complain_on_overflow */
    226237         coff_mips_reloc,       /* special_function */
    227238         "REFWORD",             /* name */
    228          true,                  /* partial_inplace */
     239         TRUE,                  /* partial_inplace */
    229240         0xffffffff,            /* src_mask */
    230241         0xffffffff,            /* dst_mask */
    231          false),                /* pcrel_offset */
     242         FALSE),                /* pcrel_offset */
    232243
    233244  /* A 26 bit absolute jump address.  */
     
    236247         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    237248         26,                    /* bitsize */
    238          false,                 /* pc_relative */
     249         FALSE,                 /* pc_relative */
    239250         0,                     /* bitpos */
    240251         complain_overflow_dont, /* complain_on_overflow */
     
    244255         coff_mips_reloc,       /* special_function */
    245256         "JMPADDR",             /* name */
    246          true,                  /* partial_inplace */
     257         TRUE,                  /* partial_inplace */
    247258         0x3ffffff,             /* src_mask */
    248259         0x3ffffff,             /* dst_mask */
    249          false),                /* pcrel_offset */
     260         FALSE),                /* pcrel_offset */
    250261
    251262  /* The high 16 bits of a symbol value.  Handled by the function
     
    255266         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    256267         16,                    /* bitsize */
    257          false,                 /* pc_relative */
     268         FALSE,                 /* pc_relative */
    258269         0,                     /* bitpos */
    259270         complain_overflow_bitfield, /* complain_on_overflow */
    260271         coff_mips_reloc,       /* special_function */
    261272         "REFHI",               /* name */
    262          true,                  /* partial_inplace */
     273         TRUE,                  /* partial_inplace */
    263274         0xffff,                /* src_mask */
    264275         0xffff,                /* dst_mask */
    265          false),                /* pcrel_offset */
     276         FALSE),                /* pcrel_offset */
    266277
    267278  /* The low 16 bits of a symbol value.  */
     
    270281         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    271282         16,                    /* bitsize */
    272          false,                 /* pc_relative */
     283         FALSE,                 /* pc_relative */
    273284         0,                     /* bitpos */
    274285         complain_overflow_dont, /* complain_on_overflow */
    275286         coff_mips_reloc,       /* special_function */
    276287         "REFLO",               /* name */
    277          true,                  /* partial_inplace */
     288         TRUE,                  /* partial_inplace */
    278289         0xffff,                /* src_mask */
    279290         0xffff,                /* dst_mask */
    280          false),                /* pcrel_offset */
     291         FALSE),                /* pcrel_offset */
    281292
    282293  /* A reference to an offset from the gp register.  Handled by the
     
    286297         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    287298         16,                    /* bitsize */
    288          false,                 /* pc_relative */
     299         FALSE,                 /* pc_relative */
    289300         0,                     /* bitpos */
    290301         complain_overflow_signed, /* complain_on_overflow */
    291302         coff_mips_reloc,       /* special_function */
    292303         "GPREL",               /* name */
    293          true,                  /* partial_inplace */
     304         TRUE,                  /* partial_inplace */
    294305         0xffff,                /* src_mask */
    295306         0xffff,                /* dst_mask */
    296          false),                /* pcrel_offset */
     307         FALSE),                /* pcrel_offset */
    297308
    298309  /* A reference to a literal using an offset from the gp register.
     
    302313         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    303314         16,                    /* bitsize */
    304          false,                 /* pc_relative */
     315         FALSE,                 /* pc_relative */
    305316         0,                     /* bitpos */
    306317         complain_overflow_signed, /* complain_on_overflow */
    307318         coff_mips_reloc,       /* special_function */
    308319         "LITERAL",             /* name */
    309          true,                  /* partial_inplace */
     320         TRUE,                  /* partial_inplace */
    310321         0xffff,                /* src_mask */
    311322         0xffff,                /* dst_mask */
    312          false),                /* pcrel_offset */
     323         FALSE),                /* pcrel_offset */
    313324
    314325  EMPTY_HOWTO (8),
     
    342353         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    343354         32,                    /* bitsize */
    344          false,                 /* pc_relative */
     355         FALSE,                 /* pc_relative */
    345356         0,                     /* bitpos */
    346357         complain_overflow_bitfield, /* complain_on_overflow */
    347358         coff_mips_reloc,       /* special_function */
    348359         "rva32",               /* name */
    349          true,                  /* partial_inplace */
     360         TRUE,                  /* partial_inplace */
    350361         0xffffffff,            /* src_mask */
    351362         0xffffffff,            /* dst_mask */
    352          false),                /* pcrel_offset */
     363         FALSE),                /* pcrel_offset */
    353364  EMPTY_HOWTO (35),
    354365  EMPTY_HOWTO (36),
     
    357368         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    358369         32,                    /* bitsize */
    359          false,                 /* pc_relative */
     370         FALSE,                 /* pc_relative */
    360371         0,                     /* bitpos */
    361372         complain_overflow_bitfield, /* complain_on_overflow */
    362373         coff_mips_reloc,       /* special_function */
    363374         "PAIR",                /* name */
    364          true,                  /* partial_inplace */
     375         TRUE,                  /* partial_inplace */
    365376         0xffffffff,            /* src_mask */
    366377         0xffffffff,            /* dst_mask */
    367          false),                /* pcrel_offset */
     378         FALSE),                /* pcrel_offset */
    368379};
    369380
     
    518529      mips_type = MIPS_R_REFLO;
    519530      break;
    520     case BFD_RELOC_MIPS_GPREL:
     531    case BFD_RELOC_GPREL16:
    521532      mips_type = MIPS_R_GPREL;
    522533      break;
     
    558569  struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
    559570
    560   reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
    561   reloc_dst->r_symndx =
    562     bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
    563   reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
     571  reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr);
     572  reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
     573  reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type);
    564574  reloc_dst->r_size = 0;
    565575  reloc_dst->r_extern = 0;
     
    605615             PAIR reloc and output it accordingly.  The symndx is really
    606616             the low 16 bits of the addend */
    607           bfd_h_put_32 (abfd, reloc_src->r_vaddr,
    608                         (bfd_byte *) reloc_dst->r_vaddr);
    609           bfd_h_put_32 (abfd, reloc_src->r_symndx,
    610                         (bfd_byte *) reloc_dst->r_symndx);
    611 
    612           bfd_h_put_16(abfd, MIPS_R_PAIR, (bfd_byte *)
    613                        reloc_dst->r_type);
     617          H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
     618          H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
     619          H_PUT_16 (abfd, MIPS_R_PAIR, reloc_dst->r_type);
    614620          return RELSZ;
    615621        }
     
    617623    }
    618624
    619   bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
    620   bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
    621 
    622   bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
    623                reloc_dst->r_type);
     625  H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
     626  H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
     627
     628  H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
    624629  return RELSZ;
    625630}
     
    629634#define NO_COFF_RELOCS
    630635
    631 static boolean
     636static bfd_boolean
    632637coff_pe_mips_relocate_section (output_bfd, info, input_bfd,
    633638                               input_section, contents, relocs, syms,
     
    643648{
    644649  bfd_vma gp;
    645   boolean gp_undefined;
     650  bfd_boolean gp_undefined;
    646651  size_t adjust;
    647652  struct internal_reloc *rel;
    648653  struct internal_reloc *rel_end;
    649654  unsigned int i;
    650   boolean got_lo;
     655  bfd_boolean got_lo;
    651656
    652657  if (info->relocateable)
     
    654659    (*_bfd_error_handler) (_("\
    655660%s: `ld -r' not supported with PE MIPS objects\n"),
    656                           bfd_get_filename (input_bfd));
     661                           bfd_archive_filename (input_bfd));
    657662    bfd_set_error (bfd_error_bad_value);
    658     return false;
     663    return FALSE;
    659664  }
    660665
     
    670675  gp = _bfd_get_gp_value (output_bfd);
    671676  if (gp == 0)
    672     gp_undefined = true;
     677    gp_undefined = TRUE;
    673678  else
    674     gp_undefined = false;
    675 
    676   got_lo = false;
     679    gp_undefined = FALSE;
     680
     681  got_lo = FALSE;
    677682
    678683  adjust = 0;
     
    716721                                       sym, &addend);
    717722      if (howto == NULL)
    718         return false;
     723        return FALSE;
    719724
    720725      /* If we are doing a relocateable link, then we can just ignore
     
    768773              if (! ((*info->callbacks->undefined_symbol)
    769774                     (info, h->root.root.string, input_bfd, input_section,
    770                       rel->r_vaddr - input_section->vma, true)))
    771                 return false;
     775                      rel->r_vaddr - input_section->vma, TRUE)))
     776                return FALSE;
    772777            }
    773778        }
     
    789794
    790795#define UI(x) (*_bfd_error_handler) (_("%s: unimplemented %s\n"), \
    791                                     bfd_get_filename (input_bfd), x); \
     796                                     bfd_archive_filename (input_bfd), x); \
    792797              bfd_set_error (bfd_error_bad_value);
    793798
     
    815820            {
    816821              (*_bfd_error_handler) (_("%s: jump too far away\n"),
    817                                     bfd_get_filename (input_bfd));
     822                                     bfd_archive_filename (input_bfd));
    818823              bfd_set_error (bfd_error_bad_value);
    819               return false;
     824              return FALSE;
    820825            }
    821826          tmp &= 0xfc000000;
     
    842847            default:
    843848              (*_bfd_error_handler) (_("%s: bad pair/reflo after refhi\n"),
    844                                     bfd_get_filename (input_bfd));
     849                                     bfd_archive_filename (input_bfd));
    845850              bfd_set_error (bfd_error_bad_value);
    846               return false;
     851              return FALSE;
    847852            }
    848853          tmp &= 0xffff0000;
     
    895900    }
    896901
    897   return true;
     902  return TRUE;
    898903}
    899904
     
    906911   we treat all symbols starting with L as local.  */
    907912
    908 static boolean coff_mips_is_local_label_name PARAMS ((bfd *, const char *));
    909 
    910 static boolean
     913static bfd_boolean coff_mips_is_local_label_name
     914   PARAMS ((bfd *, const char *));
     915
     916static bfd_boolean
    911917coff_mips_is_local_label_name (abfd, name)
    912918     bfd *abfd;
     
    914920{
    915921  if (name[0] == 'L')
    916     return true;
     922    return TRUE;
    917923
    918924  return _bfd_coff_is_local_label_name (abfd, name);
Note: See TracChangeset for help on using the changeset viewer.