Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
RISC-V/GAS: Improve handling of invalid relocs
Browse files Browse the repository at this point in the history
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 <[email protected]>

	* config/tc-riscv.c (md_apply_fix): Report TLS relocations against
	constants.  Report disallowed symbol subtractions.
  • Loading branch information
aswaterman authored and palmer-dabbelt committed Jan 9, 2017
1 parent 8dcba69 commit f1d775f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gas/config/tc-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit f1d775f

Please sign in to comment.