RISC-V/GAS: Improve handling of invalid relocs
[deliverable/binutils-gdb.git] / gas / config / tc-riscv.c
index b8da6ce390be2d07edd6fda93cb2c8dedd531914..3f09101108e21fba07c44586214e22994a5c26b2 100644 (file)
@@ -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)
     {
This page took 0.023017 seconds and 4 git commands to generate.