]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* obj-aout.h, a.out object file format for gas, the assembler. |
a161fe53 | 2 | Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, |
44f2f9d2 | 3 | 2002, 2003, 2005 Free Software Foundation, Inc. |
252b5132 RH |
4 | |
5 | This file is part of GAS, the GNU Assembler. | |
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 | |
9 | published by the Free Software Foundation; either version 2, | |
10 | or (at your option) any later version. | |
11 | ||
12 | GAS is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | |
15 | the GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GAS; see the file COPYING. If not, write to the Free | |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
dcd619be | 20 | 02111-1307, USA. */ |
252b5132 RH |
21 | |
22 | /* Tag to validate a.out object file format processing */ | |
23 | #define OBJ_AOUT 1 | |
24 | ||
25 | #include "targ-cpu.h" | |
26 | ||
27 | #ifdef BFD_ASSEMBLER | |
28 | ||
29 | #include "bfd/libaout.h" | |
30 | ||
31 | #define OUTPUT_FLAVOR bfd_target_aout_flavour | |
32 | ||
33 | #else /* ! BFD_ASSEMBLER */ | |
34 | ||
35 | #ifndef VMS | |
dcd619be | 36 | #include "aout_gnu.h" /* Needed to define struct nlist. Sigh. */ |
252b5132 RH |
37 | #else |
38 | #include "a_out.h" | |
39 | #endif | |
40 | ||
41 | #ifndef AOUT_MACHTYPE | |
42 | #define AOUT_MACHTYPE 0 | |
43 | #endif /* AOUT_MACHTYPE */ | |
44 | ||
45 | extern const short seg_N_TYPE[]; | |
46 | extern const segT N_TYPE_seg[]; | |
47 | ||
48 | #ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE | |
49 | #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC) | |
50 | #endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */ | |
51 | ||
52 | #endif /* ! BFD_ASSEMBLER */ | |
53 | ||
4c63da97 AM |
54 | extern const pseudo_typeS aout_pseudo_table[]; |
55 | ||
56 | #ifndef obj_pop_insert | |
57 | #define obj_pop_insert() pop_insert (aout_pseudo_table) | |
58 | #endif | |
59 | ||
ea1562b3 | 60 | /* Symbol table entry data type. */ |
252b5132 | 61 | |
ea1562b3 | 62 | typedef struct nlist obj_symbol_type; /* Symbol table entry. */ |
252b5132 RH |
63 | |
64 | /* Symbol table macros and constants */ | |
65 | ||
66 | #ifdef BFD_ASSEMBLER | |
67 | ||
49309057 ILT |
68 | #define S_SET_OTHER(S,V) \ |
69 | (aout_symbol (symbol_get_bfdsym (S))->other = (V)) | |
70 | #define S_SET_TYPE(S,T) \ | |
71 | (aout_symbol (symbol_get_bfdsym (S))->type = (T)) | |
72 | #define S_SET_DESC(S,D) \ | |
73 | (aout_symbol (symbol_get_bfdsym (S))->desc = (D)) | |
74 | #define S_GET_OTHER(S) \ | |
75 | (aout_symbol (symbol_get_bfdsym (S))->other) | |
76 | #define S_GET_TYPE(S) \ | |
77 | (aout_symbol (symbol_get_bfdsym (S))->type) | |
78 | #define S_GET_DESC(S) \ | |
79 | (aout_symbol (symbol_get_bfdsym (S))->desc) | |
252b5132 RH |
80 | |
81 | asection *text_section, *data_section, *bss_section; | |
82 | ||
83 | #define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT) | |
a161fe53 | 84 | #define obj_frob_file_before_fix() obj_aout_frob_file_before_fix () |
252b5132 | 85 | |
ea1562b3 NC |
86 | extern void obj_aout_frob_symbol (symbolS *, int *); |
87 | extern void obj_aout_frob_file_before_fix (void); | |
88 | ||
89 | #define obj_sec_sym_ok_for_reloc(SEC) 1 | |
252b5132 RH |
90 | |
91 | #else | |
92 | ||
93 | /* We use the sy_obj field to record whether a symbol is weak. */ | |
94 | #define OBJ_SYMFIELD_TYPE char | |
95 | ||
ea1562b3 NC |
96 | /* Macros to extract information from a symbol table entry. |
97 | This syntactic indirection allows independence regarding a.out or coff. | |
98 | The argument (s) of all these macros is a pointer to a symbol table entry. */ | |
252b5132 | 99 | |
ea1562b3 | 100 | /* True if the symbol is external. */ |
252b5132 RH |
101 | #define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT) |
102 | ||
ea1562b3 | 103 | /* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT. */ |
252b5132 RH |
104 | #define S_IS_DEFINED(s) \ |
105 | (S_GET_TYPE (s) != N_UNDF || S_GET_DESC (s) != 0) | |
106 | ||
107 | #define S_IS_COMMON(s) \ | |
108 | (S_GET_TYPE (s) == N_UNDF && S_GET_VALUE (s) != 0) | |
109 | ||
a161fe53 AM |
110 | /* Return true for symbols that should not be reduced to section |
111 | symbols or eliminated from expressions, because they may be | |
112 | overridden by the linker. */ | |
ae6063d4 | 113 | #define S_FORCE_RELOC(s, strict) \ |
a161fe53 AM |
114 | (!SEG_NORMAL (S_GET_SEGMENT (s))) |
115 | ||
252b5132 RH |
116 | #define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER) |
117 | ||
ea1562b3 | 118 | /* True if a debug special symbol entry. */ |
252b5132 | 119 | #define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB) |
ea1562b3 | 120 | /* True if a symbol is local symbol name. */ |
252b5132 RH |
121 | #define S_IS_LOCAL(s) \ |
122 | ((S_GET_NAME (s) \ | |
123 | && !S_IS_DEBUG (s) \ | |
124 | && (strchr (S_GET_NAME (s), '\001') != NULL \ | |
125 | || strchr (S_GET_NAME (s), '\002') != NULL \ | |
126 | || (S_LOCAL_NAME(s) && !flag_keep_locals))) \ | |
127 | || (flag_strip_local_absolute \ | |
128 | && ! S_IS_EXTERNAL(s) \ | |
129 | && S_GET_SEGMENT (s) == absolute_section)) | |
ea1562b3 | 130 | /* True if a symbol is not defined in this file. */ |
252b5132 | 131 | #define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT) |
ea1562b3 NC |
132 | /* True if the symbol has been generated because of a .stabd directive. */ |
133 | #define S_IS_STABD(s) (S_GET_NAME(s) == NULL) | |
252b5132 | 134 | |
ea1562b3 NC |
135 | /* Accessors. */ |
136 | /* The name of the symbol. */ | |
252b5132 | 137 | #define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name) |
ea1562b3 | 138 | /* The pointer to the string table. */ |
252b5132 | 139 | #define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx) |
ea1562b3 | 140 | /* The type of the symbol. */ |
252b5132 | 141 | #define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE) |
ea1562b3 | 142 | /* The numeric value of the segment. */ |
252b5132 | 143 | #define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)]) |
ea1562b3 | 144 | /* The n_other expression value. */ |
252b5132 | 145 | #define S_GET_OTHER(s) ((s)->sy_symbol.n_other) |
ea1562b3 | 146 | /* The n_desc expression value. */ |
252b5132 RH |
147 | #define S_GET_DESC(s) ((s)->sy_symbol.n_desc) |
148 | /* Whether the symbol is weak. */ | |
149 | #define S_GET_WEAK(s) ((s)->sy_obj) | |
150 | ||
ea1562b3 NC |
151 | /* Modifiers. */ |
152 | /* Assume that a symbol cannot be simultaneously in more than on segment. */ | |
153 | /* Set segment. */ | |
154 | #define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type |= SEGMENT_TO_SYMBOL_TYPE (seg)) | |
155 | /* The symbol is external. */ | |
252b5132 | 156 | #define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT) |
ea1562b3 | 157 | /* The symbol is not external. */ |
252b5132 | 158 | #define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT) |
ea1562b3 | 159 | /* Set the name of the symbol. */ |
252b5132 | 160 | #define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v)) |
ea1562b3 | 161 | /* Set the offset in the string table. */ |
252b5132 | 162 | #define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v)) |
ea1562b3 | 163 | /* Set the n_type field. */ |
252b5132 | 164 | #define S_SET_TYPE(s,t) ((s)->sy_symbol.n_type = (t)) |
ea1562b3 | 165 | /* Set the n_other expression value. */ |
252b5132 | 166 | #define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v)) |
ea1562b3 | 167 | /* Set the n_desc expression value. */ |
252b5132 RH |
168 | #define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v)) |
169 | /* Mark the symbol as weak. This causes n_type to be adjusted when | |
170 | the symbol is written out. */ | |
171 | #define S_SET_WEAK(s) ((s)->sy_obj = 1) | |
172 | ||
ea1562b3 | 173 | /* File header macro and type definition. */ |
252b5132 | 174 | |
ea1562b3 NC |
175 | #define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE (h) \ |
176 | + H_GET_TEXT_SIZE (h) \ | |
177 | + H_GET_DATA_SIZE (h) \ | |
178 | + H_GET_TEXT_RELOCATION_SIZE (h) \ | |
179 | + H_GET_DATA_RELOCATION_SIZE (h) \ | |
180 | + H_GET_LINENO_SIZE (h) \ | |
181 | + H_GET_SYMBOL_TABLE_SIZE (h) \ | |
182 | + H_GET_STRING_SIZE (h)) | |
252b5132 RH |
183 | |
184 | #define H_GET_HEADER_SIZE(h) (EXEC_BYTES_SIZE) | |
185 | #define H_GET_TEXT_SIZE(h) ((h)->header.a_text) | |
186 | #define H_GET_DATA_SIZE(h) ((h)->header.a_data) | |
187 | #define H_GET_BSS_SIZE(h) ((h)->header.a_bss) | |
188 | #define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize) | |
189 | #define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize) | |
190 | #define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms) | |
191 | #define H_GET_ENTRY_POINT(h) ((h)->header.a_entry) | |
192 | #define H_GET_STRING_SIZE(h) ((h)->string_table_size) | |
193 | #define H_GET_LINENO_SIZE(h) (0) | |
194 | ||
195 | #define H_GET_DYNAMIC(h) ((h)->header.a_info >> 31) | |
196 | #define H_GET_VERSION(h) (((h)->header.a_info >> 24) & 0x7f) | |
197 | #define H_GET_MACHTYPE(h) (((h)->header.a_info >> 16) & 0xff) | |
198 | #define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info & 0xffff) | |
199 | ||
200 | #define H_SET_DYNAMIC(h,v) ((h)->header.a_info = (((v) << 31) \ | |
ea1562b3 NC |
201 | | (H_GET_VERSION (h) << 24) \ |
202 | | (H_GET_MACHTYPE (h) << 16) \ | |
203 | | (H_GET_MAGIC_NUMBER (h)))) | |
252b5132 | 204 | |
ea1562b3 | 205 | #define H_SET_VERSION(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC (h) << 31) \ |
252b5132 | 206 | | ((v) << 24) \ |
ea1562b3 NC |
207 | | (H_GET_MACHTYPE (h) << 16) \ |
208 | | (H_GET_MAGIC_NUMBER (h)))) | |
252b5132 | 209 | |
ea1562b3 NC |
210 | #define H_SET_MACHTYPE(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC (h) << 31) \ |
211 | | (H_GET_VERSION (h) << 24) \ | |
252b5132 | 212 | | ((v) << 16) \ |
ea1562b3 | 213 | | (H_GET_MAGIC_NUMBER (h)))) |
252b5132 | 214 | |
ea1562b3 NC |
215 | #define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC (h) << 31) \ |
216 | | (H_GET_VERSION (h) << 24) \ | |
217 | | (H_GET_MACHTYPE (h) << 16) \ | |
252b5132 RH |
218 | | ((v)))) |
219 | ||
ea1562b3 NC |
220 | #define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align (SEG_TEXT, (v))) |
221 | #define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align (SEG_DATA, (v))) | |
222 | #define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align (SEG_BSS, (v))) | |
252b5132 | 223 | |
ea1562b3 NC |
224 | #define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE ((h),(t)),\ |
225 | H_SET_DATA_RELOCATION_SIZE ((h),(d))) | |
252b5132 RH |
226 | |
227 | #define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v)) | |
228 | #define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v)) | |
229 | #define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * 12) | |
230 | ||
231 | #define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v)) | |
232 | #define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v)) | |
233 | ||
234 | typedef struct | |
ea1562b3 NC |
235 | { |
236 | struct exec header; /* a.out header. */ | |
237 | long string_table_size; /* names + '\0' + sizeof (int). */ | |
238 | } | |
252b5132 RH |
239 | |
240 | object_headers; | |
241 | ||
ea1562b3 | 242 | /* Line numbering stuff. */ |
252b5132 RH |
243 | #define OBJ_EMIT_LINENO(a, b, c) {;} |
244 | ||
245 | struct fix; | |
ea1562b3 | 246 | extern void tc_aout_fix_to_chars (char *, struct fix *, relax_addressT); |
252b5132 RH |
247 | |
248 | #endif | |
249 | ||
4c63da97 | 250 | #define obj_read_begin_hook() {;} |
252b5132 RH |
251 | #define obj_symbol_new_hook(s) {;} |
252 | ||
253 | #define EMIT_SECTION_SYMBOLS 0 | |
254 | ||
255 | #define AOUT_STABS |