Back to index

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

Go to the source code of this file.

Classes

struct  openrisc_reloc_map

Defines

#define ELF_ARCH   bfd_arch_openrisc
#define ELF_MACHINE_CODE   EM_OPENRISC
#define ELF_MACHINE_ALT1   EM_OPENRISC_OLD
#define ELF_MAXPAGESIZE   0x1000
#define TARGET_BIG_SYM   bfd_elf32_openrisc_vec
#define TARGET_BIG_NAME   "elf32-openrisc"
#define elf_info_to_howto_rel   NULL
#define elf_info_to_howto   openrisc_info_to_howto_rela
#define elf_backend_relocate_section   openrisc_elf_relocate_section
#define elf_backend_gc_mark_hook   openrisc_elf_gc_mark_hook
#define elf_backend_check_relocs   openrisc_elf_check_relocs
#define elf_backend_can_gc_sections   1
#define elf_backend_rela_normal   1
#define bfd_elf32_bfd_reloc_type_lookup   openrisc_reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup   openrisc_reloc_name_lookup
#define elf_backend_object_p   openrisc_elf_object_p
#define elf_backend_final_write_processing   openrisc_elf_final_write_processing

Functions

static reloc_howto_type * openrisc_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
static reloc_howto_type * openrisc_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
static void openrisc_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst)
static bfd_reloc_status_type openrisc_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd, asection *input_section, bfd_byte *contents, Elf_Internal_Rela *rel, bfd_vma relocation)
static bfd_boolean openrisc_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd, asection *input_section, bfd_byte *contents, Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, asection **local_sections)
static asectionopenrisc_elf_gc_mark_hook (asection *sec, struct bfd_link_info *info, Elf_Internal_Rela *rel, struct elf_link_hash_entry *h, Elf_Internal_Sym *sym)
static bfd_boolean openrisc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, const Elf_Internal_Rela *relocs)
static bfd_boolean openrisc_elf_object_p (bfd *abfd)
static void openrisc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)

Variables

static reloc_howto_type openrisc_elf_howto_table []
static struct openrisc_reloc_map []

Class Documentation

struct openrisc_reloc_map

Definition at line 183 of file elf32-openrisc.c.

Class Members
bfd_reloc_code_real_type bfd_reloc_val
unsigned int openrisc_reloc_val

Define Documentation

Definition at line 570 of file elf32-openrisc.c.

Definition at line 569 of file elf32-openrisc.c.

Definition at line 552 of file elf32-openrisc.c.

Definition at line 566 of file elf32-openrisc.c.

Definition at line 564 of file elf32-openrisc.c.

Definition at line 573 of file elf32-openrisc.c.

Definition at line 563 of file elf32-openrisc.c.

Definition at line 572 of file elf32-openrisc.c.

#define elf_backend_rela_normal   1

Definition at line 567 of file elf32-openrisc.c.

Definition at line 562 of file elf32-openrisc.c.

Definition at line 561 of file elf32-openrisc.c.

Definition at line 560 of file elf32-openrisc.c.

Definition at line 554 of file elf32-openrisc.c.

Definition at line 553 of file elf32-openrisc.c.

#define ELF_MAXPAGESIZE   0x1000

Definition at line 555 of file elf32-openrisc.c.

#define TARGET_BIG_NAME   "elf32-openrisc"

Definition at line 558 of file elf32-openrisc.c.

Definition at line 557 of file elf32-openrisc.c.


Function Documentation

static bfd_boolean openrisc_elf_check_relocs ( bfd abfd,
struct bfd_link_info info,
asection sec,
const Elf_Internal_Rela relocs 
) [static]

Definition at line 465 of file elf32-openrisc.c.

{
  Elf_Internal_Shdr *symtab_hdr;
  struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
  const Elf_Internal_Rela *rel;
  const Elf_Internal_Rela *rel_end;

  if (info->relocatable)
    return TRUE;

  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
  sym_hashes = elf_sym_hashes (abfd);
  sym_hashes_end =
    sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
  if (!elf_bad_symtab (abfd))
    sym_hashes_end -= symtab_hdr->sh_info;

  rel_end = relocs + sec->reloc_count;
  for (rel = relocs; rel < rel_end; rel++)
    {
      struct elf_link_hash_entry *h;
      unsigned long r_symndx;

      r_symndx = ELF32_R_SYM (rel->r_info);
      if (r_symndx < symtab_hdr->sh_info)
       h = NULL;
      else
       {
         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
         while (h->root.type == bfd_link_hash_indirect
               || h->root.type == bfd_link_hash_warning)
           h = (struct elf_link_hash_entry *) h->root.u.i.link;
       }

      switch (ELF32_R_TYPE (rel->r_info))
       {
         /* This relocation describes the C++ object vtable hierarchy.
            Reconstruct it for later use during GC.  */
       case R_OPENRISC_GNU_VTINHERIT:
         if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
           return FALSE;
         break;

         /* This relocation describes which C++ vtable entries are actually
            used.  Record for later use during GC.  */
       case R_OPENRISC_GNU_VTENTRY:
         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
           return FALSE;
         break;
       }
    }

  return TRUE;
}

Here is the call graph for this function:

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

Definition at line 535 of file elf32-openrisc.c.

{
  unsigned long val;

  switch (bfd_get_mach (abfd))
    {
    default:
      val = 0;
      break;
    }

  elf_elfheader (abfd)->e_flags &= ~0xf;
  elf_elfheader (abfd)->e_flags |= val;
}

Here is the call graph for this function:

static asection* openrisc_elf_gc_mark_hook ( asection sec,
struct bfd_link_info info,
Elf_Internal_Rela rel,
struct elf_link_hash_entry h,
Elf_Internal_Sym *  sym 
) [static]

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

{
  if (h != NULL)
    switch (ELF32_R_TYPE (rel->r_info))
      {
      case R_OPENRISC_GNU_VTINHERIT:
      case R_OPENRISC_GNU_VTENTRY:
       return NULL;
      }

  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
}

Here is the call graph for this function:

static bfd_boolean openrisc_elf_object_p ( bfd abfd) [static]

Definition at line 526 of file elf32-openrisc.c.

Here is the call graph for this function:

static bfd_boolean openrisc_elf_relocate_section ( bfd output_bfd,
struct bfd_link_info info,
bfd input_bfd,
asection input_section,
bfd_byte contents,
Elf_Internal_Rela relocs,
Elf_Internal_Sym *  local_syms,
asection **  local_sections 
) [static]

Definition at line 310 of file elf32-openrisc.c.

{
  Elf_Internal_Shdr *symtab_hdr;
  struct elf_link_hash_entry **sym_hashes;
  Elf_Internal_Rela *rel;
  Elf_Internal_Rela *relend;

  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
  sym_hashes = elf_sym_hashes (input_bfd);
  relend = relocs + input_section->reloc_count;

  for (rel = relocs; rel < relend; rel++)
    {
      reloc_howto_type *howto;
      unsigned long r_symndx;
      Elf_Internal_Sym *sym;
      asection *sec;
      struct elf_link_hash_entry *h;
      bfd_vma relocation;
      bfd_reloc_status_type r;
      const char *name = NULL;
      int r_type;

      r_type = ELF32_R_TYPE (rel->r_info);
      r_symndx = ELF32_R_SYM (rel->r_info);

      if (r_type == R_OPENRISC_GNU_VTINHERIT
         || r_type == R_OPENRISC_GNU_VTENTRY)
       continue;

      if ((unsigned int) r_type >
         (sizeof openrisc_elf_howto_table / sizeof (reloc_howto_type)))
       abort ();

      howto = openrisc_elf_howto_table + ELF32_R_TYPE (rel->r_info);
      h = NULL;
      sym = NULL;
      sec = NULL;

      if (r_symndx < symtab_hdr->sh_info)
       {
         sym = local_syms + r_symndx;
         sec = local_sections[r_symndx];
         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);

         name = bfd_elf_string_from_elf_section
           (input_bfd, symtab_hdr->sh_link, sym->st_name);
         name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
       }
      else
       {
         bfd_boolean unresolved_reloc, warned;

         RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
                               r_symndx, symtab_hdr, sym_hashes,
                               h, sec, relocation,
                               unresolved_reloc, warned);
       }

      if (sec != NULL && elf_discarded_section (sec))
       {
         /* For relocs against symbols from removed linkonce sections,
            or sections discarded by a linker script, we just want the
            section contents zeroed.  Avoid any special processing.  */
         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
         rel->r_info = 0;
         rel->r_addend = 0;
         continue;
       }

      if (info->relocatable)
       continue;

      r = openrisc_final_link_relocate (howto, input_bfd, input_section,
                                   contents, rel, relocation);

      if (r != bfd_reloc_ok)
       {
         const char *msg = NULL;

         switch (r)
           {
           case bfd_reloc_overflow:
             r = info->callbacks->reloc_overflow
              (info, (h ? &h->root : NULL), name, howto->name,
               (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
             break;

           case bfd_reloc_undefined:
             r = info->callbacks->undefined_symbol
              (info, name, input_bfd, input_section, rel->r_offset, TRUE);
             break;

           case bfd_reloc_outofrange:
             msg = _("internal error: out of range error");
             break;

           case bfd_reloc_notsupported:
             msg = _("internal error: unsupported relocation error");
             break;

           case bfd_reloc_dangerous:
             msg = _("internal error: dangerous relocation");
             break;

           default:
             msg = _("internal error: unknown error");
             break;
           }

         if (msg)
           r = info->callbacks->warning
             (info, msg, name, input_bfd, input_section, rel->r_offset);

         if (!r)
           return FALSE;
       }
    }

  return TRUE;
}

Here is the call graph for this function:

static bfd_reloc_status_type openrisc_final_link_relocate ( reloc_howto_type *  howto,
bfd input_bfd,
asection input_section,
bfd_byte contents,
Elf_Internal_Rela rel,
bfd_vma  relocation 
) [static]

Definition at line 252 of file elf32-openrisc.c.

{
  bfd_reloc_status_type r = bfd_reloc_ok;

  switch (howto->type)
    {
    case R_OPENRISC_LO_16_IN_INSN:
      relocation &= 0xffff;
      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
                                contents, rel->r_offset,
                                relocation, rel->r_addend);
      break;

    default:
      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
                                contents, rel->r_offset,
                                relocation, rel->r_addend);
    }

  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 237 of file elf32-openrisc.c.

{
  unsigned int r_type;

  r_type = ELF32_R_TYPE (dst->r_info);
  BFD_ASSERT (r_type < (unsigned int) R_OPENRISC_max);
  cache_ptr->howto = & openrisc_elf_howto_table[r_type];
}
static reloc_howto_type* openrisc_reloc_name_lookup ( bfd *abfd  ATTRIBUTE_UNUSED,
const char *  r_name 
) [static]

Definition at line 218 of file elf32-openrisc.c.

{
  unsigned int i;

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

  return NULL;
}

Here is the call graph for this function:

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

Definition at line 204 of file elf32-openrisc.c.

{
  unsigned int i;

  for (i = ARRAY_SIZE (openrisc_reloc_map); --i;)
    if (openrisc_reloc_map[i].bfd_reloc_val == code)
      return & openrisc_elf_howto_table[openrisc_reloc_map[i].
                                   openrisc_reloc_val];

  return NULL;
}

Variable Documentation

reloc_howto_type openrisc_elf_howto_table[] [static]

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

Initial value:
{
  { BFD_RELOC_NONE,         R_OPENRISC_NONE },
  { BFD_RELOC_32,           R_OPENRISC_32 },
  { BFD_RELOC_16,           R_OPENRISC_16 },
  { BFD_RELOC_8,            R_OPENRISC_8 },
  { BFD_RELOC_OPENRISC_REL_26,     R_OPENRISC_INSN_REL_26 },
  { BFD_RELOC_OPENRISC_ABS_26,     R_OPENRISC_INSN_ABS_26 },
  { BFD_RELOC_HI16,         R_OPENRISC_HI_16_IN_INSN },
  { BFD_RELOC_LO16,         R_OPENRISC_LO_16_IN_INSN },
  { BFD_RELOC_VTABLE_INHERIT,      R_OPENRISC_GNU_VTINHERIT },
  { BFD_RELOC_VTABLE_ENTRY,        R_OPENRISC_GNU_VTENTRY }
}

Definition at line 189 of file elf32-openrisc.c.