aboutsummaryrefslogtreecommitdiff
path: root/gas/write.c
diff options
context:
space:
mode:
Diffstat (limited to 'gas/write.c')
-rw-r--r--gas/write.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/gas/write.c b/gas/write.c
index 55c757d..1af81a7 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -54,26 +54,34 @@
(! SEG_NORMAL (SEG))
#endif
+#ifndef md_register_arithmetic
+# define md_register_arithmetic 1
+#endif
+
#ifndef TC_FORCE_RELOCATION_SUB_ABS
-#define TC_FORCE_RELOCATION_SUB_ABS(FIX) 0
+#define TC_FORCE_RELOCATION_SUB_ABS(FIX, SEG) \
+ (!md_register_arithmetic && (SEG) == reg_section)
#endif
#ifndef TC_FORCE_RELOCATION_SUB_LOCAL
#ifdef DIFF_EXPR_OK
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 0
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \
+ (!md_register_arithmetic && (SEG) == reg_section)
#else
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 1
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1
#endif
#endif
#ifndef TC_VALIDATE_FIX_SUB
#ifdef UNDEFINED_DIFFERENCE_OK
/* The PA needs this for PIC code generation. */
-#define TC_VALIDATE_FIX_SUB(FIX) 1
+#define TC_VALIDATE_FIX_SUB(FIX, SEG) \
+ (md_register_arithmetic || (SEG) != reg_section)
#else
-#define TC_VALIDATE_FIX_SUB(FIX) \
- ((FIX)->fx_r_type == BFD_RELOC_GPREL32 \
- || (FIX)->fx_r_type == BFD_RELOC_GPREL16)
+#define TC_VALIDATE_FIX_SUB(FIX, SEG) \
+ ((md_register_arithmetic || (SEG) != reg_section) \
+ && ((FIX)->fx_r_type == BFD_RELOC_GPREL32 \
+ || (FIX)->fx_r_type == BFD_RELOC_GPREL16))
#endif
#endif
@@ -924,14 +932,14 @@ fixup_segment (fixS *fixP, segT this_segment)
#endif
}
else if (sub_symbol_segment == absolute_section
- && !TC_FORCE_RELOCATION_SUB_ABS (fixP))
+ && !TC_FORCE_RELOCATION_SUB_ABS (fixP, add_symbol_segment))
{
add_number -= S_GET_VALUE (fixP->fx_subsy);
fixP->fx_offset = add_number;
fixP->fx_subsy = NULL;
}
else if (sub_symbol_segment == this_segment
- && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP))
+ && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP, add_symbol_segment))
{
add_number -= S_GET_VALUE (fixP->fx_subsy);
fixP->fx_offset = (add_number + fixP->fx_dot_value
@@ -953,14 +961,20 @@ fixup_segment (fixS *fixP, segT this_segment)
fixP->fx_subsy = NULL;
fixP->fx_pcrel = 1;
}
- else if (!TC_VALIDATE_FIX_SUB (fixP))
+ else if (!TC_VALIDATE_FIX_SUB (fixP, add_symbol_segment))
{
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("can't resolve `%s' {%s section} - `%s' {%s section}"),
- fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
- segment_name (add_symbol_segment),
- S_GET_NAME (fixP->fx_subsy),
- segment_name (sub_symbol_segment));
+ if (!md_register_arithmetic
+ && (add_symbol_segment == reg_section
+ || sub_symbol_segment == reg_section))
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("register value used as expression"));
+ else
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("can't resolve `%s' {%s section} - `%s' {%s section}"),
+ fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
+ segment_name (add_symbol_segment),
+ S_GET_NAME (fixP->fx_subsy),
+ segment_name (sub_symbol_segment));
}
}
@@ -1090,8 +1104,8 @@ install_reloc (asection *sec, arelent *reloc, fragS *fragp,
&& (sym = *reloc->sym_ptr_ptr) != NULL
&& (sym->flags & BSF_KEEP) == 0
&& ((sym->flags & BSF_SECTION_SYM) == 0
- || !EMIT_SECTION_SYMBOLS
- || !bfd_is_abs_section (sym->section)))
+ || (EMIT_SECTION_SYMBOLS
+ && !bfd_is_abs_section (sym->section))))
as_bad_where (file, line, _("redefined symbol cannot be used on reloc"));
s = bfd_install_relocation (stdoutput, reloc,