Back to index

cell-binutils  2.17cvs20070401
Defines | Functions | Variables
coff-m68k.c File Reference
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "coff/m68k.h"
#include "coff/internal.h"
#include "libcoff.h"
#include "coffcode.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER   (2)
#define COFF_PAGE_SIZE   0x2000
#define RELOC_SPECIAL_FN   0
#define m68kcoff_howto_table   _bfd_m68kcoff_howto_table
#define m68k_rtype2howto   _bfd_m68kcoff_rtype2howto
#define m68k_howto2rtype   _bfd_m68kcoff_howto2rtype
#define m68k_reloc_type_lookup   _bfd_m68kcoff_reloc_type_lookup
#define m68k_reloc_name_lookup   _bfd_m68kcoff_reloc_name_lookup
#define BADMAG(x)   M68KBADMAG(x)
#define M68   1 /* Customize coffcode.h */
#define STAT_REL
#define RTYPE2HOWTO(internal, relocentry)   m68k_rtype2howto(internal, (relocentry)->r_type)
#define SELECT_RELOC(external, internal)   external.r_type = m68k_howto2rtype (internal)
#define coff_bfd_reloc_type_lookup   m68k_reloc_type_lookup
#define coff_bfd_reloc_name_lookup   m68k_reloc_name_lookup
#define coff_rtype_to_howto   m68kcoff_rtype_to_howto
#define coff_bfd_is_local_label_name   m68k_coff_is_local_label_name
#define coff_relocate_section   _bfd_coff_generic_relocate_section
#define TARGET_SYM   m68kcoff_vec
#define TARGET_NAME   "coff-m68k"

Functions

static bfd_boolean
m68k_coff_is_local_label_name 
PARAMS ((bfd *, const char *))
static bfd_boolean m68k_coff_is_local_label_name (bfd *abfd, const char *name)
STAT_REL reloc_howto_type
*m68k_reloc_type_lookup 
PARAMS ((bfd *, bfd_reloc_code_real_type))
STAT_REL int m68k_howto2rtype PARAMS ((reloc_howto_type *))
STAT_REL void m68k_rtype2howto PARAMS ((arelent *, int))
STAT_REL void m68k_rtype2howto (arelent *internal, int relocentry)
STAT_REL int m68k_howto2rtype (reloc_howto_type *internal)
STAT_REL reloc_howto_type * m68k_reloc_type_lookup (abfd, bfd_reloc_code_real_type code)
STAT_REL reloc_howto_type * m68k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
static reloc_howto_type
*m68kcoff_rtype_to_howto 
PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *))
static reloc_howto_type * m68kcoff_rtype_to_howto (abfd, asection *sec, struct internal_reloc *rel, h, sym, bfd_vma *addendp)
bfd_boolean bfd_m68k_coff_create_embedded_relocs (bfd *abfd, struct bfd_link_info *info, asection *datasec, asection *relsec, char **errmsg)

Variables

reloc_howto_type m68kcoff_howto_table []

Define Documentation

#define BADMAG (   x)    M68KBADMAG(x)

Definition at line 116 of file coff-m68k.c.

Definition at line 541 of file coff-m68k.c.

Definition at line 230 of file coff-m68k.c.

Definition at line 229 of file coff-m68k.c.

Definition at line 51 of file coff-m68k.c.

#define COFF_PAGE_SIZE   0x2000

Definition at line 55 of file coff-m68k.c.

Definition at line 543 of file coff-m68k.c.

Definition at line 235 of file coff-m68k.c.

#define M68   1 /* Customize coffcode.h */

Definition at line 118 of file coff-m68k.c.

#define m68k_howto2rtype   _bfd_m68kcoff_howto2rtype

Definition at line 92 of file coff-m68k.c.

#define m68k_reloc_name_lookup   _bfd_m68kcoff_reloc_name_lookup

Definition at line 94 of file coff-m68k.c.

#define m68k_reloc_type_lookup   _bfd_m68kcoff_reloc_type_lookup

Definition at line 93 of file coff-m68k.c.

#define m68k_rtype2howto   _bfd_m68kcoff_rtype2howto

Definition at line 91 of file coff-m68k.c.

#define m68kcoff_howto_table   _bfd_m68kcoff_howto_table

Definition at line 90 of file coff-m68k.c.

#define RELOC_SPECIAL_FN   0

Definition at line 59 of file coff-m68k.c.

#define RTYPE2HOWTO (   internal,
  relocentry 
)    m68k_rtype2howto(internal, (relocentry)->r_type)

Definition at line 223 of file coff-m68k.c.

#define SELECT_RELOC (   external,
  internal 
)    external.r_type = m68k_howto2rtype (internal)

Definition at line 226 of file coff-m68k.c.

#define STAT_REL

Definition at line 134 of file coff-m68k.c.

#define TARGET_NAME   "coff-m68k"

Definition at line 552 of file coff-m68k.c.

#define TARGET_SYM   m68kcoff_vec

Definition at line 548 of file coff-m68k.c.


Function Documentation

bfd_boolean bfd_m68k_coff_create_embedded_relocs ( bfd abfd,
struct bfd_link_info info,
asection datasec,
asection relsec,
char **  errmsg 
)

Definition at line 456 of file coff-m68k.c.

{
  char *extsyms;
  bfd_size_type symesz;
  struct internal_reloc *irel, *irelend;
  bfd_byte *p;
  bfd_size_type amt;

  BFD_ASSERT (! info->relocatable);

  *errmsg = NULL;

  if (datasec->reloc_count == 0)
    return TRUE;

  extsyms = obj_coff_external_syms (abfd);
  symesz = bfd_coff_symesz (abfd);

  irel = _bfd_coff_read_internal_relocs (abfd, datasec, TRUE, NULL, FALSE,
                                    NULL);
  irelend = irel + datasec->reloc_count;

  amt = (bfd_size_type) datasec->reloc_count * 12;
  relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt);
  if (relsec->contents == NULL)
    return FALSE;

  p = relsec->contents;

  for (; irel < irelend; irel++, p += 12)
    {
      asection *targetsec;

      /* We are going to write a four byte longword into the runtime
       reloc section.  The longword will be the address in the data
       section which must be relocated.  It is followed by the name
       of the target section NUL-padded or truncated to 8
       characters.  */

      /* We can only relocate absolute longword relocs at run time.  */
      if (irel->r_type != R_RELLONG)
       {
         *errmsg = _("unsupported reloc type");
         bfd_set_error (bfd_error_bad_value);
         return FALSE;
       }

      if (irel->r_symndx == -1)
       targetsec = bfd_abs_section_ptr;
      else
       {
         struct coff_link_hash_entry *h;

         h = obj_coff_sym_hashes (abfd)[irel->r_symndx];
         if (h == NULL)
           {
             struct internal_syment isym;

             bfd_coff_swap_sym_in (abfd, extsyms + symesz * irel->r_symndx,
                                &isym);
             targetsec = coff_section_from_bfd_index (abfd, isym.n_scnum);
           }
         else if (h->root.type == bfd_link_hash_defined
                 || h->root.type == bfd_link_hash_defweak)
           targetsec = h->root.u.def.section;
         else
           targetsec = NULL;
       }

      bfd_put_32 (abfd,
                (irel->r_vaddr - datasec->vma + datasec->output_offset), p);
      memset (p + 4, 0, 8);
      if (targetsec != NULL)
       strncpy ((char *) p + 4, targetsec->output_section->name, 8);
    }

  return TRUE;
}

Here is the call graph for this function:

static bfd_boolean m68k_coff_is_local_label_name ( bfd abfd,
const char *  name 
) [static]

Definition at line 78 of file coff-m68k.c.

{
  if (name[0] == 'L' && name[1] == '%')
    return TRUE;

  return _bfd_coff_is_local_label_name (abfd, name);
}

Here is the call graph for this function:

STAT_REL int m68k_howto2rtype ( reloc_howto_type *  internal)

Definition at line 161 of file coff-m68k.c.

{
  if (internal->pc_relative)
    {
      switch (internal->bitsize)
       {
       case 32: return R_PCRLONG;
       case 16: return R_PCRWORD;
       case 8: return R_PCRBYTE;
       }
    }
  else
    {
      switch (internal->bitsize)
       {
       case 32: return R_RELLONG;
       case 16: return R_RELWORD;
       case 8: return R_RELBYTE;
       }
    }
  return R_RELLONG;
}
STAT_REL reloc_howto_type* m68k_reloc_name_lookup ( bfd *abfd  ATTRIBUTE_UNUSED,
const char *  r_name 
)

Definition at line 206 of file coff-m68k.c.

{
  unsigned int i;

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

  return NULL;
}

Here is the call graph for this function:

STAT_REL reloc_howto_type* m68k_reloc_type_lookup ( abfd  ,
bfd_reloc_code_real_type  code 
)

Definition at line 186 of file coff-m68k.c.

{
  switch (code)
    {
    default:                return NULL;
    case BFD_RELOC_8:              return m68kcoff_howto_table + 0;
    case BFD_RELOC_16:             return m68kcoff_howto_table + 1;
    case BFD_RELOC_CTOR:
    case BFD_RELOC_32:             return m68kcoff_howto_table + 2;
    case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3;
    case BFD_RELOC_16_PCREL:       return m68kcoff_howto_table + 4;
    case BFD_RELOC_32_PCREL:       return m68kcoff_howto_table + 5;
      /* FIXME: There doesn't seem to be a code for R_RELLONG_NEG.  */
    }
  /*NOTREACHED*/
}
STAT_REL void m68k_rtype2howto ( arelent internal,
int  relocentry 
)

Definition at line 144 of file coff-m68k.c.

{
  switch (relocentry)
    {
    case R_RELBYTE:  internal->howto = m68kcoff_howto_table + 0; break;
    case R_RELWORD:  internal->howto = m68kcoff_howto_table + 1; break;
    case R_RELLONG:  internal->howto = m68kcoff_howto_table + 2; break;
    case R_PCRBYTE:  internal->howto = m68kcoff_howto_table + 3; break;
    case R_PCRWORD:  internal->howto = m68kcoff_howto_table + 4; break;
    case R_PCRLONG:  internal->howto = m68kcoff_howto_table + 5; break;
    case R_RELLONG_NEG:     internal->howto = m68kcoff_howto_table + 6; break;
    }
}
static reloc_howto_type* m68kcoff_rtype_to_howto ( abfd  ,
asection sec,
struct internal_reloc rel,
,
sym  ,
bfd_vma addendp 
) [static]

Definition at line 243 of file coff-m68k.c.

{
  arelent relent;
  reloc_howto_type *howto;

  RTYPE2HOWTO (&relent, rel);

  howto = relent.howto;

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

  return howto;
}
static bfd_boolean m68k_coff_is_local_label_name PARAMS ( (bfd *, const char *)  ) [static]
STAT_REL int m68k_howto2rtype PARAMS ( (reloc_howto_type *)  )

Variable Documentation

reloc_howto_type m68kcoff_howto_table[]
Initial value:
  {
    HOWTO (R_RELBYTE,              0,  0,        8,  FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "8",      TRUE, 0x000000ff,0x000000ff, FALSE),
    HOWTO (R_RELWORD,              0,  1,        16, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "16",     TRUE, 0x0000ffff,0x0000ffff, FALSE),
    HOWTO (R_RELLONG,              0,  2,        32, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "32",     TRUE, 0xffffffff,0xffffffff, FALSE),
    HOWTO (R_PCRBYTE,              0,  0,        8,  TRUE,  0, complain_overflow_signed,   RELOC_SPECIAL_FN, "DISP8",    TRUE, 0x000000ff,0x000000ff, FALSE),
    HOWTO (R_PCRWORD,              0,  1,        16, TRUE,  0, complain_overflow_signed,   RELOC_SPECIAL_FN, "DISP16",   TRUE, 0x0000ffff,0x0000ffff, FALSE),
    HOWTO (R_PCRLONG,              0,  2,        32, TRUE,  0, complain_overflow_signed,   RELOC_SPECIAL_FN, "DISP32",   TRUE, 0xffffffff,0xffffffff, FALSE),
    HOWTO (R_RELLONG_NEG,      0, -2,     32, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "-32",    TRUE, 0xffffffff,0xffffffff, FALSE),
  }

Definition at line 103 of file coff-m68k.c.