Skip to content
Commit 56576f4a authored by mengqinggang's avatar mengqinggang Committed by liuzhensong
Browse files

LoongArch: gas: Add support for linker relaxation.

Add gas -mrelax and -mno-relax option.
Add R_LARCH_RELAX reloc for instrction if it can be relaxed.
ADD R_LARCH_ALIGN reloc for align pseudo instruction because relax.
Add ADD/SUB reloc pair for debug and exception data to calculate symbol
substraction because relax.

gas/ChangeLog:

	* config/tc-loongarch.c:
	(struct loongarch_cl_insn): New macro_id member.
	(enum options): New OPTION_RELAX and OPTION_NO_RELAX.
	(struct option): New mrelax and mno-relax.
	(md_parse_option): Likewise.
	(get_internal_label):
	(loongarch_args_parser_can_match_arg_helper): Generate relax reloc.
	(move_insn): Set fx_frag and fx_where if exist.
	(append_fixp_and_insn): Call frag_wane and frag_new for linker relax
	relocs.
	(loongarch_assemble_INSNs): New loongarch_cl_insn pointer parameter.
	(md_assemble): Fix function call.
	(fix_reloc_insn): Likewise.
	(md_apply_fix): Generate ADD/SUB reloc pair for debug and exception
	data.
	(loongarch_fix_adjustable): Delete.
	(md_convert_frag): Generate new fix.
	(loongarch_pre_output_hook): New function.
	(loongarch_make_nops): Likewise.
	(loongarch_frag_align_code): Likewise.
	(loongarch_insert_uleb128_fixes): Likewise.
	(loongarch_md_finish): Likewise.
	* config/tc-loongarch.h
	(md_allow_local_subtract): New macro define.
	(loongarch_frag_align_code): New declare.
	(md_do_align): Likewise.
	(loongarch_fix_adjustable): Delete.
	(tc_fix_adjustable): New macro define.
	(TC_FORCE_RELOCATION_SUB_SAME): Likewise.
	(TC_LINKRELAX_FIXUP): Likewise.
	(TC_FORCE_RELOCATION_LOCAL): Likewise.
	(DWARF2_USE_FIXED_ADVANCE_PC): Likewise.
	(MD_APPLY_SYM_VALUE): Likewise.
	(tc_symbol_new_hook): New extern.
	(NOP_OPCODE): Delete.
	(loongarch_pre_output_hook): New macro define.
	(md_pre_output_hook): Likewise.
	(md_finish): Likewise.
	(loongarch_md_finish): New extern.
	* testsuite/gas/all/align.d: Mark as unsupported on LoongArch.
	* testsuite/gas/all/gas.exp: Xfail loongarch*-*.
	* testsuite/gas/all/relax.d: Likewise.
	* testsuite/gas/elf/dwarf-5-irp.d: Likewise.
	* testsuite/gas/elf/dwarf-5-loc0.d: Likewise.
	* testsuite/gas/elf/dwarf-5-macro-include.d: Likewise.
	* testsuite/gas/elf/dwarf-5-macro.d: Likewise.
	* testsuite/gas/elf/dwarf2-11.d: Likewise.
	* testsuite/gas/elf/dwarf2-15.d: Likewise.
	* testsuite/gas/elf/dwarf2-16.d: Likewise.
	* testsuite/gas/elf/dwarf2-17.d: Likewise.
	* testsuite/gas/elf/dwarf2-18.d: Likewise.
	* testsuite/gas/elf/dwarf2-19.d: Likewise.
	* testsuite/gas/elf/dwarf2-5.d: Likewise.
	* testsuite/gas/elf/ehopt0.d: Likewise.
	* testsuite/gas/elf/elf.exp: Likewise.
	* testsuite/gas/elf/section11.d: Likewise.
	* testsuite/gas/lns/lns.exp: Likewise.
	* testsuite/gas/loongarch/jmp_op.d: Regenerated.
	* testsuite/gas/loongarch/li.d: Likewise.
	* testsuite/gas/loongarch/macro_op.d: Likewise.
	* testsuite/gas/loongarch/macro_op_32.d: Likewise.
	* testsuite/gas/loongarch/macro_op_large_abs.d: Likewise.
	* testsuite/gas/loongarch/macro_op_large_pc.d: Likewise.
	* testsuite/gas/loongarch/relax_align.d: New test.
	* testsuite/gas/loongarch/relax_align.s: New test.
	* testsuite/gas/loongarch/uleb128.d: New test.
	* testsuite/gas/loongarch/uleb128.s: New test.
parent 76244462
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment