OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [gas/] [config/] [tc-pj.c] - Diff between revs 156 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 156 Rev 816
/* tc-pj.c -- Assemble code for Pico Java
/* tc-pj.c -- Assemble code for Pico Java
   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007
   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
 
 
   This file is part of GAS, the GNU Assembler.
   This file is part of GAS, the GNU Assembler.
 
 
   GAS is free software; you can redistribute it and/or modify
   GAS is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   the Free Software Foundation; either version 3, or (at your option)
   any later version.
   any later version.
 
 
   GAS is distributed in the hope that it will be useful,
   GAS is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with GAS; see the file COPYING.  If not, write to
   along with GAS; see the file COPYING.  If not, write to
   the Free Software Foundation, 51 Franklin Street - Fifth Floor,
   the Free Software Foundation, 51 Franklin Street - Fifth Floor,
   Boston, MA 02110-1301, USA.  */
   Boston, MA 02110-1301, USA.  */
 
 
/* Contributed by Steve Chamberlain of Transmeta <sac@pobox.com>.  */
/* Contributed by Steve Chamberlain of Transmeta <sac@pobox.com>.  */
 
 
#include "as.h"
#include "as.h"
#include "safe-ctype.h"
#include "safe-ctype.h"
#include "opcode/pj.h"
#include "opcode/pj.h"
 
 
extern const pj_opc_info_t pj_opc_info[512];
extern const pj_opc_info_t pj_opc_info[512];
 
 
const char comment_chars[]        = "!/";
const char comment_chars[]        = "!/";
const char line_separator_chars[] = ";";
const char line_separator_chars[] = ";";
const char line_comment_chars[]   = "/!#";
const char line_comment_chars[]   = "/!#";
 
 
static int pending_reloc;
static int pending_reloc;
static struct hash_control *opcode_hash_control;
static struct hash_control *opcode_hash_control;
 
 
static void
static void
little (int ignore ATTRIBUTE_UNUSED)
little (int ignore ATTRIBUTE_UNUSED)
{
{
  target_big_endian = 0;
  target_big_endian = 0;
}
}
 
 
static void
static void
big (int ignore ATTRIBUTE_UNUSED)
big (int ignore ATTRIBUTE_UNUSED)
{
{
  target_big_endian = 1;
  target_big_endian = 1;
}
}
 
 
const pseudo_typeS md_pseudo_table[] =
const pseudo_typeS md_pseudo_table[] =
{
{
  {"ml",    little, 0},
  {"ml",    little, 0},
  {"mb",    big,    0},
  {"mb",    big,    0},
  {0, 0, 0}
  {0, 0, 0}
};
};
 
 
const char FLT_CHARS[] = "rRsSfFdDxXpP";
const char FLT_CHARS[] = "rRsSfFdDxXpP";
const char EXP_CHARS[] = "eE";
const char EXP_CHARS[] = "eE";
 
 
void
void
md_operand (expressionS *op)
md_operand (expressionS *op)
{
{
  if (strncmp (input_line_pointer, "%hi16", 5) == 0)
  if (strncmp (input_line_pointer, "%hi16", 5) == 0)
    {
    {
      if (pending_reloc)
      if (pending_reloc)
        as_bad (_("confusing relocation expressions"));
        as_bad (_("confusing relocation expressions"));
      pending_reloc = BFD_RELOC_PJ_CODE_HI16;
      pending_reloc = BFD_RELOC_PJ_CODE_HI16;
      input_line_pointer += 5;
      input_line_pointer += 5;
      expression (op);
      expression (op);
    }
    }
 
 
  if (strncmp (input_line_pointer, "%lo16", 5) == 0)
  if (strncmp (input_line_pointer, "%lo16", 5) == 0)
    {
    {
      if (pending_reloc)
      if (pending_reloc)
        as_bad (_("confusing relocation expressions"));
        as_bad (_("confusing relocation expressions"));
      pending_reloc = BFD_RELOC_PJ_CODE_LO16;
      pending_reloc = BFD_RELOC_PJ_CODE_LO16;
      input_line_pointer += 5;
      input_line_pointer += 5;
      expression (op);
      expression (op);
    }
    }
}
}
 
 
/* Parse an expression and then restore the input line pointer.  */
/* Parse an expression and then restore the input line pointer.  */
 
 
static char *
static char *
parse_exp_save_ilp (char *s, expressionS *op)
parse_exp_save_ilp (char *s, expressionS *op)
{
{
  char *save = input_line_pointer;
  char *save = input_line_pointer;
 
 
  input_line_pointer = s;
  input_line_pointer = s;
  expression (op);
  expression (op);
  s = input_line_pointer;
  s = input_line_pointer;
  input_line_pointer = save;
  input_line_pointer = save;
  return s;
  return s;
}
}
 
 
/* This is called by emit_expr via TC_CONS_FIX_NEW when creating a
/* This is called by emit_expr via TC_CONS_FIX_NEW when creating a
   reloc for a cons.  We could use the definition there, except that
   reloc for a cons.  We could use the definition there, except that
   we want to handle magic pending reloc expressions specially.  */
   we want to handle magic pending reloc expressions specially.  */
 
 
void
void
pj_cons_fix_new_pj (fragS *frag, int where, int nbytes, expressionS *exp)
pj_cons_fix_new_pj (fragS *frag, int where, int nbytes, expressionS *exp)
{
{
  static int rv[5][2] =
  static int rv[5][2] =
  { { 0, 0 },
  { { 0, 0 },
    { BFD_RELOC_8, BFD_RELOC_8 },
    { BFD_RELOC_8, BFD_RELOC_8 },
    { BFD_RELOC_PJ_CODE_DIR16, BFD_RELOC_16 },
    { BFD_RELOC_PJ_CODE_DIR16, BFD_RELOC_16 },
    { 0, 0 },
    { 0, 0 },
    { BFD_RELOC_PJ_CODE_DIR32, BFD_RELOC_32 }};
    { BFD_RELOC_PJ_CODE_DIR32, BFD_RELOC_32 }};
 
 
  fix_new_exp (frag, where, nbytes, exp, 0,
  fix_new_exp (frag, where, nbytes, exp, 0,
               pending_reloc ? pending_reloc
               pending_reloc ? pending_reloc
               : rv[nbytes][(now_seg->flags & SEC_CODE) ? 0 : 1]);
               : rv[nbytes][(now_seg->flags & SEC_CODE) ? 0 : 1]);
 
 
  pending_reloc = 0;
  pending_reloc = 0;
}
}
 
 
/* Turn a reloc description character from the pj-opc.h table into
/* Turn a reloc description character from the pj-opc.h table into
   code which BFD can handle.  */
   code which BFD can handle.  */
 
 
static int
static int
c_to_r (int x)
c_to_r (int x)
{
{
  switch (x)
  switch (x)
    {
    {
    case O_R8:
    case O_R8:
      return BFD_RELOC_8_PCREL;
      return BFD_RELOC_8_PCREL;
    case O_U8:
    case O_U8:
    case O_8:
    case O_8:
      return BFD_RELOC_8;
      return BFD_RELOC_8;
    case O_R16:
    case O_R16:
      return BFD_RELOC_PJ_CODE_REL16;
      return BFD_RELOC_PJ_CODE_REL16;
    case O_U16:
    case O_U16:
    case O_16:
    case O_16:
      return BFD_RELOC_PJ_CODE_DIR16;
      return BFD_RELOC_PJ_CODE_DIR16;
    case O_R32:
    case O_R32:
      return BFD_RELOC_PJ_CODE_REL32;
      return BFD_RELOC_PJ_CODE_REL32;
    case O_32:
    case O_32:
      return BFD_RELOC_PJ_CODE_DIR32;
      return BFD_RELOC_PJ_CODE_DIR32;
    }
    }
  abort ();
  abort ();
  return 0;
  return 0;
}
}
 
 
/* Handler for the ipush fake opcode,
/* Handler for the ipush fake opcode,
   turns ipush <foo> into sipush lo16<foo>, sethi hi16<foo>.  */
   turns ipush <foo> into sipush lo16<foo>, sethi hi16<foo>.  */
 
 
static void
static void
ipush_code (pj_opc_info_t *opcode ATTRIBUTE_UNUSED, char *str)
ipush_code (pj_opc_info_t *opcode ATTRIBUTE_UNUSED, char *str)
{
{
  char *b = frag_more (6);
  char *b = frag_more (6);
  expressionS arg;
  expressionS arg;
 
 
  b[0] = 0x11;
  b[0] = 0x11;
  b[3] = 0xed;
  b[3] = 0xed;
  parse_exp_save_ilp (str + 1, &arg);
  parse_exp_save_ilp (str + 1, &arg);
  if (pending_reloc)
  if (pending_reloc)
    {
    {
      as_bad (_("can't have relocation for ipush"));
      as_bad (_("can't have relocation for ipush"));
      pending_reloc = 0;
      pending_reloc = 0;
    }
    }
 
 
  fix_new_exp (frag_now, b - frag_now->fr_literal + 1, 2,
  fix_new_exp (frag_now, b - frag_now->fr_literal + 1, 2,
               &arg, 0, BFD_RELOC_PJ_CODE_DIR16);
               &arg, 0, BFD_RELOC_PJ_CODE_DIR16);
  fix_new_exp (frag_now, b - frag_now->fr_literal + 4, 2,
  fix_new_exp (frag_now, b - frag_now->fr_literal + 4, 2,
               &arg, 0, BFD_RELOC_PJ_CODE_HI16);
               &arg, 0, BFD_RELOC_PJ_CODE_HI16);
}
}
 
 
/* Insert names into the opcode table which are really mini macros,
/* Insert names into the opcode table which are really mini macros,
   not opcodes.  The fakeness is indicated with an opcode of -1.  */
   not opcodes.  The fakeness is indicated with an opcode of -1.  */
 
 
static void
static void
fake_opcode (const char *name,
fake_opcode (const char *name,
             void (*func) (struct pj_opc_info_t *, char *))
             void (*func) (struct pj_opc_info_t *, char *))
{
{
  pj_opc_info_t * fake = xmalloc (sizeof (pj_opc_info_t));
  pj_opc_info_t * fake = xmalloc (sizeof (pj_opc_info_t));
 
 
  fake->opcode = -1;
  fake->opcode = -1;
  fake->opcode_next = -1;
  fake->opcode_next = -1;
  fake->u.func = func;
  fake->u.func = func;
  hash_insert (opcode_hash_control, name, (char *) fake);
  hash_insert (opcode_hash_control, name, (char *) fake);
}
}
 
 
/* Enter another entry into the opcode hash table so the same opcode
/* Enter another entry into the opcode hash table so the same opcode
   can have another name.  */
   can have another name.  */
 
 
static void
static void
alias (const char *new, const char *old)
alias (const char *new, const char *old)
{
{
  hash_insert (opcode_hash_control, new,
  hash_insert (opcode_hash_control, new,
               (char *) hash_find (opcode_hash_control, old));
               (char *) hash_find (opcode_hash_control, old));
}
}
 
 
/* This function is called once, at assembler startup time.  It sets
/* This function is called once, at assembler startup time.  It sets
   up the hash table with all the opcodes in it, and also initializes
   up the hash table with all the opcodes in it, and also initializes
   some aliases for compatibility with other assemblers.  */
   some aliases for compatibility with other assemblers.  */
 
 
void
void
md_begin (void)
md_begin (void)
{
{
  const pj_opc_info_t *opcode;
  const pj_opc_info_t *opcode;
  opcode_hash_control = hash_new ();
  opcode_hash_control = hash_new ();
 
 
  /* Insert names into hash table.  */
  /* Insert names into hash table.  */
  for (opcode = pj_opc_info; opcode->u.name; opcode++)
  for (opcode = pj_opc_info; opcode->u.name; opcode++)
    hash_insert (opcode_hash_control, opcode->u.name, (char *) opcode);
    hash_insert (opcode_hash_control, opcode->u.name, (char *) opcode);
 
 
  /* Insert the only fake opcode.  */
  /* Insert the only fake opcode.  */
  fake_opcode ("ipush", ipush_code);
  fake_opcode ("ipush", ipush_code);
 
 
  /* Add some aliases for opcode names.  */
  /* Add some aliases for opcode names.  */
  alias ("ifeq_s", "ifeq");
  alias ("ifeq_s", "ifeq");
  alias ("ifne_s", "ifne");
  alias ("ifne_s", "ifne");
  alias ("if_icmpge_s", "if_icmpge");
  alias ("if_icmpge_s", "if_icmpge");
  alias ("if_icmpne_s", "if_icmpne");
  alias ("if_icmpne_s", "if_icmpne");
  alias ("if_icmpeq_s", "if_icmpeq");
  alias ("if_icmpeq_s", "if_icmpeq");
  alias ("if_icmpgt_s", "if_icmpgt");
  alias ("if_icmpgt_s", "if_icmpgt");
  alias ("goto_s", "goto");
  alias ("goto_s", "goto");
 
 
  bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
  bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
}
}
 
 
/* This is the guts of the machine-dependent assembler.  STR points to
/* This is the guts of the machine-dependent assembler.  STR points to
   a machine dependent instruction.  This function is supposed to emit
   a machine dependent instruction.  This function is supposed to emit
   the frags/bytes it assembles to.  */
   the frags/bytes it assembles to.  */
 
 
void
void
md_assemble (char *str)
md_assemble (char *str)
{
{
  char *op_start;
  char *op_start;
  char *op_end;
  char *op_end;
 
 
  pj_opc_info_t *opcode;
  pj_opc_info_t *opcode;
  char *output;
  char *output;
  int idx = 0;
  int idx = 0;
  char pend;
  char pend;
 
 
  int nlen = 0;
  int nlen = 0;
 
 
  /* Drop leading whitespace.  */
  /* Drop leading whitespace.  */
  while (*str == ' ')
  while (*str == ' ')
    str++;
    str++;
 
 
  /* Find the op code end.  */
  /* Find the op code end.  */
  op_start = str;
  op_start = str;
  for (op_end = str;
  for (op_end = str;
       *op_end && !is_end_of_line[*op_end & 0xff] && *op_end != ' ';
       *op_end && !is_end_of_line[*op_end & 0xff] && *op_end != ' ';
       op_end++)
       op_end++)
    nlen++;
    nlen++;
 
 
  pend = *op_end;
  pend = *op_end;
  *op_end = 0;
  *op_end = 0;
 
 
  if (nlen == 0)
  if (nlen == 0)
    as_bad (_("can't find opcode "));
    as_bad (_("can't find opcode "));
 
 
  opcode = (pj_opc_info_t *) hash_find (opcode_hash_control, op_start);
  opcode = (pj_opc_info_t *) hash_find (opcode_hash_control, op_start);
  *op_end = pend;
  *op_end = pend;
 
 
  if (opcode == NULL)
  if (opcode == NULL)
    {
    {
      as_bad (_("unknown opcode %s"), op_start);
      as_bad (_("unknown opcode %s"), op_start);
      return;
      return;
    }
    }
 
 
  if (opcode->opcode == -1)
  if (opcode->opcode == -1)
    {
    {
      /* It's a fake opcode.  Dig out the args and pretend that was
      /* It's a fake opcode.  Dig out the args and pretend that was
         what we were passed.  */
         what we were passed.  */
      (*opcode->u.func) (opcode, op_end);
      (*opcode->u.func) (opcode, op_end);
    }
    }
  else
  else
    {
    {
      int an;
      int an;
 
 
      output = frag_more (opcode->len);
      output = frag_more (opcode->len);
      output[idx++] = opcode->opcode;
      output[idx++] = opcode->opcode;
 
 
      if (opcode->opcode_next != -1)
      if (opcode->opcode_next != -1)
        output[idx++] = opcode->opcode_next;
        output[idx++] = opcode->opcode_next;
 
 
      for (an = 0; opcode->arg[an]; an++)
      for (an = 0; opcode->arg[an]; an++)
        {
        {
          expressionS arg;
          expressionS arg;
 
 
          if (*op_end == ',' && an != 0)
          if (*op_end == ',' && an != 0)
            op_end++;
            op_end++;
 
 
          if (*op_end == 0)
          if (*op_end == 0)
            as_bad ("expected expresssion");
            as_bad ("expected expresssion");
 
 
          op_end = parse_exp_save_ilp (op_end, &arg);
          op_end = parse_exp_save_ilp (op_end, &arg);
 
 
          fix_new_exp (frag_now,
          fix_new_exp (frag_now,
                       output - frag_now->fr_literal + idx,
                       output - frag_now->fr_literal + idx,
                       ASIZE (opcode->arg[an]),
                       ASIZE (opcode->arg[an]),
                       &arg,
                       &arg,
                       PCREL (opcode->arg[an]),
                       PCREL (opcode->arg[an]),
                       pending_reloc ? pending_reloc : c_to_r (opcode->arg[an]));
                       pending_reloc ? pending_reloc : c_to_r (opcode->arg[an]));
 
 
          idx += ASIZE (opcode->arg[an]);
          idx += ASIZE (opcode->arg[an]);
          pending_reloc = 0;
          pending_reloc = 0;
        }
        }
 
 
      while (ISSPACE (*op_end))
      while (ISSPACE (*op_end))
        op_end++;
        op_end++;
 
 
      if (*op_end != 0)
      if (*op_end != 0)
        as_warn ("extra stuff on line ignored");
        as_warn ("extra stuff on line ignored");
 
 
    }
    }
 
 
  if (pending_reloc)
  if (pending_reloc)
    as_bad ("Something forgot to clean up\n");
    as_bad ("Something forgot to clean up\n");
 
 
}
}
 
 
char *
char *
md_atof (int type, char *litP, int *sizeP)
md_atof (int type, char *litP, int *sizeP)
{
{
  return ieee_md_atof (type, litP, sizeP, target_big_endian);
  return ieee_md_atof (type, litP, sizeP, target_big_endian);
}
}


const char *md_shortopts = "";
const char *md_shortopts = "";
 
 
struct option md_longopts[] =
struct option md_longopts[] =
{
{
#define OPTION_LITTLE (OPTION_MD_BASE)
#define OPTION_LITTLE (OPTION_MD_BASE)
#define OPTION_BIG    (OPTION_LITTLE + 1)
#define OPTION_BIG    (OPTION_LITTLE + 1)
 
 
  {"little", no_argument, NULL, OPTION_LITTLE},
  {"little", no_argument, NULL, OPTION_LITTLE},
  {"big", no_argument, NULL, OPTION_BIG},
  {"big", no_argument, NULL, OPTION_BIG},
  {NULL, no_argument, NULL, 0}
  {NULL, no_argument, NULL, 0}
};
};
size_t md_longopts_size = sizeof (md_longopts);
size_t md_longopts_size = sizeof (md_longopts);
 
 
int
int
md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
{
{
  switch (c)
  switch (c)
    {
    {
    case OPTION_LITTLE:
    case OPTION_LITTLE:
      little (0);
      little (0);
      break;
      break;
    case OPTION_BIG:
    case OPTION_BIG:
      big (0);
      big (0);
      break;
      break;
    default:
    default:
      return 0;
      return 0;
    }
    }
  return 1;
  return 1;
}
}
 
 
void
void
md_show_usage (FILE *stream)
md_show_usage (FILE *stream)
{
{
  fprintf (stream, _("\
  fprintf (stream, _("\
PJ options:\n\
PJ options:\n\
-little                 generate little endian code\n\
-little                 generate little endian code\n\
-big                    generate big endian code\n"));
-big                    generate big endian code\n"));
}
}
 
 
/* Apply a fixup to the object file.  */
/* Apply a fixup to the object file.  */
 
 
void
void
md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
{
{
  char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
  char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
  long val = *valP;
  long val = *valP;
  long max, min;
  long max, min;
  int shift;
  int shift;
 
 
  max = min = 0;
  max = min = 0;
  shift = 0;
  shift = 0;
  switch (fixP->fx_r_type)
  switch (fixP->fx_r_type)
    {
    {
    case BFD_RELOC_VTABLE_INHERIT:
    case BFD_RELOC_VTABLE_INHERIT:
    case BFD_RELOC_VTABLE_ENTRY:
    case BFD_RELOC_VTABLE_ENTRY:
      fixP->fx_done = 0;
      fixP->fx_done = 0;
      return;
      return;
 
 
    case BFD_RELOC_PJ_CODE_REL16:
    case BFD_RELOC_PJ_CODE_REL16:
      if (val < -0x8000 || val >= 0x7fff)
      if (val < -0x8000 || val >= 0x7fff)
        as_bad_where (fixP->fx_file, fixP->fx_line, _("pcrel too far"));
        as_bad_where (fixP->fx_file, fixP->fx_line, _("pcrel too far"));
      buf[0] |= (val >> 8) & 0xff;
      buf[0] |= (val >> 8) & 0xff;
      buf[1] = val & 0xff;
      buf[1] = val & 0xff;
      break;
      break;
 
 
    case BFD_RELOC_PJ_CODE_HI16:
    case BFD_RELOC_PJ_CODE_HI16:
      *buf++ = val >> 24;
      *buf++ = val >> 24;
      *buf++ = val >> 16;
      *buf++ = val >> 16;
      fixP->fx_addnumber = val & 0xffff;
      fixP->fx_addnumber = val & 0xffff;
      break;
      break;
 
 
    case BFD_RELOC_PJ_CODE_DIR16:
    case BFD_RELOC_PJ_CODE_DIR16:
    case BFD_RELOC_PJ_CODE_LO16:
    case BFD_RELOC_PJ_CODE_LO16:
      *buf++ = val >> 8;
      *buf++ = val >> 8;
      *buf++ = val >> 0;
      *buf++ = val >> 0;
 
 
      max = 0xffff;
      max = 0xffff;
      min = -0xffff;
      min = -0xffff;
      break;
      break;
 
 
    case BFD_RELOC_8:
    case BFD_RELOC_8:
      max = 0xff;
      max = 0xff;
      min = -0xff;
      min = -0xff;
      *buf++ = val;
      *buf++ = val;
      break;
      break;
 
 
    case BFD_RELOC_PJ_CODE_DIR32:
    case BFD_RELOC_PJ_CODE_DIR32:
      *buf++ = val >> 24;
      *buf++ = val >> 24;
      *buf++ = val >> 16;
      *buf++ = val >> 16;
      *buf++ = val >> 8;
      *buf++ = val >> 8;
      *buf++ = val >> 0;
      *buf++ = val >> 0;
      break;
      break;
 
 
    case BFD_RELOC_32:
    case BFD_RELOC_32:
      if (target_big_endian)
      if (target_big_endian)
        {
        {
          *buf++ = val >> 24;
          *buf++ = val >> 24;
          *buf++ = val >> 16;
          *buf++ = val >> 16;
          *buf++ = val >> 8;
          *buf++ = val >> 8;
          *buf++ = val >> 0;
          *buf++ = val >> 0;
        }
        }
      else
      else
        {
        {
          *buf++ = val >> 0;
          *buf++ = val >> 0;
          *buf++ = val >> 8;
          *buf++ = val >> 8;
          *buf++ = val >> 16;
          *buf++ = val >> 16;
          *buf++ = val >> 24;
          *buf++ = val >> 24;
        }
        }
      break;
      break;
 
 
    case BFD_RELOC_16:
    case BFD_RELOC_16:
      if (target_big_endian)
      if (target_big_endian)
        {
        {
          *buf++ = val >> 8;
          *buf++ = val >> 8;
          *buf++ = val >> 0;
          *buf++ = val >> 0;
        }
        }
      else
      else
        {
        {
          *buf++ = val >> 0;
          *buf++ = val >> 0;
          *buf++ = val >> 8;
          *buf++ = val >> 8;
        }
        }
      break;
      break;
 
 
    default:
    default:
      abort ();
      abort ();
    }
    }
 
 
  if (max != 0 && (val < min || val > max))
  if (max != 0 && (val < min || val > max))
    as_bad_where (fixP->fx_file, fixP->fx_line, _("offset out of range"));
    as_bad_where (fixP->fx_file, fixP->fx_line, _("offset out of range"));
 
 
  if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
  if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
    fixP->fx_done = 1;
    fixP->fx_done = 1;
}
}
 
 
/* Put number into target byte order.  Always put values in an
/* Put number into target byte order.  Always put values in an
   executable section into big endian order.  */
   executable section into big endian order.  */
 
 
void
void
md_number_to_chars (char *ptr, valueT use, int nbytes)
md_number_to_chars (char *ptr, valueT use, int nbytes)
{
{
  if (target_big_endian || now_seg->flags & SEC_CODE)
  if (target_big_endian || now_seg->flags & SEC_CODE)
    number_to_chars_bigendian (ptr, use, nbytes);
    number_to_chars_bigendian (ptr, use, nbytes);
  else
  else
    number_to_chars_littleendian (ptr, use, nbytes);
    number_to_chars_littleendian (ptr, use, nbytes);
}
}
 
 
/* Translate internal representation of relocation info to BFD target
/* Translate internal representation of relocation info to BFD target
   format.  */
   format.  */
 
 
arelent *
arelent *
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
{
{
  arelent *rel;
  arelent *rel;
  bfd_reloc_code_real_type r_type;
  bfd_reloc_code_real_type r_type;
 
 
  rel = xmalloc (sizeof (arelent));
  rel = xmalloc (sizeof (arelent));
  rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
  rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
  *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
  *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
  rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
  rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
 
  r_type = fixp->fx_r_type;
  r_type = fixp->fx_r_type;
  rel->addend = fixp->fx_addnumber;
  rel->addend = fixp->fx_addnumber;
  rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
  rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
 
 
  if (rel->howto == NULL)
  if (rel->howto == NULL)
    {
    {
      as_bad_where (fixp->fx_file, fixp->fx_line,
      as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("Cannot represent relocation type %s"),
                    _("Cannot represent relocation type %s"),
                    bfd_get_reloc_code_name (r_type));
                    bfd_get_reloc_code_name (r_type));
      /* Set howto to a garbage value so that we can keep going.  */
      /* Set howto to a garbage value so that we can keep going.  */
      rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32);
      rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32);
      assert (rel->howto != NULL);
      assert (rel->howto != NULL);
    }
    }
 
 
  return rel;
  return rel;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.