Commit | Line | Data |
---|---|---|
fecd2382 RP |
1 | /* a.out object file format |
2 | Copyright (C) 1989, 1990, 1991 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 | |
8 | published by the Free Software Foundation; either version 1, | |
9 | or (at your option) any later version. | |
10 | ||
11 | GAS is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | |
14 | the GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public | |
17 | License along with GAS; see the file COPYING. If not, write | |
18 | to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | /* $Id$ */ | |
21 | ||
22 | /* Tag to validate a.out object file format processing */ | |
23 | #define OBJ_AOUT 1 | |
24 | ||
25 | #include "targ-cpu.h" | |
26 | ||
27 | #ifndef VMS | |
28 | #include "a.out.gnu.h" /* Needed to define struct nlist. Sigh. */ | |
29 | #else | |
30 | #include "a_out.h" | |
31 | #endif | |
32 | ||
33 | extern const short seg_N_TYPE[]; | |
34 | extern const segT N_TYPE_seg[]; | |
35 | ||
36 | #ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE | |
37 | #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC) | |
38 | #endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */ | |
39 | ||
40 | /* SYMBOL TABLE */ | |
41 | /* Symbol table entry data type */ | |
42 | ||
43 | typedef struct nlist obj_symbol_type; /* Symbol table entry */ | |
44 | ||
45 | /* If compiler generate leading underscores, remove them. */ | |
46 | ||
47 | #ifndef STRIP_UNDERSCORE | |
48 | #define STRIP_UNDERSCORE 0 | |
49 | #endif /* STRIP_UNDERSCORE */ | |
50 | ||
51 | /* Symbol table macros and constants */ | |
52 | ||
53 | /* | |
54 | * Macros to extract information from a symbol table entry. | |
55 | * This syntaxic indirection allows independence regarding a.out or coff. | |
56 | * The argument (s) of all these macros is a pointer to a symbol table entry. | |
57 | */ | |
58 | ||
59 | /* True if the symbol is external */ | |
60 | #define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT) | |
61 | ||
62 | /* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */ | |
63 | #define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_OTHER(s) != 0) || (S_GET_DESC(s) != 0)) | |
64 | ||
65 | #define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER) | |
66 | ||
67 | /* True if a debug special symbol entry */ | |
68 | #define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB) | |
69 | /* True if a symbol is local symbol name */ | |
70 | /* A symbol name whose name begin with ^A is a gas internal pseudo symbol | |
71 | nameless symbols come from .stab directives. */ | |
72 | #define S_IS_LOCAL(s) (S_GET_NAME(s) && \ | |
73 | !S_IS_DEBUG(s) && \ | |
74 | (S_GET_NAME(s)[0] == '\001' || \ | |
75 | (S_LOCAL_NAME(s) && !flagseen['L']))) | |
76 | /* True if a symbol is not defined in this file */ | |
77 | #define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT) | |
78 | /* True if the symbol has been generated because of a .stabd directive */ | |
79 | #define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0) | |
80 | ||
81 | /* Accessors */ | |
82 | /* The value of the symbol */ | |
83 | #define S_GET_VALUE(s) (((s)->sy_symbol.n_value)) | |
84 | /* The name of the symbol */ | |
85 | #define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name) | |
86 | /* The pointer to the string table */ | |
87 | #define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx) | |
88 | /* The type of the symbol */ | |
89 | #define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE) | |
90 | /* The numeric value of the segment */ | |
91 | #define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)]) | |
92 | /* The n_other expression value */ | |
93 | #define S_GET_OTHER(s) ((s)->sy_symbol.n_other) | |
94 | /* The n_desc expression value */ | |
95 | #define S_GET_DESC(s) ((s)->sy_symbol.n_desc) | |
96 | ||
97 | /* Modifiers */ | |
98 | /* Set the value of the symbol */ | |
99 | #define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v)) | |
100 | /* Assume that a symbol cannot be simultaneously in more than on segment */ | |
101 | /* set segment */ | |
102 | #define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg)) | |
103 | /* The symbol is external */ | |
104 | #define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT) | |
105 | /* The symbol is not external */ | |
106 | #define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT) | |
107 | /* Set the name of the symbol */ | |
108 | #define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v)) | |
109 | /* Set the offset in the string table */ | |
110 | #define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v)) | |
111 | /* Set the n_other expression value */ | |
112 | #define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v)) | |
113 | /* Set the n_desc expression value */ | |
114 | #define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v)) | |
115 | ||
116 | /* File header macro and type definition */ | |
117 | ||
118 | #define H_GET_FILE_SIZE(h) (sizeof(struct exec) + \ | |
119 | H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ | |
120 | H_GET_SYMBOL_TABLE_SIZE(h) + \ | |
121 | H_GET_TEXT_RELOCATION_SIZE(h) + \ | |
122 | H_GET_DATA_RELOCATION_SIZE(h) + \ | |
123 | (h)->string_table_size) | |
124 | ||
125 | #define H_GET_TEXT_SIZE(h) ((h)->header.a_text) | |
126 | #define H_GET_DATA_SIZE(h) ((h)->header.a_data) | |
127 | #define H_GET_BSS_SIZE(h) ((h)->header.a_bss) | |
128 | #define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize) | |
129 | #define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize) | |
130 | #define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms) | |
131 | #define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info) | |
132 | #define H_GET_ENTRY_POINT(h) ((h)->header.a_entry) | |
133 | #define H_GET_STRING_SIZE(h) ((h)->string_table_size) | |
134 | #ifdef EXEC_MACHINE_TYPE | |
135 | #define H_GET_MACHINE_TYPE(h) ((h)->header.a_machtype) | |
136 | #endif /* EXEC_MACHINE_TYPE */ | |
137 | #ifdef EXEC_VERSION | |
138 | #define H_GET_VERSION(h) ((h)->header.a_version) | |
139 | #endif /* EXEC_VERSION */ | |
140 | ||
141 | #define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v))) | |
142 | #define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v))) | |
143 | #define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v))) | |
144 | ||
145 | #define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\ | |
146 | H_SET_DATA_RELOCATION_SIZE((h),(d))) | |
147 | ||
148 | #define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v)) | |
149 | #define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v)) | |
150 | #define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \ | |
151 | sizeof(struct nlist)) | |
152 | ||
153 | #define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = (v)) | |
154 | ||
155 | #define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v)) | |
156 | #define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v)) | |
157 | #ifdef EXEC_MACHINE_TYPE | |
158 | #define H_SET_MACHINE_TYPE(h,v) ((h)->header.a_machtype = (v)) | |
159 | #endif /* EXEC_MACHINE_TYPE */ | |
160 | #ifdef EXEC_VERSION | |
161 | #define H_SET_VERSION(h,v) ((h)->header.a_version = (v)) | |
162 | #endif /* EXEC_VERSION */ | |
163 | ||
164 | /* | |
165 | * Current means for getting the name of a segment. | |
166 | * This will change for infinite-segments support (e.g. COFF). | |
167 | */ | |
168 | #define segment_name(seg) ( seg_name[(int)(seg)] ) | |
169 | extern char *const seg_name[]; | |
170 | ||
171 | typedef struct { | |
172 | struct exec header; /* a.out header */ | |
173 | long string_table_size; /* names + '\0' + sizeof(int) */ | |
174 | } object_headers; | |
175 | ||
176 | /* line numbering stuff. */ | |
177 | #define OBJ_EMIT_LINENO(a, b, c) ; | |
178 | #define obj_pre_write_hook(a) ; | |
179 | ||
180 | /* | |
181 | * Local Variables: | |
182 | * comment-column: 0 | |
183 | * fill-column: 131 | |
184 | * End: | |
185 | */ | |
186 | ||
187 | /* end of obj-aout.h */ |