/* tc-sh.c -- Assemble code for the Renesas / SuperH SH
- Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
- Free Software Foundation, Inc.
+ Copyright (C) 1993-2015 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
/* Add expression EXP of SIZE bytes to offset OFF of fragment FRAG. */
void
-sh_cons_fix_new (fragS *frag, int off, int size, expressionS *exp)
+sh_cons_fix_new (fragS *frag, int off, int size, expressionS *exp,
+ bfd_reloc_code_real_type r_type)
{
- bfd_reloc_code_real_type r_type = BFD_RELOC_UNUSED;
+ r_type = BFD_RELOC_UNUSED;
if (sh_check_fixup (exp, &r_type))
as_bad (_("Invalid PIC expression."));
r_type = BFD_RELOC_32;
break;
-#ifdef HAVE_SH64
case 8:
r_type = BFD_RELOC_64;
break;
-#endif
default:
goto error;
/* Clobbers input_line_pointer, checks end-of-line. */
/* NBYTES 1=.byte, 2=.word, 4=.long */
static void
-sh_elf_cons (register int nbytes)
+sh_elf_cons (int nbytes)
{
expressionS exp;
symbol_get_frag (r->X_add_symbol),
&frag_off))
{
- l->X_add_number -= r->X_add_number;
- l->X_add_number -= frag_off / OCTETS_PER_BYTE;
- l->X_add_number += (S_GET_VALUE (l->X_add_symbol)
- - S_GET_VALUE (r->X_add_symbol));
+ offsetT symval_diff = S_GET_VALUE (l->X_add_symbol)
+ - S_GET_VALUE (r->X_add_symbol);
+ subtract_from_result (l, r->X_add_number, r->X_extrabit);
+ subtract_from_result (l, frag_off / OCTETS_PER_BYTE, 0);
+ add_to_result (l, symval_diff, symval_diff < 0);
l->X_op = O_constant;
l->X_add_symbol = 0;
return 1;
the other symbol. We have to adjust the relocation type here. */
if (fixP->fx_pcrel)
{
+#ifndef HAVE_SH64
+ /* Safeguard; this must not occur for non-sh64 configurations. */
+ gas_assert (fixP->fx_r_type != BFD_RELOC_64);
+#endif
+
switch (fixP->fx_r_type)
{
default:
buf[highbyte] |= (val >> 8) & 0xf;
break;
+#ifndef HAVE_SH64
+ case BFD_RELOC_64:
+ apply_full_field_fix (fixP, buf, *valP, 8);
+ break;
+#endif
+
case BFD_RELOC_32:
case BFD_RELOC_32_PCREL:
apply_full_field_fix (fixP, buf, val, 4);
if (SWITCH_TABLE (fixp))
{
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
- rel->addend = 0;
+ rel->addend = rel->address - S_GET_VALUE(fixp->fx_subsy);
if (r_type == BFD_RELOC_16)
r_type = BFD_RELOC_SH_SWITCH16;
else if (r_type == BFD_RELOC_8)