2001-12-08 04:46:03 +01:00
|
|
|
|
/* tc-xstormy16.c -- Assembler for the Sanyo XSTORMY16.
|
2014-03-05 12:46:15 +01:00
|
|
|
|
Copyright (C) 2000-2014 Free Software Foundation, Inc.
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
This file is part of GAS, the GNU Assembler.
|
|
|
|
|
|
|
|
|
|
GAS is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-03 13:01:12 +02:00
|
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
GAS is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with GAS; see the file COPYING. If not, write to
|
2005-05-05 11:13:19 +02:00
|
|
|
|
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
#include "as.h"
|
2002-05-11 11:53:52 +02:00
|
|
|
|
#include "subsegs.h"
|
2001-12-08 04:46:03 +01:00
|
|
|
|
#include "symcat.h"
|
|
|
|
|
#include "opcodes/xstormy16-desc.h"
|
|
|
|
|
#include "opcodes/xstormy16-opc.h"
|
|
|
|
|
#include "cgen.h"
|
|
|
|
|
|
|
|
|
|
/* Structure to hold all of the different components describing
|
|
|
|
|
an individual instruction. */
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const CGEN_INSN * insn;
|
|
|
|
|
const CGEN_INSN * orig_insn;
|
|
|
|
|
CGEN_FIELDS fields;
|
|
|
|
|
#if CGEN_INT_INSN_P
|
|
|
|
|
CGEN_INSN_INT buffer [1];
|
|
|
|
|
#define INSN_VALUE(buf) (*(buf))
|
|
|
|
|
#else
|
|
|
|
|
unsigned char buffer [CGEN_MAX_INSN_SIZE];
|
|
|
|
|
#define INSN_VALUE(buf) (buf)
|
|
|
|
|
#endif
|
|
|
|
|
char * addr;
|
|
|
|
|
fragS * frag;
|
|
|
|
|
int num_fixups;
|
|
|
|
|
fixS * fixups [GAS_CGEN_MAX_FIXUPS];
|
|
|
|
|
int indices [MAX_OPERAND_INSTANCES];
|
|
|
|
|
}
|
|
|
|
|
xstormy16_insn;
|
|
|
|
|
|
|
|
|
|
const char comment_chars[] = ";";
|
|
|
|
|
const char line_comment_chars[] = "#";
|
|
|
|
|
const char line_separator_chars[] = "|";
|
|
|
|
|
const char EXP_CHARS[] = "eE";
|
|
|
|
|
const char FLT_CHARS[] = "dD";
|
|
|
|
|
|
|
|
|
|
#define O_fptr_symbol (O_max + 1)
|
|
|
|
|
|
|
|
|
|
#define XSTORMY16_SHORTOPTS ""
|
|
|
|
|
const char * md_shortopts = XSTORMY16_SHORTOPTS;
|
|
|
|
|
|
|
|
|
|
struct option md_longopts[] =
|
|
|
|
|
{
|
|
|
|
|
{NULL, no_argument, NULL, 0}
|
|
|
|
|
};
|
|
|
|
|
size_t md_longopts_size = sizeof (md_longopts);
|
|
|
|
|
|
|
|
|
|
int
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_parse_option (int c ATTRIBUTE_UNUSED,
|
|
|
|
|
char * arg ATTRIBUTE_UNUSED)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_show_usage (FILE * stream)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
fprintf (stream, _(" XSTORMY16 specific command line options:\n"));
|
2002-05-11 11:53:52 +02:00
|
|
|
|
}
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
/* The target specific pseudo-ops which we support. */
|
|
|
|
|
const pseudo_typeS md_pseudo_table[] =
|
|
|
|
|
{
|
|
|
|
|
{ "word", cons, 4 },
|
|
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_begin (void)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
/* Initialize the `cgen' interface. */
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
/* Set the machine number and endian. */
|
|
|
|
|
gas_cgen_cpu_desc = xstormy16_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0,
|
|
|
|
|
CGEN_CPU_OPEN_ENDIAN,
|
|
|
|
|
CGEN_ENDIAN_LITTLE,
|
|
|
|
|
CGEN_CPU_OPEN_END);
|
|
|
|
|
xstormy16_cgen_init_asm (gas_cgen_cpu_desc);
|
|
|
|
|
|
|
|
|
|
/* This is a callback from cgen to gas to parse operands. */
|
|
|
|
|
cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-12 11:09:11 +02:00
|
|
|
|
static bfd_boolean skipping_fptr = FALSE;
|
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
void
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_assemble (char * str)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
xstormy16_insn insn;
|
|
|
|
|
char * errmsg;
|
|
|
|
|
|
2003-05-12 11:09:11 +02:00
|
|
|
|
/* Make sure that if we had an erroneous input line which triggered
|
|
|
|
|
the skipping_fptr boolean that it does not affect following lines. */
|
|
|
|
|
skipping_fptr = FALSE;
|
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
/* Initialize GAS's cgen interface for a new instruction. */
|
|
|
|
|
gas_cgen_init_parse ();
|
|
|
|
|
|
|
|
|
|
insn.insn = xstormy16_cgen_assemble_insn
|
|
|
|
|
(gas_cgen_cpu_desc, str, & insn.fields, insn.buffer, & errmsg);
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
if (!insn.insn)
|
|
|
|
|
{
|
2009-07-24 13:45:01 +02:00
|
|
|
|
as_bad ("%s", errmsg);
|
2001-12-08 04:46:03 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Doesn't really matter what we pass for RELAX_P here. */
|
|
|
|
|
gas_cgen_finish_insn (insn.insn, insn.buffer,
|
|
|
|
|
CGEN_FIELDS_BITSIZE (& insn.fields), 0, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-11 11:53:52 +02:00
|
|
|
|
void
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_operand (expressionS * e)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
if (*input_line_pointer != '@')
|
|
|
|
|
return;
|
|
|
|
|
|
2003-05-20 13:58:20 +02:00
|
|
|
|
if (strncmp (input_line_pointer + 1, "fptr", 4) == 0)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
input_line_pointer += 5;
|
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
|
if (*input_line_pointer != '(')
|
|
|
|
|
{
|
2009-07-24 13:45:01 +02:00
|
|
|
|
as_bad (_("Expected '('"));
|
2001-12-08 04:46:03 +01:00
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
input_line_pointer++;
|
|
|
|
|
|
|
|
|
|
expression (e);
|
|
|
|
|
|
|
|
|
|
if (*input_line_pointer != ')')
|
|
|
|
|
{
|
2009-07-24 13:45:01 +02:00
|
|
|
|
as_bad (_("Missing ')'"));
|
2001-12-08 04:46:03 +01:00
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
input_line_pointer++;
|
2003-05-12 11:09:11 +02:00
|
|
|
|
SKIP_WHITESPACE ();
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
if (e->X_op != O_symbol)
|
2009-07-24 13:45:01 +02:00
|
|
|
|
as_bad (_("Not a symbolic expression"));
|
2003-05-12 11:09:11 +02:00
|
|
|
|
else if (* input_line_pointer == '-')
|
|
|
|
|
/* We are computing the difference of two function pointers
|
|
|
|
|
like this:
|
|
|
|
|
|
|
|
|
|
.hword @fptr (foo) - @fptr (bar)
|
|
|
|
|
|
|
|
|
|
In this situation we do not want to generate O_fptr_symbol
|
|
|
|
|
operands because the result is an absolute value, not a
|
|
|
|
|
function pointer.
|
|
|
|
|
|
|
|
|
|
We need to make the check here, rather than when the fixup
|
|
|
|
|
is generated as the function names (foo & bar in the above
|
|
|
|
|
example) might be local symbols and we want the expression
|
|
|
|
|
to be evaluated now. This kind of thing can happen when
|
|
|
|
|
gcc is generating computed gotos. */
|
|
|
|
|
skipping_fptr = TRUE;
|
|
|
|
|
else if (skipping_fptr)
|
|
|
|
|
skipping_fptr = FALSE;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
else
|
|
|
|
|
e->X_op = O_fptr_symbol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
err:
|
|
|
|
|
ignore_rest_of_line ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Called while parsing data to create a fixup.
|
|
|
|
|
Create BFD_RELOC_XSTORMY16_FPTR16 relocations. */
|
|
|
|
|
|
|
|
|
|
void
|
2005-03-24 21:40:28 +01:00
|
|
|
|
xstormy16_cons_fix_new (fragS *f,
|
|
|
|
|
int where,
|
|
|
|
|
int nbytes,
|
gas TC_PARSE_CONS_EXPRESSION communication with TC_CONS_FIX_NEW
A number of targets pass extra information from TC_PARSE_CONS_EXPRESSION
to TC_CONS_FIX_NEW via static variables. That's OK, but not best
practice. tc-ppc.c goes further in implementing its own replacement
for cons(), because the generic one doesn't allow relocation modifiers
on constants. This patch fixes both of these warts.
* gas/config/tc-alpha.h (TC_CONS_FIX_NEW): Add RELOC parameter.
* gas/config/tc-arc.c (arc_cons_fix_new): Add reloc parameter.
* gas/config/tc-arc.h (arc_cons_fix_new): Update prototype.
(TC_CONS_FIX_NEW): Add RELOC parameter.
* gas/config/tc-arm.c (cons_fix_new_arm): Similarly
* gas/config/tc-arm.h (cons_fix_new_arm, TC_CONS_FIX_NEW): Similarly.
* gas/config/tc-cr16.c (cr16_cons_fix_new): Similarly.
* gas/config/tc-cr16.h (cr16_cons_fix_new, TC_CONS_FIX_NEW): Similarly.
* gas/config/tc-crx.h (TC_CONS_FIX_NEW): Similarly.
* gas/config/tc-m32c.c (m32c_cons_fix_new): Similarly.
* gas/config/tc-m32c.h (m32c_cons_fix_new, TC_CONS_FIX_NEW): Similarly.
* gas/config/tc-mn10300.c (mn10300_cons_fix_new): Similarly.
* gas/config/tc-mn10300.h (mn10300_cons_fix_new, TC_CONS_FIX_NEW):
Similarly.
* gas/config/tc-ns32k.c (cons_fix_new_ns32k): Similarly.
* gas/config/tc-ns32k.h (cons_fix_new_ns32k): Similarly.
* gas/config/tc-pj.c (pj_cons_fix_new_pj): Similarly.
* gas/config/tc-pj.h (pj_cons_fix_new_pj, TC_CONS_FIX_NEW): Similarly.
* gas/config/tc-rx.c (rx_cons_fix_new): Similarly.
* gas/config/tc-rx.h (rx_cons_fix_new, TC_CONS_FIX_NEW): Similarly.
* gas/config/tc-sh.c (sh_cons_fix_new): Similarly.
* gas/config/tc-sh.h (sh_cons_fix_new, TC_CONS_FIX_NEW): Similarly.
* gas/config/tc-tic54x.c (tic54x_cons_fix_new): Similarly.
* gas/config/tc-tic54x.h (tic54x_cons_fix_new, TC_CONS_FIX_NEW):
Similarly.
* gas/config/tc-tic6x.c (tic6x_cons_fix_new): Similarly.
* gas/config/tc-tic6x.h (tic6x_cons_fix_new, TC_CONS_FIX_NEW):
Similarly.
* gas/config/tc-arc.c (arc_parse_cons_expression): Return reloc.
* gas/config/tc-arc.h (arc_parse_cons_expression): Update proto.
* gas/config/tc-avr.c (exp_mod_data): Make global.
(pexp_mod_data): Delete.
(avr_parse_cons_expression): Return exp_mod_data pointer.
(avr_cons_fix_new): Add exp_mod_data_t pointer param.
(exp_mod_data_t): Move typedef..
* gas/config/tc-avr.h: ..to here.
(exp_mod_data): Declare.
(TC_PARSE_CONS_RETURN_TYPE, TC_PARSE_CONS_RETURN_NONE): Define.
(avr_parse_cons_expression, avr_cons_fix_new): Update prototype.
(TC_CONS_FIX_NEW): Update.
* gas/config/tc-hppa.c (hppa_field_selector): Delete static var.
(cons_fix_new_hppa): Add hppa_field_selector param.
(fix_new_hppa): Adjust.
(parse_cons_expression_hppa): Return field selector.
* gas/config/tc-hppa.h (parse_cons_expression_hppa): Update proto.
(cons_fix_new_hppa): Likewise.
(TC_PARSE_CONS_RETURN_TYPE, TC_PARSE_CONS_RETURN_NONE): Define.
* gas/config/tc-i386.c (got_reloc): Delete static var.
(x86_cons_fix_new): Add reloc param.
(x86_cons): Return got reloc.
* gas/config/tc-i386.h (x86_cons, x86_cons_fix_new): Update proto.
(TC_CONS_FIX_NEW): Add RELOC param.
* gas/config/tc-ia64.c (ia64_cons_fix_new): Add reloc param. Adjust
calls.
* gas/config/tc-ia64.h (ia64_cons_fix_new): Update prototype.
(TC_CONS_FIX_NEW): Add reloc param.
* gas/config/tc-microblaze.c (parse_cons_expression_microblaze):
Return reloc.
(cons_fix_new_microblaze): Add reloc param.
* gas/config/tc-microblaze.h: Formatting.
(parse_cons_expression_microblaze): Update proto.
(cons_fix_new_microblaze): Likewise.
* gas/config/tc-nios2.c (nios2_tls_ldo_reloc): Delete static var.
(nios2_cons): Return ldo reloc.
(nios2_cons_fix_new): Delete.
* gas/config/tc-nios2.h (nios2_cons): Update prototype.
(nios2_cons_fix_new, TC_CONS_FIX_NEW): Delete.
* gas/config/tc-ppc.c (md_pseudo_table): Remove quad, long, word,
short. Make llong use cons.
(ppc_elf_suffix): Return BFD_RELOC_NONE rather than BFD_RELOC_UNUSED.
(ppc_elf_cons): Delete.
(ppc_elf_parse_cons): New function.
(ppc_elf_validate_fix): Don't check for BFD_RELOC_UNUSED.
(md_assemble): Use BFD_RELOC_NONE rather than BFD_RELOC_UNUSED.
* gas/config/tc-ppc.h (TC_PARSE_CONS_EXPRESSION): Define
(ppc_elf_parse_cons): Declare.
* gas/config/tc-sparc.c (sparc_cons_special_reloc): Delete static var.
(sparc_cons): Return reloc specifier.
(cons_fix_new_sparc): Add reloc specifier param.
(sparc_cfi_emit_pcrel_expr): Use emit_expr_with_reloc.
* gas/config/tc-sparc.h (TC_PARSE_CONS_RETURN_TYPE): Define.
(TC_PARSE_CONS_RETURN_NONE): Define.
(sparc_cons, cons_fix_new_sparc): Update prototype.
* gas/config/tc-v850.c (hold_cons_reloc): Delete static var.
(v850_reloc_prefix): Use BFD_RELOC_NONE rather than BFD_RELOC_UNUSED.
(md_assemble): Likewise.
(parse_cons_expression_v850): Return reloc.
(cons_fix_new_v850): Add reloc parameter.
* gas/config/tc-v850.h (parse_cons_expression_v850): Update proto.
(cons_fix_new_v850): Likewise.
* gas/config/tc-vax.c (vax_cons_special_reloc): Delete static var.
(vax_cons): Return reloc.
(vax_cons_fix_new): Add reloc parameter.
* gas/config/tc-vax.h (vax_cons, vax_cons_fix_new): Update proto.
* gas/config/tc-xstormy16.c (xstormy16_cons_fix_new): Add reloc param.
* gas/config/tc-xstormy16.h (xstormy16_cons_fix_new): Update proto.
* gas/dwarf2dbg.c (TC_PARSE_CONS_RETURN_NONE): Provide default.
(emit_fixed_inc_line_addr): Adjust exmit_expr_fix calls.
* gas/read.c (TC_PARSE_CONS_EXPRESSION): Return value.
(do_parse_cons_expression): Adjust.
(cons_worker): Pass return value from TC_PARSE_CONS_EXPRESSION
to emit_expr_with_reloc.
(emit_expr_with_reloc): New function handling reloc, mostly
extracted from..
(emit_expr): ..here.
(emit_expr_fix): Add reloc param. Adjust TC_CONS_FIX_NEW invocation.
Handle reloc.
(parse_mri_cons): Convert to ISO.
* gas/read.h (TC_PARSE_CONS_RETURN_TYPE): Define.
(TC_PARSE_CONS_RETURN_NONE): Define.
(emit_expr_with_reloc): Declare.
(emit_expr_fix): Update prototype.
* gas/write.c (write_object_file): Update TC_CONS_FIX_NEW invocation.
2014-04-08 07:08:22 +02:00
|
|
|
|
expressionS *exp,
|
|
|
|
|
bfd_reloc_code_real_type code)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
if (exp->X_op == O_fptr_symbol)
|
|
|
|
|
{
|
2004-10-18 10:02:25 +02:00
|
|
|
|
switch (nbytes)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
2004-10-18 10:02:25 +02:00
|
|
|
|
case 4:
|
|
|
|
|
/* This can happen when gcc is generating debug output.
|
|
|
|
|
For example it can create a stab with the address of
|
|
|
|
|
a function:
|
|
|
|
|
|
|
|
|
|
.stabs "foo:F(0,21)",36,0,0,@fptr(foo)
|
|
|
|
|
|
|
|
|
|
Since this does not involve switching code pages, we
|
|
|
|
|
just allow the reloc to be generated without any
|
|
|
|
|
@fptr behaviour. */
|
|
|
|
|
exp->X_op = O_symbol;
|
|
|
|
|
code = BFD_RELOC_32;
|
|
|
|
|
break;
|
2005-03-24 21:40:28 +01:00
|
|
|
|
|
2004-10-18 10:02:25 +02:00
|
|
|
|
case 2:
|
|
|
|
|
exp->X_op = O_symbol;
|
|
|
|
|
code = BFD_RELOC_XSTORMY16_FPTR16;
|
|
|
|
|
break;
|
2005-03-24 21:40:28 +01:00
|
|
|
|
|
2004-10-18 10:02:25 +02:00
|
|
|
|
default:
|
2009-07-24 13:45:01 +02:00
|
|
|
|
as_bad (_("unsupported fptr fixup size %d"), nbytes);
|
2001-12-08 04:46:03 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (nbytes == 1)
|
|
|
|
|
code = BFD_RELOC_8;
|
|
|
|
|
else if (nbytes == 2)
|
|
|
|
|
code = BFD_RELOC_16;
|
|
|
|
|
else if (nbytes == 4)
|
|
|
|
|
code = BFD_RELOC_32;
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-07-24 13:45:01 +02:00
|
|
|
|
as_bad (_("unsupported fixup size %d"), nbytes);
|
2001-12-08 04:46:03 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
* config/obj-evax.h (S_SET_OTHER, S_SET_TYPE, S_SET_DESC): Don't define.
* config/tc-crx.c (gettrap): Constify arg.
(handle_LoadStor, get_cinv_parameters): Likewise.
(getreg_image): Fix enum warning
(md_assemble): Restore input line char.
* config/tc-hppa.c (tc_gen_reloc): Fix enum warning.
* config/tc-i960.c (mem_fmt): Rename var to fix shadow warning.
* config/tc-sh.c (sh_fdpic): Only define when OBJ_ELF.
(build_Mytes): Fix build failure for non-elf targets.
* config/tc-tic4x.c (tic4x_eval): Restore terminator char.
* config/tc-xtensa.c (xtensa_end_directive): Fix switch enum warning.
* cgen.c (gas_cgen_md_apply_fix): Avoid set but unused warning.
* ecoff.c (add_ecoff_symbol): Likewise.
* itbl-ops.c (append_insns_as_macros): Likewise.
* listing.c (debugging_pseudo): Likewise.
* read.c (s_mri_common, stringer): Likewise.
* config/obj-coff.c (coff_frob_section): Likewise.
* config/tc-alpha.c (emit_ldgp, s_alpha_proc): Likewise.
* config/tc-arm.c (my_get_expression): Likewise.
* config/tc-hppa.c (process_exit, pa_type_args): Likewise.
* config/tc-m32c.c (md_assemble): Likewise.
* config/tc-microblaze.c (md_convert_frag): Likewise.
* config/tc-mips.c (s_change_section): Likewise.
* config/tc-mt.c (mt_fix_adjustable): Likewise.
* config/tc-xtensa.c (xtensa_literal_pseudo): Likewise.
* config/obj-aout.c (obj_aout_frob_symbol): Delete set but otherwise
unused vars.
* config/tc-alpha.c (load_expression): Likewise.
(s_alpha_rdata, s_alpha_section, s_alpha_prologue): Likewise.
* config/tc-arm.c (parse_neon_el_struct_list): Likewise.
* config/tc-avr.c (extract_word): Likewise.
* config/tc-cris.c (cris_get_expression): Likewise.
* config/tc-d30v.c (build_insn, find_format): Likewise.
* config/tc-dlx.c (machine_ip): Likewise.
* config/tc-hppa.c (pa_get_absolute_expression): Likewise.
* config/tc-i370.c (md_assemble): Likewise.
* config/tc-i960.c (brtab_emit): Likewise.
* config/tc-iq2000.c (s_iq2000_ent): Likewise.
* config/tc-m32c.c (md_convert_frag): Likewise.
* config/tc-m68hc11.c (fixup24, build_jump_insn): Likewise.
(md_estimate_size_before_relax, md_apply_fix): Likewise.
* config/tc-m68k.c (md_show_usage): Likewise.
* config/tc-microblaze.c (microblaze_s_lcomm): Likewise.
* config/tc-mips.c (s_mips_end): Likewise.
* config/tc-mmix.c (mmix_byte, mmix_cons): Likewise.
* config/tc-mn10300.c (md_assemble): Likewise.
* config/tc-msp430.c (extract_word): Likewise.
* config/tc-mt.c (md_assemble): Likewise.
* config/tc-or32.c (machine_ip): Likewise.
* config/tc-pj.c (md_apply_fix): Likewise.
* config/tc-s390.c (md_gather_operands): Likewise.
* config/tc-sh.c (sh_cons_align): Likewise.
* config/tc-sparc.c (sparc_cons_align): Likewise.
* config/tc-tic4x.c (tic4x_sect): Likewise.
* config/tc-tic54x.c (tic54x_stringer): Likewise.
* config/tc-vax.c (vip_op): Likewise.
* config/tc-xstormy16.c (xstormy16_cons_fix_new): Likewise.
* config/tc-xtensa.c (md_assemble): Likewise.
(xtensa_fix_short_loop_frags, convert_frag_immed): Likewise.
(xtensa_move_literals): Likewise.
2010-06-28 16:06:57 +02:00
|
|
|
|
fix_new_exp (f, where, nbytes, exp, 0, code);
|
2001-12-08 04:46:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-11 11:53:52 +02:00
|
|
|
|
/* Called while parsing an instruction to create a fixup.
|
2001-12-08 04:46:03 +01:00
|
|
|
|
Create BFD_RELOC_XSTORMY16_FPTR16 relocations. */
|
|
|
|
|
|
|
|
|
|
fixS *
|
2005-03-24 21:40:28 +01:00
|
|
|
|
xstormy16_cgen_record_fixup_exp (fragS * frag,
|
|
|
|
|
int where,
|
|
|
|
|
const CGEN_INSN * insn,
|
|
|
|
|
int length,
|
|
|
|
|
const CGEN_OPERAND * operand,
|
|
|
|
|
int opinfo,
|
|
|
|
|
expressionS * exp)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
fixS *fixP;
|
|
|
|
|
operatorT op = exp->X_op;
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
if (op == O_fptr_symbol)
|
|
|
|
|
exp->X_op = O_symbol;
|
|
|
|
|
|
|
|
|
|
fixP = gas_cgen_record_fixup_exp (frag, where, insn, length,
|
|
|
|
|
operand, opinfo, exp);
|
|
|
|
|
|
|
|
|
|
if (op == O_fptr_symbol)
|
|
|
|
|
{
|
|
|
|
|
if (operand->type != XSTORMY16_OPERAND_IMM16)
|
2009-07-24 13:45:01 +02:00
|
|
|
|
as_bad (_("unsupported fptr fixup"));
|
2001-12-08 04:46:03 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fixP->fx_r_type = BFD_RELOC_XSTORMY16_FPTR16;
|
|
|
|
|
fixP->fx_where += 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fixP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
valueT
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_section_align (segT segment, valueT size)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
int align = bfd_get_section_alignment (stdoutput, segment);
|
2005-03-24 21:40:28 +01:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
return ((size + (1 << align) - 1) & (-1 << align));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
symbolS *
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return an initial guess of the length by which a fragment must grow to
|
|
|
|
|
hold a branch to reach its destination.
|
|
|
|
|
Also updates fr_type/fr_subtype as necessary.
|
|
|
|
|
|
|
|
|
|
Called just before doing relaxation.
|
|
|
|
|
Any symbol that is now undefined will not become defined.
|
|
|
|
|
The guess for fr_var is ACTUALLY the growth beyond fr_fix.
|
|
|
|
|
Whatever we do to grow fr_fix or fr_var contributes to our returned value.
|
|
|
|
|
Although it may not be explicit in the frag, pretend fr_var starts with a
|
|
|
|
|
0 value. */
|
|
|
|
|
|
|
|
|
|
int
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED,
|
|
|
|
|
segT segment ATTRIBUTE_UNUSED)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
/* No assembler relaxation is defined (or necessary) for this port. */
|
|
|
|
|
abort ();
|
2002-05-11 11:53:52 +02:00
|
|
|
|
}
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
/* *fragP has been relaxed to its final size, and now needs to have
|
|
|
|
|
the bytes inside it modified to conform to the new size.
|
|
|
|
|
|
|
|
|
|
Called after relaxation is finished.
|
|
|
|
|
fragP->fr_type == rs_machine_dependent.
|
|
|
|
|
fragP->fr_subtype is the subtype of what the address relaxed to. */
|
|
|
|
|
|
|
|
|
|
void
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
|
|
|
|
|
segT sec ATTRIBUTE_UNUSED,
|
|
|
|
|
fragS * fragP ATTRIBUTE_UNUSED)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
/* No assembler relaxation is defined (or necessary) for this port. */
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Functions concerning relocs. */
|
|
|
|
|
|
|
|
|
|
/* The location from which a PC relative jump should be calculated,
|
|
|
|
|
given a PC relative reloc. */
|
|
|
|
|
|
|
|
|
|
long
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_pcrel_from_section (fixS * fixP, segT sec)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
2005-02-17 14:46:05 +01:00
|
|
|
|
if ((fixP->fx_addsy != (symbolS *) NULL
|
|
|
|
|
&& (! S_IS_DEFINED (fixP->fx_addsy)
|
|
|
|
|
|| S_GET_SEGMENT (fixP->fx_addsy) != sec))
|
|
|
|
|
|| xstormy16_force_relocation (fixP))
|
2003-05-22 10:57:32 +02:00
|
|
|
|
/* The symbol is undefined,
|
|
|
|
|
or it is defined but not in this section,
|
|
|
|
|
or the relocation will be relative to this symbol not the section symbol.
|
|
|
|
|
Let the linker figure it out. */
|
|
|
|
|
return 0;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
return fixP->fx_frag->fr_address + fixP->fx_where;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the bfd reloc type for OPERAND of INSN at fixup FIXP.
|
|
|
|
|
Returns BFD_RELOC_NONE if no reloc type can be found.
|
|
|
|
|
*FIXP may be modified if desired. */
|
|
|
|
|
|
|
|
|
|
bfd_reloc_code_real_type
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_cgen_lookup_reloc (const CGEN_INSN * insn ATTRIBUTE_UNUSED,
|
|
|
|
|
const CGEN_OPERAND * operand,
|
|
|
|
|
fixS * fixP)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
switch (operand->type)
|
|
|
|
|
{
|
|
|
|
|
case XSTORMY16_OPERAND_IMM2:
|
|
|
|
|
case XSTORMY16_OPERAND_IMM3:
|
|
|
|
|
case XSTORMY16_OPERAND_IMM3B:
|
|
|
|
|
case XSTORMY16_OPERAND_IMM4:
|
|
|
|
|
case XSTORMY16_OPERAND_HMEM8:
|
|
|
|
|
return BFD_RELOC_NONE;
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2002-12-20 22:14:20 +01:00
|
|
|
|
case XSTORMY16_OPERAND_IMM12:
|
|
|
|
|
fixP->fx_where += 2;
|
|
|
|
|
return BFD_RELOC_XSTORMY16_12;
|
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
case XSTORMY16_OPERAND_IMM8:
|
|
|
|
|
case XSTORMY16_OPERAND_LMEM8:
|
|
|
|
|
return fixP->fx_pcrel ? BFD_RELOC_8_PCREL : BFD_RELOC_8;
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
case XSTORMY16_OPERAND_IMM16:
|
2002-12-17 04:55:46 +01:00
|
|
|
|
/* This might have been processed at parse time. */
|
2001-12-08 04:46:03 +01:00
|
|
|
|
fixP->fx_where += 2;
|
2002-12-17 04:55:46 +01:00
|
|
|
|
if (fixP->fx_cgen.opinfo && fixP->fx_cgen.opinfo != BFD_RELOC_NONE)
|
|
|
|
|
return fixP->fx_cgen.opinfo;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
return fixP->fx_pcrel ? BFD_RELOC_16_PCREL : BFD_RELOC_16;
|
|
|
|
|
|
|
|
|
|
case XSTORMY16_OPERAND_ABS24:
|
|
|
|
|
return BFD_RELOC_XSTORMY16_24;
|
|
|
|
|
|
|
|
|
|
case XSTORMY16_OPERAND_REL8_4:
|
2003-01-07 22:27:58 +01:00
|
|
|
|
fixP->fx_addnumber -= 2;
|
|
|
|
|
case XSTORMY16_OPERAND_REL8_2:
|
|
|
|
|
fixP->fx_addnumber -= 2;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
fixP->fx_pcrel = 1;
|
|
|
|
|
return BFD_RELOC_8_PCREL;
|
|
|
|
|
|
|
|
|
|
case XSTORMY16_OPERAND_REL12:
|
|
|
|
|
fixP->fx_where += 2;
|
2002-05-11 11:53:52 +02:00
|
|
|
|
/* Fall through... */
|
2001-12-08 04:46:03 +01:00
|
|
|
|
case XSTORMY16_OPERAND_REL12A:
|
2003-01-07 22:27:58 +01:00
|
|
|
|
fixP->fx_addnumber -= 2;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
fixP->fx_pcrel = 1;
|
|
|
|
|
return BFD_RELOC_XSTORMY16_REL_12;
|
|
|
|
|
|
|
|
|
|
default : /* avoid -Wall warning */
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See whether we need to force a relocation into the output file.
|
|
|
|
|
This is used to force out switch and PC relative relocations when
|
|
|
|
|
relaxing. */
|
|
|
|
|
|
|
|
|
|
int
|
2005-03-24 21:40:28 +01:00
|
|
|
|
xstormy16_force_relocation (fixS * fix)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
2003-01-23 13:51:05 +01:00
|
|
|
|
if (fix->fx_r_type == BFD_RELOC_XSTORMY16_FPTR16)
|
|
|
|
|
return 1;
|
2002-09-05 02:01:18 +02:00
|
|
|
|
|
2003-01-23 13:51:05 +01:00
|
|
|
|
return generic_force_reloc (fix);
|
2001-12-08 04:46:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true if a relocation against a symbol may be replaced with
|
|
|
|
|
a relocation against section+offset. */
|
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean
|
2005-03-24 21:40:28 +01:00
|
|
|
|
xstormy16_fix_adjustable (fixS * fixP)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
2002-01-15 12:58:45 +01:00
|
|
|
|
/* We need the symbol name for the VTABLE entries. */
|
2002-09-05 02:01:18 +02:00
|
|
|
|
if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
|
2002-01-15 12:58:45 +01:00
|
|
|
|
|| fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
|
2005-03-24 21:40:28 +01:00
|
|
|
|
return FALSE;
|
2002-01-15 12:58:45 +01:00
|
|
|
|
|
2002-09-05 02:01:18 +02:00
|
|
|
|
if (fixP->fx_r_type == BFD_RELOC_XSTORMY16_FPTR16)
|
2005-03-24 21:40:28 +01:00
|
|
|
|
return FALSE;
|
2002-09-05 02:01:18 +02:00
|
|
|
|
|
2005-03-24 21:40:28 +01:00
|
|
|
|
return TRUE;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
gas:
* cgen.c, cgen.h, tc.h, write.c, config/obj-coff.c
* config/tc-a29k.c, config/tc-alpha.c, config/tc-alpha.h
* config/tc-arc.c, config/tc-arc.h, config/tc-arm.c
* config/tc-arm.h, config/tc-avr.c, config/tc-avr.h
* config/tc-cris.c, config/tc-crx.c, config/tc-d10v.c
* config/tc-d10v.h, config/tc-d30v.c, config/tc-d30v.h
* config/tc-dlx.c, config/tc-dlx.h, config/tc-fr30.h
* config/tc-frv.c, config/tc-frv.h, config/tc-h8300.c
* config/tc-h8500.c, config/tc-hppa.c, config/tc-hppa.h
* config/tc-i370.c, config/tc-i370.h, config/tc-i386.c
* config/tc-i386.h, config/tc-i860.c, config/tc-i860.h
* config/tc-i960.c, config/tc-i960.h, config/tc-ia64.c
* config/tc-ip2k.c, config/tc-ip2k.h, config/tc-iq2000.c
* config/tc-iq2000.h, config/tc-m32r.c, config/tc-m32r.h
* config/tc-m68hc11.c, config/tc-m68hc11.h, config/tc-m68k.c
* config/tc-m68k.h, config/tc-m88k.c, config/tc-maxq.c
* config/tc-mcore.c, config/tc-mcore.h, config/tc-mips.c
* config/tc-mips.h, config/tc-mmix.c, config/tc-mn10200.c
* config/tc-mn10300.c, config/tc-msp430.c, config/tc-ns32k.c
* config/tc-openrisc.h, config/tc-or32.c, config/tc-or32.h
* config/tc-pdp11.c, config/tc-pj.c, config/tc-pj.h
* config/tc-ppc.c, config/tc-ppc.h, config/tc-s390.c
* config/tc-s390.h, config/tc-sh64.c, config/tc-sh.c
* config/tc-sh.h, config/tc-sparc.c, config/tc-sparc.h
* config/tc-tahoe.c, config/tc-tic30.c, config/tc-tic4x.c
* config/tc-tic54x.c, config/tc-tic80.c, config/tc-v850.c
* config/tc-v850.h, config/tc-vax.c, config/tc-vax.h
* config/tc-w65.c, config/tc-xstormy16.c, config/tc-xstormy16.h
* config/tc-xtensa.c, config/tc-z8k.c:
Replace all instances of the string "_apply_fix3" with
"_apply_fix".
* po/POTFILES.in, po/gas.pot: Regenerate.
bfd:
* coff-i386.c: Change md_apply_fix3 to md_apply_fix in comment.
cgen:
* doc/porting.texi: Change all mention of md_apply_fix3 and
gas_cgen_md_apply_fix3 to md_apply_fix and gas_cgen_md_apply_fix
respectively.
2005-06-07 19:54:22 +02:00
|
|
|
|
/* This is a copy of gas_cgen_md_apply_fix, with some enhancements to
|
2001-12-08 04:46:03 +01:00
|
|
|
|
do various things that would not be valid for all ports. */
|
|
|
|
|
|
|
|
|
|
void
|
gas:
* cgen.c, cgen.h, tc.h, write.c, config/obj-coff.c
* config/tc-a29k.c, config/tc-alpha.c, config/tc-alpha.h
* config/tc-arc.c, config/tc-arc.h, config/tc-arm.c
* config/tc-arm.h, config/tc-avr.c, config/tc-avr.h
* config/tc-cris.c, config/tc-crx.c, config/tc-d10v.c
* config/tc-d10v.h, config/tc-d30v.c, config/tc-d30v.h
* config/tc-dlx.c, config/tc-dlx.h, config/tc-fr30.h
* config/tc-frv.c, config/tc-frv.h, config/tc-h8300.c
* config/tc-h8500.c, config/tc-hppa.c, config/tc-hppa.h
* config/tc-i370.c, config/tc-i370.h, config/tc-i386.c
* config/tc-i386.h, config/tc-i860.c, config/tc-i860.h
* config/tc-i960.c, config/tc-i960.h, config/tc-ia64.c
* config/tc-ip2k.c, config/tc-ip2k.h, config/tc-iq2000.c
* config/tc-iq2000.h, config/tc-m32r.c, config/tc-m32r.h
* config/tc-m68hc11.c, config/tc-m68hc11.h, config/tc-m68k.c
* config/tc-m68k.h, config/tc-m88k.c, config/tc-maxq.c
* config/tc-mcore.c, config/tc-mcore.h, config/tc-mips.c
* config/tc-mips.h, config/tc-mmix.c, config/tc-mn10200.c
* config/tc-mn10300.c, config/tc-msp430.c, config/tc-ns32k.c
* config/tc-openrisc.h, config/tc-or32.c, config/tc-or32.h
* config/tc-pdp11.c, config/tc-pj.c, config/tc-pj.h
* config/tc-ppc.c, config/tc-ppc.h, config/tc-s390.c
* config/tc-s390.h, config/tc-sh64.c, config/tc-sh.c
* config/tc-sh.h, config/tc-sparc.c, config/tc-sparc.h
* config/tc-tahoe.c, config/tc-tic30.c, config/tc-tic4x.c
* config/tc-tic54x.c, config/tc-tic80.c, config/tc-v850.c
* config/tc-v850.h, config/tc-vax.c, config/tc-vax.h
* config/tc-w65.c, config/tc-xstormy16.c, config/tc-xstormy16.h
* config/tc-xtensa.c, config/tc-z8k.c:
Replace all instances of the string "_apply_fix3" with
"_apply_fix".
* po/POTFILES.in, po/gas.pot: Regenerate.
bfd:
* coff-i386.c: Change md_apply_fix3 to md_apply_fix in comment.
cgen:
* doc/porting.texi: Change all mention of md_apply_fix3 and
gas_cgen_md_apply_fix3 to md_apply_fix and gas_cgen_md_apply_fix
respectively.
2005-06-07 19:54:22 +02:00
|
|
|
|
xstormy16_md_apply_fix (fixS * fixP,
|
2005-03-24 21:40:28 +01:00
|
|
|
|
valueT * valueP,
|
|
|
|
|
segT seg ATTRIBUTE_UNUSED)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
char *where = fixP->fx_frag->fr_literal + fixP->fx_where;
|
2002-09-05 02:01:18 +02:00
|
|
|
|
valueT value = *valueP;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
/* Canonical name, since used a lot. */
|
|
|
|
|
CGEN_CPU_DESC cd = gas_cgen_cpu_desc;
|
|
|
|
|
|
2003-01-07 22:27:58 +01:00
|
|
|
|
/* md_cgen_lookup_reloc() will adjust this to compensate for where
|
|
|
|
|
in the opcode the relocation happens, for pcrel relocations. We
|
|
|
|
|
have no other way of keeping track of what this offset needs to
|
|
|
|
|
be. */
|
|
|
|
|
fixP->fx_addnumber = 0;
|
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
/* This port has pc-relative relocs and DIFF_EXPR_OK defined, so
|
|
|
|
|
it must deal with turning a BFD_RELOC_{8,16,32,64} into a
|
|
|
|
|
BFD_RELOC_*_PCREL for the case of
|
|
|
|
|
|
2005-03-24 21:40:28 +01:00
|
|
|
|
.word something-. */
|
2001-12-08 04:46:03 +01:00
|
|
|
|
if (fixP->fx_pcrel)
|
|
|
|
|
switch (fixP->fx_r_type)
|
|
|
|
|
{
|
|
|
|
|
case BFD_RELOC_8:
|
|
|
|
|
fixP->fx_r_type = BFD_RELOC_8_PCREL;
|
|
|
|
|
break;
|
|
|
|
|
case BFD_RELOC_16:
|
|
|
|
|
fixP->fx_r_type = BFD_RELOC_16_PCREL;
|
|
|
|
|
break;
|
|
|
|
|
case BFD_RELOC_32:
|
|
|
|
|
fixP->fx_r_type = BFD_RELOC_32_PCREL;
|
|
|
|
|
break;
|
|
|
|
|
case BFD_RELOC_64:
|
|
|
|
|
fixP->fx_r_type = BFD_RELOC_64_PCREL;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
if (fixP->fx_addsy == (symbolS *) NULL)
|
2002-09-05 02:01:18 +02:00
|
|
|
|
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"));
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
int opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
|
|
|
|
|
const CGEN_OPERAND *operand = cgen_operand_lookup_by_num (cd, opindex);
|
|
|
|
|
const char *errmsg;
|
|
|
|
|
bfd_reloc_code_real_type reloc_type;
|
|
|
|
|
CGEN_FIELDS *fields = alloca (CGEN_CPU_SIZEOF_FIELDS (cd));
|
|
|
|
|
const CGEN_INSN *insn = fixP->fx_cgen.insn;
|
|
|
|
|
|
|
|
|
|
/* If the reloc has been fully resolved finish the operand here. */
|
|
|
|
|
/* FIXME: This duplicates the capabilities of code in BFD. */
|
|
|
|
|
if (fixP->fx_done)
|
|
|
|
|
{
|
|
|
|
|
CGEN_CPU_SET_FIELDS_BITSIZE (cd) (fields, CGEN_INSN_BITSIZE (insn));
|
|
|
|
|
CGEN_CPU_SET_VMA_OPERAND (cd) (cd, opindex, fields, (bfd_vma) value);
|
|
|
|
|
|
|
|
|
|
#if CGEN_INT_INSN_P
|
|
|
|
|
{
|
|
|
|
|
CGEN_INSN_INT insn_value =
|
2005-02-23 13:28:06 +01:00
|
|
|
|
cgen_get_insn_value (cd, (unsigned char *) where,
|
|
|
|
|
CGEN_INSN_BITSIZE (insn));
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
/* ??? 0 is passed for `pc'. */
|
|
|
|
|
errmsg = CGEN_CPU_INSERT_OPERAND (cd) (cd, opindex, fields,
|
|
|
|
|
&insn_value, (bfd_vma) 0);
|
2005-02-23 13:28:06 +01:00
|
|
|
|
cgen_put_insn_value (cd, (unsigned char *) where,
|
|
|
|
|
CGEN_INSN_BITSIZE (insn), insn_value);
|
2001-12-08 04:46:03 +01:00
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
/* ??? 0 is passed for `pc'. */
|
2005-02-23 13:28:06 +01:00
|
|
|
|
errmsg = CGEN_CPU_INSERT_OPERAND (cd) (cd, opindex, fields,
|
|
|
|
|
(unsigned char *) where,
|
2001-12-08 04:46:03 +01:00
|
|
|
|
(bfd_vma) 0);
|
|
|
|
|
#endif
|
|
|
|
|
if (errmsg)
|
|
|
|
|
as_bad_where (fixP->fx_file, fixP->fx_line, "%s", errmsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fixP->fx_done)
|
2002-01-15 12:58:45 +01:00
|
|
|
|
return;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
/* The operand isn't fully resolved. Determine a BFD reloc value
|
|
|
|
|
based on the operand information and leave it to
|
|
|
|
|
bfd_install_relocation. Note that this doesn't work when
|
2002-11-30 09:39:46 +01:00
|
|
|
|
!partial_inplace. */
|
2001-12-08 04:46:03 +01:00
|
|
|
|
|
|
|
|
|
reloc_type = md_cgen_lookup_reloc (insn, operand, fixP);
|
|
|
|
|
if (reloc_type != BFD_RELOC_NONE)
|
2005-03-24 21:40:28 +01:00
|
|
|
|
fixP->fx_r_type = reloc_type;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
as_bad_where (fixP->fx_file, fixP->fx_line,
|
|
|
|
|
_("unresolved expression that must be resolved"));
|
|
|
|
|
fixP->fx_done = 1;
|
2002-01-15 12:58:45 +01:00
|
|
|
|
return;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (fixP->fx_done)
|
|
|
|
|
{
|
|
|
|
|
/* We're finished with this fixup. Install it because
|
|
|
|
|
bfd_install_relocation won't be called to do it. */
|
|
|
|
|
switch (fixP->fx_r_type)
|
|
|
|
|
{
|
|
|
|
|
case BFD_RELOC_8:
|
|
|
|
|
md_number_to_chars (where, value, 1);
|
|
|
|
|
break;
|
|
|
|
|
case BFD_RELOC_16:
|
|
|
|
|
md_number_to_chars (where, value, 2);
|
|
|
|
|
break;
|
|
|
|
|
case BFD_RELOC_32:
|
|
|
|
|
md_number_to_chars (where, value, 4);
|
|
|
|
|
break;
|
|
|
|
|
case BFD_RELOC_64:
|
|
|
|
|
md_number_to_chars (where, value, 8);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
as_bad_where (fixP->fx_file, fixP->fx_line,
|
|
|
|
|
_("internal error: can't install fix for reloc type %d (`%s')"),
|
|
|
|
|
fixP->fx_r_type, bfd_get_reloc_code_name (fixP->fx_r_type));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* bfd_install_relocation will be called to finish things up. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
.byte global-0x7f00
|
2002-05-11 11:53:52 +02:00
|
|
|
|
|
2001-12-08 04:46:03 +01:00
|
|
|
|
we'll get a spurious error message if we try to stuff 0x7f00 into
|
|
|
|
|
the byte. */
|
|
|
|
|
if (! fixP->fx_done)
|
|
|
|
|
*valueP = 0;
|
|
|
|
|
|
|
|
|
|
/* Tuck `value' away for use by tc_gen_reloc.
|
|
|
|
|
See the comment describing fx_addnumber in write.h.
|
2003-05-22 10:57:32 +02:00
|
|
|
|
This field is misnamed (or misused :-). */
|
|
|
|
|
fixP->fx_addnumber += value;
|
2001-12-08 04:46:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Write a value out to the object file, using the appropriate endianness. */
|
|
|
|
|
|
|
|
|
|
void
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_number_to_chars (char * buf, valueT val, int n)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
|
|
|
|
number_to_chars_littleendian (buf, val, n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
2005-03-24 21:40:28 +01:00
|
|
|
|
md_atof (int type, char * litP, int * sizeP)
|
2001-12-08 04:46:03 +01:00
|
|
|
|
{
|
2007-10-17 18:45:56 +02:00
|
|
|
|
return ieee_md_atof (type, litP, sizeP, FALSE);
|
2001-12-08 04:46:03 +01:00
|
|
|
|
}
|