]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/config/tc-loongarch.h
bus error with fuzzed archive element
[thirdparty/binutils-gdb.git] / gas / config / tc-loongarch.h
1 /* tc-loongarch.h -- Header file for tc-loongarch.c.
2 Copyright (C) 2021-2024 Free Software Foundation, Inc.
3 Contributed by Loongson Ltd.
4
5 This file is part of GAS.
6
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the license, or
10 (at your option) any later version.
11
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING3. If not,
19 see <http://www.gnu.org/licenses/>. */
20
21 #ifndef TC_LOONGARCH
22 #define TC_LOONGARCH
23
24 #include "opcode/loongarch.h"
25
26 #define TARGET_BYTES_BIG_ENDIAN 0
27 #define TARGET_ARCH bfd_arch_loongarch
28
29 #define TARGET_MACH (loongarch_mach ())
30 extern unsigned long loongarch_mach (void);
31
32 #define WORKING_DOT_WORD 1
33 #define REPEAT_CONS_EXPRESSIONS
34
35 /* Early than md_begin. */
36 #define md_after_parse_args loongarch_after_parse_args
37 extern void loongarch_after_parse_args (void);
38
39 extern void loongarch_pop_insert (void);
40 #define md_pop_insert() loongarch_pop_insert ()
41
42 #define TARGET_FORMAT loongarch_target_format ()
43 extern const char *loongarch_target_format (void);
44
45 #define md_relax_frag(segment, fragp, stretch) \
46 loongarch_relax_frag (segment, fragp, stretch)
47 extern int loongarch_relax_frag (asection *, struct frag *, long);
48 #define md_section_align(seg, size) (size)
49 #define md_undefined_symbol(name) (0)
50 #define md_operand(x)
51
52 extern bool loongarch_frag_align_code (int, int);
53 #define md_do_align(N, FILL, LEN, MAX, LABEL) \
54 if ((N) != 0 && !(FILL) && !need_pass_2 && subseg_text_p (now_seg)) \
55 { \
56 if (loongarch_frag_align_code (N, MAX)) \
57 goto LABEL; \
58 }
59
60 /* The following two macros let the linker resolve all the relocs
61 due to relaxation.
62
63 This is called to see whether a reloc against a defined symbol
64 should be converted into a reloc against a section.
65
66 If relax and norelax have different value may cause ld ".eh_frame_hdr
67 refers to overlapping FDEs" error when link relax .o and norelax .o. */
68 #define tc_fix_adjustable(fixp) 0
69
70 /* Tne difference between same-section symbols may be affected by linker
71 relaxation, so do not resolve such expressions in the assembler. */
72 #define md_allow_local_subtract(l,r,s) 0
73
74 /* If subsy of BFD_RELOC32/64 and PC in same segment, and without relax
75 or PC at start of subsy or with relax but sub_symbol_segment not in
76 SEC_CODE, we generate 32/64_PCREL. */
77 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \
78 (!(LARCH_opts.thin_add_sub \
79 && (BFD_RELOC_32 || BFD_RELOC_64) \
80 && (!LARCH_opts.relax \
81 || S_GET_VALUE (FIX->fx_subsy) \
82 == FIX->fx_frag->fr_address + FIX->fx_where \
83 || (LARCH_opts.relax \
84 && ((S_GET_SEGMENT (FIX->fx_subsy)->flags & SEC_CODE) == 0)))))
85
86 #define TC_VALIDATE_FIX_SUB(FIX, SEG) 1
87 #define DIFF_EXPR_OK 1
88
89 /* Postpone text-section label subtraction calculation until linking, since
90 linker relaxations might change the deltas. */
91 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
92 (LARCH_opts.relax ? \
93 (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
94 || ((SEC)->flags & SEC_CODE) != 0) \
95 : (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC))) \
96
97 #define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE) \
98 || (seg->flags & SEC_DEBUGGING))
99
100 #define TC_FORCE_RELOCATION_LOCAL(FIX) 1
101
102 /* Adjust debug_line after relaxation. */
103 #define DWARF2_USE_FIXED_ADVANCE_PC 1
104
105 /* Values passed to md_apply_fix don't include symbol values. */
106 #define MD_APPLY_SYM_VALUE(FIX) 0
107
108 #define TARGET_USE_CFIPOP 1
109 #define DWARF2_DEFAULT_RETURN_COLUMN 1 /* $ra. */
110 #define DWARF2_CIE_DATA_ALIGNMENT -4
111
112 #define tc_cfi_frame_initial_instructions \
113 loongarch_cfi_frame_initial_instructions
114 extern void loongarch_cfi_frame_initial_instructions (void);
115
116 #define tc_symbol_new_hook(sym) \
117 if (0 == strcmp (sym->bsym->name, FAKE_LABEL_NAME)) \
118 S_SET_OTHER (sym, STV_HIDDEN);
119
120 #define tc_parse_to_dw2regnum tc_loongarch_parse_to_dw2regnum
121 extern void tc_loongarch_parse_to_dw2regnum (expressionS *);
122
123 extern void loongarch_pre_output_hook (void);
124 #define md_pre_output_hook loongarch_pre_output_hook ()
125 #define GAS_SORT_RELOCS 1
126
127 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
128
129 #define HANDLE_ALIGN(fragp) loongarch_handle_align (fragp)
130 extern void loongarch_handle_align (struct frag *);
131 #define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4)
132
133 #define elf_tc_final_processing loongarch_elf_final_processing
134 extern void loongarch_elf_final_processing (void);
135
136 #define MAX_RELOC_NUMBER_A_INSN 20
137
138 struct reloc_info
139 {
140 bfd_reloc_code_real_type type;
141 expressionS value;
142 };
143
144 #define md_finish loongarch_md_finish
145 extern void loongarch_md_finish (void);
146
147 #endif