This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [ARC] Don't allow pc-rel relocations for J* instructions.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6ec1f28285f0a24587f7b5935e6d3fd4011fbb01

commit 6ec1f28285f0a24587f7b5935e6d3fd4011fbb01
Author: Claudiu Zissulescu <claziss@synopsys.com>
Date:   Tue Apr 5 16:22:19 2016 +0200

    [ARC] Don't allow pc-rel relocations for J* instructions.
    
    gas/
    2016-04-05  Claudiu Zissulescu  <claziss@synopsys.com>
    
            * config/tc-arc.c (assemble_insn): Prohibit pc-rel relocations for
            JUMP instructions type.
            * testsuite/gas/arc/relocs-errors.d: New file.
            * testsuite/gas/arc/relocs-errors.err: Likewise.
            * testsuite/gas/arc/relocs-errors.s: Likewise.

Diff:
---
 gas/ChangeLog                           | 8 ++++++++
 gas/config/tc-arc.c                     | 6 +++++-
 gas/testsuite/gas/arc/relocs-errors.d   | 1 +
 gas/testsuite/gas/arc/relocs-errors.err | 7 +++++++
 gas/testsuite/gas/arc/relocs-errors.s   | 7 +++++++
 5 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 7c1c6a0..0f4d58f 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2016-04-05  Claudiu Zissulescu  <claziss@synopsys.com>
+
+        * config/tc-arc.c (assemble_insn): Prohibit pc-rel relocations for
+	JUMP instructions type.
+        * testsuite/gas/arc/relocs-errors.d: New file.
+        * testsuite/gas/arc/relocs-errors.err: Likewise.
+        * testsuite/gas/arc/relocs-errors.s: Likewise.
+
 2016-04-04  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR gas/19498
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index 4f9c336..40643ad 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -3363,6 +3363,10 @@ assemble_insn (const struct arc_opcode *opcode,
 	  switch (t->X_md)
 	    {
 	    case O_plt:
+	      if (opcode->class == JUMP)
+		as_bad_where (frag_now->fr_file, frag_now->fr_line,
+			      _("Unable to use @plt relocatio for insn %s"),
+			      opcode->name);
 	      needGOTSymbol = TRUE;
 	      reloc = find_reloc ("plt", opcode->name,
 				  pflags, nflg,
@@ -3376,7 +3380,7 @@ assemble_insn (const struct arc_opcode *opcode,
 	      break;
 	    case O_pcl:
 	      reloc = ARC_RELOC_TABLE (t->X_md)->reloc;
-	      if (ARC_SHORT (opcode->mask))
+	      if (ARC_SHORT (opcode->mask) || opcode->class == JUMP)
 		as_bad_where (frag_now->fr_file, frag_now->fr_line,
 			      _("Unable to use @pcl relocation for insn %s"),
 			      opcode->name);
diff --git a/gas/testsuite/gas/arc/relocs-errors.d b/gas/testsuite/gas/arc/relocs-errors.d
new file mode 100644
index 0000000..29373a7
--- /dev/null
+++ b/gas/testsuite/gas/arc/relocs-errors.d
@@ -0,0 +1 @@
+#error-output: relocs-errors.err
diff --git a/gas/testsuite/gas/arc/relocs-errors.err b/gas/testsuite/gas/arc/relocs-errors.err
new file mode 100644
index 0000000..3bafa15
--- /dev/null
+++ b/gas/testsuite/gas/arc/relocs-errors.err
@@ -0,0 +1,7 @@
+[^:]*: Assembler messages:
+[^:]*:1: Error: Unable to use @plt relocatio for insn j
+[^:]*:2: Error: Unable to use @plt relocatio for insn jl
+[^:]*:3: Error: Unable to use @plt relocatio for insn j
+[^:]*:5: Error: Unable to use @pcl relocation for insn j
+[^:]*:6: Error: Unable to use @pcl relocation for insn jl
+[^:]*:7: Error: Unable to use @pcl relocation for insn j
diff --git a/gas/testsuite/gas/arc/relocs-errors.s b/gas/testsuite/gas/arc/relocs-errors.s
new file mode 100644
index 0000000..8e963a0
--- /dev/null
+++ b/gas/testsuite/gas/arc/relocs-errors.s
@@ -0,0 +1,7 @@
+	j    sym@plt
+	jl   sym@plt
+	jeq  sym@plt
+
+	j    sym@pcl
+	jl   sym@pcl
+	jeq  sym@pcl


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]