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