static int64_t stack_top;
static int last_reloc_is_sop_push_pcrel_1 = 0;
int last_reloc_is_sop_push_pcrel = last_reloc_is_sop_push_pcrel_1;
- segT sub_segment;
last_reloc_is_sop_push_pcrel_1 = 0;
char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
(use md_number_to_chars (buf, 0, fixP->fx_size)). */
case BFD_RELOC_64:
case BFD_RELOC_32:
- if (fixP->fx_r_type == BFD_RELOC_32
- && fixP->fx_addsy && fixP->fx_subsy
- && (sub_segment = S_GET_SEGMENT (fixP->fx_subsy))
- && strcmp (sub_segment->name, ".eh_frame") == 0
- && S_GET_VALUE (fixP->fx_subsy)
- == fixP->fx_frag->fr_address + fixP->fx_where)
+ if (fixP->fx_pcrel)
{
- fixP->fx_r_type = BFD_RELOC_LARCH_32_PCREL;
- fixP->fx_subsy = NULL;
- break;
+ switch (fixP->fx_r_type)
+ {
+ case BFD_RELOC_64:
+ fixP->fx_r_type = BFD_RELOC_LARCH_64_PCREL;
+ break;
+ case BFD_RELOC_32:
+ fixP->fx_r_type = BFD_RELOC_LARCH_32_PCREL;
+ break;
+ default:
+ break;
+ }
}
if (fixP->fx_addsy && fixP->fx_subsy)
relaxation, so do not resolve such expressions in the assembler. */
#define md_allow_local_subtract(l,r,s) 0
-/* Values passed to md_apply_fix don't include symbol values. */
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1
+/* If subsy of BFD_RELOC32/64 and PC in same segment, and without relax
+ or PC at start of subsy or with relax but sub_symbol_segment not in
+ SEC_CODE, we generate 32/64_PCREL. */
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \
+ (!((BFD_RELOC_32 || BFD_RELOC_64) \
+ &&(!LARCH_opts.relax \
+ || S_GET_VALUE (FIX->fx_subsy) \
+ == FIX->fx_frag->fr_address + FIX->fx_where \
+ || (LARCH_opts.relax \
+ && ((S_GET_SEGMENT (FIX->fx_subsy)->flags & SEC_CODE) == 0)))))
#define TC_VALIDATE_FIX_SUB(FIX, SEG) 1
#define DIFF_EXPR_OK 1