Back to index

cell-binutils  2.17cvs20070401
Defines | Functions | Variables
nlm32-ppc.c File Reference
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "nlm/ppc-ext.h"
#include "libnlm.h"
#include "nlmswap.h"
#include "nlm-target.h"

Go to the source code of this file.

Defines

#define ARCH_SIZE   32
#define Nlm_External_Fixed_Header   Nlm32_powerpc_External_Fixed_Header
#define TARGET_BIG_NAME   "nlm32-powerpc"
#define TARGET_BIG_SYM   nlmNAME (powerpc_vec)
#define TARGET_BACKEND_DATA   & nlm32_powerpc_backend

Functions

static bfd_boolean nlm_powerpc_read_reloc (bfd *abfd, nlmNAME(symbol_type)*sym, asection **secp, arelent *rel)
static bfd_boolean nlm_powerpc_mangle_relocs (bfd *abfd ATTRIBUTE_UNUSED, asection *sec ATTRIBUTE_UNUSED, const void *data ATTRIBUTE_UNUSED, bfd_vma offset ATTRIBUTE_UNUSED, bfd_size_type count ATTRIBUTE_UNUSED)
static bfd_boolean nlm_powerpc_read_import (bfd *abfd, nlmNAME(symbol_type)*sym)
static bfd_boolean nlm_powerpc_write_import (bfd *abfd, asection *sec, arelent *rel)
static bfd_boolean nlm_powerpc_write_external (bfd *abfd, bfd_size_type count, asymbol *sym, struct reloc_and_sec *relocs)
static bfd_boolean nlm_powerpc_set_public_section (bfd *abfd, nlmNAME(symbol_type)*sym)
static bfd_vma nlm_powerpc_get_public_offset (bfd *abfd, asymbol *sym)

Variables

static reloc_howto_type nlm_powerpc_howto
static struct nlm_backend_data

Define Documentation

#define ARCH_SIZE   32

Definition at line 28 of file nlm32-ppc.c.

Definition at line 31 of file nlm32-ppc.c.

#define TARGET_BACKEND_DATA   & nlm32_powerpc_backend

Definition at line 984 of file nlm32-ppc.c.

#define TARGET_BIG_NAME   "nlm32-powerpc"

Definition at line 982 of file nlm32-ppc.c.

#define TARGET_BIG_SYM   nlmNAME (powerpc_vec)

Definition at line 983 of file nlm32-ppc.c.


Function Documentation

static bfd_vma nlm_powerpc_get_public_offset ( bfd abfd,
asymbol sym 
) [static]

Definition at line 913 of file nlm32-ppc.c.

{
  bfd_vma offset;
  asection *sec;

  offset = bfd_asymbol_value (sym);
  sec = bfd_get_section (sym);
  if (sec->flags & SEC_CODE)
    {
      offset -= nlm_get_text_low (abfd);
      offset |= NLM_HIBIT;
    }
  else if (sec->flags & (SEC_DATA | SEC_ALLOC))
    {
      /* SEC_ALLOC is for the .bss section.  */
      offset -= nlm_get_data_low (abfd);
    }
  else
    {
      /* We can't handle an exported symbol that is not in the code or
        data segment.  */
      bfd_set_error (bfd_error_invalid_operation);
      /* FIXME: No way to return error.  */
      abort ();
    }

  return offset;
}

Here is the call graph for this function:

static bfd_boolean nlm_powerpc_mangle_relocs ( bfd *abfd  ATTRIBUTE_UNUSED,
asection *sec  ATTRIBUTE_UNUSED,
const void *data  ATTRIBUTE_UNUSED,
bfd_vma offset  ATTRIBUTE_UNUSED,
bfd_size_type count  ATTRIBUTE_UNUSED 
) [static]

Definition at line 600 of file nlm32-ppc.c.

{
  return TRUE;
}
static bfd_boolean nlm_powerpc_read_import ( bfd abfd,
nlmNAME(symbol_type)*  sym 
) [static]

Definition at line 612 of file nlm32-ppc.c.

{
  struct nlm_relent *nlm_relocs;   /* Relocation records for symbol.  */
  bfd_size_type rcount;                   /* Number of relocs.  */
  bfd_byte temp[NLM_TARGET_LONG_SIZE];    /* Temporary 32-bit value.  */
  unsigned char symlength;         /* Length of symbol name.  */
  char *name;

  if (bfd_bread (& symlength, (bfd_size_type) sizeof (symlength), abfd)
      != sizeof (symlength))
    return FALSE;
  sym -> symbol.the_bfd = abfd;
  name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
  if (name == NULL)
    return FALSE;
  if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
    return FALSE;
  name[symlength] = '\0';
  sym -> symbol.name = name;
  sym -> symbol.flags = 0;
  sym -> symbol.value = 0;
  sym -> symbol.section = bfd_und_section_ptr;
  if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd)
      != sizeof (temp))
    return FALSE;
  rcount = H_GET_32 (abfd, temp);
  nlm_relocs = bfd_alloc (abfd, rcount * sizeof (struct nlm_relent));
  if (nlm_relocs == NULL)
    return FALSE;
  sym -> relocs = nlm_relocs;
  sym -> rcnt = 0;
  while (sym -> rcnt < rcount)
    {
      asection *section;

      if (! nlm_powerpc_read_reloc (abfd, sym, &section, &nlm_relocs -> reloc))
       return FALSE;
      nlm_relocs -> section = section;
      nlm_relocs++;
      sym -> rcnt++;
    }
  return TRUE;
}

Here is the call graph for this function:

static bfd_boolean nlm_powerpc_read_reloc ( bfd abfd,
nlmNAME(symbol_type)*  sym,
asection **  secp,
arelent rel 
) [static]

Definition at line 538 of file nlm32-ppc.c.

{
  bfd_byte temp[4];
  bfd_vma val;
  const char *name;

  if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
    return FALSE;

  val = bfd_get_32 (abfd, temp);

  /* The value is a word offset into either the code or data segment.
     This is the location which needs to be adjusted.

     The high bit is 0 if the value is an offset into the data
     segment, or 1 if the value is an offset into the text segment.

     If this is a relocation fixup rather than an imported symbol (the
     sym argument is NULL), then the second most significant bit is 0
     if the address of the data segment should be added to the
     location addressed by the value, or 1 if the address of the text
     segment should be added.

     If this is an imported symbol, the second most significant bit is
     not used and must be 0.  */

  if ((val & NLM_HIBIT) == 0)
    name = NLM_INITIALIZED_DATA_NAME;
  else
    {
      name = NLM_CODE_NAME;
      val &=~ NLM_HIBIT;
    }
  *secp = bfd_get_section_by_name (abfd, name);

  if (sym == NULL)
    {
      if ((val & (NLM_HIBIT >> 1)) == 0)
       name = NLM_INITIALIZED_DATA_NAME;
      else
       {
         name = NLM_CODE_NAME;
         val &=~ (NLM_HIBIT >> 1);
       }
      rel->sym_ptr_ptr = bfd_get_section_by_name (abfd, name)->symbol_ptr_ptr;
    }

  rel->howto   = & nlm_powerpc_howto;
  rel->address = val << 2;
  rel->addend  = 0;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bfd_boolean nlm_powerpc_set_public_section ( bfd abfd,
nlmNAME(symbol_type)*  sym 
) [static]

Definition at line 892 of file nlm32-ppc.c.

{
  if (sym->symbol.value & NLM_HIBIT)
    {
      sym->symbol.value &= ~NLM_HIBIT;
      sym->symbol.flags |= BSF_FUNCTION;
      sym->symbol.section =
       bfd_get_section_by_name (abfd, NLM_CODE_NAME);
    }
  else
    sym->symbol.section =
      bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);

  sym->symbol.value <<= 2;

  return TRUE;
}

Here is the call graph for this function:

static bfd_boolean nlm_powerpc_write_external ( bfd abfd,
bfd_size_type  count,
asymbol sym,
struct reloc_and_sec relocs 
) [static]

Definition at line 843 of file nlm32-ppc.c.

{
  unsigned int i;
  bfd_byte len;
  unsigned char temp[NLM_TARGET_LONG_SIZE];
#ifdef OLDFORMAT
  static int indx;
#endif

  len = strlen (sym->name);
  if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
       != sizeof (bfd_byte))
      || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
    return FALSE;

  bfd_put_32 (abfd, count, temp);
  if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
    return FALSE;

  for (i = 0; i < count; i++)
    {
#ifndef OLDFORMAT
      if (! nlm_powerpc_write_import (abfd, relocs[i].sec, relocs[i].rel))
       return FALSE;
#else
      if (! nlm_powerpc_write_reloc (abfd, relocs[i].sec,
                                 relocs[i].rel, indx))
       return FALSE;
#endif
    }

#ifdef OLDFORMAT
  ++indx;
#endif

  return TRUE;
}

Here is the call graph for this function:

static bfd_boolean nlm_powerpc_write_import ( bfd abfd,
asection sec,
arelent rel 
) [static]

Definition at line 661 of file nlm32-ppc.c.

{
  asymbol *sym;
  bfd_vma val;
  bfd_byte temp[4];

  /* PowerPC NetWare only supports one kind of reloc.  */
  if (rel->addend != 0
      || rel->howto == NULL
      || rel->howto->rightshift != 0
      || rel->howto->size != 2
      || rel->howto->bitsize != 32
      || rel->howto->bitpos != 0
      || rel->howto->pc_relative
      || (rel->howto->src_mask != 0xffffffff && rel->addend != 0)
      || rel->howto->dst_mask != 0xffffffff)
    {
      bfd_set_error (bfd_error_invalid_operation);
      return FALSE;
    }

  sym = *rel->sym_ptr_ptr;

  /* The value we write out is the offset into the appropriate
     segment, rightshifted by two.  This offset is the section vma,
     adjusted by the vma of the lowest section in that segment, plus
     the address of the relocation.  */
  val = bfd_get_section_vma (abfd, sec) + rel->address;
  if ((val & 3) != 0)
    {
      bfd_set_error (bfd_error_bad_value);
      return FALSE;
    }
  val >>= 2;

  /* The high bit is 0 if the reloc is in the data section, or 1 if
     the reloc is in the code section.  */
  if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
    val -= nlm_get_data_low (abfd);
  else
    {
      val -= nlm_get_text_low (abfd);
      val |= NLM_HIBIT;
    }

  if (! bfd_is_und_section (bfd_get_section (sym)))
    {
      /* This is an internal relocation fixup.  The second most
        significant bit is 0 if this is a reloc against the data
        segment, or 1 if it is a reloc against the text segment.  */
      if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
       val |= NLM_HIBIT >> 1;
    }

  bfd_put_32 (abfd, val, temp);
  if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
    return FALSE;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 946 of file nlm32-ppc.c.

reloc_howto_type nlm_powerpc_howto [static]
Initial value:
  HOWTO (0,                 
        0,                  
        2,                  
        32,                 
        FALSE,                     
        0,                  
        complain_overflow_bitfield, 
        0,                  
        "32",               
        TRUE,               
        0xffffffff,         
        0xffffffff,         
        FALSE)

Definition at line 520 of file nlm32-ppc.c.