1 /* m88k.h -- Assembler for the Motorola 88000
2    Contributed by Devon Bowen of Buffalo University
3    and Torbjorn Granlund of the Swedish Institute of Computer Science.
4    Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000,
5    2002 Free Software Foundation, Inc.
6 
7 This file is part of GAS, the GNU Assembler.
8 
9 GAS is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13 
14 GAS is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with GAS; see the file COPYING.  If not, write to the Free
21 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 02111-1307, USA.  */
23 
24 #define TC_M88K
25 
26 #define TARGET_BYTES_BIG_ENDIAN 1
27 #undef REGISTER_PREFIX
28 
29 #ifdef OBJ_AOUT
30 #ifdef TE_OpenBSD
31 #define TARGET_FORMAT "a.out-m88k-openbsd"
32 #endif
33 #endif
34 
35 #ifdef M88KCOFF
36 #define BFD_ARCH bfd_arch_m88k
37 #define COFF_MAGIC MC88OMAGIC
38 #define COFF_FLAGS F_AR32W
39 #endif
40 
41 #ifdef OBJ_ELF
42 #define BFD_ARCH bfd_arch_m88k
43 #define TARGET_ARCH bfd_arch_m88k
44 #define TARGET_FORMAT		"elf32-m88k"
45 #if defined(TE_OpenBSD)
46 #define REGISTER_PREFIX '%'
47 #else
48 #define REGISTER_PREFIX '#'
49 #endif
50 #endif
51 
52 #define CUSTOM_RELOC_FORMAT
53 
54 /* different type of relocation available in the m88k */
55 
56 #ifdef BFD_ASSEMBLER
57 #include "bfd.h"
58 #define	m88k_reloc_type bfd_reloc_code_real
59 #else
60 enum m88k_reloc_type
61 {
62   RELOC_LO16,		/* lo16(sym) */
63   RELOC_HI16,		/* hi16(sym) */
64   RELOC_PC16,		/* bb0, bb1, bcnd */
65   RELOC_PC26,		/* br, bsr */
66   RELOC_32,		/* jump tables, etc */
67   RELOC_IW16,		/* global access through linker regs 28 */
68   NO_RELOC
69 };
70 
71 #define NEED_FX_R_TYPE
72 #ifdef M88KCOFF
73 #define TC_KEEP_FX_OFFSET
74 #endif
75 #define TC_CONS_RELOC RELOC_32
76 
77 struct reloc_info_m88k
78 {
79   unsigned long int r_address;
80   unsigned int r_symbolnum:24;
81   unsigned int r_extern:1;
82   unsigned int r_pad:3;
83   enum m88k_reloc_type r_type:4;
84   long int r_addend;
85 };
86 
87 #define relocation_info reloc_info_m88k
88 #endif /* BFD_ASSEMBLER */
89 
90 #ifdef OBJ_ELF
91 
92 /* This is used to recognize #abdiff, #got_rel and #plt symbols.
93    The relocation type is stored in X_md.  */
94 #define md_parse_name m88k_parse_name
95 extern int m88k_parse_name (const char *, expressionS *, char *);
96 
97 /* This expression evaluates to true if the relocation is for a local
98    object for which we still want to do the relocation at runtime.
99    False if we are willing to perform this relocation while building
100    the .o file.  Only concerns pcrel relocs.  */
101 
102 #define TC_FORCE_RELOCATION_LOCAL(FIX)			\
103   (!(FIX)->fx_pcrel					\
104    || (FIX)->fx_plt					\
105    || (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL	\
106    || TC_FORCE_RELOCATION (FIX))
107 
108 /* Keep relocations relative to the GOT, or non-PC relative.  */
109 #define tc_fix_adjustable(FIX) m88k_fix_adjustable (FIX)
110 extern int m88k_fix_adjustable PARAMS ((struct fix *));
111 
112 #endif /* OBJ_ELF */
113 
114 #ifndef OBJ_ELF
115 /* The m88k uses '@' to start local labels, except on ELF.  */
116 #define LEX_AT (LEX_BEGIN_NAME | LEX_NAME)
117 
118 #ifndef BFD_ASSEMBLER
119 #define LOCAL_LABEL(name) \
120   ((name[0] =='@' && (name [1] == 'L' || name [1] == '.')) \
121    || (name[0] == 'L' && name[1] == '0' && name[2] == '\001'))
122 #endif
123 #endif /* OBJ_ELF */
124 
125 #if !defined(OBJ_ELF) || !defined(TE_OpenBSD)
126 /* The m88k uses pseudo-ops with no leading period, except on OpenBSD ELF.  */
127 #define NO_PSEUDO_DOT 1
128 #endif
129 
130 /* Don't warn on word overflow; it happens on %hi relocs.  */
131 #undef WARN_SIGNED_OVERFLOW_WORD
132 
133 #define md_convert_frag(b,s,f)		{as_fatal (_("m88k convert_frag\n"));}
134 
135 /* We don't need to do anything special for undefined symbols.  */
136 #define md_undefined_symbol(s) 0
137 
138 /* We have no special operand handling.  */
139 #define md_operand(e)
140 
141 #define tc_aout_pre_write_hook(x)      do { } while (0)
142 #define tc_crawl_symbol_chain(a)       do { } while (0)
143 
144 #ifdef M88KCOFF
145 
146 /* Whether a reloc should be output.  */
147 #define TC_COUNT_RELOC(fixp) ((fixp)->fx_addsy != NULL)
148 
149 /* Get the BFD reloc type to use for a gas fixS structure.  */
150 #define TC_COFF_FIX2RTYPE(fixp) tc_coff_fix2rtype (fixp)
151 
152 /* No special hook needed for symbols.  */
153 #define tc_coff_symbol_emit_hook(s)
154 
155 /* Align sections to a four byte boundary.  */
156 #ifndef max
157 #define max(a,b)	(((a) > (b)) ? (a) : (b))
158 #endif
159 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN)	max (section_alignment[(int) (SEG)], 4)
160 
161 #endif /* M88KCOFF */
162 
163 /* Fill in rs_align_code fragments.  */
164 extern void m88k_handle_align PARAMS ((fragS *));
165 #define HANDLE_ALIGN(frag)  m88k_handle_align (frag)
166 
167 #define MAX_MEM_FOR_RS_ALIGN_CODE  (3 + 4)
168 
169 #define elf_tc_final_processing m88k_elf_final_processing
170 extern void m88k_elf_final_processing (void);
171 
172 /* word pseudo outputs 32-bit values, no risk of ``broken words'' */
173 #define WORKING_DOT_WORD
174