/* tc-mn10300.c -- Assembler code for the Matsushita 10300
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
int value;
};
-struct dwarf2_line_info debug_line;
-
/* Generic assembler global variables which must be defined by all
targets. */
static boolean other_register_name PARAMS ((expressionS *expressionP));
static void set_arch_mach PARAMS ((int));
+/* Set linkrelax here to avoid fixups in most sections. */
+int linkrelax = 1;
+
static int current_machine;
/* Fixups. */
/* The target specific pseudo-ops which we support. */
const pseudo_typeS md_pseudo_table[] =
{
- { "file", dwarf2_directive_file },
- { "loc", dwarf2_directive_loc },
+ { "file", dwarf2_directive_file, 0 },
+ { "loc", dwarf2_directive_loc, 0 },
{ "am30", set_arch_mach, AM30 },
{ "am33", set_arch_mach, AM33 },
{ "mn10300", set_arch_mach, MN103 },
int
md_parse_option (c, arg)
- int c;
- char *arg;
+ int c ATTRIBUTE_UNUSED;
+ char *arg ATTRIBUTE_UNUSED;
{
return 0;
}
symbolS *
md_undefined_symbol (name)
- char *name;
+ char *name ATTRIBUTE_UNUSED;
{
return 0;
}
void
md_convert_frag (abfd, sec, fragP)
- bfd *abfd;
+ bfd *abfd ATTRIBUTE_UNUSED;
asection *sec;
fragS *fragP;
{
op++;
}
- /* This is both a simplification (we don't have to write md_apply_fix)
- and support for future optimizations (branch shortening and similar
- stuff in the linker). */
- linkrelax = 1;
-
/* Set the default machine type. */
if (!bfd_set_arch_mach (stdoutput, bfd_arch_mn10300, MN103))
as_warn (_("could not set architecture and machine"));
}
}
- if (debug_type == DEBUG_DWARF2)
- {
- bfd_vma addr;
-
- /* First update the notion of the current source line. */
- dwarf2_where (&debug_line);
-
- /* We want the offset of the start of this instruction within the
- the current frag. */
- addr = frag_now->fr_address + frag_now_fix () - real_size;
-
- /* And record the information. */
- dwarf2_gen_line_info (addr, &debug_line);
- }
+ dwarf2_emit_insn (real_size);
}
/* If while processing a fixup, a reloc really needs to be created
arelent *
tc_gen_reloc (seg, fixp)
- asection *seg;
+ asection *seg ATTRIBUTE_UNUSED;
fixS *fixp;
{
arelent *reloc;
md_pcrel_from (fixp)
fixS *fixp;
{
- return fixp->fx_frag->fr_address;
-#if 0
if (fixp->fx_addsy != (symbolS *) NULL && !S_IS_DEFINED (fixp->fx_addsy))
{
/* The symbol is undefined. Let the linker figure it out. */
return 0;
}
return fixp->fx_frag->fr_address + fixp->fx_where;
-#endif
}
int
valueT *valuep;
segT seg;
{
- /* We shouldn't ever get here because linkrelax is nonzero. */
- abort ();
- fixp->fx_done = 1;
+ char *fixpos = fixp->fx_where + fixp->fx_frag->fr_literal;
+ int size = 0;
+ int value;
+
+ assert (fixp->fx_r_type < BFD_RELOC_UNUSED);
+
+ /* This should never happen. */
+ if (seg->flags & SEC_ALLOC)
+ abort ();
+
+ /* 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. */
+ if (fixp->fx_addsy == (symbolS *) NULL || fixp->fx_pcrel)
+ value = *valuep;
+ else
+ value = fixp->fx_offset;
+
+ /* If the fix is relative to a symbol which is not defined, or not
+ in the same segment as the fix, we cannot resolve it here. */
+ if (fixp->fx_addsy != NULL
+ && (! S_IS_DEFINED (fixp->fx_addsy)
+ || (S_GET_SEGMENT (fixp->fx_addsy) != seg)))
+ {
+ fixp->fx_done = 0;
+ return 0;
+ }
+
+ switch (fixp->fx_r_type)
+ {
+ case BFD_RELOC_8:
+ size = 1;
+ break;
+
+ case BFD_RELOC_16:
+ size = 2;
+ break;
+
+ case BFD_RELOC_32:
+ size = 4;
+ break;
+
+ case BFD_RELOC_VTABLE_INHERIT:
+ case BFD_RELOC_VTABLE_ENTRY:
+ fixp->fx_done = 0;
+ return 1;
+
+ case BFD_RELOC_NONE:
+ default:
+ as_bad_where (fixp->fx_file, fixp->fx_line,
+ _("Bad relocation fixup type (%d)"), fixp->fx_r_type);
+ }
+
+ md_number_to_chars (fixpos, value, size);
+
+ /* If a symbol remains, pass the fixup, as a reloc, onto the linker. */
+ if (fixp->fx_addsy == NULL)
+ fixp->fx_done = 1;
+
return 0;
}
+/* Return nonzero if the fixup in FIXP will require a relocation,
+ even it if appears that the fixup could be completely handled
+ within GAS. */
+
+int
+mn10300_force_relocation (fixp)
+ struct fix *fixp;
+{
+ if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT
+ || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
+ return 1;
+
+ return 0;
+}
+
+/* Return zero if the fixup in fixp should be left alone and not
+ adjusted. */
+
+boolean
+mn10300_fix_adjustable (fixp)
+ struct fix *fixp;
+{
+ /* Prevent all adjustments to global symbols. */
+ if (S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy))
+ return 0;
+
+ if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT
+ || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
+ return 0;
+
+ return 1;
+}
+
/* Insert an operand value into an instruction. */
static void
static unsigned long
check_operand (insn, operand, val)
- unsigned long insn;
+ unsigned long insn ATTRIBUTE_UNUSED;
const struct mn10300_operand *operand;
offsetT val;
{
current_machine = mach;
}
-
-void
-mn10300_finalize ()
-{
- if (debug_type == DEBUG_DWARF2)
- dwarf2_finish ();
-}