Ignore:
Timestamp:
Feb 6, 2017, 1:00:00 PM (8 years ago)
Author:
Silvan Scherrer
Message:

binutils: update trunk to version 2.27

Location:
binutils/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • binutils/trunk

  • TabularUnified binutils/trunk/gas/config/tc-rl78.c

    r970 r1973  
    11/* tc-rl78.c -- Assembler for the Renesas RL78
    2    Copyright (C) 2011-2014 Free Software Foundation, Inc.
     2   Copyright (C) 2011-2016 Free Software Foundation, Inc.
    33
    44   This file is part of GAS, the GNU Assembler.
     
    103103rl78_linkrelax_branch (void)
    104104{
     105  rl78_relax (RL78_RELAX_BRANCH, 0);
    105106  rl78_bytes.link_relax |= RL78_RELAXA_BRA;
    106107}
     
    131132
    132133int
    133 rl78_has_prefix ()
     134rl78_has_prefix (void)
    134135{
    135136  return rl78_bytes.n_prefix;
     
    281282{
    282283  OPTION_RELAX = OPTION_MD_BASE,
     284  OPTION_NORELAX,
    283285  OPTION_G10,
     286  OPTION_G13,
     287  OPTION_G14,
    284288  OPTION_32BIT_DOUBLES,
    285289  OPTION_64BIT_DOUBLES,
     
    293297{
    294298  {"relax", no_argument, NULL, OPTION_RELAX},
     299  {"norelax", no_argument, NULL, OPTION_NORELAX},
    295300  {"mg10", no_argument, NULL, OPTION_G10},
     301  {"mg13", no_argument, NULL, OPTION_G13},
     302  {"mg14", no_argument, NULL, OPTION_G14},
     303  {"mrl78", no_argument, NULL, OPTION_G14},
    296304  {"m32bit-doubles", no_argument, NULL, OPTION_32BIT_DOUBLES},
    297305  {"m64bit-doubles", no_argument, NULL, OPTION_64BIT_DOUBLES},
     
    301309
    302310int
    303 md_parse_option (int c, char * arg ATTRIBUTE_UNUSED)
     311md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
    304312{
    305313  switch (c)
     
    308316      linkrelax = 1;
    309317      return 1;
     318    case OPTION_NORELAX:
     319      linkrelax = 0;
     320      return 1;
    310321
    311322    case OPTION_G10:
     323      elf_flags &= ~ E_FLAG_RL78_CPU_MASK;
    312324      elf_flags |= E_FLAG_RL78_G10;
     325      return 1;
     326
     327    case OPTION_G13:
     328      elf_flags &= ~ E_FLAG_RL78_CPU_MASK;
     329      elf_flags |= E_FLAG_RL78_G13;
     330      return 1;
     331
     332    case OPTION_G14:
     333      elf_flags &= ~ E_FLAG_RL78_CPU_MASK;
     334      elf_flags |= E_FLAG_RL78_G14;
    313335      return 1;
    314336
     
    324346}
    325347
    326 void
    327 md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
     348int
     349rl78_isa_g10 (void)
     350{
     351  return (elf_flags & E_FLAG_RL78_CPU_MASK) == E_FLAG_RL78_G10;
     352}
     353
     354int
     355rl78_isa_g13 (void)
     356{
     357  return (elf_flags & E_FLAG_RL78_CPU_MASK) == E_FLAG_RL78_G13;
     358}
     359
     360int
     361rl78_isa_g14 (void)
     362{
     363  return (elf_flags & E_FLAG_RL78_CPU_MASK) == E_FLAG_RL78_G14;
     364}
     365
     366void
     367md_show_usage (FILE * stream)
    328368{
    329369  fprintf (stream, _(" RL78 specific command line options:\n"));
     370  fprintf (stream, _("  --mrelax          Enable link time relaxation\n"));
    330371  fprintf (stream, _("  --mg10            Enable support for G10 variant\n"));
     372  fprintf (stream, _("  --mg13            Selects the G13 core.\n"));
     373  fprintf (stream, _("  --mg14            Selects the G14 core [default]\n"));
     374  fprintf (stream, _("  --mrl78           Alias for --mg14\n"));
    331375  fprintf (stream, _("  --m32bit-doubles  [default]\n"));
    332   fprintf (stream, _("  --m64bit-doubles\n"));
     376  fprintf (stream, _("  --m64bit-doubles  Source code uses 64-bit doubles\n"));
    333377}
    334378
     
    365409};
    366410
     411static symbolS * rl78_abs_sym = NULL;
     412
    367413void
    368414md_begin (void)
    369415{
     416  rl78_abs_sym = symbol_make ("__rl78_abs__");
    370417}
    371418
     
    390437
    391438static void
    392 require_end_of_expr (char *fname)
     439require_end_of_expr (const char *fname)
    393440{
    394441  while (* input_line_pointer == ' '
     
    408455static struct
    409456{
    410   char * fname;
     457  const char * fname;
    411458  int    reloc;
    412459}
     
    456503  if (rl78_bytes.n_relax || rl78_bytes.link_relax)
    457504    {
    458       fragP->tc_frag_data = malloc (sizeof (rl78_bytesT));
     505      fragP->tc_frag_data = XNEW (rl78_bytesT);
    459506      memcpy (fragP->tc_frag_data, & rl78_bytes, sizeof (rl78_bytesT));
    460507    }
     
    487534}
    488535
    489 char *
     536const char *
    490537md_atof (int type, char * litP, int * sizeP)
    491538{
     
    644691    case BFD_RELOC_RL78_HI16:
    645692      if (size != 2)
    646         as_bad (_("%%hi16/%%lo16 only applies to .short or .hword"));
    647       type = exp->X_md;
     693        {
     694          /* Fixups to assembler generated expressions do not use %hi or %lo.  */
     695          if (frag->fr_file)
     696            as_bad (_("%%hi16/%%lo16 only applies to .short or .hword"));
     697        }
     698      else
     699        type = exp->X_md;
    648700      break;
    649701    case BFD_RELOC_RL78_HI8:
    650702      if (size != 1)
    651         as_bad (_("%%hi8 only applies to .byte"));
    652       type = exp->X_md;
     703        {
     704          /* Fixups to assembler generated expressions do not use %hi or %lo.  */
     705          if (frag->fr_file)
     706            as_bad (_("%%hi8 only applies to .byte"));
     707        }
     708      else
     709        type = exp->X_md;
    653710      break;
    654711    default:
     
    708765  OT_bt_es,
    709766  OT_bc,
    710   OT_bh
     767  OT_bh,
     768  OT_sk,
     769  OT_call,
     770  OT_br,
    711771} op_type_T;
    712772
     
    731791
    732792static op_type_T
    733 rl78_opcode_type (char * op)
    734 {
     793rl78_opcode_type (char * ops)
     794{
     795  unsigned char *op = (unsigned char *)ops;
     796
    735797  if (op[0] == 0x31
    736798      && ((op[1] & 0x0f) == 0x05
     
    755817      && (op[1] & 0xef) == 0xc3)
    756818    return OT_bh;
     819
     820  if (op[0] == 0x61
     821      && (op[1] & 0xcf) == 0xc8)
     822    return OT_sk;
     823
     824  if (op[0] == 0x61
     825      && (op[1] & 0xef) == 0xe3)
     826    return OT_sk;
     827
     828  if (op[0] == 0xfc)
     829    return OT_call;
     830
     831  if ((op[0] & 0xec) == 0xec)
     832    return OT_br;
    757833
    758834  return OT_other;
     
    806882   value is the difference between fr_fix and the actual size.  We
    807883   compute the total size in rl78_relax_frag and store it in fr_subtype,
    808    sowe only need to subtract fx_fix and return it.  */
     884   so we only need to subtract fx_fix and return it.  */
    809885
    810886int
     
    852928                           & sym_addr))
    853929    {
     930      /* If we don't expect the linker to do relaxing, don't emit
     931         expanded opcodes that only the linker will relax.  */
     932      if (!linkrelax)
     933        return newsize - oldsize;
     934
    854935      /* If we don't, we must use the maximum size for the linker.  */
    855936      switch (fragP->tc_frag_data->relax[ri].type)
     
    871952              newsize = 6;
    872953              break;
    873             case OT_other:
     954            case OT_sk:
     955              newsize = 2;
     956              break;
     957            default:
    874958              newsize = oldsize;
    875959              break;
     
    9181002            newsize = 6;
    9191003          break;
    920         case OT_other:
     1004        case OT_sk:
     1005          newsize = 2;
     1006          break;
     1007        default:
    9211008          newsize = oldsize;
    9221009          break;
     
    9431030  tprintf (" -> new %d old %d delta %d\n", newsize, oldsize, newsize-oldsize);
    9441031  return newsize - oldsize;
    945  }
    946  
     1032}
     1033
    9471034/* This lets us test for the opcode type and the desired size in a
    9481035   switch statement.  */
     
    9781065     be the frag address.  */
    9791066  mypc = fragP->fr_address + (fragP->fr_opcode - fragP->fr_literal);
    980   tprintf("\033[32mmypc: 0x%x\033[0m\n", (int)mypc);
     1067  tprintf ("\033[32mmypc: 0x%x\033[0m\n", (int)mypc);
    9811068
    9821069  /* Try to get the target address.  If we fail here, we just use the
    9831070     largest format.  */
    9841071  if (rl78_frag_fix_value (fragP, segment, 0, & addr0,
    985                          fragP->tc_frag_data->relax[ri].type != RL78_RELAX_BRANCH, 0))
     1072                           fragP->tc_frag_data->relax[ri].type != RL78_RELAX_BRANCH, 0))
    9861073    {
    9871074      /* We don't know the target address.  */
     
    10131100          disp -= 3;
    10141101          op[2] = disp;
     1102          reloc_type = keep_reloc ? BFD_RELOC_8_PCREL : BFD_RELOC_NONE;
    10151103          break;
    10161104
     
    10301118          disp -= 4;
    10311119          op[3] = disp;
     1120          reloc_type = keep_reloc ? BFD_RELOC_8_PCREL : BFD_RELOC_NONE;
    10321121          break;
    10331122
     
    10471136          disp -= 4;
    10481137          op[3] = disp;
     1138          reloc_type = keep_reloc ? BFD_RELOC_8_PCREL : BFD_RELOC_NONE;
    10491139          break;
    10501140
     
    10641154          disp -= 2;
    10651155          op[1] = disp;
     1156          reloc_type = keep_reloc ? BFD_RELOC_8_PCREL : BFD_RELOC_NONE;
    10661157          break;
    10671158
     
    10811172          disp -= 3;
    10821173          op[2] = disp;
     1174          reloc_type = keep_reloc ? BFD_RELOC_8_PCREL : BFD_RELOC_NONE;
    10831175          break;
    10841176
     
    10951187          break;
    10961188
     1189        case OPCODE (OT_sk, 2): /* SK<cond> - no change */
     1190          reloc_type = keep_reloc ? BFD_RELOC_16_PCREL : BFD_RELOC_NONE;
     1191          break;
     1192
    10971193        default:
    1098           fprintf(stderr, "Missed case %d %d at 0x%lx\n",
    1099                   rl78_opcode_type (fragP->fr_opcode), fragP->fr_subtype, mypc);
    1100           abort ();
    1101          
     1194          reloc_type = fix ? fix->fx_r_type : BFD_RELOC_NONE;
     1195          break;
    11021196        }
    11031197      break;
     
    11671261    }
    11681262
     1263  if (fixp->fx_r_type == BFD_RELOC_RL78_RELAX && !linkrelax)
     1264    {
     1265      reloc[0] = NULL;
     1266      return reloc;
     1267    }
     1268
    11691269  if (fixp->fx_subsy
    11701270      && S_GET_SEGMENT (fixp->fx_subsy) == absolute_section)
     
    11741274    }
    11751275
    1176   reloc[0]                = (arelent *) xmalloc (sizeof (arelent));
    1177   reloc[0]->sym_ptr_ptr   = (asymbol **) xmalloc (sizeof (asymbol *));
     1276  reloc[0]                = XNEW (arelent);
     1277  reloc[0]->sym_ptr_ptr   = XNEW (asymbol *);
    11781278  * reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
    11791279  reloc[0]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
     
    11871287
    11881288#define OPX(REL,SYM,ADD)                                                        \
    1189   reloc[rp]                = (arelent *) xmalloc (sizeof (arelent));            \
    1190   reloc[rp]->sym_ptr_ptr   = (asymbol **) xmalloc (sizeof (asymbol *));         \
     1289  reloc[rp]                = XNEW (arelent);            \
     1290  reloc[rp]->sym_ptr_ptr   = XNEW (asymbol *);          \
    11911291  reloc[rp]->howto         = bfd_reloc_type_lookup (stdoutput, REL);            \
    11921292  reloc[rp]->addend        = ADD;                                               \
     
    11951295  reloc[++rp] = NULL
    11961296#define OPSYM(SYM) OPX(BFD_RELOC_RL78_SYM, SYM, 0)
    1197 #define OPIMM(IMM) OPX(BFD_RELOC_RL78_SYM, abs_symbol.bsym, IMM)
     1297
     1298  /* FIXME: We cannot do the normal thing for an immediate value reloc,
     1299     ie creating a RL78_SYM reloc in the *ABS* section with an offset
     1300     equal to the immediate value we want to store.  This fails because
     1301     the reloc processing in bfd_perform_relocation and bfd_install_relocation
     1302     will short circuit such relocs and never pass them on to the special
     1303     reloc processing code.  So instead we create a RL78_SYM reloc against
     1304     the __rl78_abs__ symbol and arrange for the linker scripts to place
     1305     this symbol at address 0.  */
     1306#define OPIMM(IMM) OPX (BFD_RELOC_RL78_SYM, symbol_get_bfdsym (rl78_abs_sym), IMM)
     1307
    11981308#define OP(OP) OPX(BFD_RELOC_RL78_##OP, *reloc[0]->sym_ptr_ptr, 0)
    11991309#define SYM0() reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RL78_SYM)
     
    13181428  unsigned long val;
    13191429
     1430  /* We always defer overflow checks for these to the linker, as it
     1431     needs to do PLT stuff.  */
     1432  if (f->fx_r_type == BFD_RELOC_RL78_CODE)
     1433    f->fx_no_overflow = 1;
     1434
    13201435  if (f->fx_addsy && S_FORCE_RELOC (f->fx_addsy, 1))
    13211436    return;
     
    13261441  val = (unsigned long) * t;
    13271442
     1443  if (f->fx_addsy == NULL)
     1444    f->fx_done = 1;
     1445
    13281446  switch (f->fx_r_type)
    13291447    {
     
    13321450
    13331451    case BFD_RELOC_RL78_RELAX:
    1334       f->fx_done = 1;
     1452      f->fx_done = 0;
    13351453      break;
    13361454
     
    13421460      /* Fall through.  */
    13431461    case BFD_RELOC_8:
     1462    case BFD_RELOC_RL78_SADDR: /* We need to store the 8 LSB, but this works.  */
    13441463      op[0] = val;
    13451464      break;
     
    14021521    }
    14031522
    1404   if (f->fx_addsy == NULL)
    1405     f->fx_done = 1;
    14061523}
    14071524
     
    14101527{
    14111528  int align = bfd_get_section_alignment (stdoutput, segment);
    1412   return ((size + (1 << align) - 1) & (-1 << align));
    1413 }
     1529  return ((size + (1 << align) - 1) & -(1 << align));
     1530}
Note: See TracChangeset for help on using the changeset viewer.