This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 4/5] RISC-V/GAS: Improve handling of invalid relocs
- From: Palmer Dabbelt <palmer at dabbelt dot com>
- To: binutils at sourceware dot org
- Cc: Andrew Waterman <andrew at sifive dot com>
- Cc: amorda at gmail dot com
- Date: Sun, 1 Jan 2017 18:24:52 -0800
- Subject: [PATCH 4/5] RISC-V/GAS: Improve handling of invalid relocs
- Authentication-results: sourceware.org; auth=none
- References: <20170102022453.25556-1-palmer@dabbelt.com>
From: Andrew Waterman <andrew@sifive.com>
TLS relocs against constants previously segfaulted, and illegal
symbol subtractions were silently ignored.
The previous behavior was to segfault.
gas/ChangeLog
2016-12-21 Andrew Waterman <andrew@sifive.com>
* config/tc-riscv.c (md_apply_fix): Report TLS relocations against
constants. Report disallowed symbol subtractions.
---
gas/config/tc-riscv.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 03db275..03c84e8 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1889,7 +1889,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:
@@ -2045,6 +2049,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)
{
--
2.10.2