}
int
-loongarch_parse_expr (const char *expr,
+loongarch_parse_expr (const char *exp,
struct reloc_info *reloc_stack_top,
size_t max_reloc_num,
size_t *reloc_num,
struct yy_buffer_state *buffstate;
top = reloc_stack_top;
end = top + max_reloc_num;
- buffstate = yy_scan_string (expr);
+ buffstate = yy_scan_string (exp);
ret = yyparse ();
if (ret == 0)
if (*str == '\0')
break;
- struct loongarch_cl_insn the_one = { 0 };
+ struct loongarch_cl_insn the_one;
+ memset (&the_one, 0, sizeof (the_one));
the_one.name = str;
the_one.expand_from_macro = expand_from_macro;
return generic_force_reloc (fixp);
}
+/* 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. */
+bool
+loongarch_force_relocation_sub_local (fixS *fixp, segT sec ATTRIBUTE_UNUSED)
+{
+ return !(LARCH_opts.thin_add_sub
+ && (fixp->fx_r_type == BFD_RELOC_32
+ || fixp->fx_r_type == BFD_RELOC_64)
+ && (!LARCH_opts.relax
+ || (S_GET_VALUE (fixp->fx_subsy)
+ == fixp->fx_frag->fr_address + fixp->fx_where)
+ || (S_GET_SEGMENT (fixp->fx_subsy)->flags & SEC_CODE) == 0));
+}
+
+/* Postpone text-section label subtraction calculation until linking, since
+ linker relaxations might change the deltas. */
+bool
+loongarch_force_relocation_sub_same(fixS *fixp ATTRIBUTE_UNUSED, segT sec)
+{
+ return LARCH_opts.relax && (sec->flags & SEC_CODE) != 0;
+}
+
static void fix_reloc_insn (fixS *fixP, bfd_vma reloc_val, char *buf)
{
reloc_howto_type *howto;
#ifndef TC_LOONGARCH
#define TC_LOONGARCH
-#include "opcode/loongarch.h"
-
#define TARGET_BYTES_BIG_ENDIAN 0
#define TARGET_ARCH bfd_arch_loongarch
/* 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) \
- (!(LARCH_opts.thin_add_sub \
- && ((FIX)->fx_r_type == BFD_RELOC_32 \
- ||(FIX)->fx_r_type == 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)))))
+extern bool loongarch_force_relocation_sub_local (struct fix *, asection *);
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEC) \
+ loongarch_force_relocation_sub_local (FIX, SEC)
#define TC_VALIDATE_FIX_SUB(FIX, SEG) 1
#define DIFF_EXPR_OK 1
/* Postpone text-section label subtraction calculation until linking, since
linker relaxations might change the deltas. */
+extern bool loongarch_force_relocation_sub_same(struct fix *, asection *);
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
- (LARCH_opts.relax ? \
- (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
- || ((SEC)->flags & SEC_CODE) != 0) \
- : (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC))) \
+ (loongarch_force_relocation_sub_same (FIX, SEC) \
+ || GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC))
#define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE) \
|| (seg->flags & SEC_DEBUGGING))