#include <stdio.h>
#include "as.h"
-#include "subsegs.h"
+#include "subsegs.h"
#include "symcat.h"
#include "opcodes/xstormy16-desc.h"
#include "opcodes/xstormy16-opc.h"
FILE * stream;
{
fprintf (stream, _(" XSTORMY16 specific command line options:\n"));
-}
+}
/* The target specific pseudo-ops which we support. */
const pseudo_typeS md_pseudo_table[] =
md_begin ()
{
/* Initialize the `cgen' interface. */
-
+
/* Set the machine number and endian. */
gas_cgen_cpu_desc = xstormy16_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0,
CGEN_CPU_OPEN_ENDIAN,
insn.insn = xstormy16_cgen_assemble_insn
(gas_cgen_cpu_desc, str, & insn.fields, insn.buffer, & errmsg);
-
+
if (!insn.insn)
{
as_bad (errmsg);
CGEN_FIELDS_BITSIZE (& insn.fields), 0, NULL);
}
-void
+void
md_operand (e)
expressionS * e;
{
fix = fix_new_exp (f, where, nbytes, exp, 0, code);
}
-/* Called while parsing an instruction to create a fixup.
+/* Called while parsing an instruction to create a fixup.
Create BFD_RELOC_XSTORMY16_FPTR16 relocations. */
fixS *
{
fixS *fixP;
operatorT op = exp->X_op;
-
+
if (op == O_fptr_symbol)
exp->X_op = O_symbol;
{
/* No assembler relaxation is defined (or necessary) for this port. */
abort ();
-}
+}
/* *fragP has been relaxed to its final size, and now needs to have
the bytes inside it modified to conform to the new size.
case XSTORMY16_OPERAND_IMM12:
case XSTORMY16_OPERAND_HMEM8:
return BFD_RELOC_NONE;
-
+
case XSTORMY16_OPERAND_IMM8:
case XSTORMY16_OPERAND_LMEM8:
return fixP->fx_pcrel ? BFD_RELOC_8_PCREL : BFD_RELOC_8;
-
+
case XSTORMY16_OPERAND_IMM16:
fixP->fx_where += 2;
return fixP->fx_pcrel ? BFD_RELOC_16_PCREL : BFD_RELOC_16;
case XSTORMY16_OPERAND_REL12:
fixP->fx_where += 2;
- /* Fall through... */
+ /* Fall through... */
case XSTORMY16_OPERAND_REL12A:
fixP->fx_pcrel = 1;
return BFD_RELOC_XSTORMY16_REL_12;
return 1;
default:
- return 0;
+ break;
}
+
+ return S_FORCE_RELOC (fix->fx_addsy);
}
/* Return true if a relocation against a symbol may be replaced with
xstormy16_fix_adjustable (fixP)
fixS * fixP;
{
- if (fixP->fx_addsy == NULL)
- return 1;
-
- /* Prevent all adjustments to global symbols. */
- if (S_IS_EXTERN (fixP->fx_addsy))
- return 0;
-
- if (S_IS_WEAK (fixP->fx_addsy))
- return 0;
-
/* We need the symbol name for the VTABLE entries. */
- if ( fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
+ if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
|| fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
return 0;
- return ! xstormy16_force_relocation (fixP);
+ if (fixP->fx_r_type == BFD_RELOC_XSTORMY16_FPTR16)
+ return 0;
+
+ return 1;
}
/* This is a copy of gas_cgen_md_apply_fix3, with some enhancements to
segT seg ATTRIBUTE_UNUSED;
{
char *where = fixP->fx_frag->fr_literal + fixP->fx_where;
- valueT value;
+ valueT value = *valueP;
/* Canonical name, since used a lot. */
CGEN_CPU_DESC cd = gas_cgen_cpu_desc;
default:
break;
}
-
- /* FIXME FIXME FIXME: The value we are passed in *valuep includes
- the symbol values. Since we are using BFD_ASSEMBLER, if we are
- doing this relocation the code in write.c is going to call
- bfd_install_relocation, which is also going to use the symbol
- value. That means that if the reloc is fully resolved we want to
- use *valuep since bfd_install_relocation is not being used.
- However, if the reloc is not fully resolved we do not want to use
- *valuep, and must use fx_offset instead. However, if the reloc
- is PC relative, we do want to use *valuep since it includes the
- result of md_pcrel_from. This is confusing. */
if (fixP->fx_addsy == (symbolS *) NULL)
- {
- value = *valueP;
- fixP->fx_done = 1;
- }
- else if (fixP->fx_pcrel)
- value = *valueP;
- else
- {
- value = fixP->fx_offset;
- if (fixP->fx_subsy != (symbolS *) NULL)
- {
- if (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)
- value -= S_GET_VALUE (fixP->fx_subsy);
- else
- {
- /* We don't actually support subtracting a symbol. */
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("expression too complex"));
- }
- }
- }
+ fixP->fx_done = 1;
+
+ /* We don't actually support subtracting a symbol. */
+ if (fixP->fx_subsy != (symbolS *) NULL)
+ as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
{
/* This is a RELA port. Thus, it does not need to store a
value if it is going to make a reloc. What's more, when
assembling a line like
-
+
.byte global-0x7f00
-
+
we'll get a spurious error message if we try to stuff 0x7f00 into
the byte. */
if (! fixP->fx_done)
md_number_to_chars (litP, (valueT) (*wordP--), sizeof (LITTLENUM_TYPE));
litP += sizeof (LITTLENUM_TYPE);
}
-
+
return 0;
}