* [PATCH] Don't allow pc-rel relocations for J* instructions.
@ 2016-04-04 15:24 Claudiu Zissulescu
2016-04-05 14:09 ` Nick Clifton
0 siblings, 1 reply; 3+ messages in thread
From: Claudiu Zissulescu @ 2016-04-04 15:24 UTC (permalink / raw)
To: binutils; +Cc: Claudiu.Zissulescu, Francois.Bedard
This is a small patch that throws an error if one tries to use a branch instruction with a pc-relative relocation.
Ok to apply?
Claudiu
gas/
2016-03-31 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.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
---
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 +++++++
4 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 gas/testsuite/gas/arc/relocs-errors.d
create mode 100644 gas/testsuite/gas/arc/relocs-errors.err
create mode 100644 gas/testsuite/gas/arc/relocs-errors.s
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
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Don't allow pc-rel relocations for J* instructions.
2016-04-04 15:24 [PATCH] Don't allow pc-rel relocations for J* instructions Claudiu Zissulescu
@ 2016-04-05 14:09 ` Nick Clifton
2016-04-05 14:27 ` Claudiu Zissulescu
0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2016-04-05 14:09 UTC (permalink / raw)
To: Claudiu Zissulescu, binutils; +Cc: Francois.Bedard
Hi Claudiu,
> gas/
> 2016-03-31 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.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] Don't allow pc-rel relocations for J* instructions.
2016-04-05 14:09 ` Nick Clifton
@ 2016-04-05 14:27 ` Claudiu Zissulescu
0 siblings, 0 replies; 3+ messages in thread
From: Claudiu Zissulescu @ 2016-04-05 14:27 UTC (permalink / raw)
To: Nick Clifton, binutils; +Cc: Francois.Bedard
Hi Nick,
Thank you for your review, patch committed.
Claudiu
> > gas/
> > 2016-03-31 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.
>
> Approved - please apply.
>
> Cheers
> Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-05 14:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-04 15:24 [PATCH] Don't allow pc-rel relocations for J* instructions Claudiu Zissulescu
2016-04-05 14:09 ` Nick Clifton
2016-04-05 14:27 ` Claudiu Zissulescu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).