1*1424dfb3Schristos /* This file is tc-wasm32.h.
2*1424dfb3Schristos    Copyright (C) 2017-2020 Free Software Foundation, Inc.
3*1424dfb3Schristos 
4*1424dfb3Schristos    This file is part of GAS, the GNU Assembler.
5*1424dfb3Schristos 
6*1424dfb3Schristos    GAS is free software; you can redistribute it and/or modify
7*1424dfb3Schristos    it under the terms of the GNU General Public License as published by
8*1424dfb3Schristos    the Free Software Foundation; either version 3, or (at your option)
9*1424dfb3Schristos    any later version.
10*1424dfb3Schristos 
11*1424dfb3Schristos    GAS is distributed in the hope that it will be useful,
12*1424dfb3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*1424dfb3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*1424dfb3Schristos    GNU General Public License for more details.
15*1424dfb3Schristos 
16*1424dfb3Schristos    You should have received a copy of the GNU General Public License
17*1424dfb3Schristos    along with GAS; see the file COPYING.  If not, write to the Free
18*1424dfb3Schristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19*1424dfb3Schristos    02110-1301, USA.  */
20*1424dfb3Schristos 
21*1424dfb3Schristos #define TC_WASM32
22*1424dfb3Schristos #define TARGET_FORMAT                       "elf32-wasm32"
23*1424dfb3Schristos #define TARGET_ARCH                        bfd_arch_wasm32
24*1424dfb3Schristos #define TARGET_MACH                                      1
25*1424dfb3Schristos 
26*1424dfb3Schristos /* WebAssembly is strictly little-endian.  */
27*1424dfb3Schristos #define TARGET_BYTES_BIG_ENDIAN                          0
28*1424dfb3Schristos #define md_number_to_chars    number_to_chars_littleendian
29*1424dfb3Schristos 
30*1424dfb3Schristos #define DIFF_EXPR_OK
31*1424dfb3Schristos 
32*1424dfb3Schristos /* No machine-dependent operand expressions.  */
33*1424dfb3Schristos #define md_operand(x)
34*1424dfb3Schristos 
35*1424dfb3Schristos /* No broken word processing.  */
36*1424dfb3Schristos #define WORKING_DOT_WORD
37*1424dfb3Schristos 
38*1424dfb3Schristos /* Force some relocations.  */
39*1424dfb3Schristos #define EXTERN_FORCE_RELOC                     1
40*1424dfb3Schristos extern int wasm32_force_relocation (struct fix *);
41*1424dfb3Schristos #define TC_FORCE_RELOCATION(fix)               wasm32_force_relocation (fix)
42*1424dfb3Schristos #define TC_FORCE_RELOCATION_LOCAL(fix)         1
43*1424dfb3Schristos #define TC_FORCE_RELOCATION_SUB_SAME(fix,seg)  wasm32_force_relocation (fix)
44*1424dfb3Schristos #define TC_FORCE_RELOCATION_SUB_ABS(fix,seg)   wasm32_force_relocation (fix)
45*1424dfb3Schristos #define TC_FORCE_RELOCATION_SUB_LOCAL(fix,seg) wasm32_force_relocation (fix)
46*1424dfb3Schristos #define TC_VALIDATE_FIX_SUB(fix,seg)           wasm32_force_relocation (fix)
47*1424dfb3Schristos 
48*1424dfb3Schristos /* This is ELF, values passed to md_apply_fix don't include the symbol
49*1424dfb3Schristos    value.  */
50*1424dfb3Schristos #define MD_APPLY_SYM_VALUE(FIX)         0
51*1424dfb3Schristos 
52*1424dfb3Schristos /* PC-relative relocations are relative to the relocation offset.  */
53*1424dfb3Schristos #define MD_PCREL_FROM_SECTION(FIX, SEC) 0
54*1424dfb3Schristos 
55*1424dfb3Schristos #define DWARF2_LINE_MIN_INSN_LENGTH 	1
56*1424dfb3Schristos 
57*1424dfb3Schristos /* WebAssembly uses 32-bit addresses.  */
58*1424dfb3Schristos #define TC_ADDRESS_BYTES()              4
59*1424dfb3Schristos #define DWARF2_ADDR_SIZE(bfd)           4
60*1424dfb3Schristos 
61*1424dfb3Schristos /* Enable cfi directives.  */
62*1424dfb3Schristos #define TARGET_USE_CFIPOP               1
63*1424dfb3Schristos 
64*1424dfb3Schristos /* The stack grows down, and there is no harm in claiming it is only
65*1424dfb3Schristos    byte aligned.  */
66*1424dfb3Schristos #define DWARF2_CIE_DATA_ALIGNMENT      -1
67*1424dfb3Schristos 
68*1424dfb3Schristos /* Define the column that represents the PC.  FIXME: this depends on
69*1424dfb3Schristos    the ABI. */
70*1424dfb3Schristos #define DWARF2_DEFAULT_RETURN_COLUMN   36
71*1424dfb3Schristos 
72*1424dfb3Schristos /* Define a hook to setup initial CFI state.  */
73*1424dfb3Schristos #define tc_cfi_frame_initial_instructions() do { } while (0)
74*1424dfb3Schristos 
75*1424dfb3Schristos #define elf_tc_final_processing()
76*1424dfb3Schristos #define md_post_relax_hook
77*1424dfb3Schristos #define md_start_line_hook()
78*1424dfb3Schristos #define HANDLE_ALIGN(fragP)
79*1424dfb3Schristos 
80*1424dfb3Schristos 
81*1424dfb3Schristos extern bfd_boolean wasm32_fix_adjustable (struct fix *);
82*1424dfb3Schristos #define tc_fix_adjustable(FIX) wasm32_fix_adjustable (FIX)
83*1424dfb3Schristos 
84*1424dfb3Schristos /* Type names for blocks and signatures.  */
85*1424dfb3Schristos #define BLOCK_TYPE_NONE              0x40
86*1424dfb3Schristos #define BLOCK_TYPE_I32               0x7f
87*1424dfb3Schristos #define BLOCK_TYPE_I64               0x7e
88*1424dfb3Schristos #define BLOCK_TYPE_F32               0x7d
89*1424dfb3Schristos #define BLOCK_TYPE_F64               0x7c
90