This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_28-branch] RISC-V/GAS: Improve handling of invalid relocs
- From: Palmer Dabbelt <palmer at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 17 Jan 2017 05:34:35 -0000
- Subject: [binutils-gdb/binutils-2_28-branch] RISC-V/GAS: Improve handling of invalid relocs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2398b2bad9812c7bada17563805ee61f72c8cc87
commit 2398b2bad9812c7bada17563805ee61f72c8cc87
Author: Andrew Waterman <andrew@sifive.com>
Date: Wed Dec 21 12:47:13 2016 -0800
RISC-V/GAS: Improve handling of invalid relocs
TLS relocs against constants previously segfaulted, and illegal
symbol subtractions were silently ignored.
The previous behavior was to segfault.
gas/ChangeLog
2017-01-09 Andrew Waterman <andrew@sifive.com>
* config/tc-riscv.c (md_apply_fix): Report TLS relocations against
constants. Report disallowed symbol subtractions.
Diff:
---
gas/ChangeLog | 6 ++++++
gas/config/tc-riscv.c | 10 +++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 266f22e..80857d7 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -11,6 +11,12 @@
* testsuite/gas/i386/x86-64-avx512_vpopcntdqd.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_vpopcntdqd.s: Ditto.
+2017-01-09 Andrew Waterman <andrew@sifive.com>
+
+ * config/tc-riscv.c (append_insn): Don't eagerly apply relocations
+ against constants.
+ (md_apply_fix): Mark relocations against constants as "done."
+
2017-01-09 Palmer Dabbelt <palmer@dabbelt.com>
Kito Cheng <kito.cheng@gmail.com>
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 3fe9e63..bf870e6 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1879,7 +1879,11 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
case BFD_RELOC_RISCV_TLS_GD_HI20:
case BFD_RELOC_RISCV_TLS_DTPREL32:
case BFD_RELOC_RISCV_TLS_DTPREL64:
- S_SET_THREAD_LOCAL (fixP->fx_addsy);
+ if (fixP->fx_addsy != NULL)
+ S_SET_THREAD_LOCAL (fixP->fx_addsy);
+ else
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("TLS relocation against a constant"));
break;
case BFD_RELOC_64:
@@ -2035,6 +2039,10 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
as_fatal (_("internal error: bad relocation #%d"), fixP->fx_r_type);
}
+ if (fixP->fx_subsy != NULL)
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("unsupported symbol subtraction"));
+
/* Add an R_RISCV_RELAX reloc if the reloc is relaxable. */
if (relaxable && fixP->fx_tcbit && fixP->fx_addsy != NULL)
{