2cf33fd1bc2c17cd6093a307a4d419f9415d1516
[deliverable/binutils-gdb.git] / gas / config / obj-aout.h
1 /* obj-aout.h, a.out object file format for gas, the assembler.
2 Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 98, 1999
3 Free Software Foundation, Inc.
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
20 02111-1307, USA. */
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
36 #include "aout_gnu.h" /* Needed to define struct nlist. Sigh. */
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
54 /* SYMBOL TABLE */
55 /* Symbol table entry data type */
56
57 typedef struct nlist obj_symbol_type; /* Symbol table entry */
58
59 /* Symbol table macros and constants */
60
61 #ifdef BFD_ASSEMBLER
62
63 #define S_SET_OTHER(S,V) \
64 (aout_symbol (symbol_get_bfdsym (S))->other = (V))
65 #define S_SET_TYPE(S,T) \
66 (aout_symbol (symbol_get_bfdsym (S))->type = (T))
67 #define S_SET_DESC(S,D) \
68 (aout_symbol (symbol_get_bfdsym (S))->desc = (D))
69 #define S_GET_OTHER(S) \
70 (aout_symbol (symbol_get_bfdsym (S))->other)
71 #define S_GET_TYPE(S) \
72 (aout_symbol (symbol_get_bfdsym (S))->type)
73 #define S_GET_DESC(S) \
74 (aout_symbol (symbol_get_bfdsym (S))->desc)
75
76 asection *text_section, *data_section, *bss_section;
77
78 #define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT)
79 #define obj_frob_file() obj_aout_frob_file ()
80 extern void obj_aout_frob_symbol PARAMS ((symbolS *, int *));
81 extern void obj_aout_frob_file PARAMS ((void));
82
83 #define obj_sec_sym_ok_for_reloc(SEC) (1)
84
85 #else
86
87 /* We use the sy_obj field to record whether a symbol is weak. */
88 #define OBJ_SYMFIELD_TYPE char
89
90 /*
91 * Macros to extract information from a symbol table entry.
92 * This syntaxic indirection allows independence regarding a.out or coff.
93 * The argument (s) of all these macros is a pointer to a symbol table entry.
94 */
95
96 /* True if the symbol is external */
97 #define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
98
99 /* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
100 #define S_IS_DEFINED(s) \
101 (S_GET_TYPE (s) != N_UNDF || S_GET_DESC (s) != 0)
102
103 #define S_IS_COMMON(s) \
104 (S_GET_TYPE (s) == N_UNDF && S_GET_VALUE (s) != 0)
105
106 #define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
107
108 /* True if a debug special symbol entry */
109 #define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
110 /* True if a symbol is local symbol name */
111 #define S_IS_LOCAL(s) \
112 ((S_GET_NAME (s) \
113 && !S_IS_DEBUG (s) \
114 && (strchr (S_GET_NAME (s), '\001') != NULL \
115 || strchr (S_GET_NAME (s), '\002') != NULL \
116 || (S_LOCAL_NAME(s) && !flag_keep_locals))) \
117 || (flag_strip_local_absolute \
118 && ! S_IS_EXTERNAL(s) \
119 && S_GET_SEGMENT (s) == absolute_section))
120 /* True if a symbol is not defined in this file */
121 #define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
122 /* True if the symbol has been generated because of a .stabd directive */
123 #define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
124
125 /* Accessors */
126 /* The name of the symbol */
127 #define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
128 /* The pointer to the string table */
129 #define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
130 /* The type of the symbol */
131 #define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
132 /* The numeric value of the segment */
133 #define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
134 /* The n_other expression value */
135 #define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
136 /* The n_desc expression value */
137 #define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
138 /* Whether the symbol is weak. */
139 #define S_GET_WEAK(s) ((s)->sy_obj)
140
141 /* Modifiers */
142 /* Assume that a symbol cannot be simultaneously in more than on segment */
143 /* set segment */
144 #define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
145 /* The symbol is external */
146 #define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
147 /* The symbol is not external */
148 #define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
149 /* Set the name of the symbol */
150 #define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
151 /* Set the offset in the string table */
152 #define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
153 /* Set the n_type field */
154 #define S_SET_TYPE(s,t) ((s)->sy_symbol.n_type = (t))
155 /* Set the n_other expression value */
156 #define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
157 /* Set the n_desc expression value */
158 #define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
159 /* Mark the symbol as weak. This causes n_type to be adjusted when
160 the symbol is written out. */
161 #define S_SET_WEAK(s) ((s)->sy_obj = 1)
162
163 /* File header macro and type definition */
164
165 #define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE(h) \
166 + H_GET_TEXT_SIZE(h) \
167 + H_GET_DATA_SIZE(h) \
168 + H_GET_SYMBOL_TABLE_SIZE(h) \
169 + H_GET_TEXT_RELOCATION_SIZE(h) \
170 + H_GET_DATA_RELOCATION_SIZE(h) \
171 + H_GET_STRING_SIZE(h))
172
173 #define H_GET_HEADER_SIZE(h) (EXEC_BYTES_SIZE)
174 #define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
175 #define H_GET_DATA_SIZE(h) ((h)->header.a_data)
176 #define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
177 #define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
178 #define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
179 #define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
180 #define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
181 #define H_GET_STRING_SIZE(h) ((h)->string_table_size)
182 #define H_GET_LINENO_SIZE(h) (0)
183
184 #define H_GET_DYNAMIC(h) ((h)->header.a_info >> 31)
185 #define H_GET_VERSION(h) (((h)->header.a_info >> 24) & 0x7f)
186 #define H_GET_MACHTYPE(h) (((h)->header.a_info >> 16) & 0xff)
187 #define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info & 0xffff)
188
189 #define H_SET_DYNAMIC(h,v) ((h)->header.a_info = (((v) << 31) \
190 | (H_GET_VERSION(h) << 24) \
191 | (H_GET_MACHTYPE(h) << 16) \
192 | (H_GET_MAGIC_NUMBER(h))))
193
194 #define H_SET_VERSION(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
195 | ((v) << 24) \
196 | (H_GET_MACHTYPE(h) << 16) \
197 | (H_GET_MAGIC_NUMBER(h))))
198
199 #define H_SET_MACHTYPE(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
200 | (H_GET_VERSION(h) << 24) \
201 | ((v) << 16) \
202 | (H_GET_MAGIC_NUMBER(h))))
203
204 #define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
205 | (H_GET_VERSION(h) << 24) \
206 | (H_GET_MACHTYPE(h) << 16) \
207 | ((v))))
208
209 #define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
210 #define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
211 #define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
212
213 #define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
214 H_SET_DATA_RELOCATION_SIZE((h),(d)))
215
216 #define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
217 #define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
218 #define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * 12)
219
220 #define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
221 #define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
222
223 typedef struct
224 {
225 struct exec header; /* a.out header */
226 long string_table_size; /* names + '\0' + sizeof(int) */
227 }
228
229 object_headers;
230
231 /* line numbering stuff. */
232 #define OBJ_EMIT_LINENO(a, b, c) {;}
233
234 struct fix;
235 void tc_aout_fix_to_chars PARAMS ((char *where, struct fix *fixP, relax_addressT segment_address));
236
237 #endif
238
239 #define obj_symbol_new_hook(s) {;}
240
241 #define EMIT_SECTION_SYMBOLS 0
242
243 #define AOUT_STABS
244
245 /* end of obj-aout.h */
This page took 0.055818 seconds and 4 git commands to generate.