Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
elf32-or32.c File Reference
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "elf-bfd.h"
#include "elf/or32.h"
#include "libiberty.h"
#include "elf32-target.h"

Go to the source code of this file.

Classes

struct  or32_consth
struct  or32_reloc_map

Defines

#define USE_REL   1
#define TARGET_LITTLE_SYM   bfd_elf32_or32_little_vec
#define TARGET_LITTLE_NAME   "elf32-littleor32"
#define TARGET_BIG_SYM   bfd_elf32_or32_big_vec
#define TARGET_BIG_NAME   "elf32-or32"
#define ELF_ARCH   bfd_arch_or32
#define ELF_MACHINE_CODE   EM_OR32
#define ELF_MAXPAGESIZE   0x1000
#define elf_info_to_howto   0
#define elf_info_to_howto_rel   or32_info_to_howto_rel
#define elf_backend_object_p   or32_elf_object_p
#define elf_backend_final_write_processing   or32_elf_final_write_processing

Functions

static bfd_boolean or32_elf_object_p (bfd *abfd)
static void or32_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
static bfd_reloc_status_type or32_elf_32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
static bfd_reloc_status_type or32_elf_16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
static bfd_reloc_status_type or32_elf_8_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry, asymbol *symbol, void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
static bfd_reloc_status_type or32_elf_consth_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry, asymbol *symbol, void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
static bfd_reloc_status_type or32_elf_const_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data, asection *input_section, bfd *output_bfd, char **error_message)
static bfd_reloc_status_type or32_elf_jumptarg_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol ATTRIBUTE_UNUSED, void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
static reloc_howto_type * bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
static void or32_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst)

Variables

static struct or32_consthor32_consth_list
static reloc_howto_type elf_or32_howto_table []
static struct or32_reloc_map []

Class Documentation

struct or32_consth

Definition at line 144 of file elf32-or32.c.

Collaboration diagram for or32_consth:
Class Members
bfd_vma addend
bfd_byte * addr
struct or32_consth * next
struct or32_reloc_map

Definition at line 437 of file elf32-or32.c.

Class Members
bfd_reloc_code_real_type bfd_reloc_val
unsigned char elf_reloc_val

Define Documentation

#define ELF_ARCH   bfd_arch_or32

Definition at line 503 of file elf32-or32.c.

Definition at line 510 of file elf32-or32.c.

Definition at line 509 of file elf32-or32.c.

#define elf_info_to_howto   0

Definition at line 507 of file elf32-or32.c.

Definition at line 508 of file elf32-or32.c.

#define ELF_MACHINE_CODE   EM_OR32

Definition at line 504 of file elf32-or32.c.

#define ELF_MAXPAGESIZE   0x1000

Definition at line 505 of file elf32-or32.c.

#define TARGET_BIG_NAME   "elf32-or32"

Definition at line 502 of file elf32-or32.c.

Definition at line 501 of file elf32-or32.c.

#define TARGET_LITTLE_NAME   "elf32-littleor32"

Definition at line 500 of file elf32-or32.c.

#define TARGET_LITTLE_SYM   bfd_elf32_or32_little_vec

Definition at line 499 of file elf32-or32.c.

#define USE_REL   1

Definition at line 30 of file elf32-or32.c.


Function Documentation

static reloc_howto_type* bfd_elf32_bfd_reloc_name_lookup ( bfd *abfd  ATTRIBUTE_UNUSED,
const char *  r_name 
) [static]

Definition at line 470 of file elf32-or32.c.

{
  unsigned int i;

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

  return NULL;
}

Here is the call graph for this function:

static reloc_howto_type* bfd_elf32_bfd_reloc_type_lookup ( bfd *abfd  ATTRIBUTE_UNUSED,
bfd_reloc_code_real_type  code 
) [static]

Definition at line 457 of file elf32-or32.c.

{
  unsigned int i;

  for (i = ARRAY_SIZE (or32_reloc_map); i--;)
    if (or32_reloc_map[i].bfd_reloc_val == code)
      return &elf_or32_howto_table[or32_reloc_map[i].elf_reloc_val];

  return NULL;
}
static bfd_reloc_status_type or32_elf_16_reloc ( bfd abfd,
arelent reloc_entry,
asymbol symbol,
void *  data,
asection input_section,
bfd output_bfd,
char **error_message  ATTRIBUTE_UNUSED 
) [static]

Definition at line 80 of file elf32-or32.c.

{
  if (output_bfd != NULL)
    {
      unsigned short insn;
      bfd_size_type addr = reloc_entry->address;

      reloc_entry->address += input_section->output_offset;

      insn = bfd_get_16 (abfd, (bfd_byte *) data + addr);
      insn += symbol->section->output_section->vma;
      insn += symbol->section->output_offset;
      insn += symbol->value;
      bfd_put_16 (abfd, insn, (bfd_byte *) data + addr);

      return bfd_reloc_ok;
    }

  return bfd_reloc_continue;
}
static bfd_reloc_status_type or32_elf_32_reloc ( bfd abfd,
arelent reloc_entry,
asymbol symbol,
void *  data,
asection input_section,
bfd output_bfd,
char **error_message  ATTRIBUTE_UNUSED 
) [static]

Definition at line 52 of file elf32-or32.c.

{
  if (output_bfd != NULL)
    {
      unsigned long insn;
      bfd_size_type addr = reloc_entry->address;

      reloc_entry->address += input_section->output_offset;

      insn = bfd_get_32 (abfd, (bfd_byte *) data + addr);
      insn += symbol->section->output_section->vma;
      insn += symbol->section->output_offset;
      insn += symbol->value;
      bfd_put_32 (abfd, insn, (bfd_byte *) data + addr);

      return bfd_reloc_ok;
    }

  return bfd_reloc_continue;
}
static bfd_reloc_status_type or32_elf_8_reloc ( bfd *abfd  ATTRIBUTE_UNUSED,
arelent reloc_entry,
asymbol symbol,
void *  data,
asection input_section,
bfd output_bfd,
char **error_message  ATTRIBUTE_UNUSED 
) [static]

Definition at line 108 of file elf32-or32.c.

{
  if (output_bfd != NULL)
    {
      unsigned char insn;
      bfd_size_type addr = reloc_entry->address;

      reloc_entry->address += input_section->output_offset;

      insn = bfd_get_8 (abfd, (bfd_byte *) data + addr);
      insn += symbol->section->output_section->vma;
      insn += symbol->section->output_offset;
      insn += symbol->value;
      bfd_put_8 (abfd, insn, (bfd_byte *) data + addr);

      return bfd_reloc_ok;
    }

  return bfd_reloc_continue;
}
static bfd_reloc_status_type or32_elf_const_reloc ( bfd abfd,
arelent reloc_entry,
asymbol symbol,
void *  data,
asection input_section,
bfd output_bfd,
char **  error_message 
) [static]

Definition at line 206 of file elf32-or32.c.

{
  if (or32_consth_list != NULL)
    {
      struct or32_consth *l;

      l = or32_consth_list;
      while (l != NULL)
       {
         unsigned long insn;
         unsigned long val;
          unsigned long vallo;
         struct or32_consth *next;

         /* Do the HI16 relocation.  Note that we actually don't need
            to know anything about the LO16 itself, except where to
            find the low 16 bits of the addend needed by the LO16.  */
         insn = bfd_get_32 (abfd, l->addr);
         vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
                 & 0xffff);
         val = ((insn & 0xffff) << 16) + vallo;
         val += l->addend;

         insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
         bfd_put_32 (abfd, insn, l->addr);

         next = l->next;
         free (l);
         l = next;
       }

      or32_consth_list = NULL;
    }

  if (output_bfd != NULL)
    {
      unsigned long insn, tmp;
      bfd_size_type addr = reloc_entry->address;

      reloc_entry->address += input_section->output_offset;

      insn = bfd_get_32 (abfd, (bfd_byte *) data + addr);
      tmp = insn & 0x0000ffff;
      tmp += symbol->section->output_section->vma;
      tmp += symbol->section->output_offset;
      tmp += symbol->value;
      insn = (insn & 0xffff0000) | (tmp & 0x0000ffff);
      bfd_put_32 (abfd, insn, (bfd_byte *) data + addr);

      return bfd_reloc_ok;
    }

  /* Now do the LO16 reloc in the usual way.  */
  return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
                            input_section, output_bfd, error_message);
}

Here is the call graph for this function:

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

Definition at line 156 of file elf32-or32.c.

{
  bfd_reloc_status_type ret;
  bfd_vma relocation;
  struct or32_consth *n;

  ret = bfd_reloc_ok;

  if (bfd_is_und_section (symbol->section)
      && output_bfd == NULL)
    ret = bfd_reloc_undefined;

  if (bfd_is_com_section (symbol->section))
    relocation = 0;
  else
    relocation = symbol->value;

  relocation += symbol->section->output_section->vma;
  relocation += symbol->section->output_offset;
  relocation += reloc_entry->addend;

  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
    return bfd_reloc_outofrange;

  /* Save the information, and let LO16 do the actual relocation.  */
  n = bfd_malloc (sizeof *n);
  if (n == NULL)
    return bfd_reloc_outofrange;
  n->addr = (bfd_byte *) data + reloc_entry->address;
  n->addend = relocation;
  n->next = or32_consth_list;
  or32_consth_list = n;

  if (output_bfd != NULL)
    reloc_entry->address += input_section->output_offset;

  return ret;
}

Here is the call graph for this function:

static void or32_elf_final_write_processing ( bfd abfd,
bfd_boolean linker  ATTRIBUTE_UNUSED 
) [static]

Definition at line 45 of file elf32-or32.c.

{
  elf_elfheader (abfd)->e_flags &=~ EF_OR32_MACH;
}
static bfd_reloc_status_type or32_elf_jumptarg_reloc ( bfd abfd,
arelent reloc_entry,
asymbol *symbol  ATTRIBUTE_UNUSED,
void *  data,
asection input_section,
bfd output_bfd,
char **error_message  ATTRIBUTE_UNUSED 
) [static]

Definition at line 270 of file elf32-or32.c.

{
  if (output_bfd != NULL)
    {
      unsigned long insn, tmp;
      bfd_size_type addr = reloc_entry->address;

      reloc_entry->address += input_section->output_offset;

      insn = bfd_get_32 (abfd, (bfd_byte *) data + addr);
      tmp = insn | 0xfc000000;
      tmp -= (input_section->output_offset >> 2);
      insn = (insn & 0xfc000000) | (tmp & 0x03ffffff);
      bfd_put_32 (abfd, insn, (bfd_byte *) data + addr);

      return bfd_reloc_ok;
    }

  return bfd_reloc_continue;
}
static bfd_boolean or32_elf_object_p ( bfd abfd) [static]

Definition at line 35 of file elf32-or32.c.

{
  (void) bfd_default_set_arch_mach (abfd, bfd_arch_or32, 0);
  return TRUE;
}

Here is the call graph for this function:

static void or32_info_to_howto_rel ( bfd *abfd  ATTRIBUTE_UNUSED,
arelent cache_ptr,
Elf_Internal_Rela dst 
) [static]

Definition at line 488 of file elf32-or32.c.

{
  unsigned int r_type;

  r_type = ELF32_R_TYPE (dst->r_info);
  BFD_ASSERT (r_type < (unsigned int) R_OR32_max);
  cache_ptr->howto = &elf_or32_howto_table[r_type];
}

Variable Documentation

reloc_howto_type elf_or32_howto_table[] [static]

Definition at line 297 of file elf32-or32.c.

Definition at line 153 of file elf32-or32.c.

struct or32_reloc_map[] [static]
Initial value:
{
  { BFD_RELOC_NONE, R_OR32_NONE },
  { BFD_RELOC_32, R_OR32_32 },
  { BFD_RELOC_16, R_OR32_16 },
  { BFD_RELOC_8, R_OR32_8 },
  { BFD_RELOC_LO16, R_OR32_CONST },
  { BFD_RELOC_HI16, R_OR32_CONSTH },
  { BFD_RELOC_32_GOT_PCREL, R_OR32_JUMPTARG },
  { BFD_RELOC_VTABLE_INHERIT, R_OR32_GNU_VTINHERIT },
  { BFD_RELOC_VTABLE_ENTRY, R_OR32_GNU_VTENTRY },
}

Definition at line 443 of file elf32-or32.c.