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/elf32-arc.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* ARC-specific support for 32-bit ELF
    2    Copyright 1994, 1995, 1997, 1999, 2001 Free Software Foundation, Inc.
     2   Copyright 1994, 1995, 1997, 1999, 2001, 2002
     3   Free Software Foundation, Inc.
    34   Contributed by Doug Evans (dje@cygnus.com).
    45
     
    2425#include "elf-bfd.h"
    2526#include "elf/arc.h"
     27#include "libiberty.h"
    2628
    2729static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
    2830  PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
    2931static void arc_info_to_howto_rel
    30   PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
    31 static boolean arc_elf_object_p
     32  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
     33static bfd_boolean arc_elf_object_p
    3234  PARAMS ((bfd *));
    3335static void arc_elf_final_write_processing
    34   PARAMS ((bfd *, boolean));
     36  PARAMS ((bfd *, bfd_boolean));
     37static bfd_reloc_status_type arc_elf_b22_pcrel
     38  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
    3539
    3640/* Try to minimize the amount of space occupied by relocation tables
    3741   on the ROM (not that the ROM won't be swamped by other ELF overhead).  */
    3842
    39 #define USE_REL
     43#define USE_REL 1
    4044
    4145static reloc_howto_type elf_arc_howto_table[] =
     
    4650         2,                     /* size (0 = byte, 1 = short, 2 = long)  */
    4751         32,                    /* bitsize  */
    48          false,                 /* pc_relative  */
     52         FALSE,                 /* pc_relative  */
    4953         0,                     /* bitpos  */
    5054         complain_overflow_bitfield, /* complain_on_overflow  */
    5155         bfd_elf_generic_reloc, /* special_function  */
    5256         "R_ARC_NONE",          /* name  */
    53          false,                 /* partial_inplace  */
     57         TRUE,                  /* partial_inplace  */
    5458         0,                     /* src_mask  */
    5559         0,                     /* dst_mask  */
    56          false),                /* pcrel_offset  */
     60         FALSE),                /* pcrel_offset  */
    5761
    5862  /* A standard 32 bit relocation.  */
     
    6165         2,                     /* size (0 = byte, 1 = short, 2 = long)  */
    6266         32,                    /* bitsize  */
    63          false,                 /* pc_relative  */
     67         FALSE,                 /* pc_relative  */
    6468         0,                     /* bitpos  */
    6569         complain_overflow_bitfield, /* complain_on_overflow  */
    6670         bfd_elf_generic_reloc, /* special_function  */
    6771         "R_ARC_32",            /* name  */
    68          false,                 /* partial_inplace  */
     72         TRUE,                  /* partial_inplace  */
    6973         0xffffffff,            /* src_mask  */
    7074         0xffffffff,            /* dst_mask  */
    71          false),                /* pcrel_offset  */
     75         FALSE),                /* pcrel_offset  */
    7276
    7377  /* A 26 bit absolute branch, right shifted by 2.  */
     
    7680         2,                     /* size (0 = byte, 1 = short, 2 = long)  */
    7781         26,                    /* bitsize  */
    78          false,                 /* pc_relative  */
     82         FALSE,                 /* pc_relative  */
    7983         0,                     /* bitpos  */
    8084         complain_overflow_bitfield, /* complain_on_overflow  */
    8185         bfd_elf_generic_reloc, /* special_function  */
    8286         "R_ARC_B26",           /* name  */
    83          false,                 /* partial_inplace  */
     87         TRUE,                  /* partial_inplace  */
    8488         0x00ffffff,            /* src_mask  */
    8589         0x00ffffff,            /* dst_mask  */
    86          false),                /* pcrel_offset  */
     90         FALSE),                /* pcrel_offset  */
    8791
    8892  /* A relative 22 bit branch; bits 21-2 are stored in bits 26-7.  */
     
    9195         2,                     /* size (0 = byte, 1 = short, 2 = long)  */
    9296         22,                    /* bitsize  */
    93          true,                  /* pc_relative  */
     97         TRUE,                  /* pc_relative  */
    9498         7,                     /* bitpos  */
    9599         complain_overflow_signed, /* complain_on_overflow  */
    96          bfd_elf_generic_reloc, /* special_function  */
     100         arc_elf_b22_pcrel,     /* special_function  */
    97101         "R_ARC_B22_PCREL",     /* name  */
    98          false,                 /* partial_inplace  */
     102         TRUE,                  /* partial_inplace  */
    99103         0x07ffff80,            /* src_mask  */
    100104         0x07ffff80,            /* dst_mask  */
    101          true),                 /* pcrel_offset  */
    102 
     105         FALSE),                /* pcrel_offset  */
    103106};
    104107
     
    127130  unsigned int i;
    128131
    129   for (i = 0; i < sizeof (arc_reloc_map) / sizeof (struct arc_reloc_map); i++)
    130     {
    131       if (arc_reloc_map[i].bfd_reloc_val == code)
    132         return &elf_arc_howto_table[arc_reloc_map[i].elf_reloc_val];
    133     }
     132  for (i = ARRAY_SIZE (arc_reloc_map); i--;)
     133    if (arc_reloc_map[i].bfd_reloc_val == code)
     134      return elf_arc_howto_table + arc_reloc_map[i].elf_reloc_val;
     135
    134136  return NULL;
    135137}
     
    141143     bfd *abfd ATTRIBUTE_UNUSED;
    142144     arelent *cache_ptr;
    143      Elf32_Internal_Rel *dst;
     145     Elf_Internal_Rela *dst;
    144146{
    145147  unsigned int r_type;
     
    152154/* Set the right machine number for an ARC ELF file.  */
    153155
    154 static boolean
     156static bfd_boolean
    155157arc_elf_object_p (abfd)
    156158     bfd *abfd;
    157159{
    158   int mach = bfd_mach_arc_6;
     160  unsigned int mach = bfd_mach_arc_6;
    159161
    160162  if (elf_elfheader(abfd)->e_machine == EM_ARC)
     
    188190arc_elf_final_write_processing (abfd, linker)
    189191     bfd *abfd;
    190      boolean linker ATTRIBUTE_UNUSED;
     192     bfd_boolean linker ATTRIBUTE_UNUSED;
    191193{
    192194  unsigned long val;
     
    208210      break;
    209211    }
    210   elf_elfheader (abfd)->e_machine = EM_ARC;
    211212  elf_elfheader (abfd)->e_flags &=~ EF_ARC_MACH;
    212213  elf_elfheader (abfd)->e_flags |= val;
     214}
     215
     216bfd_reloc_status_type
     217arc_elf_b22_pcrel (abfd, reloc_entry, symbol, data, input_section,
     218                   output_bfd, error_message)
     219     bfd * abfd;
     220     arelent * reloc_entry;
     221     asymbol * symbol;
     222     PTR data;
     223     asection * input_section;
     224     bfd * output_bfd;
     225     char ** error_message;
     226{
     227  /* If linking, back up the final symbol address by the address of the
     228     reloc.  This cannot be accomplished by setting the pcrel_offset
     229     field to TRUE, as bfd_install_relocation will detect this and refuse
     230     to install the offset in the first place, but bfd_perform_relocation
     231     will still insist on removing it.  */
     232  if (output_bfd == (bfd *) NULL)
     233    reloc_entry->addend -= reloc_entry->address;
     234
     235  /* Fall through to the default elf reloc handler.  */
     236  return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
     237                                input_section, output_bfd, error_message);
    213238}
    214239
Note: See TracChangeset for help on using the changeset viewer.