aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog12
-rw-r--r--gas/config/tc-xtensa.c51
-rw-r--r--gas/testsuite/ChangeLog8
-rw-r--r--gas/testsuite/gas/xtensa/all.exp1
-rw-r--r--gas/testsuite/gas/xtensa/err-pcrel.s6
-rw-r--r--gas/testsuite/gas/xtensa/pcrel.d19
-rw-r--r--gas/testsuite/gas/xtensa/pcrel.s9
-rw-r--r--gas/testsuite/gas/xtensa/xtensa-err.exp30
8 files changed, 118 insertions, 18 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index ba26d2d..f16ae72 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,15 @@
+2007-12-07 Bob Wilson <bob.wilson@acm.org>
+
+ * config/tc-xtensa.c (O_pcrel): Define.
+ (suffix_relocs): Add pcrel suffix.
+ (md_pseudo_table): Add 4byte and 2byte directives.
+ (xtensa_elf_cons): Pass correct pcrel argument to fix_new_exp.
+ (xg_assemble_literal): Likewise. Check for O_pcrel.
+ (expression_maybe_register): Reorganize. Handle BFD_RELOC_32_PCREL.
+ (xg_valid_literal_expression): Allow O_pcrel.
+ (md_pcrel_from, md_apply_fix): Handle BFD_RELOC_32_PCREL.
+ (tc_gen_reloc): Fix punctuation in error message.
+
2007-12-06 Bob Wilson <bob.wilson@acm.org>
* config/tc-xtensa.c (xg_force_frag_space): Delete.
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 66ff380..5599a1d 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -354,6 +354,7 @@ op_placement_info_table op_placement_table;
#define O_pltrel O_md1 /* like O_symbol but use a PLT reloc */
#define O_hi16 O_md2 /* use high 16 bits of symbolic value */
#define O_lo16 O_md3 /* use low 16 bits of symbolic value */
+#define O_pcrel O_md4 /* value is a PC-relative offset */
struct suffix_reloc_map
{
@@ -370,6 +371,7 @@ static struct suffix_reloc_map suffix_relocs[] =
SUFFIX_MAP ("l", BFD_RELOC_LO16, O_lo16),
SUFFIX_MAP ("h", BFD_RELOC_HI16, O_hi16),
SUFFIX_MAP ("plt", BFD_RELOC_XTENSA_PLT, O_pltrel),
+ SUFFIX_MAP ("pcrel", BFD_RELOC_32_PCREL, O_pcrel),
{ (char *) 0, 0, BFD_RELOC_UNUSED, 0 }
};
@@ -999,7 +1001,9 @@ const pseudo_typeS md_pseudo_table[] =
{ "frame", s_ignore, 0 }, /* Formerly used for STABS debugging. */
{ "long", xtensa_elf_cons, 4 },
{ "word", xtensa_elf_cons, 4 },
+ { "4byte", xtensa_elf_cons, 4 },
{ "short", xtensa_elf_cons, 2 },
+ { "2byte", xtensa_elf_cons, 2 },
{ "begin", xtensa_begin_directive, 0 },
{ "end", xtensa_end_directive, 0 },
{ "literal", xtensa_literal_pseudo, 0 },
@@ -1550,7 +1554,7 @@ xtensa_elf_cons (int nbytes)
char *p = frag_more ((int) nbytes);
xtensa_set_frag_assembly_state (frag_now);
fix_new_exp (frag_now, p - frag_now->fr_literal,
- nbytes, &exp, 0, reloc);
+ nbytes, &exp, reloc_howto->pc_relative, reloc);
}
}
else
@@ -1768,27 +1772,30 @@ expression_maybe_register (xtensa_opcode opc, int opnd, expressionS *tok)
&& ((reloc = xtensa_elf_suffix (&input_line_pointer, tok))
!= BFD_RELOC_NONE))
{
- if (reloc == BFD_RELOC_UNUSED)
+ switch (reloc)
{
- as_bad (_("unsupported relocation"));
- return;
- }
-
- if (tok->X_op == O_constant)
- {
- switch (reloc)
+ case BFD_RELOC_LO16:
+ if (tok->X_op == O_constant)
{
- case BFD_RELOC_LO16:
tok->X_add_number &= 0xffff;
return;
-
- case BFD_RELOC_HI16:
+ }
+ break;
+ case BFD_RELOC_HI16:
+ if (tok->X_op == O_constant)
+ {
tok->X_add_number = ((unsigned) tok->X_add_number) >> 16;
return;
-
- default:
- break;
}
+ break;
+ case BFD_RELOC_UNUSED:
+ as_bad (_("unsupported relocation"));
+ return;
+ case BFD_RELOC_32_PCREL:
+ as_bad (_("pcrel relocation not allowed in an instruction"));
+ return;
+ default:
+ break;
}
tok->X_op = map_suffix_reloc_to_operator (reloc);
}
@@ -3124,6 +3131,7 @@ xg_valid_literal_expression (const expressionS *exp)
case O_uminus:
case O_subtract:
case O_pltrel:
+ case O_pcrel:
return TRUE;
default:
return FALSE;
@@ -3992,6 +4000,7 @@ xg_assemble_literal (/* const */ TInsn *insn)
emit_state state;
symbolS *lit_sym = NULL;
bfd_reloc_code_real_type reloc;
+ bfd_boolean pcrel = FALSE;
char *p;
/* size = 4 for L32R. It could easily be larger when we move to
@@ -4030,6 +4039,9 @@ xg_assemble_literal (/* const */ TInsn *insn)
switch (emit_val->X_op)
{
+ case O_pcrel:
+ pcrel = TRUE;
+ /* fall through */
case O_pltrel:
p = frag_more (litsize);
xtensa_set_frag_assembly_state (frag_now);
@@ -4039,7 +4051,7 @@ xg_assemble_literal (/* const */ TInsn *insn)
else
emit_val->X_op = O_constant;
fix_new_exp (frag_now, p - frag_now->fr_literal,
- litsize, emit_val, 0, reloc);
+ litsize, emit_val, pcrel, reloc);
break;
default:
@@ -5430,6 +5442,9 @@ md_pcrel_from (fixS *fixP)
if (fixP->fx_r_type == BFD_RELOC_XTENSA_ASM_EXPAND)
return 0;
+ if (fixP->fx_r_type == BFD_RELOC_32_PCREL)
+ return addr;
+
if (!insnbuf)
{
insnbuf = xtensa_insnbuf_alloc (isa);
@@ -5604,7 +5619,6 @@ xtensa_symbol_new_hook (symbolS *sym)
}
-
void
md_apply_fix (fixS *fixP, valueT *valP, segT seg)
{
@@ -5620,6 +5634,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
switch (fixP->fx_r_type)
{
+ case BFD_RELOC_32_PCREL:
case BFD_RELOC_32:
case BFD_RELOC_16:
case BFD_RELOC_8:
@@ -5786,7 +5801,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
}
if (!fixp->fx_pcrel != !reloc->howto->pc_relative)
- as_fatal (_("internal error? cannot generate `%s' relocation"),
+ as_fatal (_("internal error; cannot generate `%s' relocation"),
bfd_get_reloc_code_name (fixp->fx_r_type));
return reloc;
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 3f06e0e..aa5e20c 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2007-12-07 Bob Wilson <bob.wilson@acm.org>
+
+ * gas/xtensa/all.exp: Run new pcrel test.
+ * gas/xtensa/err-pcrel.s: New.
+ * gas/xtensa/pcrel.d: New.
+ * gas/xtensa/pcrel.s: New.
+ * gas/xtensa/xtensa-err.exp: New.
+
2007-11-30 Bob Wilson <bob.wilson@acm.org>
* gas/elf/elf.exp: Disable ehopt test for Xtensa.
diff --git a/gas/testsuite/gas/xtensa/all.exp b/gas/testsuite/gas/xtensa/all.exp
index 89b3cdf..d4b2493 100644
--- a/gas/testsuite/gas/xtensa/all.exp
+++ b/gas/testsuite/gas/xtensa/all.exp
@@ -79,6 +79,7 @@ if [istarget xtensa*-*-*] then {
if [all_ones $x1] then { pass $testname } else { fail $testname }
run_dump_test "short_branch_offset"
+ run_dump_test "pcrel"
}
if [info exists errorInfo] then {
diff --git a/gas/testsuite/gas/xtensa/err-pcrel.s b/gas/testsuite/gas/xtensa/err-pcrel.s
new file mode 100644
index 0000000..5b32538
--- /dev/null
+++ b/gas/testsuite/gas/xtensa/err-pcrel.s
@@ -0,0 +1,6 @@
+# { dg-do assemble { target xtensa*-*-* } }
+ .text
+ .global foo
+ beqz a2, 1f@pcrel # { dg-error "relocation not allowed" "" }
+1: movi a2, foo@pcrel # { dg-error "relocation not allowed" "" }
+foo: .short foo@pcrel # { dg-error "relocations do not fit" "" }
diff --git a/gas/testsuite/gas/xtensa/pcrel.d b/gas/testsuite/gas/xtensa/pcrel.d
new file mode 100644
index 0000000..0e5f757
--- /dev/null
+++ b/gas/testsuite/gas/xtensa/pcrel.d
@@ -0,0 +1,19 @@
+#as:
+#objdump: -r -j .literal -j .text
+#name: pc-relative relocs
+
+.*: +file format .*xtensa.*
+
+RELOCATION RECORDS FOR \[\.literal\]:
+OFFSET TYPE VALUE
+00000000 R_XTENSA_32_PCREL foo
+
+
+RELOCATION RECORDS FOR \[\.text\]:
+OFFSET TYPE VALUE
+00000003 R_XTENSA_SLOT0_OP \.literal
+00000006 R_XTENSA_32_PCREL foo
+0000000a R_XTENSA_32_PCREL \.text\+0x00000003
+0000000e R_XTENSA_32_PCREL \.text\+0x00000006
+
+
diff --git a/gas/testsuite/gas/xtensa/pcrel.s b/gas/testsuite/gas/xtensa/pcrel.s
new file mode 100644
index 0000000..5e832b4
--- /dev/null
+++ b/gas/testsuite/gas/xtensa/pcrel.s
@@ -0,0 +1,9 @@
+ .text
+ .align 4
+ .global foo
+foo: entry sp, 16
+ .literal .Lit0, foo@pcrel
+1: l32r a2, .Lit0
+.L2: .word foo@pcrel
+ .long 1b@pcrel
+ .4byte .L2@pcrel
diff --git a/gas/testsuite/gas/xtensa/xtensa-err.exp b/gas/testsuite/gas/xtensa/xtensa-err.exp
new file mode 100644
index 0000000..60ffd36
--- /dev/null
+++ b/gas/testsuite/gas/xtensa/xtensa-err.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2001, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+if { ! [istarget "xtensa*-*-*"] } {
+ return
+}
+
+proc run_xtensa_err_tests { } {
+ global srcdir subdir runtests
+
+ load_lib gas-dg.exp
+ dg-init
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s]] "" ""
+ dg-finish
+}
+
+run_xtensa_err_tests