Back to index

cell-binutils  2.17cvs20070401
Defines | Functions | Variables
coff-i860.c File Reference
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "coff/i860.h"
#include "coff/internal.h"
#include "libcoff.h"
#include "coffcode.h"

Go to the source code of this file.


#define COFF_PAGE_SIZE   0x1000
#define DOIT(x)   x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
#define SELECT_RELOC(x, howto)   { x.r_type = howto->type; }
#define BADMAG(x)   I860BADMAG(x)
#define I860   1 /* Customize coffcode.h */
#define RTYPE2HOWTO(cache_ptr, dst)
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr)
#define coff_relocate_section   _bfd_coff_generic_relocate_section
#define coff_rtype_to_howto   coff_i860_rtype_to_howto
#define coff_bfd_reloc_type_lookup   coff_i860_reloc_type_lookup
#define coff_bfd_reloc_name_lookup   coff_i860_reloc_name_lookup
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section)   i860_reloc_processing (relent, reloc, symbols, abfd, section)


static bfd_reloc_status_type coff_i860_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data, asection *input_section ATTRIBUTE_UNUSED, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
static bfd_reloc_status_type coff_i860_reloc_nyi (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry, asymbol *symbol ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED, asection *input_section ATTRIBUTE_UNUSED, bfd *output_bfd ATTRIBUTE_UNUSED, char **error_message ATTRIBUTE_UNUSED)
static reloc_howto_type * coff_i860_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, struct internal_reloc *rel, struct coff_link_hash_entry *h, struct internal_syment *sym, bfd_vma *addendp)
static reloc_howto_type * coff_i860_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
static reloc_howto_type * coff_i860_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
static void i860_reloc_processing (arelent *cache_ptr, struct internal_reloc *dst, asymbol **symbols, bfd *abfd, asection *asect)
static const bfd_targeti3coff_object_p (bfd *a)


static reloc_howto_type howto_table []
const bfd_target i860coff_vec

Define Documentation

#define BADMAG (   x)    I860BADMAG(x)

Definition at line 439 of file coff-i860.c.

Definition at line 451 of file coff-i860.c.

#define CALC_ADDEND (   abfd,

Definition at line 466 of file coff-i860.c.

Definition at line 637 of file coff-i860.c.

Definition at line 636 of file coff-i860.c.

Definition at line 34 of file coff-i860.c.

#define COFF_PAGE_SIZE   0x1000

Definition at line 37 of file coff-i860.c.

Definition at line 469 of file coff-i860.c.

Definition at line 635 of file coff-i860.c.

#define DOIT (   x)    x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
#define I860   1 /* Customize coffcode.h */

Definition at line 440 of file coff-i860.c.


Definition at line 147 of file coff-i860.c.

#define RELOC_PROCESSING (   relent,
)    i860_reloc_processing (relent, reloc, symbols, abfd, section)

Definition at line 639 of file coff-i860.c.

#define RTYPE2HOWTO (   cache_ptr,
((cache_ptr)->howto =                                                 \
   ((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0])    \
    ? howto_table + (dst)->r_type                              \
    : NULL))

Definition at line 442 of file coff-i860.c.

#define SELECT_RELOC (   x,
)    { x.r_type = howto->type; }

Definition at line 438 of file coff-i860.c.

Function Documentation

static bfd_reloc_status_type coff_i860_reloc ( bfd abfd,
arelent reloc_entry,
asymbol symbol,
void *  data,
asection *input_section  ATTRIBUTE_UNUSED,
bfd output_bfd,
char **error_message  ATTRIBUTE_UNUSED 
) [static]

Definition at line 49 of file coff-i860.c.

  symvalue diff;

  if (output_bfd == (bfd *) NULL)
    return bfd_reloc_continue;

  if (bfd_is_com_section (symbol->section))
      /* We are relocating a common symbol.  The current value in the
        object file is ORIG + OFFSET, where ORIG is the value of the
        common symbol as seen by the object file when it was compiled
        (this may be zero if the symbol was undefined) and OFFSET is
        the offset into the common symbol (normally zero, but may be
        non-zero when referring to a field in a common structure).
        ORIG is the negative of reloc_entry->addend, which is set by
        the CALC_ADDEND macro below.  We want to replace the value in
        the object file with NEW + OFFSET, where NEW is the value of
        the common symbol which we are going to put in the final
        object file.  NEW is symbol->value.  */
      diff = symbol->value + reloc_entry->addend;
      /* For some reason bfd_perform_relocation always effectively
        ignores the addend for a COFF target when producing
        relocatable output.  This seems to be always wrong for 860
        COFF, so we handle the addend here instead.  */
      diff = reloc_entry->addend;

#define DOIT(x) \
  x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))

    if (diff != 0)
       reloc_howto_type *howto = reloc_entry->howto;
       unsigned char *addr = (unsigned char *) data + reloc_entry->address;

       switch (howto->size)
         case 0:
             char x = bfd_get_8 (abfd, addr);
             DOIT (x);
             bfd_put_8 (abfd, x, addr);

         case 1:
             short x = bfd_get_16 (abfd, addr);
             DOIT (x);
             bfd_put_16 (abfd, (bfd_vma) x, addr);

         case 2:
             long x = bfd_get_32 (abfd, addr);
             DOIT (x);
             bfd_put_32 (abfd, (bfd_vma) x, addr);

           abort ();

  /* Now let bfd_perform_relocation finish everything up.  */
  return bfd_reloc_continue;
static reloc_howto_type* coff_i860_reloc_name_lookup ( bfd *abfd  ATTRIBUTE_UNUSED,
const char *  r_name 
) [static]

Definition at line 559 of file coff-i860.c.

  unsigned int i;

  for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++)
    if (howto_table[i].name != NULL
       && strcasecmp (howto_table[i].name, r_name) == 0)
      return &howto_table[i];

  return NULL;

Here is the call graph for this function:

static bfd_reloc_status_type coff_i860_reloc_nyi ( bfd *abfd  ATTRIBUTE_UNUSED,
arelent reloc_entry,
asymbol *symbol  ATTRIBUTE_UNUSED,
asection *input_section  ATTRIBUTE_UNUSED,
bfd *output_bfd  ATTRIBUTE_UNUSED,
char **error_message  ATTRIBUTE_UNUSED 
) [static]

Definition at line 133 of file coff-i860.c.

  reloc_howto_type *howto = reloc_entry->howto;
  fprintf (stderr, _("Relocation `%s' not yet implemented\n"), howto->name);
  return bfd_reloc_notsupported;

Here is the call graph for this function:

static reloc_howto_type* coff_i860_reloc_type_lookup ( bfd *abfd  ATTRIBUTE_UNUSED,
bfd_reloc_code_real_type  code 
) [static]
static reloc_howto_type* coff_i860_rtype_to_howto ( bfd *abfd  ATTRIBUTE_UNUSED,
asection sec,
struct internal_reloc rel,
struct coff_link_hash_entry h,
struct internal_syment sym,
bfd_vma addendp 
) [static]

Definition at line 472 of file coff-i860.c.


  reloc_howto_type *howto;

  if (rel->r_type > sizeof (howto_table) / sizeof (howto_table[0]))
      bfd_set_error (bfd_error_bad_value);
      return NULL;

  howto = howto_table + rel->r_type;

  if (howto->pc_relative)
    *addendp += sec->vma;

  if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
      /* This is a common symbol.  The section contents include the
        size (sym->n_value) as an addend.  The relocate_section
        function will be adding in the final value of the symbol.  We
        need to subtract out the current size in order to get the
        correct result.  */

      BFD_ASSERT (h != NULL);

      /* I think we *do* want to bypass this.  If we don't, I have seen some data
        parameters get the wrong relocation address.  If I link two versions
        with and without this section bypassed and then do a binary comparison,
        the addresses which are different can be looked up in the map.  The
        case in which this section has been bypassed has addresses which correspond
        to values I can find in the map.  */
      *addendp -= sym->n_value;

  /* If the output symbol is common (in which case this must be a
     relocatable link), we need to add in the final size of the
     common symbol.  */
  if (h != NULL && h->root.type == bfd_link_hash_common)
    *addendp += h->root.u.c.size;

  return howto;

Here is the call graph for this function:

static const bfd_target* i3coff_object_p ( bfd a) [static]

Definition at line 645 of file coff-i860.c.

  return coff_object_p (a);

Here is the call graph for this function:

static void i860_reloc_processing ( arelent cache_ptr,
struct internal_reloc dst,
asymbol **  symbols,
bfd abfd,
asection asect 
) [static]

Definition at line 577 of file coff-i860.c.

  if (dst->r_type == COFF860_R_PAIR)
      /* Handle the PAIR relocation specially.  */
      cache_ptr->howto = howto_table + dst->r_type;
      cache_ptr->address = dst->r_vaddr;
      cache_ptr->addend = dst->r_symndx;
      cache_ptr->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
      /* For every other relocation, do exactly what coff_slurp_reloc_table
         would do (which this code is taken directly from).  */
      asymbol *ptr = NULL;
      cache_ptr->address = dst->r_vaddr;

      if (dst->r_symndx != -1)
         if (dst->r_symndx < 0 || dst->r_symndx >= obj_conv_table_size (abfd))
              (_("%B: warning: illegal symbol index %ld in relocs"),
               abfd, dst->r_symndx);
             cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
             ptr = NULL;
             cache_ptr->sym_ptr_ptr = (symbols
                                   + obj_convert (abfd)[dst->r_symndx]);
             ptr = *(cache_ptr->sym_ptr_ptr);
         cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
         ptr = NULL;

      /* The symbols definitions that we have read in have been
        relocated as if their sections started at 0. But the offsets
        refering to the symbols in the raw data have not been
        modified, so we have to have a negative addend to compensate.

        Note that symbols which used to be common must be left alone.  */

      /* Calculate any reloc addend by looking at the symbol.  */
      CALC_ADDEND (abfd, ptr, (*dst), cache_ptr);

      cache_ptr->address -= asect->vma;

      /* Fill in the cache_ptr->howto field from dst->r_type.  */
      RTYPE2HOWTO (cache_ptr, dst);

Variable Documentation

reloc_howto_type howto_table[] [static]

Definition at line 150 of file coff-i860.c.

Definition at line 654 of file coff-i860.c.