1 |
/* BFD back-end for ieee-695 objects. |
/* BFD back-end for ieee-695 objects. |
2 |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
3 |
2000, 2001, 2002 |
2000, 2001, 2002, 2003, 2004, 2005 |
4 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
5 |
|
|
6 |
Written by Steve Chamberlain of Cygnus Support. |
Written by Steve Chamberlain of Cygnus Support. |
40 |
int buffer; |
int buffer; |
41 |
}; |
}; |
42 |
|
|
43 |
static boolean ieee_write_byte PARAMS ((bfd *, int)); |
static bfd_boolean ieee_write_byte |
44 |
static boolean ieee_write_2bytes PARAMS ((bfd *, int)); |
PARAMS ((bfd *, int)); |
45 |
static boolean ieee_write_int PARAMS ((bfd *, bfd_vma)); |
static bfd_boolean ieee_write_2bytes |
46 |
static boolean ieee_write_id PARAMS ((bfd *, const char *)); |
PARAMS ((bfd *, int)); |
47 |
static unsigned short read_2bytes PARAMS ((common_header_type *)); |
static bfd_boolean ieee_write_int |
48 |
static void bfd_get_string PARAMS ((common_header_type *, char *, size_t)); |
PARAMS ((bfd *, bfd_vma)); |
49 |
static char *read_id PARAMS ((common_header_type *)); |
static bfd_boolean ieee_write_id |
50 |
static boolean ieee_write_expression |
PARAMS ((bfd *, const char *)); |
51 |
PARAMS ((bfd *, bfd_vma, asymbol *, boolean, unsigned int)); |
static unsigned short read_2bytes |
52 |
static void ieee_write_int5 PARAMS ((bfd_byte *, bfd_vma)); |
PARAMS ((common_header_type *)); |
53 |
static boolean ieee_write_int5_out PARAMS ((bfd *, bfd_vma)); |
static void bfd_get_string |
54 |
static boolean parse_int PARAMS ((common_header_type *, bfd_vma *)); |
PARAMS ((common_header_type *, char *, size_t)); |
55 |
static int parse_i PARAMS ((common_header_type *, boolean *)); |
static char *read_id |
56 |
static bfd_vma must_parse_int PARAMS ((common_header_type *)); |
PARAMS ((common_header_type *)); |
57 |
|
static bfd_boolean ieee_write_expression |
58 |
|
PARAMS ((bfd *, bfd_vma, asymbol *, bfd_boolean, unsigned int)); |
59 |
|
static void ieee_write_int5 |
60 |
|
PARAMS ((bfd_byte *, bfd_vma)); |
61 |
|
static bfd_boolean ieee_write_int5_out |
62 |
|
PARAMS ((bfd *, bfd_vma)); |
63 |
|
static bfd_boolean parse_int |
64 |
|
PARAMS ((common_header_type *, bfd_vma *)); |
65 |
|
static int parse_i |
66 |
|
PARAMS ((common_header_type *, bfd_boolean *)); |
67 |
|
static bfd_vma must_parse_int |
68 |
|
PARAMS ((common_header_type *)); |
69 |
static void parse_expression |
static void parse_expression |
70 |
PARAMS ((ieee_data_type *, bfd_vma *, ieee_symbol_index_type *, |
PARAMS ((ieee_data_type *, bfd_vma *, ieee_symbol_index_type *, |
71 |
boolean *, unsigned int *, asection **)); |
bfd_boolean *, unsigned int *, asection **)); |
72 |
static file_ptr ieee_part_after PARAMS ((ieee_data_type *, file_ptr)); |
static file_ptr ieee_part_after |
73 |
|
PARAMS ((ieee_data_type *, file_ptr)); |
74 |
static ieee_symbol_type *get_symbol |
static ieee_symbol_type *get_symbol |
75 |
PARAMS ((bfd *, ieee_data_type *, ieee_symbol_type *, unsigned int *, |
PARAMS ((bfd *, ieee_data_type *, ieee_symbol_type *, unsigned int *, |
76 |
ieee_symbol_type ***, unsigned int *, int)); |
ieee_symbol_type ***, unsigned int *, int)); |
77 |
static boolean ieee_slurp_external_symbols PARAMS ((bfd *)); |
static bfd_boolean ieee_slurp_external_symbols |
78 |
static boolean ieee_slurp_symbol_table PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
79 |
static long ieee_get_symtab_upper_bound PARAMS ((bfd *)); |
static bfd_boolean ieee_slurp_symbol_table |
80 |
static long ieee_get_symtab PARAMS ((bfd *, asymbol **)); |
PARAMS ((bfd *)); |
81 |
|
static long ieee_get_symtab_upper_bound |
82 |
|
PARAMS ((bfd *)); |
83 |
|
static long ieee_canonicalize_symtab |
84 |
|
PARAMS ((bfd *, asymbol **)); |
85 |
static asection *get_section_entry |
static asection *get_section_entry |
86 |
PARAMS ((bfd *, ieee_data_type *i, unsigned int)); |
PARAMS ((bfd *, ieee_data_type *i, unsigned int)); |
87 |
static void ieee_slurp_sections PARAMS ((bfd *)); |
static void ieee_slurp_sections |
88 |
static boolean ieee_slurp_debug PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
89 |
const bfd_target *ieee_archive_p PARAMS ((bfd *)); |
static bfd_boolean ieee_slurp_debug |
90 |
const bfd_target *ieee_object_p PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
91 |
static void ieee_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); |
const bfd_target *ieee_archive_p |
92 |
|
PARAMS ((bfd *)); |
93 |
|
const bfd_target *ieee_object_p |
94 |
|
PARAMS ((bfd *)); |
95 |
|
static void ieee_get_symbol_info |
96 |
|
PARAMS ((bfd *, asymbol *, symbol_info *)); |
97 |
static void ieee_print_symbol |
static void ieee_print_symbol |
98 |
PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); |
PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); |
99 |
static boolean do_one |
static bfd_boolean do_one |
100 |
PARAMS ((ieee_data_type *, ieee_per_section_type *, unsigned char *, |
PARAMS ((ieee_data_type *, ieee_per_section_type *, unsigned char *, |
101 |
asection *, int)); |
asection *, int)); |
102 |
static boolean ieee_slurp_section_data PARAMS ((bfd *)); |
static bfd_boolean ieee_slurp_section_data |
103 |
static boolean ieee_new_section_hook PARAMS ((bfd *, asection *)); |
PARAMS ((bfd *)); |
104 |
static long ieee_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); |
static bfd_boolean ieee_new_section_hook |
105 |
static boolean ieee_get_section_contents |
PARAMS ((bfd *, asection *)); |
106 |
|
static long ieee_get_reloc_upper_bound |
107 |
|
PARAMS ((bfd *, sec_ptr)); |
108 |
|
static bfd_boolean ieee_get_section_contents |
109 |
PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); |
PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); |
110 |
static long ieee_canonicalize_reloc |
static long ieee_canonicalize_reloc |
111 |
PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); |
PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); |
112 |
static int comp PARAMS ((const PTR, const PTR)); |
static int comp |
113 |
static boolean ieee_write_section_part PARAMS ((bfd *)); |
PARAMS ((const PTR, const PTR)); |
114 |
static boolean do_with_relocs PARAMS ((bfd *, asection *)); |
static bfd_boolean ieee_write_section_part |
115 |
static boolean do_as_repeat PARAMS ((bfd *, asection *)); |
PARAMS ((bfd *)); |
116 |
static boolean do_without_relocs PARAMS ((bfd *, asection *)); |
static bfd_boolean do_with_relocs |
117 |
static boolean ieee_mkobject PARAMS ((bfd *)); |
PARAMS ((bfd *, asection *)); |
118 |
static void fill PARAMS ((void)); |
static bfd_boolean do_as_repeat |
119 |
static void flush PARAMS ((void)); |
PARAMS ((bfd *, asection *)); |
120 |
static void write_int PARAMS ((int)); |
static bfd_boolean do_without_relocs |
121 |
static void copy_id PARAMS ((void)); |
PARAMS ((bfd *, asection *)); |
122 |
static void copy_expression PARAMS ((void)); |
static bfd_boolean ieee_mkobject |
123 |
static void fill_int PARAMS ((struct output_buffer_struct *)); |
PARAMS ((bfd *)); |
124 |
static void drop_int PARAMS ((struct output_buffer_struct *)); |
static void fill |
125 |
static void copy_int PARAMS ((void)); |
PARAMS ((void)); |
126 |
static void f1_record PARAMS ((void)); |
static void flush |
127 |
static void f0_record PARAMS ((void)); |
PARAMS ((void)); |
128 |
static void copy_till_end PARAMS ((void)); |
static void write_int |
129 |
static void f2_record PARAMS ((void)); |
PARAMS ((int)); |
130 |
static void f8_record PARAMS ((void)); |
static void copy_id |
131 |
static void e2_record PARAMS ((void)); |
PARAMS ((void)); |
132 |
static void block PARAMS ((void)); |
static void copy_expression |
133 |
static void relocate_debug PARAMS ((bfd *, bfd *)); |
PARAMS ((void)); |
134 |
static boolean ieee_write_debug_part PARAMS ((bfd *)); |
static void fill_int |
135 |
static boolean ieee_write_data_part PARAMS ((bfd *)); |
PARAMS ((struct output_buffer_struct *)); |
136 |
static boolean init_for_output PARAMS ((bfd *)); |
static void drop_int |
137 |
static boolean ieee_set_section_contents |
PARAMS ((struct output_buffer_struct *)); |
138 |
PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); |
static void copy_int |
139 |
static boolean ieee_write_external_part PARAMS ((bfd *)); |
PARAMS ((void)); |
140 |
static boolean ieee_write_me_part PARAMS ((bfd *)); |
static void f1_record |
141 |
static boolean ieee_write_processor PARAMS ((bfd *)); |
PARAMS ((void)); |
142 |
static boolean ieee_write_object_contents PARAMS ((bfd *)); |
static void f0_record |
143 |
static asymbol *ieee_make_empty_symbol PARAMS ((bfd *)); |
PARAMS ((void)); |
144 |
static bfd *ieee_openr_next_archived_file PARAMS ((bfd *, bfd *)); |
static void copy_till_end |
145 |
static boolean ieee_find_nearest_line |
PARAMS ((void)); |
146 |
|
static void f2_record |
147 |
|
PARAMS ((void)); |
148 |
|
static void f8_record |
149 |
|
PARAMS ((void)); |
150 |
|
static void e2_record |
151 |
|
PARAMS ((void)); |
152 |
|
static void block |
153 |
|
PARAMS ((void)); |
154 |
|
static void relocate_debug |
155 |
|
PARAMS ((bfd *, bfd *)); |
156 |
|
static bfd_boolean ieee_write_debug_part |
157 |
|
PARAMS ((bfd *)); |
158 |
|
static bfd_boolean ieee_write_data_part |
159 |
|
PARAMS ((bfd *)); |
160 |
|
static bfd_boolean init_for_output |
161 |
|
PARAMS ((bfd *)); |
162 |
|
static bfd_boolean ieee_set_section_contents |
163 |
|
PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type)); |
164 |
|
static bfd_boolean ieee_write_external_part |
165 |
|
PARAMS ((bfd *)); |
166 |
|
static bfd_boolean ieee_write_me_part |
167 |
|
PARAMS ((bfd *)); |
168 |
|
static bfd_boolean ieee_write_processor |
169 |
|
PARAMS ((bfd *)); |
170 |
|
static bfd_boolean ieee_write_object_contents |
171 |
|
PARAMS ((bfd *)); |
172 |
|
static asymbol *ieee_make_empty_symbol |
173 |
|
PARAMS ((bfd *)); |
174 |
|
static bfd *ieee_openr_next_archived_file |
175 |
|
PARAMS ((bfd *, bfd *)); |
176 |
|
static bfd_boolean ieee_find_nearest_line |
177 |
PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, |
PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, |
178 |
const char **, unsigned int *)); |
const char **, unsigned int *)); |
179 |
static int ieee_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); |
static int ieee_generic_stat_arch_elt |
180 |
static int ieee_sizeof_headers PARAMS ((bfd *, boolean)); |
PARAMS ((bfd *, struct stat *)); |
181 |
|
static int ieee_sizeof_headers |
182 |
|
PARAMS ((bfd *, bfd_boolean)); |
183 |
|
|
184 |
/* Functions for writing to ieee files in the strange way that the |
/* Functions for writing to ieee files in the strange way that the |
185 |
standard requires. */ |
standard requires. */ |
186 |
|
|
187 |
static boolean |
static bfd_boolean |
188 |
ieee_write_byte (abfd, barg) |
ieee_write_byte (abfd, barg) |
189 |
bfd *abfd; |
bfd *abfd; |
190 |
int barg; |
int barg; |
193 |
|
|
194 |
byte = barg; |
byte = barg; |
195 |
if (bfd_bwrite ((PTR) &byte, (bfd_size_type) 1, abfd) != 1) |
if (bfd_bwrite ((PTR) &byte, (bfd_size_type) 1, abfd) != 1) |
196 |
return false; |
return FALSE; |
197 |
return true; |
return TRUE; |
198 |
} |
} |
199 |
|
|
200 |
static boolean |
static bfd_boolean |
201 |
ieee_write_2bytes (abfd, bytes) |
ieee_write_2bytes (abfd, bytes) |
202 |
bfd *abfd; |
bfd *abfd; |
203 |
int bytes; |
int bytes; |
207 |
buffer[0] = bytes >> 8; |
buffer[0] = bytes >> 8; |
208 |
buffer[1] = bytes & 0xff; |
buffer[1] = bytes & 0xff; |
209 |
if (bfd_bwrite ((PTR) buffer, (bfd_size_type) 2, abfd) != 2) |
if (bfd_bwrite ((PTR) buffer, (bfd_size_type) 2, abfd) != 2) |
210 |
return false; |
return FALSE; |
211 |
return true; |
return TRUE; |
212 |
} |
} |
213 |
|
|
214 |
static boolean |
static bfd_boolean |
215 |
ieee_write_int (abfd, value) |
ieee_write_int (abfd, value) |
216 |
bfd *abfd; |
bfd *abfd; |
217 |
bfd_vma value; |
bfd_vma value; |
219 |
if (value <= 127) |
if (value <= 127) |
220 |
{ |
{ |
221 |
if (! ieee_write_byte (abfd, (bfd_byte) value)) |
if (! ieee_write_byte (abfd, (bfd_byte) value)) |
222 |
return false; |
return FALSE; |
223 |
} |
} |
224 |
else |
else |
225 |
{ |
{ |
226 |
unsigned int length; |
unsigned int length; |
227 |
|
|
228 |
/* How many significant bytes ? */ |
/* How many significant bytes ? */ |
229 |
/* FIXME FOR LONGER INTS */ |
/* FIXME FOR LONGER INTS. */ |
230 |
if (value & 0xff000000) |
if (value & 0xff000000) |
231 |
length = 4; |
length = 4; |
232 |
else if (value & 0x00ff0000) |
else if (value & 0x00ff0000) |
239 |
if (! ieee_write_byte (abfd, |
if (! ieee_write_byte (abfd, |
240 |
(bfd_byte) ((int) ieee_number_repeat_start_enum |
(bfd_byte) ((int) ieee_number_repeat_start_enum |
241 |
+ length))) |
+ length))) |
242 |
return false; |
return FALSE; |
243 |
switch (length) |
switch (length) |
244 |
{ |
{ |
245 |
case 4: |
case 4: |
246 |
if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24))) |
if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24))) |
247 |
return false; |
return FALSE; |
248 |
/* Fall through. */ |
/* Fall through. */ |
249 |
case 3: |
case 3: |
250 |
if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16))) |
if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16))) |
251 |
return false; |
return FALSE; |
252 |
/* Fall through. */ |
/* Fall through. */ |
253 |
case 2: |
case 2: |
254 |
if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8))) |
if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8))) |
255 |
return false; |
return FALSE; |
256 |
/* Fall through. */ |
/* Fall through. */ |
257 |
case 1: |
case 1: |
258 |
if (! ieee_write_byte (abfd, (bfd_byte) (value))) |
if (! ieee_write_byte (abfd, (bfd_byte) (value))) |
259 |
return false; |
return FALSE; |
260 |
} |
} |
261 |
} |
} |
262 |
|
|
263 |
return true; |
return TRUE; |
264 |
} |
} |
265 |
|
|
266 |
static boolean |
static bfd_boolean |
267 |
ieee_write_id (abfd, id) |
ieee_write_id (abfd, id) |
268 |
bfd *abfd; |
bfd *abfd; |
269 |
const char *id; |
const char *id; |
273 |
if (length <= 127) |
if (length <= 127) |
274 |
{ |
{ |
275 |
if (! ieee_write_byte (abfd, (bfd_byte) length)) |
if (! ieee_write_byte (abfd, (bfd_byte) length)) |
276 |
return false; |
return FALSE; |
277 |
} |
} |
278 |
else if (length < 255) |
else if (length < 255) |
279 |
{ |
{ |
280 |
if (! ieee_write_byte (abfd, ieee_extension_length_1_enum) |
if (! ieee_write_byte (abfd, ieee_extension_length_1_enum) |
281 |
|| ! ieee_write_byte (abfd, (bfd_byte) length)) |
|| ! ieee_write_byte (abfd, (bfd_byte) length)) |
282 |
return false; |
return FALSE; |
283 |
} |
} |
284 |
else if (length < 65535) |
else if (length < 65535) |
285 |
{ |
{ |
286 |
if (! ieee_write_byte (abfd, ieee_extension_length_2_enum) |
if (! ieee_write_byte (abfd, ieee_extension_length_2_enum) |
287 |
|| ! ieee_write_2bytes (abfd, (int) length)) |
|| ! ieee_write_2bytes (abfd, (int) length)) |
288 |
return false; |
return FALSE; |
289 |
} |
} |
290 |
else |
else |
291 |
{ |
{ |
293 |
(_("%s: string too long (%d chars, max 65535)"), |
(_("%s: string too long (%d chars, max 65535)"), |
294 |
bfd_get_filename (abfd), length); |
bfd_get_filename (abfd), length); |
295 |
bfd_set_error (bfd_error_invalid_operation); |
bfd_set_error (bfd_error_invalid_operation); |
296 |
return false; |
return FALSE; |
297 |
} |
} |
298 |
|
|
299 |
if (bfd_bwrite ((PTR) id, (bfd_size_type) length, abfd) != length) |
if (bfd_bwrite ((PTR) id, (bfd_size_type) length, abfd) != length) |
300 |
return false; |
return FALSE; |
301 |
return true; |
return TRUE; |
302 |
} |
} |
303 |
|
|
304 |
/*************************************************************************** |
/* Functions for reading from ieee files in the strange way that the |
305 |
Functions for reading from ieee files in the strange way that the |
standard requires. */ |
|
standard requires: |
|
|
*/ |
|
306 |
|
|
307 |
#define this_byte(ieee) *((ieee)->input_p) |
#define this_byte(ieee) *((ieee)->input_p) |
308 |
#define next_byte(ieee) ((ieee)->input_p++) |
#define next_byte(ieee) ((ieee)->input_p++) |
314 |
{ |
{ |
315 |
unsigned char c1 = this_byte_and_next (ieee); |
unsigned char c1 = this_byte_and_next (ieee); |
316 |
unsigned char c2 = this_byte_and_next (ieee); |
unsigned char c2 = this_byte_and_next (ieee); |
317 |
|
|
318 |
return (c1 << 8) | c2; |
return (c1 << 8) | c2; |
319 |
} |
} |
320 |
|
|
325 |
size_t length; |
size_t length; |
326 |
{ |
{ |
327 |
size_t i; |
size_t i; |
328 |
|
|
329 |
for (i = 0; i < length; i++) |
for (i = 0; i < length; i++) |
330 |
{ |
string[i] = this_byte_and_next (ieee); |
|
string[i] = this_byte_and_next (ieee); |
|
|
} |
|
331 |
} |
} |
332 |
|
|
333 |
static char * |
static char * |
336 |
{ |
{ |
337 |
size_t length; |
size_t length; |
338 |
char *string; |
char *string; |
339 |
|
|
340 |
length = this_byte_and_next (ieee); |
length = this_byte_and_next (ieee); |
341 |
if (length <= 0x7f) |
if (length <= 0x7f) |
342 |
{ |
{ |
343 |
/* Simple string of length 0 to 127 */ |
/* Simple string of length 0 to 127. */ |
344 |
} |
} |
345 |
else if (length == 0xde) |
else if (length == 0xde) |
346 |
{ |
{ |
347 |
/* Length is next byte, allowing 0..255 */ |
/* Length is next byte, allowing 0..255. */ |
348 |
length = this_byte_and_next (ieee); |
length = this_byte_and_next (ieee); |
349 |
} |
} |
350 |
else if (length == 0xdf) |
else if (length == 0xdf) |
351 |
{ |
{ |
352 |
/* Length is next two bytes, allowing 0..65535 */ |
/* Length is next two bytes, allowing 0..65535. */ |
353 |
length = this_byte_and_next (ieee); |
length = this_byte_and_next (ieee); |
354 |
length = (length * 256) + this_byte_and_next (ieee); |
length = (length * 256) + this_byte_and_next (ieee); |
355 |
} |
} |
356 |
/* Buy memory and read string */ |
|
357 |
|
/* Buy memory and read string. */ |
358 |
string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1); |
string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1); |
359 |
if (!string) |
if (!string) |
360 |
return NULL; |
return NULL; |
363 |
return string; |
return string; |
364 |
} |
} |
365 |
|
|
366 |
static boolean |
static bfd_boolean |
367 |
ieee_write_expression (abfd, value, symbol, pcrel, index) |
ieee_write_expression (abfd, value, symbol, pcrel, index) |
368 |
bfd *abfd; |
bfd *abfd; |
369 |
bfd_vma value; |
bfd_vma value; |
370 |
asymbol *symbol; |
asymbol *symbol; |
371 |
boolean pcrel; |
bfd_boolean pcrel; |
372 |
unsigned int index; |
unsigned int index; |
373 |
{ |
{ |
374 |
unsigned int term_count = 0; |
unsigned int term_count = 0; |
376 |
if (value != 0) |
if (value != 0) |
377 |
{ |
{ |
378 |
if (! ieee_write_int (abfd, value)) |
if (! ieee_write_int (abfd, value)) |
379 |
return false; |
return FALSE; |
380 |
term_count++; |
term_count++; |
381 |
} |
} |
382 |
|
|
383 |
if (bfd_is_com_section (symbol->section) |
/* Badly formatted binaries can have a missing symbol, |
384 |
|| bfd_is_und_section (symbol->section)) |
so test here to prevent a seg fault. */ |
385 |
{ |
if (symbol != NULL) |
|
/* Def of a common symbol */ |
|
|
if (! ieee_write_byte (abfd, ieee_variable_X_enum) |
|
|
|| ! ieee_write_int (abfd, symbol->value)) |
|
|
return false; |
|
|
term_count++; |
|
|
} |
|
|
else if (! bfd_is_abs_section (symbol->section)) |
|
386 |
{ |
{ |
387 |
/* Ref to defined symbol - */ |
if (bfd_is_com_section (symbol->section) |
388 |
|
|| bfd_is_und_section (symbol->section)) |
|
if (symbol->flags & BSF_GLOBAL) |
|
389 |
{ |
{ |
390 |
if (! ieee_write_byte (abfd, ieee_variable_I_enum) |
/* Def of a common symbol. */ |
391 |
|
if (! ieee_write_byte (abfd, ieee_variable_X_enum) |
392 |
|| ! ieee_write_int (abfd, symbol->value)) |
|| ! ieee_write_int (abfd, symbol->value)) |
393 |
return false; |
return FALSE; |
394 |
term_count++; |
term_count ++; |
395 |
} |
} |
396 |
else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM)) |
else if (! bfd_is_abs_section (symbol->section)) |
397 |
{ |
{ |
398 |
/* This is a reference to a defined local symbol. We can |
/* Ref to defined symbol - */ |
399 |
easily do a local as a section+offset. */ |
|
400 |
if (! ieee_write_byte (abfd, ieee_variable_R_enum) |
if (symbol->flags & BSF_GLOBAL) |
|
|| ! ieee_write_byte (abfd, |
|
|
(bfd_byte) (symbol->section->index |
|
|
+ IEEE_SECTION_NUMBER_BASE))) |
|
|
return false; |
|
|
term_count++; |
|
|
if (symbol->value != 0) |
|
401 |
{ |
{ |
402 |
if (! ieee_write_int (abfd, symbol->value)) |
if (! ieee_write_byte (abfd, ieee_variable_I_enum) |
403 |
return false; |
|| ! ieee_write_int (abfd, symbol->value)) |
404 |
|
return FALSE; |
405 |
term_count++; |
term_count++; |
406 |
} |
} |
407 |
} |
else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM)) |
408 |
else |
{ |
409 |
{ |
/* This is a reference to a defined local symbol. We can |
410 |
(*_bfd_error_handler) |
easily do a local as a section+offset. */ |
411 |
(_("%s: unrecognized symbol `%s' flags 0x%x"), |
if (! ieee_write_byte (abfd, ieee_variable_R_enum) |
412 |
bfd_get_filename (abfd), bfd_asymbol_name (symbol), |
|| ! ieee_write_byte (abfd, |
413 |
symbol->flags); |
(bfd_byte) (symbol->section->index |
414 |
bfd_set_error (bfd_error_invalid_operation); |
+ IEEE_SECTION_NUMBER_BASE))) |
415 |
return false; |
return FALSE; |
416 |
|
|
417 |
|
term_count++; |
418 |
|
if (symbol->value != 0) |
419 |
|
{ |
420 |
|
if (! ieee_write_int (abfd, symbol->value)) |
421 |
|
return FALSE; |
422 |
|
term_count++; |
423 |
|
} |
424 |
|
} |
425 |
|
else |
426 |
|
{ |
427 |
|
(*_bfd_error_handler) |
428 |
|
(_("%s: unrecognized symbol `%s' flags 0x%x"), |
429 |
|
bfd_get_filename (abfd), bfd_asymbol_name (symbol), |
430 |
|
symbol->flags); |
431 |
|
bfd_set_error (bfd_error_invalid_operation); |
432 |
|
return FALSE; |
433 |
|
} |
434 |
} |
} |
435 |
} |
} |
436 |
|
|
437 |
if (pcrel) |
if (pcrel) |
438 |
{ |
{ |
439 |
/* subtract the pc from here by asking for PC of this section*/ |
/* Subtract the pc from here by asking for PC of this section. */ |
440 |
if (! ieee_write_byte (abfd, ieee_variable_P_enum) |
if (! ieee_write_byte (abfd, ieee_variable_P_enum) |
441 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
442 |
(bfd_byte) (index + IEEE_SECTION_NUMBER_BASE)) |
(bfd_byte) (index + IEEE_SECTION_NUMBER_BASE)) |
443 |
|| ! ieee_write_byte (abfd, ieee_function_minus_enum)) |
|| ! ieee_write_byte (abfd, ieee_function_minus_enum)) |
444 |
return false; |
return FALSE; |
445 |
} |
} |
446 |
|
|
447 |
/* Handle the degenerate case of a 0 address. */ |
/* Handle the degenerate case of a 0 address. */ |
448 |
if (term_count == 0) |
if (term_count == 0) |
449 |
{ |
if (! ieee_write_int (abfd, (bfd_vma) 0)) |
450 |
if (! ieee_write_int (abfd, (bfd_vma) 0)) |
return FALSE; |
|
return false; |
|
|
} |
|
451 |
|
|
452 |
while (term_count > 1) |
while (term_count > 1) |
453 |
{ |
{ |
454 |
if (! ieee_write_byte (abfd, ieee_function_plus_enum)) |
if (! ieee_write_byte (abfd, ieee_function_plus_enum)) |
455 |
return false; |
return FALSE; |
456 |
term_count--; |
term_count--; |
457 |
} |
} |
458 |
|
|
459 |
return true; |
return TRUE; |
460 |
} |
} |
461 |
|
|
462 |
/*****************************************************************************/ |
/* Writes any integer into the buffer supplied and always takes 5 bytes. */ |
463 |
|
|
|
/* |
|
|
writes any integer into the buffer supplied and always takes 5 bytes |
|
|
*/ |
|
464 |
static void |
static void |
465 |
ieee_write_int5 (buffer, value) |
ieee_write_int5 (buffer, value) |
466 |
bfd_byte *buffer; |
bfd_byte *buffer; |
473 |
buffer[4] = (value >> 0) & 0xff; |
buffer[4] = (value >> 0) & 0xff; |
474 |
} |
} |
475 |
|
|
476 |
static boolean |
static bfd_boolean |
477 |
ieee_write_int5_out (abfd, value) |
ieee_write_int5_out (abfd, value) |
478 |
bfd *abfd; |
bfd *abfd; |
479 |
bfd_vma value; |
bfd_vma value; |
482 |
|
|
483 |
ieee_write_int5 (b, value); |
ieee_write_int5 (b, value); |
484 |
if (bfd_bwrite ((PTR) b, (bfd_size_type) 5, abfd) != 5) |
if (bfd_bwrite ((PTR) b, (bfd_size_type) 5, abfd) != 5) |
485 |
return false; |
return FALSE; |
486 |
return true; |
return TRUE; |
487 |
} |
} |
488 |
|
|
489 |
static boolean |
static bfd_boolean |
490 |
parse_int (ieee, value_ptr) |
parse_int (ieee, value_ptr) |
491 |
common_header_type *ieee; |
common_header_type *ieee; |
492 |
bfd_vma *value_ptr; |
bfd_vma *value_ptr; |
493 |
{ |
{ |
494 |
int value = this_byte (ieee); |
int value = this_byte (ieee); |
495 |
int result; |
int result; |
496 |
|
|
497 |
if (value >= 0 && value <= 127) |
if (value >= 0 && value <= 127) |
498 |
{ |
{ |
499 |
*value_ptr = value; |
*value_ptr = value; |
500 |
next_byte (ieee); |
next_byte (ieee); |
501 |
return true; |
return TRUE; |
502 |
} |
} |
503 |
else if (value >= 0x80 && value <= 0x88) |
else if (value >= 0x80 && value <= 0x88) |
504 |
{ |
{ |
505 |
unsigned int count = value & 0xf; |
unsigned int count = value & 0xf; |
506 |
|
|
507 |
result = 0; |
result = 0; |
508 |
next_byte (ieee); |
next_byte (ieee); |
509 |
while (count) |
while (count) |
512 |
count--; |
count--; |
513 |
} |
} |
514 |
*value_ptr = result; |
*value_ptr = result; |
515 |
return true; |
return TRUE; |
516 |
} |
} |
517 |
return false; |
return FALSE; |
518 |
} |
} |
519 |
|
|
520 |
static int |
static int |
521 |
parse_i (ieee, ok) |
parse_i (ieee, ok) |
522 |
common_header_type *ieee; |
common_header_type *ieee; |
523 |
boolean *ok; |
bfd_boolean *ok; |
524 |
{ |
{ |
525 |
bfd_vma x; |
bfd_vma x; |
526 |
*ok = parse_int (ieee, &x); |
*ok = parse_int (ieee, &x); |
547 |
#if KEEPMINUSPCININST |
#if KEEPMINUSPCININST |
548 |
|
|
549 |
#define SRC_MASK(arg) arg |
#define SRC_MASK(arg) arg |
550 |
#define PCREL_OFFSET false |
#define PCREL_OFFSET FALSE |
551 |
|
|
552 |
#else |
#else |
553 |
|
|
554 |
#define SRC_MASK(arg) 0 |
#define SRC_MASK(arg) 0 |
555 |
#define PCREL_OFFSET true |
#define PCREL_OFFSET TRUE |
556 |
|
|
557 |
#endif |
#endif |
558 |
|
|
561 |
0, |
0, |
562 |
2, |
2, |
563 |
32, |
32, |
564 |
false, |
FALSE, |
565 |
0, |
0, |
566 |
complain_overflow_bitfield, |
complain_overflow_bitfield, |
567 |
0, |
0, |
568 |
"abs32", |
"abs32", |
569 |
true, |
TRUE, |
570 |
0xffffffff, |
0xffffffff, |
571 |
0xffffffff, |
0xffffffff, |
572 |
false); |
FALSE); |
573 |
|
|
574 |
static reloc_howto_type abs16_howto = |
static reloc_howto_type abs16_howto = |
575 |
HOWTO (1, |
HOWTO (1, |
576 |
0, |
0, |
577 |
1, |
1, |
578 |
16, |
16, |
579 |
false, |
FALSE, |
580 |
0, |
0, |
581 |
complain_overflow_bitfield, |
complain_overflow_bitfield, |
582 |
0, |
0, |
583 |
"abs16", |
"abs16", |
584 |
true, |
TRUE, |
585 |
0x0000ffff, |
0x0000ffff, |
586 |
0x0000ffff, |
0x0000ffff, |
587 |
false); |
FALSE); |
588 |
|
|
589 |
static reloc_howto_type abs8_howto = |
static reloc_howto_type abs8_howto = |
590 |
HOWTO (1, |
HOWTO (1, |
591 |
0, |
0, |
592 |
0, |
0, |
593 |
8, |
8, |
594 |
false, |
FALSE, |
595 |
0, |
0, |
596 |
complain_overflow_bitfield, |
complain_overflow_bitfield, |
597 |
0, |
0, |
598 |
"abs8", |
"abs8", |
599 |
true, |
TRUE, |
600 |
0x000000ff, |
0x000000ff, |
601 |
0x000000ff, |
0x000000ff, |
602 |
false); |
FALSE); |
603 |
|
|
604 |
static reloc_howto_type rel32_howto = |
static reloc_howto_type rel32_howto = |
605 |
HOWTO (1, |
HOWTO (1, |
606 |
0, |
0, |
607 |
2, |
2, |
608 |
32, |
32, |
609 |
true, |
TRUE, |
610 |
0, |
0, |
611 |
complain_overflow_signed, |
complain_overflow_signed, |
612 |
0, |
0, |
613 |
"rel32", |
"rel32", |
614 |
true, |
TRUE, |
615 |
SRC_MASK (0xffffffff), |
SRC_MASK (0xffffffff), |
616 |
0xffffffff, |
0xffffffff, |
617 |
PCREL_OFFSET); |
PCREL_OFFSET); |
621 |
0, |
0, |
622 |
1, |
1, |
623 |
16, |
16, |
624 |
true, |
TRUE, |
625 |
0, |
0, |
626 |
complain_overflow_signed, |
complain_overflow_signed, |
627 |
0, |
0, |
628 |
"rel16", |
"rel16", |
629 |
true, |
TRUE, |
630 |
SRC_MASK (0x0000ffff), |
SRC_MASK (0x0000ffff), |
631 |
0x0000ffff, |
0x0000ffff, |
632 |
PCREL_OFFSET); |
PCREL_OFFSET); |
636 |
0, |
0, |
637 |
0, |
0, |
638 |
8, |
8, |
639 |
true, |
TRUE, |
640 |
0, |
0, |
641 |
complain_overflow_signed, |
complain_overflow_signed, |
642 |
0, |
0, |
643 |
"rel8", |
"rel8", |
644 |
true, |
TRUE, |
645 |
SRC_MASK (0x000000ff), |
SRC_MASK (0x000000ff), |
646 |
0x000000ff, |
0x000000ff, |
647 |
PCREL_OFFSET); |
PCREL_OFFSET); |
653 |
ieee_data_type *ieee; |
ieee_data_type *ieee; |
654 |
bfd_vma *value; |
bfd_vma *value; |
655 |
ieee_symbol_index_type *symbol; |
ieee_symbol_index_type *symbol; |
656 |
boolean *pcrel; |
bfd_boolean *pcrel; |
657 |
unsigned int *extra; |
unsigned int *extra; |
658 |
asection **section; |
asection **section; |
659 |
|
|
664 |
#define INC sp++; |
#define INC sp++; |
665 |
#define DEC sp--; |
#define DEC sp--; |
666 |
|
|
667 |
boolean loop = true; |
bfd_boolean loop = TRUE; |
668 |
ieee_value_type stack[10]; |
ieee_value_type stack[10]; |
669 |
|
|
670 |
/* The stack pointer always points to the next unused location */ |
/* The stack pointer always points to the next unused location. */ |
671 |
#define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC; |
#define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC; |
672 |
#define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value; |
#define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value; |
673 |
ieee_value_type *sp = stack; |
ieee_value_type *sp = stack; |
678 |
switch (this_byte (&(ieee->h))) |
switch (this_byte (&(ieee->h))) |
679 |
{ |
{ |
680 |
case ieee_variable_P_enum: |
case ieee_variable_P_enum: |
681 |
/* P variable, current program counter for section n */ |
/* P variable, current program counter for section n. */ |
682 |
{ |
{ |
683 |
int section_n; |
int section_n; |
684 |
|
|
685 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
686 |
*pcrel = true; |
*pcrel = TRUE; |
687 |
section_n = must_parse_int (&(ieee->h)); |
section_n = must_parse_int (&(ieee->h)); |
688 |
PUSH (NOSYMBOL, bfd_abs_section_ptr, 0); |
PUSH (NOSYMBOL, bfd_abs_section_ptr, 0); |
689 |
break; |
break; |
690 |
} |
} |
691 |
case ieee_variable_L_enum: |
case ieee_variable_L_enum: |
692 |
/* L variable address of section N */ |
/* L variable address of section N. */ |
693 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
694 |
PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); |
PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); |
695 |
break; |
break; |
696 |
case ieee_variable_R_enum: |
case ieee_variable_R_enum: |
697 |
/* R variable, logical address of section module */ |
/* R variable, logical address of section module. */ |
698 |
/* FIXME, this should be different to L */ |
/* FIXME, this should be different to L. */ |
699 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
700 |
PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); |
PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); |
701 |
break; |
break; |
702 |
case ieee_variable_S_enum: |
case ieee_variable_S_enum: |
703 |
/* S variable, size in MAUS of section module */ |
/* S variable, size in MAUS of section module. */ |
704 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
705 |
PUSH (NOSYMBOL, |
PUSH (NOSYMBOL, |
706 |
0, |
0, |
707 |
ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size); |
ieee->section_table[must_parse_int (&(ieee->h))]->size); |
708 |
break; |
break; |
709 |
case ieee_variable_I_enum: |
case ieee_variable_I_enum: |
710 |
/* Push the address of variable n */ |
/* Push the address of variable n. */ |
711 |
{ |
{ |
712 |
ieee_symbol_index_type sy; |
ieee_symbol_index_type sy; |
713 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
718 |
} |
} |
719 |
break; |
break; |
720 |
case ieee_variable_X_enum: |
case ieee_variable_X_enum: |
721 |
/* Push the address of external variable n */ |
/* Push the address of external variable n. */ |
722 |
{ |
{ |
723 |
ieee_symbol_index_type sy; |
ieee_symbol_index_type sy; |
724 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
768 |
else |
else |
769 |
{ |
{ |
770 |
/* Thats all that we can understand. */ |
/* Thats all that we can understand. */ |
771 |
loop = false; |
loop = FALSE; |
772 |
} |
} |
773 |
} |
} |
774 |
} |
} |
780 |
terms. We can tell if that's the case by ensuring that |
terms. We can tell if that's the case by ensuring that |
781 |
sp == stack here. If not, then we've pushed something too far, |
sp == stack here. If not, then we've pushed something too far, |
782 |
so we keep adding. */ |
so we keep adding. */ |
|
|
|
783 |
while (sp != stack + 1) |
while (sp != stack + 1) |
784 |
{ |
{ |
785 |
asection *section1; |
asection *section1; |
825 |
} |
} |
826 |
|
|
827 |
static unsigned int last_index; |
static unsigned int last_index; |
828 |
static char last_type; /* is the index for an X or a D */ |
static char last_type; /* Is the index for an X or a D. */ |
829 |
|
|
830 |
static ieee_symbol_type * |
static ieee_symbol_type * |
831 |
get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type) |
get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type) |
837 |
unsigned int *max_index; |
unsigned int *max_index; |
838 |
int this_type; |
int this_type; |
839 |
{ |
{ |
840 |
/* Need a new symbol */ |
/* Need a new symbol. */ |
841 |
unsigned int new_index = must_parse_int (&(ieee->h)); |
unsigned int new_index = must_parse_int (&(ieee->h)); |
842 |
|
|
843 |
if (new_index != last_index || this_type != last_type) |
if (new_index != last_index || this_type != last_type) |
844 |
{ |
{ |
845 |
ieee_symbol_type *new_symbol; |
ieee_symbol_type *new_symbol; |
855 |
**pptr = new_symbol; |
**pptr = new_symbol; |
856 |
*pptr = &new_symbol->next; |
*pptr = &new_symbol->next; |
857 |
if (new_index > *max_index) |
if (new_index > *max_index) |
858 |
{ |
*max_index = new_index; |
859 |
*max_index = new_index; |
|
|
} |
|
860 |
last_type = this_type; |
last_type = this_type; |
861 |
new_symbol->symbol.section = bfd_abs_section_ptr; |
new_symbol->symbol.section = bfd_abs_section_ptr; |
862 |
return new_symbol; |
return new_symbol; |
864 |
return last_symbol; |
return last_symbol; |
865 |
} |
} |
866 |
|
|
867 |
static boolean |
static bfd_boolean |
868 |
ieee_slurp_external_symbols (abfd) |
ieee_slurp_external_symbols (abfd) |
869 |
bfd *abfd; |
bfd *abfd; |
870 |
{ |
{ |
875 |
ieee_symbol_type **prev_reference_ptr = &ieee->external_reference; |
ieee_symbol_type **prev_reference_ptr = &ieee->external_reference; |
876 |
ieee_symbol_type *symbol = (ieee_symbol_type *) NULL; |
ieee_symbol_type *symbol = (ieee_symbol_type *) NULL; |
877 |
unsigned int symbol_count = 0; |
unsigned int symbol_count = 0; |
878 |
boolean loop = true; |
bfd_boolean loop = TRUE; |
879 |
last_index = 0xffffff; |
last_index = 0xffffff; |
880 |
ieee->symbol_table_full = true; |
ieee->symbol_table_full = TRUE; |
881 |
|
|
882 |
ieee_seek (ieee, offset); |
ieee_seek (ieee, offset); |
883 |
|
|
892 |
&prev_symbols_ptr, |
&prev_symbols_ptr, |
893 |
&ieee->external_symbol_max_index, 'I'); |
&ieee->external_symbol_max_index, 'I'); |
894 |
if (symbol == NULL) |
if (symbol == NULL) |
895 |
return false; |
return FALSE; |
896 |
|
|
897 |
symbol->symbol.the_bfd = abfd; |
symbol->symbol.the_bfd = abfd; |
898 |
symbol->symbol.name = read_id (&(ieee->h)); |
symbol->symbol.name = read_id (&(ieee->h)); |
906 |
&prev_symbols_ptr, |
&prev_symbols_ptr, |
907 |
&ieee->external_symbol_max_index, 'D'); |
&ieee->external_symbol_max_index, 'D'); |
908 |
if (symbol == NULL) |
if (symbol == NULL) |
909 |
return false; |
return FALSE; |
910 |
|
|
911 |
BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index); |
BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index); |
912 |
|
|
935 |
break; |
break; |
936 |
default: |
default: |
937 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
938 |
(_("%s: unimplemented ATI record %u for symbol %u"), |
(_("%B: unimplemented ATI record %u for symbol %u"), |
939 |
bfd_archive_filename (abfd), symbol_attribute_def, |
abfd, symbol_attribute_def, symbol_name_index); |
|
symbol_name_index); |
|
940 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
941 |
return false; |
return FALSE; |
942 |
break; |
break; |
943 |
} |
} |
944 |
break; |
break; |
945 |
case ieee_external_reference_info_record_enum: |
case ieee_external_reference_info_record_enum: |
946 |
/* Skip over ATX record. */ |
/* Skip over ATX record. */ |
947 |
parse_int (&(ieee->h), &value); |
parse_int (&(ieee->h), &value); |
948 |
parse_int (&(ieee->h), &value); |
parse_int (&(ieee->h), &value); |
949 |
parse_int (&(ieee->h), &value); |
parse_int (&(ieee->h), &value); |
952 |
case ieee_atn_record_enum: |
case ieee_atn_record_enum: |
953 |
/* We may get call optimization information here, |
/* We may get call optimization information here, |
954 |
which we just ignore. The format is |
which we just ignore. The format is |
955 |
{$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs} */ |
{$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs}. */ |
956 |
parse_int (&ieee->h, &value); |
parse_int (&ieee->h, &value); |
957 |
parse_int (&ieee->h, &value); |
parse_int (&ieee->h, &value); |
958 |
parse_int (&ieee->h, &value); |
parse_int (&ieee->h, &value); |
959 |
if (value != 0x3f) |
if (value != 0x3f) |
960 |
{ |
{ |
961 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
962 |
(_("%s: unexpected ATN type %d in external part"), |
(_("%B: unexpected ATN type %d in external part"), |
963 |
bfd_archive_filename (abfd), (int) value); |
abfd, (int) value); |
964 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
965 |
return false; |
return FALSE; |
966 |
} |
} |
967 |
parse_int (&ieee->h, &value); |
parse_int (&ieee->h, &value); |
968 |
parse_int (&ieee->h, &value); |
parse_int (&ieee->h, &value); |
981 |
|
|
982 |
default: |
default: |
983 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
984 |
(_("%s: unexpected type after ATN"), |
(_("%B: unexpected type after ATN"), abfd); |
|
bfd_archive_filename (abfd)); |
|
985 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
986 |
return false; |
return FALSE; |
987 |
} |
} |
988 |
} |
} |
989 |
} |
} |
993 |
{ |
{ |
994 |
unsigned int symbol_name_index; |
unsigned int symbol_name_index; |
995 |
ieee_symbol_index_type symbol_ignore; |
ieee_symbol_index_type symbol_ignore; |
996 |
boolean pcrel_ignore; |
bfd_boolean pcrel_ignore; |
997 |
unsigned int extra; |
unsigned int extra; |
998 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
999 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1019 |
val = symbol->symbol.value; |
val = symbol->symbol.value; |
1020 |
for (s = abfd->sections; s != NULL; s = s->next) |
for (s = abfd->sections; s != NULL; s = s->next) |
1021 |
{ |
{ |
1022 |
if (val >= s->vma && val < s->vma + s->_raw_size) |
if (val >= s->vma && val < s->vma + s->size) |
1023 |
{ |
{ |
1024 |
symbol->symbol.section = s; |
symbol->symbol.section = s; |
1025 |
symbol->symbol.value -= s->vma; |
symbol->symbol.value -= s->vma; |
1037 |
bfd_vma size; |
bfd_vma size; |
1038 |
bfd_vma value; |
bfd_vma value; |
1039 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1040 |
/* Throw away the external reference index */ |
/* Throw away the external reference index. */ |
1041 |
(void) must_parse_int (&(ieee->h)); |
(void) must_parse_int (&(ieee->h)); |
1042 |
/* Fetch the default size if not resolved */ |
/* Fetch the default size if not resolved. */ |
1043 |
size = must_parse_int (&(ieee->h)); |
size = must_parse_int (&(ieee->h)); |
1044 |
/* Fetch the defautlt value if available */ |
/* Fetch the default value if available. */ |
1045 |
if (! parse_int (&(ieee->h), &value)) |
if (! parse_int (&(ieee->h), &value)) |
1046 |
{ |
{ |
1047 |
value = 0; |
value = 0; |
1048 |
} |
} |
1049 |
/* This turns into a common */ |
/* This turns into a common. */ |
1050 |
symbol->symbol.section = bfd_com_section_ptr; |
symbol->symbol.section = bfd_com_section_ptr; |
1051 |
symbol->symbol.value = size; |
symbol->symbol.value = size; |
1052 |
} |
} |
1059 |
&prev_reference_ptr, |
&prev_reference_ptr, |
1060 |
&ieee->external_reference_max_index, 'X'); |
&ieee->external_reference_max_index, 'X'); |
1061 |
if (symbol == NULL) |
if (symbol == NULL) |
1062 |
return false; |
return FALSE; |
1063 |
|
|
1064 |
symbol->symbol.the_bfd = abfd; |
symbol->symbol.the_bfd = abfd; |
1065 |
symbol->symbol.name = read_id (&(ieee->h)); |
symbol->symbol.name = read_id (&(ieee->h)); |
1072 |
break; |
break; |
1073 |
|
|
1074 |
default: |
default: |
1075 |
loop = false; |
loop = FALSE; |
1076 |
} |
} |
1077 |
} |
} |
1078 |
|
|
1104 |
if (symbol_count != abfd->symcount) |
if (symbol_count != abfd->symcount) |
1105 |
{ |
{ |
1106 |
/* There are gaps in the table -- */ |
/* There are gaps in the table -- */ |
1107 |
ieee->symbol_table_full = false; |
ieee->symbol_table_full = FALSE; |
1108 |
} |
} |
1109 |
|
|
1110 |
*prev_symbols_ptr = (ieee_symbol_type *) NULL; |
*prev_symbols_ptr = (ieee_symbol_type *) NULL; |
1111 |
*prev_reference_ptr = (ieee_symbol_type *) NULL; |
*prev_reference_ptr = (ieee_symbol_type *) NULL; |
1112 |
|
|
1113 |
return true; |
return TRUE; |
1114 |
} |
} |
1115 |
|
|
1116 |
static boolean |
static bfd_boolean |
1117 |
ieee_slurp_symbol_table (abfd) |
ieee_slurp_symbol_table (abfd) |
1118 |
bfd *abfd; |
bfd *abfd; |
1119 |
{ |
{ |
1120 |
if (! IEEE_DATA (abfd)->read_symbols) |
if (! IEEE_DATA (abfd)->read_symbols) |
1121 |
{ |
{ |
1122 |
if (! ieee_slurp_external_symbols (abfd)) |
if (! ieee_slurp_external_symbols (abfd)) |
1123 |
return false; |
return FALSE; |
1124 |
IEEE_DATA (abfd)->read_symbols = true; |
IEEE_DATA (abfd)->read_symbols = TRUE; |
1125 |
} |
} |
1126 |
return true; |
return TRUE; |
1127 |
} |
} |
1128 |
|
|
1129 |
static long |
static long |
1137 |
(abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0; |
(abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0; |
1138 |
} |
} |
1139 |
|
|
1140 |
/* |
/* Move from our internal lists to the canon table, and insert in |
1141 |
Move from our internal lists to the canon table, and insert in |
symbol index order. */ |
|
symbol index order |
|
|
*/ |
|
1142 |
|
|
1143 |
extern const bfd_target ieee_vec; |
extern const bfd_target ieee_vec; |
1144 |
|
|
1145 |
static long |
static long |
1146 |
ieee_get_symtab (abfd, location) |
ieee_canonicalize_symtab (abfd, location) |
1147 |
bfd *abfd; |
bfd *abfd; |
1148 |
asymbol **location; |
asymbol **location; |
1149 |
{ |
{ |
1171 |
|
|
1172 |
if (! ieee->symbol_table_full) |
if (! ieee->symbol_table_full) |
1173 |
{ |
{ |
1174 |
/* Arrgh - there are gaps in the table, run through and fill them */ |
/* Arrgh - there are gaps in the table, run through and fill them |
1175 |
/* up with pointers to a null place */ |
up with pointers to a null place. */ |
1176 |
unsigned int i; |
unsigned int i; |
1177 |
|
|
1178 |
for (i = 0; i < abfd->symcount; i++) |
for (i = 0; i < abfd->symcount; i++) |
1179 |
{ |
location[i] = &empty_symbol; |
|
location[i] = &empty_symbol; |
|
|
} |
|
1180 |
} |
} |
1181 |
|
|
1182 |
ieee->external_symbol_base_offset = -ieee->external_symbol_min_index; |
ieee->external_symbol_base_offset = -ieee->external_symbol_min_index; |
1183 |
for (symp = IEEE_DATA (abfd)->external_symbols; |
for (symp = IEEE_DATA (abfd)->external_symbols; |
1184 |
symp != (ieee_symbol_type *) NULL; |
symp != (ieee_symbol_type *) NULL; |
1185 |
symp = symp->next) |
symp = symp->next) |
1186 |
{ |
/* Place into table at correct index locations. */ |
1187 |
/* Place into table at correct index locations */ |
location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol; |
|
location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol; |
|
|
} |
|
1188 |
|
|
1189 |
/* The external refs are indexed in a bit */ |
/* The external refs are indexed in a bit. */ |
1190 |
ieee->external_reference_base_offset = |
ieee->external_reference_base_offset = |
1191 |
-ieee->external_reference_min_index + ieee->external_symbol_count; |
-ieee->external_reference_min_index + ieee->external_symbol_count; |
1192 |
|
|
1193 |
for (symp = IEEE_DATA (abfd)->external_reference; |
for (symp = IEEE_DATA (abfd)->external_reference; |
1194 |
symp != (ieee_symbol_type *) NULL; |
symp != (ieee_symbol_type *) NULL; |
1195 |
symp = symp->next) |
symp = symp->next) |
1196 |
{ |
location[symp->index + ieee->external_reference_base_offset] = |
1197 |
location[symp->index + ieee->external_reference_base_offset] = |
&symp->symbol; |
|
&symp->symbol; |
|
|
|
|
|
} |
|
1198 |
} |
} |
1199 |
|
|
1200 |
if (abfd->symcount) |
if (abfd->symcount) |
1201 |
{ |
location[abfd->symcount] = (asymbol *) NULL; |
1202 |
location[abfd->symcount] = (asymbol *) NULL; |
|
|
} |
|
1203 |
return abfd->symcount; |
return abfd->symcount; |
1204 |
} |
} |
1205 |
|
|
1263 |
{ |
{ |
1264 |
bfd_byte section_type[3]; |
bfd_byte section_type[3]; |
1265 |
ieee_seek (ieee, offset); |
ieee_seek (ieee, offset); |
1266 |
while (true) |
while (TRUE) |
1267 |
{ |
{ |
1268 |
switch (this_byte (&(ieee->h))) |
switch (this_byte (&(ieee->h))) |
1269 |
{ |
{ |
1279 |
section_type[0] = this_byte_and_next (&(ieee->h)); |
section_type[0] = this_byte_and_next (&(ieee->h)); |
1280 |
|
|
1281 |
/* Set minimal section attributes. Attributes are |
/* Set minimal section attributes. Attributes are |
1282 |
extended later, based on section contents. */ |
extended later, based on section contents. */ |
|
|
|
1283 |
switch (section_type[0]) |
switch (section_type[0]) |
1284 |
{ |
{ |
1285 |
case 0xC1: |
case 0xC1: |
1286 |
/* Normal attributes for absolute sections */ |
/* Normal attributes for absolute sections. */ |
1287 |
section_type[1] = this_byte (&(ieee->h)); |
section_type[1] = this_byte (&(ieee->h)); |
1288 |
section->flags = SEC_ALLOC; |
section->flags = SEC_ALLOC; |
1289 |
switch (section_type[1]) |
switch (section_type[1]) |
1290 |
{ |
{ |
1291 |
case 0xD3: /* AS Absolute section attributes */ |
case 0xD3: /* AS Absolute section attributes. */ |
1292 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1293 |
section_type[2] = this_byte (&(ieee->h)); |
section_type[2] = this_byte (&(ieee->h)); |
1294 |
switch (section_type[2]) |
switch (section_type[2]) |
1295 |
{ |
{ |
1296 |
case 0xD0: |
case 0xD0: |
1297 |
/* Normal code */ |
/* Normal code. */ |
1298 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1299 |
section->flags |= SEC_CODE; |
section->flags |= SEC_CODE; |
1300 |
break; |
break; |
1301 |
case 0xC4: |
case 0xC4: |
1302 |
/* Normal data */ |
/* Normal data. */ |
1303 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1304 |
section->flags |= SEC_DATA; |
section->flags |= SEC_DATA; |
1305 |
break; |
break; |
1306 |
case 0xD2: |
case 0xD2: |
1307 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1308 |
/* Normal rom data */ |
/* Normal rom data. */ |
1309 |
section->flags |= SEC_ROM | SEC_DATA; |
section->flags |= SEC_ROM | SEC_DATA; |
1310 |
break; |
break; |
1311 |
default: |
default: |
1313 |
} |
} |
1314 |
} |
} |
1315 |
break; |
break; |
1316 |
case 0xC3: /* Named relocatable sections (type C) */ |
case 0xC3: /* Named relocatable sections (type C). */ |
1317 |
section_type[1] = this_byte (&(ieee->h)); |
section_type[1] = this_byte (&(ieee->h)); |
1318 |
section->flags = SEC_ALLOC; |
section->flags = SEC_ALLOC; |
1319 |
switch (section_type[1]) |
switch (section_type[1]) |
1320 |
{ |
{ |
1321 |
case 0xD0: /* Normal code (CP) */ |
case 0xD0: /* Normal code (CP). */ |
1322 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1323 |
section->flags |= SEC_CODE; |
section->flags |= SEC_CODE; |
1324 |
break; |
break; |
1325 |
case 0xC4: /* Normal data (CD) */ |
case 0xC4: /* Normal data (CD). */ |
1326 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1327 |
section->flags |= SEC_DATA; |
section->flags |= SEC_DATA; |
1328 |
break; |
break; |
1329 |
case 0xD2: /* Normal rom data (CR) */ |
case 0xD2: /* Normal rom data (CR). */ |
1330 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1331 |
section->flags |= SEC_ROM | SEC_DATA; |
section->flags |= SEC_ROM | SEC_DATA; |
1332 |
break; |
break; |
1335 |
} |
} |
1336 |
} |
} |
1337 |
|
|
1338 |
/* Read section name, use it if non empty. */ |
/* Read section name, use it if non empty. */ |
1339 |
name = read_id (&ieee->h); |
name = read_id (&ieee->h); |
1340 |
if (name[0]) |
if (name[0]) |
1341 |
section->name = name; |
section->name = name; |
1342 |
|
|
1343 |
/* Skip these fields, which we don't care about */ |
/* Skip these fields, which we don't care about. */ |
1344 |
{ |
{ |
1345 |
bfd_vma parent, brother, context; |
bfd_vma parent, brother, context; |
1346 |
parse_int (&(ieee->h), &parent); |
parse_int (&(ieee->h), &parent); |
1376 |
{ |
{ |
1377 |
case ieee_section_size_enum: |
case ieee_section_size_enum: |
1378 |
section = ieee->section_table[must_parse_int (&(ieee->h))]; |
section = ieee->section_table[must_parse_int (&(ieee->h))]; |
1379 |
section->_raw_size = must_parse_int (&(ieee->h)); |
section->size = must_parse_int (&(ieee->h)); |
1380 |
break; |
break; |
1381 |
case ieee_physical_region_size_enum: |
case ieee_physical_region_size_enum: |
1382 |
section = ieee->section_table[must_parse_int (&(ieee->h))]; |
section = ieee->section_table[must_parse_int (&(ieee->h))]; |
1383 |
section->_raw_size = must_parse_int (&(ieee->h)); |
section->size = must_parse_int (&(ieee->h)); |
1384 |
break; |
break; |
1385 |
case ieee_region_base_address_enum: |
case ieee_region_base_address_enum: |
1386 |
section = ieee->section_table[must_parse_int (&(ieee->h))]; |
section = ieee->section_table[must_parse_int (&(ieee->h))]; |
1421 |
at the area in the file so that program which understand can dig it |
at the area in the file so that program which understand can dig it |
1422 |
out. */ |
out. */ |
1423 |
|
|
1424 |
static boolean |
static bfd_boolean |
1425 |
ieee_slurp_debug (abfd) |
ieee_slurp_debug (abfd) |
1426 |
bfd *abfd; |
bfd *abfd; |
1427 |
{ |
{ |
1430 |
file_ptr debug_end; |
file_ptr debug_end; |
1431 |
|
|
1432 |
if (ieee->w.r.debug_information_part == 0) |
if (ieee->w.r.debug_information_part == 0) |
1433 |
return true; |
return TRUE; |
1434 |
|
|
1435 |
sec = bfd_make_section (abfd, ".debug"); |
sec = bfd_make_section (abfd, ".debug"); |
1436 |
if (sec == NULL) |
if (sec == NULL) |
1437 |
return false; |
return FALSE; |
1438 |
sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS; |
sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS; |
1439 |
sec->filepos = ieee->w.r.debug_information_part; |
sec->filepos = ieee->w.r.debug_information_part; |
1440 |
|
|
1441 |
debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part); |
debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part); |
1442 |
sec->_raw_size = debug_end - ieee->w.r.debug_information_part; |
sec->size = debug_end - ieee->w.r.debug_information_part; |
1443 |
|
|
1444 |
return true; |
return TRUE; |
1445 |
} |
} |
1446 |
|
|
1447 |
/*********************************************************************** |
/* Archive stuff. */ |
|
* archive stuff |
|
|
*/ |
|
1448 |
|
|
1449 |
const bfd_target * |
const bfd_target * |
1450 |
ieee_archive_p (abfd) |
ieee_archive_p (abfd) |
1462 |
|
|
1463 |
abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, amt); |
abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, amt); |
1464 |
if (!abfd->tdata.ieee_ar_data) |
if (!abfd->tdata.ieee_ar_data) |
1465 |
goto error_return; |
goto error_ret_restore; |
1466 |
ieee = IEEE_AR_DATA (abfd); |
ieee = IEEE_AR_DATA (abfd); |
1467 |
|
|
1468 |
/* Ignore the return value here. It doesn't matter if we don't read |
/* Ignore the return value here. It doesn't matter if we don't read |
1578 |
return abfd->xvec; |
return abfd->xvec; |
1579 |
|
|
1580 |
got_wrong_format_error: |
got_wrong_format_error: |
|
bfd_release (abfd, ieee); |
|
|
abfd->tdata.ieee_ar_data = save; |
|
1581 |
bfd_set_error (bfd_error_wrong_format); |
bfd_set_error (bfd_error_wrong_format); |
|
|
|
1582 |
error_return: |
error_return: |
1583 |
if (elts != NULL) |
if (elts != NULL) |
1584 |
free (elts); |
free (elts); |
1585 |
|
bfd_release (abfd, ieee); |
1586 |
|
error_ret_restore: |
1587 |
|
abfd->tdata.ieee_ar_data = save; |
1588 |
|
|
1589 |
return NULL; |
return NULL; |
1590 |
} |
} |
1614 |
if (this_byte_and_next (&(ieee->h)) != Module_Beginning) |
if (this_byte_and_next (&(ieee->h)) != Module_Beginning) |
1615 |
goto got_wrong_format; |
goto got_wrong_format; |
1616 |
|
|
1617 |
ieee->read_symbols = false; |
ieee->read_symbols = FALSE; |
1618 |
ieee->read_data = false; |
ieee->read_data = FALSE; |
1619 |
ieee->section_count = 0; |
ieee->section_count = 0; |
1620 |
ieee->external_symbol_max_index = 0; |
ieee->external_symbol_max_index = 0; |
1621 |
ieee->external_symbol_min_index = IEEE_PUBLIC_BASE; |
ieee->external_symbol_min_index = IEEE_PUBLIC_BASE; |
1630 |
goto got_wrong_format; |
goto got_wrong_format; |
1631 |
ieee->mb.module_name = read_id (&(ieee->h)); |
ieee->mb.module_name = read_id (&(ieee->h)); |
1632 |
if (abfd->filename == (const char *) NULL) |
if (abfd->filename == (const char *) NULL) |
1633 |
{ |
abfd->filename = ieee->mb.module_name; |
1634 |
abfd->filename = ieee->mb.module_name; |
|
1635 |
} |
/* Determine the architecture and machine type of the object file. */ |
|
/* Determine the architecture and machine type of the object file. |
|
|
*/ |
|
1636 |
{ |
{ |
1637 |
const bfd_arch_info_type *arch; |
const bfd_arch_info_type *arch; |
1638 |
char family[10]; |
char family[10]; |
1639 |
|
|
1640 |
/* IEEE does not specify the format of the processor identificaton |
/* IEEE does not specify the format of the processor identification |
1641 |
string, so the compiler is free to put in it whatever it wants. |
string, so the compiler is free to put in it whatever it wants. |
1642 |
We try here to recognize different processors belonging to the |
We try here to recognize different processors belonging to the |
1643 |
m68k family. Code for other processors can be added here. */ |
m68k family. Code for other processors can be added here. */ |
1673 |
} |
} |
1674 |
else if (TOUPPER (processor[3]) == 'F') /* 68F333 */ |
else if (TOUPPER (processor[3]) == 'F') /* 68F333 */ |
1675 |
strcpy (family, "68332"); /* CPU32 */ |
strcpy (family, "68332"); /* CPU32 */ |
1676 |
else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers */ |
else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers. */ |
1677 |
&& ((TOUPPER (processor[2]) == 'E') |
&& ((TOUPPER (processor[2]) == 'E') |
1678 |
|| (TOUPPER (processor[2]) == 'H') |
|| (TOUPPER (processor[2]) == 'H') |
1679 |
|| (TOUPPER (processor[2]) == 'L'))) |
|| (TOUPPER (processor[2]) == 'L'))) |
1682 |
strncat (family, processor + 4, 7); |
strncat (family, processor + 4, 7); |
1683 |
family[9] = '\0'; |
family[9] = '\0'; |
1684 |
} |
} |
1685 |
else /* "Regular" processors */ |
else /* "Regular" processors. */ |
1686 |
{ |
{ |
1687 |
strncpy (family, processor, 9); |
strncpy (family, processor, 9); |
1688 |
family[9] = '\0'; |
family[9] = '\0'; |
1704 |
} |
} |
1705 |
|
|
1706 |
if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum) |
if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum) |
1707 |
{ |
goto fail; |
1708 |
goto fail; |
|
|
} |
|
1709 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1710 |
|
|
1711 |
if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau)) |
if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau)) |
1712 |
{ |
goto fail; |
1713 |
goto fail; |
|
|
} |
|
1714 |
if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address)) |
if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address)) |
1715 |
{ |
goto fail; |
|
goto fail; |
|
|
} |
|
1716 |
|
|
1717 |
/* If there is a byte order info, take it */ |
/* If there is a byte order info, take it. */ |
1718 |
if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum || |
if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum |
1719 |
this_byte (&(ieee->h)) == (int) ieee_variable_M_enum) |
|| this_byte (&(ieee->h)) == (int) ieee_variable_M_enum) |
1720 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1721 |
|
|
1722 |
for (part = 0; part < N_W_VARIABLES; part++) |
for (part = 0; part < N_W_VARIABLES; part++) |
1723 |
{ |
{ |
1724 |
boolean ok; |
bfd_boolean ok; |
1725 |
|
|
1726 |
if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum) |
if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum) |
1727 |
{ |
goto fail; |
1728 |
goto fail; |
|
|
} |
|
1729 |
if (this_byte_and_next (&(ieee->h)) != part) |
if (this_byte_and_next (&(ieee->h)) != part) |
1730 |
{ |
goto fail; |
|
goto fail; |
|
|
} |
|
1731 |
|
|
1732 |
ieee->w.offset[part] = parse_i (&(ieee->h), &ok); |
ieee->w.offset[part] = parse_i (&(ieee->h), &ok); |
1733 |
if (! ok) |
if (! ok) |
1734 |
{ |
goto fail; |
|
goto fail; |
|
|
} |
|
|
|
|
1735 |
} |
} |
1736 |
|
|
1737 |
if (ieee->w.r.external_part != 0) |
if (ieee->w.r.external_part != 0) |
1740 |
/* By now we know that this is a real IEEE file, we're going to read |
/* By now we know that this is a real IEEE file, we're going to read |
1741 |
the whole thing into memory so that we can run up and down it |
the whole thing into memory so that we can run up and down it |
1742 |
quickly. We can work out how big the file is from the trailer |
quickly. We can work out how big the file is from the trailer |
1743 |
record */ |
record. */ |
1744 |
|
|
1745 |
amt = ieee->w.r.me_record + 1; |
amt = ieee->w.r.me_record + 1; |
1746 |
IEEE_DATA (abfd)->h.first_byte = |
IEEE_DATA (abfd)->h.first_byte = |
1761 |
|
|
1762 |
/* Parse section data to activate file and section flags implied by |
/* Parse section data to activate file and section flags implied by |
1763 |
section contents. */ |
section contents. */ |
|
|
|
1764 |
if (! ieee_slurp_section_data (abfd)) |
if (! ieee_slurp_section_data (abfd)) |
1765 |
goto fail; |
goto fail; |
1766 |
|
|
1768 |
got_wrong_format: |
got_wrong_format: |
1769 |
bfd_set_error (bfd_error_wrong_format); |
bfd_set_error (bfd_error_wrong_format); |
1770 |
fail: |
fail: |
1771 |
(void) bfd_release (abfd, ieee); |
bfd_release (abfd, ieee); |
1772 |
abfd->tdata.ieee_data = save; |
abfd->tdata.ieee_data = save; |
1773 |
return (const bfd_target *) NULL; |
return (const bfd_target *) NULL; |
1774 |
} |
} |
1801 |
fprintf (file, "%s", symbol->name); |
fprintf (file, "%s", symbol->name); |
1802 |
break; |
break; |
1803 |
case bfd_print_symbol_more: |
case bfd_print_symbol_more: |
|
#if 0 |
|
|
fprintf (file, "%4x %2x", aout_symbol (symbol)->desc & 0xffff, |
|
|
aout_symbol (symbol)->other & 0xff); |
|
|
#endif |
|
1804 |
BFD_FAIL (); |
BFD_FAIL (); |
1805 |
break; |
break; |
1806 |
case bfd_print_symbol_all: |
case bfd_print_symbol_all: |
1809 |
(symbol->section == (asection *) NULL |
(symbol->section == (asection *) NULL |
1810 |
? "*abs" |
? "*abs" |
1811 |
: symbol->section->name); |
: symbol->section->name); |
1812 |
|
|
1813 |
if (symbol->name[0] == ' ') |
if (symbol->name[0] == ' ') |
1814 |
{ |
{ |
1815 |
fprintf (file, "* empty table entry "); |
fprintf (file, "* empty table entry "); |
1829 |
} |
} |
1830 |
} |
} |
1831 |
|
|
1832 |
static boolean |
static bfd_boolean |
1833 |
do_one (ieee, current_map, location_ptr, s, iterations) |
do_one (ieee, current_map, location_ptr, s, iterations) |
1834 |
ieee_data_type *ieee; |
ieee_data_type *ieee; |
1835 |
ieee_per_section_type *current_map; |
ieee_per_section_type *current_map; |
1843 |
{ |
{ |
1844 |
unsigned int number_of_maus; |
unsigned int number_of_maus; |
1845 |
unsigned int i; |
unsigned int i; |
1846 |
|
|
1847 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1848 |
number_of_maus = must_parse_int (&(ieee->h)); |
number_of_maus = must_parse_int (&(ieee->h)); |
1849 |
|
|
1857 |
|
|
1858 |
case ieee_load_with_relocation_enum: |
case ieee_load_with_relocation_enum: |
1859 |
{ |
{ |
1860 |
boolean loop = true; |
bfd_boolean loop = TRUE; |
1861 |
|
|
1862 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1863 |
while (loop) |
while (loop) |
1864 |
{ |
{ |
1871 |
case ieee_function_either_open_b_enum: |
case ieee_function_either_open_b_enum: |
1872 |
{ |
{ |
1873 |
unsigned int extra = 4; |
unsigned int extra = 4; |
1874 |
boolean pcrel = false; |
bfd_boolean pcrel = FALSE; |
1875 |
asection *section; |
asection *section; |
1876 |
ieee_reloc_type *r; |
ieee_reloc_type *r; |
1877 |
bfd_size_type amt = sizeof (ieee_reloc_type); |
bfd_size_type amt = sizeof (ieee_reloc_type); |
1878 |
|
|
1879 |
r = (ieee_reloc_type *) bfd_alloc (ieee->h.abfd, amt); |
r = (ieee_reloc_type *) bfd_alloc (ieee->h.abfd, amt); |
1880 |
if (!r) |
if (!r) |
1881 |
return false; |
return FALSE; |
1882 |
|
|
1883 |
*(current_map->reloc_tail_ptr) = r; |
*(current_map->reloc_tail_ptr) = r; |
1884 |
current_map->reloc_tail_ptr = &r->next; |
current_map->reloc_tail_ptr = &r->next; |
1900 |
if (this_byte (&(ieee->h)) == (int) ieee_comma) |
if (this_byte (&(ieee->h)) == (int) ieee_comma) |
1901 |
{ |
{ |
1902 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
1903 |
/* Fetch number of bytes to pad */ |
/* Fetch number of bytes to pad. */ |
1904 |
extra = must_parse_int (&(ieee->h)); |
extra = must_parse_int (&(ieee->h)); |
1905 |
}; |
}; |
1906 |
|
|
1918 |
default: |
default: |
1919 |
break; |
break; |
1920 |
} |
} |
1921 |
/* Build a relocation entry for this type */ |
/* Build a relocation entry for this type. */ |
1922 |
/* If pc rel then stick -ve pc into instruction |
/* If pc rel then stick -ve pc into instruction |
1923 |
and take out of reloc .. |
and take out of reloc .. |
1924 |
|
|
1997 |
|
|
1998 |
default: |
default: |
1999 |
BFD_FAIL (); |
BFD_FAIL (); |
2000 |
return false; |
return FALSE; |
2001 |
} |
} |
2002 |
} |
} |
2003 |
break; |
break; |
2015 |
} |
} |
2016 |
else |
else |
2017 |
{ |
{ |
2018 |
loop = false; |
loop = FALSE; |
2019 |
} |
} |
2020 |
} |
} |
2021 |
} |
} |
2023 |
/* Prevent more than the first load-item of an LR record |
/* Prevent more than the first load-item of an LR record |
2024 |
from being repeated (MRI convention). */ |
from being repeated (MRI convention). */ |
2025 |
if (iterations != 1) |
if (iterations != 1) |
2026 |
loop = false; |
loop = FALSE; |
2027 |
} |
} |
2028 |
} |
} |
2029 |
} |
} |
2030 |
return true; |
return TRUE; |
2031 |
} |
} |
2032 |
|
|
2033 |
/* Read in all the section data and relocation stuff too */ |
/* Read in all the section data and relocation stuff too. */ |
2034 |
static boolean |
|
2035 |
|
static bfd_boolean |
2036 |
ieee_slurp_section_data (abfd) |
ieee_slurp_section_data (abfd) |
2037 |
bfd *abfd; |
bfd *abfd; |
2038 |
{ |
{ |
2042 |
|
|
2043 |
ieee_per_section_type *current_map = (ieee_per_section_type *) NULL; |
ieee_per_section_type *current_map = (ieee_per_section_type *) NULL; |
2044 |
asection *s; |
asection *s; |
2045 |
/* Seek to the start of the data area */ |
/* Seek to the start of the data area. */ |
2046 |
if (ieee->read_data) |
if (ieee->read_data) |
2047 |
return true; |
return TRUE; |
2048 |
ieee->read_data = true; |
ieee->read_data = TRUE; |
2049 |
ieee_seek (ieee, ieee->w.r.data_part); |
ieee_seek (ieee, ieee->w.r.data_part); |
2050 |
|
|
2051 |
/* Allocate enough space for all the section contents */ |
/* Allocate enough space for all the section contents. */ |
|
|
|
2052 |
for (s = abfd->sections; s != (asection *) NULL; s = s->next) |
for (s = abfd->sections; s != (asection *) NULL; s = s->next) |
2053 |
{ |
{ |
2054 |
ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd; |
ieee_per_section_type *per = ieee_per_section (s); |
2055 |
if ((s->flags & SEC_DEBUGGING) != 0) |
if ((s->flags & SEC_DEBUGGING) != 0) |
2056 |
continue; |
continue; |
2057 |
per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size); |
per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->size); |
2058 |
if (!per->data) |
if (!per->data) |
2059 |
return false; |
return FALSE; |
|
/*SUPPRESS 68*/ |
|
2060 |
per->reloc_tail_ptr = |
per->reloc_tail_ptr = |
2061 |
(ieee_reloc_type **) & (s->relocation); |
(ieee_reloc_type **) & (s->relocation); |
2062 |
} |
} |
2063 |
|
|
2064 |
while (true) |
while (TRUE) |
2065 |
{ |
{ |
2066 |
switch (this_byte (&(ieee->h))) |
switch (this_byte (&(ieee->h))) |
2067 |
{ |
{ |
2068 |
/* IF we see anything strange then quit */ |
/* IF we see anything strange then quit. */ |
2069 |
default: |
default: |
2070 |
return true; |
return TRUE; |
2071 |
|
|
2072 |
case ieee_set_current_section_enum: |
case ieee_set_current_section_enum: |
2073 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
2074 |
section_number = must_parse_int (&(ieee->h)); |
section_number = must_parse_int (&(ieee->h)); |
2075 |
s = ieee->section_table[section_number]; |
s = ieee->section_table[section_number]; |
2076 |
s->flags |= SEC_LOAD | SEC_HAS_CONTENTS; |
s->flags |= SEC_LOAD | SEC_HAS_CONTENTS; |
2077 |
current_map = (ieee_per_section_type *) s->used_by_bfd; |
current_map = ieee_per_section (s); |
2078 |
location_ptr = current_map->data - s->vma; |
location_ptr = current_map->data - s->vma; |
2079 |
/* The document I have says that Microtec's compilers reset */ |
/* The document I have says that Microtec's compilers reset |
2080 |
/* this after a sec section, even though the standard says not */ |
this after a sec section, even though the standard says not |
2081 |
/* to. SO .. */ |
to, SO... */ |
2082 |
current_map->pc = s->vma; |
current_map->pc = s->vma; |
2083 |
break; |
break; |
2084 |
|
|
2091 |
bfd_vma value; |
bfd_vma value; |
2092 |
ieee_symbol_index_type symbol; |
ieee_symbol_index_type symbol; |
2093 |
unsigned int extra; |
unsigned int extra; |
2094 |
boolean pcrel; |
bfd_boolean pcrel; |
2095 |
|
|
2096 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
2097 |
must_parse_int (&(ieee->h)); /* Throw away section #*/ |
must_parse_int (&(ieee->h)); /* Throw away section #. */ |
2098 |
parse_expression (ieee, &value, |
parse_expression (ieee, &value, |
2099 |
&symbol, |
&symbol, |
2100 |
&pcrel, &extra, |
&pcrel, &extra, |
2101 |
0); |
0); |
2102 |
current_map->pc = value; |
current_map->pc = value; |
2103 |
BFD_ASSERT ((unsigned) (value - s->vma) <= s->_raw_size); |
BFD_ASSERT ((unsigned) (value - s->vma) <= s->size); |
2104 |
} |
} |
2105 |
break; |
break; |
2106 |
|
|
2109 |
if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum) |
if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum) |
2110 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
2111 |
abfd->start_address = must_parse_int (&(ieee->h)); |
abfd->start_address = must_parse_int (&(ieee->h)); |
2112 |
/* We've got to the end of the data now - */ |
/* We've got to the end of the data now - */ |
2113 |
return true; |
return TRUE; |
2114 |
default: |
default: |
2115 |
BFD_FAIL (); |
BFD_FAIL (); |
2116 |
return false; |
return FALSE; |
2117 |
} |
} |
2118 |
break; |
break; |
2119 |
case ieee_repeat_data_enum: |
case ieee_repeat_data_enum: |
2120 |
{ |
{ |
2121 |
/* Repeat the following LD or LR n times - we do this by |
/* Repeat the following LD or LR n times - we do this by |
2122 |
remembering the stream pointer before running it and |
remembering the stream pointer before running it and |
2123 |
resetting it and running it n times. We special case |
resetting it and running it n times. We special case |
2124 |
the repetition of a repeat_data/load_constant |
the repetition of a repeat_data/load_constant. */ |
|
*/ |
|
|
|
|
2125 |
unsigned int iterations; |
unsigned int iterations; |
2126 |
unsigned char *start; |
unsigned char *start; |
2127 |
|
|
2128 |
next_byte (&(ieee->h)); |
next_byte (&(ieee->h)); |
2129 |
iterations = must_parse_int (&(ieee->h)); |
iterations = must_parse_int (&(ieee->h)); |
2130 |
start = ieee->h.input_p; |
start = ieee->h.input_p; |
2131 |
if (start[0] == (int) ieee_load_constant_bytes_enum && |
if (start[0] == (int) ieee_load_constant_bytes_enum |
2132 |
start[1] == 1) |
&& start[1] == 1) |
2133 |
{ |
{ |
2134 |
while (iterations != 0) |
while (iterations != 0) |
2135 |
{ |
{ |
2147 |
ieee->h.input_p = start; |
ieee->h.input_p = start; |
2148 |
if (!do_one (ieee, current_map, location_ptr, s, |
if (!do_one (ieee, current_map, location_ptr, s, |
2149 |
(int) iterations)) |
(int) iterations)) |
2150 |
return false; |
return FALSE; |
2151 |
iterations--; |
iterations--; |
2152 |
} |
} |
2153 |
} |
} |
2155 |
break; |
break; |
2156 |
case ieee_load_constant_bytes_enum: |
case ieee_load_constant_bytes_enum: |
2157 |
case ieee_load_with_relocation_enum: |
case ieee_load_with_relocation_enum: |
2158 |
{ |
if (!do_one (ieee, current_map, location_ptr, s, 1)) |
2159 |
if (!do_one (ieee, current_map, location_ptr, s, 1)) |
return FALSE; |
|
return false; |
|
|
} |
|
2160 |
} |
} |
2161 |
} |
} |
2162 |
} |
} |
2163 |
|
|
2164 |
static boolean |
static bfd_boolean |
2165 |
ieee_new_section_hook (abfd, newsect) |
ieee_new_section_hook (abfd, newsect) |
2166 |
bfd *abfd; |
bfd *abfd; |
2167 |
asection *newsect; |
asection *newsect; |
2168 |
{ |
{ |
2169 |
newsect->used_by_bfd = (PTR) |
newsect->used_by_bfd |
2170 |
bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type)); |
= (PTR) bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type)); |
2171 |
if (!newsect->used_by_bfd) |
if (!newsect->used_by_bfd) |
2172 |
return false; |
return FALSE; |
2173 |
ieee_per_section (newsect)->data = (bfd_byte *) NULL; |
ieee_per_section (newsect)->data = (bfd_byte *) NULL; |
2174 |
ieee_per_section (newsect)->section = newsect; |
ieee_per_section (newsect)->section = newsect; |
2175 |
return true; |
return TRUE; |
2176 |
} |
} |
2177 |
|
|
2178 |
static long |
static long |
2187 |
return (asect->reloc_count + 1) * sizeof (arelent *); |
return (asect->reloc_count + 1) * sizeof (arelent *); |
2188 |
} |
} |
2189 |
|
|
2190 |
static boolean |
static bfd_boolean |
2191 |
ieee_get_section_contents (abfd, section, location, offset, count) |
ieee_get_section_contents (abfd, section, location, offset, count) |
2192 |
bfd *abfd; |
bfd *abfd; |
2193 |
sec_ptr section; |
sec_ptr section; |
2195 |
file_ptr offset; |
file_ptr offset; |
2196 |
bfd_size_type count; |
bfd_size_type count; |
2197 |
{ |
{ |
2198 |
ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd; |
ieee_per_section_type *p = ieee_per_section (section); |
2199 |
if ((section->flags & SEC_DEBUGGING) != 0) |
if ((section->flags & SEC_DEBUGGING) != 0) |
2200 |
return _bfd_generic_get_section_contents (abfd, section, location, |
return _bfd_generic_get_section_contents (abfd, section, location, |
2201 |
offset, count); |
offset, count); |
2202 |
ieee_slurp_section_data (abfd); |
ieee_slurp_section_data (abfd); |
2203 |
(void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count); |
(void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count); |
2204 |
return true; |
return TRUE; |
2205 |
} |
} |
2206 |
|
|
2207 |
static long |
static long |
2211 |
arelent **relptr; |
arelent **relptr; |
2212 |
asymbol **symbols; |
asymbol **symbols; |
2213 |
{ |
{ |
|
/* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/ |
|
2214 |
ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation); |
ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation); |
2215 |
ieee_data_type *ieee = IEEE_DATA (abfd); |
ieee_data_type *ieee = IEEE_DATA (abfd); |
2216 |
|
|
2219 |
|
|
2220 |
while (src != (ieee_reloc_type *) NULL) |
while (src != (ieee_reloc_type *) NULL) |
2221 |
{ |
{ |
2222 |
/* Work out which symbol to attach it this reloc to */ |
/* Work out which symbol to attach it this reloc to. */ |
2223 |
switch (src->symbol.letter) |
switch (src->symbol.letter) |
2224 |
{ |
{ |
2225 |
case 'I': |
case 'I': |
2258 |
|
|
2259 |
/* Write the section headers. */ |
/* Write the section headers. */ |
2260 |
|
|
2261 |
static boolean |
static bfd_boolean |
2262 |
ieee_write_section_part (abfd) |
ieee_write_section_part (abfd) |
2263 |
bfd *abfd; |
bfd *abfd; |
2264 |
{ |
{ |
2274 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2275 |
(bfd_byte) (s->index |
(bfd_byte) (s->index |
2276 |
+ IEEE_SECTION_NUMBER_BASE))) |
+ IEEE_SECTION_NUMBER_BASE))) |
2277 |
return false; |
return FALSE; |
2278 |
|
|
2279 |
if (abfd->flags & EXEC_P) |
if (abfd->flags & EXEC_P) |
2280 |
{ |
{ |
2281 |
/* This image is executable, so output absolute sections */ |
/* This image is executable, so output absolute sections. */ |
2282 |
if (! ieee_write_byte (abfd, ieee_variable_A_enum) |
if (! ieee_write_byte (abfd, ieee_variable_A_enum) |
2283 |
|| ! ieee_write_byte (abfd, ieee_variable_S_enum)) |
|| ! ieee_write_byte (abfd, ieee_variable_S_enum)) |
2284 |
return false; |
return FALSE; |
2285 |
} |
} |
2286 |
else |
else |
2287 |
{ |
{ |
2288 |
if (! ieee_write_byte (abfd, ieee_variable_C_enum)) |
if (! ieee_write_byte (abfd, ieee_variable_C_enum)) |
2289 |
return false; |
return FALSE; |
2290 |
} |
} |
2291 |
|
|
2292 |
switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM)) |
switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM)) |
2294 |
case SEC_CODE | SEC_LOAD: |
case SEC_CODE | SEC_LOAD: |
2295 |
case SEC_CODE: |
case SEC_CODE: |
2296 |
if (! ieee_write_byte (abfd, ieee_variable_P_enum)) |
if (! ieee_write_byte (abfd, ieee_variable_P_enum)) |
2297 |
return false; |
return FALSE; |
2298 |
break; |
break; |
2299 |
case SEC_DATA: |
case SEC_DATA: |
2300 |
default: |
default: |
2301 |
if (! ieee_write_byte (abfd, ieee_variable_D_enum)) |
if (! ieee_write_byte (abfd, ieee_variable_D_enum)) |
2302 |
return false; |
return FALSE; |
2303 |
break; |
break; |
2304 |
case SEC_ROM: |
case SEC_ROM: |
2305 |
case SEC_ROM | SEC_DATA: |
case SEC_ROM | SEC_DATA: |
2306 |
case SEC_ROM | SEC_LOAD: |
case SEC_ROM | SEC_LOAD: |
2307 |
case SEC_ROM | SEC_DATA | SEC_LOAD: |
case SEC_ROM | SEC_DATA | SEC_LOAD: |
2308 |
if (! ieee_write_byte (abfd, ieee_variable_R_enum)) |
if (! ieee_write_byte (abfd, ieee_variable_R_enum)) |
2309 |
return false; |
return FALSE; |
2310 |
} |
} |
2311 |
|
|
2312 |
|
|
2313 |
if (! ieee_write_id (abfd, s->name)) |
if (! ieee_write_id (abfd, s->name)) |
2314 |
return false; |
return FALSE; |
2315 |
#if 0 |
/* Alignment. */ |
|
ieee_write_int (abfd, 0); /* Parent */ |
|
|
ieee_write_int (abfd, 0); /* Brother */ |
|
|
ieee_write_int (abfd, 0); /* Context */ |
|
|
#endif |
|
|
/* Alignment */ |
|
2316 |
if (! ieee_write_byte (abfd, ieee_section_alignment_enum) |
if (! ieee_write_byte (abfd, ieee_section_alignment_enum) |
2317 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2318 |
(bfd_byte) (s->index |
(bfd_byte) (s->index |
2319 |
+ IEEE_SECTION_NUMBER_BASE)) |
+ IEEE_SECTION_NUMBER_BASE)) |
2320 |
|| ! ieee_write_int (abfd, (bfd_vma) 1 << s->alignment_power)) |
|| ! ieee_write_int (abfd, (bfd_vma) 1 << s->alignment_power)) |
2321 |
return false; |
return FALSE; |
2322 |
|
|
2323 |
/* Size */ |
/* Size. */ |
2324 |
if (! ieee_write_2bytes (abfd, ieee_section_size_enum) |
if (! ieee_write_2bytes (abfd, ieee_section_size_enum) |
2325 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2326 |
(bfd_byte) (s->index |
(bfd_byte) (s->index |
2327 |
+ IEEE_SECTION_NUMBER_BASE)) |
+ IEEE_SECTION_NUMBER_BASE)) |
2328 |
|| ! ieee_write_int (abfd, s->_raw_size)) |
|| ! ieee_write_int (abfd, s->size)) |
2329 |
return false; |
return FALSE; |
2330 |
if (abfd->flags & EXEC_P) |
if (abfd->flags & EXEC_P) |
2331 |
{ |
{ |
2332 |
/* Relocateable sections don't have asl records */ |
/* Relocateable sections don't have asl records. */ |
2333 |
/* Vma */ |
/* Vma. */ |
2334 |
if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum) |
if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum) |
2335 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2336 |
((bfd_byte) |
((bfd_byte) |
2337 |
(s->index |
(s->index |
2338 |
+ IEEE_SECTION_NUMBER_BASE))) |
+ IEEE_SECTION_NUMBER_BASE))) |
2339 |
|| ! ieee_write_int (abfd, s->lma)) |
|| ! ieee_write_int (abfd, s->lma)) |
2340 |
return false; |
return FALSE; |
2341 |
} |
} |
2342 |
} |
} |
2343 |
} |
} |
2344 |
|
|
2345 |
return true; |
return TRUE; |
2346 |
} |
} |
2347 |
|
|
2348 |
|
|
2349 |
static boolean |
static bfd_boolean |
2350 |
do_with_relocs (abfd, s) |
do_with_relocs (abfd, s) |
2351 |
bfd *abfd; |
bfd *abfd; |
2352 |
asection *s; |
asection *s; |
2363 |
sizeof (arelent **), |
sizeof (arelent **), |
2364 |
comp); |
comp); |
2365 |
|
|
2366 |
/* Output the section preheader */ |
/* Output the section preheader. */ |
2367 |
if (! ieee_write_byte (abfd, ieee_set_current_section_enum) |
if (! ieee_write_byte (abfd, ieee_set_current_section_enum) |
2368 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2369 |
(bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)) |
(bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)) |
2370 |
|| ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum) |
|| ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum) |
2371 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2372 |
(bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))) |
(bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))) |
2373 |
return false; |
return FALSE; |
2374 |
|
|
2375 |
if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0) |
if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0) |
2376 |
{ |
{ |
2377 |
if (! ieee_write_int (abfd, s->lma)) |
if (! ieee_write_int (abfd, s->lma)) |
2378 |
return false; |
return FALSE; |
2379 |
} |
} |
2380 |
else |
else |
2381 |
{ |
{ |
2382 |
if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) |
if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) |
2383 |
return false; |
return FALSE; |
2384 |
} |
} |
2385 |
|
|
2386 |
if (relocs_to_go == 0) |
if (relocs_to_go == 0) |
2387 |
{ |
{ |
2388 |
/* If there aren't any relocations then output the load constant |
/* If there aren't any relocations then output the load constant |
2389 |
byte opcode rather than the load with relocation opcode */ |
byte opcode rather than the load with relocation opcode. */ |
2390 |
|
while (current_byte_index < s->size) |
|
while (current_byte_index < s->_raw_size) |
|
2391 |
{ |
{ |
2392 |
bfd_size_type run; |
bfd_size_type run; |
2393 |
unsigned int MAXRUN = 127; |
unsigned int MAXRUN = 127; |
2394 |
|
|
2395 |
run = MAXRUN; |
run = MAXRUN; |
2396 |
if (run > s->_raw_size - current_byte_index) |
if (run > s->size - current_byte_index) |
2397 |
{ |
run = s->size - current_byte_index; |
|
run = s->_raw_size - current_byte_index; |
|
|
} |
|
2398 |
|
|
2399 |
if (run != 0) |
if (run != 0) |
2400 |
{ |
{ |
2401 |
if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)) |
if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)) |
2402 |
return false; |
return FALSE; |
2403 |
/* Output a stream of bytes */ |
/* Output a stream of bytes. */ |
2404 |
if (! ieee_write_int (abfd, run)) |
if (! ieee_write_int (abfd, run)) |
2405 |
return false; |
return FALSE; |
2406 |
if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) |
if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) |
2407 |
!= run) |
!= run) |
2408 |
return false; |
return FALSE; |
2409 |
current_byte_index += run; |
current_byte_index += run; |
2410 |
} |
} |
2411 |
} |
} |
2413 |
else |
else |
2414 |
{ |
{ |
2415 |
if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum)) |
if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum)) |
2416 |
return false; |
return FALSE; |
2417 |
|
|
2418 |
/* Output the data stream as the longest sequence of bytes |
/* Output the data stream as the longest sequence of bytes |
2419 |
possible, allowing for the a reasonable packet size and |
possible, allowing for the a reasonable packet size and |
2421 |
|
|
2422 |
if ((PTR) stream == (PTR) NULL) |
if ((PTR) stream == (PTR) NULL) |
2423 |
{ |
{ |
2424 |
/* Outputting a section without data, fill it up */ |
/* Outputting a section without data, fill it up. */ |
2425 |
stream = (unsigned char *) bfd_zalloc (abfd, s->_raw_size); |
stream = (unsigned char *) bfd_zalloc (abfd, s->size); |
2426 |
if (!stream) |
if (!stream) |
2427 |
return false; |
return FALSE; |
2428 |
} |
} |
2429 |
while (current_byte_index < s->_raw_size) |
while (current_byte_index < s->size) |
2430 |
{ |
{ |
2431 |
bfd_size_type run; |
bfd_size_type run; |
2432 |
unsigned int MAXRUN = 127; |
unsigned int MAXRUN = 127; |
2433 |
|
|
2434 |
if (relocs_to_go) |
if (relocs_to_go) |
2435 |
{ |
{ |
2436 |
run = (*p)->address - current_byte_index; |
run = (*p)->address - current_byte_index; |
2438 |
run = MAXRUN; |
run = MAXRUN; |
2439 |
} |
} |
2440 |
else |
else |
2441 |
{ |
run = MAXRUN; |
2442 |
run = MAXRUN; |
|
2443 |
} |
if (run > s->size - current_byte_index) |
2444 |
if (run > s->_raw_size - current_byte_index) |
run = s->size - current_byte_index; |
|
{ |
|
|
run = s->_raw_size - current_byte_index; |
|
|
} |
|
2445 |
|
|
2446 |
if (run != 0) |
if (run != 0) |
2447 |
{ |
{ |
2448 |
/* Output a stream of bytes */ |
/* Output a stream of bytes. */ |
2449 |
if (! ieee_write_int (abfd, run)) |
if (! ieee_write_int (abfd, run)) |
2450 |
return false; |
return FALSE; |
2451 |
if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) |
if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) |
2452 |
!= run) |
!= run) |
2453 |
return false; |
return FALSE; |
2454 |
current_byte_index += run; |
current_byte_index += run; |
2455 |
} |
} |
2456 |
/* Output any relocations here */ |
|
2457 |
|
/* Output any relocations here. */ |
2458 |
if (relocs_to_go && (*p) && (*p)->address == current_byte_index) |
if (relocs_to_go && (*p) && (*p)->address == current_byte_index) |
2459 |
{ |
{ |
2460 |
while (relocs_to_go |
while (relocs_to_go |
2462 |
{ |
{ |
2463 |
arelent *r = *p; |
arelent *r = *p; |
2464 |
bfd_signed_vma ov; |
bfd_signed_vma ov; |
|
|
|
|
#if 0 |
|
|
if (r->howto->pc_relative) |
|
|
{ |
|
|
r->addend += current_byte_index; |
|
|
} |
|
|
#endif |
|
|
|
|
2465 |
switch (r->howto->size) |
switch (r->howto->size) |
2466 |
{ |
{ |
2467 |
case 2: |
case 2: |
2483 |
default: |
default: |
2484 |
ov = 0; |
ov = 0; |
2485 |
BFD_FAIL (); |
BFD_FAIL (); |
2486 |
return false; |
return FALSE; |
2487 |
} |
} |
2488 |
|
|
2489 |
ov &= r->howto->src_mask; |
ov &= r->howto->src_mask; |
2494 |
|
|
2495 |
if (! ieee_write_byte (abfd, |
if (! ieee_write_byte (abfd, |
2496 |
ieee_function_either_open_b_enum)) |
ieee_function_either_open_b_enum)) |
2497 |
return false; |
return FALSE; |
2498 |
|
|
2499 |
/* abort();*/ |
/* abort();*/ |
2500 |
|
|
2504 |
*(r->sym_ptr_ptr), |
*(r->sym_ptr_ptr), |
2505 |
r->howto->pc_relative, |
r->howto->pc_relative, |
2506 |
(unsigned) s->index)) |
(unsigned) s->index)) |
2507 |
return false; |
return FALSE; |
2508 |
} |
} |
2509 |
else |
else |
2510 |
{ |
{ |
2512 |
(asymbol *) NULL, |
(asymbol *) NULL, |
2513 |
r->howto->pc_relative, |
r->howto->pc_relative, |
2514 |
(unsigned) s->index)) |
(unsigned) s->index)) |
2515 |
return false; |
return FALSE; |
2516 |
} |
} |
2517 |
|
|
2518 |
if (number_of_maus_in_address |
if (number_of_maus_in_address |
2520 |
{ |
{ |
2521 |
bfd_vma rsize = bfd_get_reloc_size (r->howto); |
bfd_vma rsize = bfd_get_reloc_size (r->howto); |
2522 |
if (! ieee_write_int (abfd, rsize)) |
if (! ieee_write_int (abfd, rsize)) |
2523 |
return false; |
return FALSE; |
2524 |
} |
} |
2525 |
if (! ieee_write_byte (abfd, |
if (! ieee_write_byte (abfd, |
2526 |
ieee_function_either_close_b_enum)) |
ieee_function_either_close_b_enum)) |
2527 |
return false; |
return FALSE; |
2528 |
|
|
2529 |
relocs_to_go--; |
relocs_to_go--; |
2530 |
p++; |
p++; |
2534 |
} |
} |
2535 |
} |
} |
2536 |
|
|
2537 |
return true; |
return TRUE; |
2538 |
} |
} |
2539 |
|
|
2540 |
/* If there are no relocations in the output section then we can be |
/* If there are no relocations in the output section then we can be |
2541 |
clever about how we write. We block items up into a max of 127 |
clever about how we write. We block items up into a max of 127 |
2542 |
bytes. */ |
bytes. */ |
2543 |
|
|
2544 |
static boolean |
static bfd_boolean |
2545 |
do_as_repeat (abfd, s) |
do_as_repeat (abfd, s) |
2546 |
bfd *abfd; |
bfd *abfd; |
2547 |
asection *s; |
asection *s; |
2548 |
{ |
{ |
2549 |
if (s->_raw_size) |
if (s->size) |
2550 |
{ |
{ |
2551 |
if (! ieee_write_byte (abfd, ieee_set_current_section_enum) |
if (! ieee_write_byte (abfd, ieee_set_current_section_enum) |
2552 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2557 |
|| ! ieee_write_byte (abfd, |
|| ! ieee_write_byte (abfd, |
2558 |
(bfd_byte) (s->index |
(bfd_byte) (s->index |
2559 |
+ IEEE_SECTION_NUMBER_BASE))) |
+ IEEE_SECTION_NUMBER_BASE))) |
2560 |
return false; |
return FALSE; |
2561 |
|
|
2562 |
if ((abfd->flags & EXEC_P) != 0) |
if ((abfd->flags & EXEC_P) != 0) |
2563 |
{ |
{ |
2564 |
if (! ieee_write_int (abfd, s->lma)) |
if (! ieee_write_int (abfd, s->lma)) |
2565 |
return false; |
return FALSE; |
2566 |
} |
} |
2567 |
else |
else |
2568 |
{ |
{ |
2569 |
if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) |
if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) |
2570 |
return false; |
return FALSE; |
2571 |
} |
} |
2572 |
|
|
2573 |
if (! ieee_write_byte (abfd, ieee_repeat_data_enum) |
if (! ieee_write_byte (abfd, ieee_repeat_data_enum) |
2574 |
|| ! ieee_write_int (abfd, s->_raw_size) |
|| ! ieee_write_int (abfd, s->size) |
2575 |
|| ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum) |
|| ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum) |
2576 |
|| ! ieee_write_byte (abfd, 1) |
|| ! ieee_write_byte (abfd, 1) |
2577 |
|| ! ieee_write_byte (abfd, 0)) |
|| ! ieee_write_byte (abfd, 0)) |
2578 |
return false; |
return FALSE; |
2579 |
} |
} |
2580 |
|
|
2581 |
return true; |
return TRUE; |
2582 |
} |
} |
2583 |
|
|
2584 |
static boolean |
static bfd_boolean |
2585 |
do_without_relocs (abfd, s) |
do_without_relocs (abfd, s) |
2586 |
bfd *abfd; |
bfd *abfd; |
2587 |
asection *s; |
asection *s; |
2591 |
if (stream == 0 || ((s->flags & SEC_LOAD) == 0)) |
if (stream == 0 || ((s->flags & SEC_LOAD) == 0)) |
2592 |
{ |
{ |
2593 |
if (! do_as_repeat (abfd, s)) |
if (! do_as_repeat (abfd, s)) |
2594 |
return false; |
return FALSE; |
2595 |
} |
} |
2596 |
else |
else |
2597 |
{ |
{ |
2598 |
unsigned int i; |
unsigned int i; |
2599 |
for (i = 0; i < s->_raw_size; i++) |
|
2600 |
|
for (i = 0; i < s->size; i++) |
2601 |
{ |
{ |
2602 |
if (stream[i] != 0) |
if (stream[i] != 0) |
2603 |
{ |
{ |
2604 |
if (! do_with_relocs (abfd, s)) |
if (! do_with_relocs (abfd, s)) |
2605 |
return false; |
return FALSE; |
2606 |
return true; |
return TRUE; |
2607 |
} |
} |
2608 |
} |
} |
2609 |
if (! do_as_repeat (abfd, s)) |
if (! do_as_repeat (abfd, s)) |
2610 |
return false; |
return FALSE; |
2611 |
} |
} |
2612 |
|
|
2613 |
return true; |
return TRUE; |
2614 |
} |
} |
2615 |
|
|
2616 |
|
|
2624 |
static bfd *output_bfd; |
static bfd *output_bfd; |
2625 |
static int output_buffer; |
static int output_buffer; |
2626 |
|
|
2627 |
static boolean |
static bfd_boolean |
2628 |
ieee_mkobject (abfd) |
ieee_mkobject (abfd) |
2629 |
bfd *abfd; |
bfd *abfd; |
2630 |
{ |
{ |
2658 |
flush () |
flush () |
2659 |
{ |
{ |
2660 |
bfd_size_type amt = output_ptr - output_ptr_start; |
bfd_size_type amt = output_ptr - output_ptr_start; |
2661 |
|
|
2662 |
if (bfd_bwrite ((PTR) (output_ptr_start), amt, output_bfd) != amt) |
if (bfd_bwrite ((PTR) (output_ptr_start), amt, output_bfd) != amt) |
2663 |
abort (); |
abort (); |
2664 |
output_ptr = output_ptr_start; |
output_ptr = output_ptr_start; |
2680 |
else |
else |
2681 |
{ |
{ |
2682 |
unsigned int length; |
unsigned int length; |
2683 |
/* How many significant bytes ? */ |
/* How many significant bytes ? */ |
2684 |
/* FIXME FOR LONGER INTS */ |
/* FIXME FOR LONGER INTS. */ |
2685 |
if (value & 0xff000000) |
if (value & 0xff000000) |
2686 |
{ |
length = 4; |
|
length = 4; |
|
|
} |
|
2687 |
else if (value & 0x00ff0000) |
else if (value & 0x00ff0000) |
2688 |
{ |
length = 3; |
|
length = 3; |
|
|
} |
|
2689 |
else if (value & 0x0000ff00) |
else if (value & 0x0000ff00) |
2690 |
{ |
length = 2; |
|
length = 2; |
|
|
} |
|
2691 |
else |
else |
2692 |
length = 1; |
length = 1; |
2693 |
|
|
2703 |
case 1: |
case 1: |
2704 |
OUT (value); |
OUT (value); |
2705 |
} |
} |
|
|
|
2706 |
} |
} |
2707 |
} |
} |
2708 |
|
|
2711 |
{ |
{ |
2712 |
int length = THIS (); |
int length = THIS (); |
2713 |
char ch; |
char ch; |
2714 |
|
|
2715 |
OUT (length); |
OUT (length); |
2716 |
NEXT (); |
NEXT (); |
2717 |
while (length--) |
while (length--) |
2729 |
int stack[10]; |
int stack[10]; |
2730 |
int *tos = stack; |
int *tos = stack; |
2731 |
int value; |
int value; |
2732 |
|
|
2733 |
while (1) |
while (1) |
2734 |
{ |
{ |
2735 |
switch (THIS ()) |
switch (THIS ()) |
2777 |
default: |
default: |
2778 |
if (THIS () > 0x84) |
if (THIS () > 0x84) |
2779 |
{ |
{ |
2780 |
/* Not a number, just bug out with the answer */ |
/* Not a number, just bug out with the answer. */ |
2781 |
write_int (*(--tos)); |
write_int (*(--tos)); |
2782 |
return; |
return; |
2783 |
} |
} |
2785 |
NEXT (); |
NEXT (); |
2786 |
break; |
break; |
2787 |
case 0xa5: |
case 0xa5: |
2788 |
/* PLUS anything */ |
/* PLUS anything. */ |
2789 |
value = *(--tos); |
value = *(--tos); |
2790 |
value += *(--tos); |
value += *(--tos); |
2791 |
*tos++ = value; |
*tos++ = value; |
2796 |
int section_number; |
int section_number; |
2797 |
ieee_data_type *ieee; |
ieee_data_type *ieee; |
2798 |
asection *s; |
asection *s; |
2799 |
|
|
2800 |
NEXT (); |
NEXT (); |
2801 |
section_number = THIS (); |
section_number = THIS (); |
2802 |
|
|
2830 |
{ |
{ |
2831 |
if (buf->buffer == output_buffer) |
if (buf->buffer == output_buffer) |
2832 |
{ |
{ |
2833 |
/* Still a chance to output the size */ |
/* Still a chance to output the size. */ |
2834 |
int value = output_ptr - buf->ptrp + 3; |
int value = output_ptr - buf->ptrp + 3; |
2835 |
buf->ptrp[0] = value >> 24; |
buf->ptrp[0] = value >> 24; |
2836 |
buf->ptrp[1] = value >> 16; |
buf->ptrp[1] = value >> 16; |
2845 |
{ |
{ |
2846 |
int type = THIS (); |
int type = THIS (); |
2847 |
int ch; |
int ch; |
2848 |
|
|
2849 |
if (type <= 0x84) |
if (type <= 0x84) |
2850 |
{ |
{ |
2851 |
NEXT (); |
NEXT (); |
2919 |
f1_record () |
f1_record () |
2920 |
{ |
{ |
2921 |
int ch; |
int ch; |
2922 |
/* ATN record */ |
|
2923 |
|
/* ATN record. */ |
2924 |
NEXT (); |
NEXT (); |
2925 |
ch = THIS (); |
ch = THIS (); |
2926 |
switch (ch) |
switch (ch) |
2960 |
} |
} |
2961 |
break; |
break; |
2962 |
case 0xd8: |
case 0xd8: |
2963 |
/* EXternal ref */ |
/* EXternal ref. */ |
2964 |
NEXT (); |
NEXT (); |
2965 |
OUT (0xf1); |
OUT (0xf1); |
2966 |
OUT (0xd8); |
OUT (0xd8); |
3014 |
break; |
break; |
3015 |
} |
} |
3016 |
} |
} |
|
|
|
3017 |
} |
} |
3018 |
|
|
3019 |
static void |
static void |
3020 |
f0_record () |
f0_record () |
3021 |
{ |
{ |
3022 |
/* Attribute record */ |
/* Attribute record. */ |
3023 |
NEXT (); |
NEXT (); |
3024 |
OUT (0xf0); |
OUT (0xf0); |
3025 |
INTn (Symbol name); |
INTn (Symbol name); |
3030 |
copy_till_end () |
copy_till_end () |
3031 |
{ |
{ |
3032 |
int ch = THIS (); |
int ch = THIS (); |
3033 |
|
|
3034 |
while (1) |
while (1) |
3035 |
{ |
{ |
3036 |
while (ch <= 0x80) |
while (ch <= 0x80) |
3089 |
case 0x01: |
case 0x01: |
3090 |
case 0x02: |
case 0x02: |
3091 |
case 0x03: |
case 0x03: |
3092 |
/* Unique typedefs for module */ |
/* Unique typedefs for module. */ |
3093 |
/* GLobal typedefs */ |
/* GLobal typedefs. */ |
3094 |
/* High level module scope beginning */ |
/* High level module scope beginning. */ |
3095 |
{ |
{ |
3096 |
struct output_buffer_struct ob; |
struct output_buffer_struct ob; |
3097 |
|
|
3098 |
NEXT (); |
NEXT (); |
3099 |
OUT (0xf8); |
OUT (0xf8); |
3100 |
OUT (ch); |
OUT (ch); |
3109 |
} |
} |
3110 |
break; |
break; |
3111 |
case 0x04: |
case 0x04: |
3112 |
/* Global function */ |
/* Global function. */ |
3113 |
{ |
{ |
3114 |
struct output_buffer_struct ob; |
struct output_buffer_struct ob; |
3115 |
|
|
3116 |
NEXT (); |
NEXT (); |
3117 |
OUT (0xf8); |
OUT (0xf8); |
3118 |
OUT (0x04); |
OUT (0x04); |
3132 |
break; |
break; |
3133 |
|
|
3134 |
case 0x05: |
case 0x05: |
3135 |
/* File name for source line numbers */ |
/* File name for source line numbers. */ |
3136 |
{ |
{ |
3137 |
struct output_buffer_struct ob; |
struct output_buffer_struct ob; |
3138 |
|
|
3139 |
NEXT (); |
NEXT (); |
3140 |
OUT (0xf8); |
OUT (0xf8); |
3141 |
OUT (0x05); |
OUT (0x05); |
3155 |
break; |
break; |
3156 |
|
|
3157 |
case 0x06: |
case 0x06: |
3158 |
/* Local function */ |
/* Local function. */ |
3159 |
{ |
{ |
3160 |
struct output_buffer_struct ob; |
struct output_buffer_struct ob; |
3161 |
|
|
3162 |
NEXT (); |
NEXT (); |
3163 |
OUT (0xf8); |
OUT (0xf8); |
3164 |
OUT (0x06); |
OUT (0x06); |
3176 |
break; |
break; |
3177 |
|
|
3178 |
case 0x0a: |
case 0x0a: |
3179 |
/* Assembler module scope beginning -*/ |
/* Assembler module scope beginning - */ |
3180 |
{ |
{ |
3181 |
struct output_buffer_struct ob; |
struct output_buffer_struct ob; |
3182 |
|
|
3205 |
case 0x0b: |
case 0x0b: |
3206 |
{ |
{ |
3207 |
struct output_buffer_struct ob; |
struct output_buffer_struct ob; |
3208 |
|
|
3209 |
NEXT (); |
NEXT (); |
3210 |
OUT (0xf8); |
OUT (0xf8); |
3211 |
OUT (0x0b); |
OUT (0x0b); |
3242 |
block () |
block () |
3243 |
{ |
{ |
3244 |
int ch; |
int ch; |
3245 |
|
|
3246 |
while (1) |
while (1) |
3247 |
{ |
{ |
3248 |
ch = THIS (); |
ch = THIS (); |
3274 |
} |
} |
3275 |
|
|
3276 |
|
|
3277 |
|
/* Moves all the debug information from the source bfd to the output |
3278 |
/* relocate_debug, |
bfd, and relocates any expressions it finds. */ |
|
moves all the debug information from the source bfd to the output |
|
|
bfd, and relocates any expressions it finds |
|
|
*/ |
|
3279 |
|
|
3280 |
static void |
static void |
3281 |
relocate_debug (output, input) |
relocate_debug (output, input) |
3298 |
/* Gather together all the debug information from each input BFD into |
/* Gather together all the debug information from each input BFD into |
3299 |
one place, relocating it and emitting it as we go. */ |
one place, relocating it and emitting it as we go. */ |
3300 |
|
|
3301 |
static boolean |
static bfd_boolean |
3302 |
ieee_write_debug_part (abfd) |
ieee_write_debug_part (abfd) |
3303 |
bfd *abfd; |
bfd *abfd; |
3304 |
{ |
{ |
3305 |
ieee_data_type *ieee = IEEE_DATA (abfd); |
ieee_data_type *ieee = IEEE_DATA (abfd); |
3306 |
bfd_chain_type *chain = ieee->chain_root; |
bfd_chain_type *chain = ieee->chain_root; |
3307 |
unsigned char obuff[OBS]; |
unsigned char obuff[OBS]; |
3308 |
boolean some_debug = false; |
bfd_boolean some_debug = FALSE; |
3309 |
file_ptr here = bfd_tell (abfd); |
file_ptr here = bfd_tell (abfd); |
3310 |
|
|
3311 |
output_ptr_start = output_ptr = obuff; |
output_ptr_start = output_ptr = obuff; |
3323 |
if (s == NULL) |
if (s == NULL) |
3324 |
{ |
{ |
3325 |
ieee->w.r.debug_information_part = 0; |
ieee->w.r.debug_information_part = 0; |
3326 |
return true; |
return TRUE; |
3327 |
} |
} |
3328 |
|
|
3329 |
ieee->w.r.debug_information_part = here; |
ieee->w.r.debug_information_part = here; |
3330 |
if (bfd_bwrite (s->contents, s->_raw_size, abfd) != s->_raw_size) |
if (bfd_bwrite (s->contents, s->size, abfd) != s->size) |
3331 |
return false; |
return FALSE; |
3332 |
} |
} |
3333 |
else |
else |
3334 |
{ |
{ |
3336 |
{ |
{ |
3337 |
bfd *entry = chain->this; |
bfd *entry = chain->this; |
3338 |
ieee_data_type *entry_ieee = IEEE_DATA (entry); |
ieee_data_type *entry_ieee = IEEE_DATA (entry); |
3339 |
|
|
3340 |
if (entry_ieee->w.r.debug_information_part) |
if (entry_ieee->w.r.debug_information_part) |
3341 |
{ |
{ |
3342 |
if (bfd_seek (entry, entry_ieee->w.r.debug_information_part, |
if (bfd_seek (entry, entry_ieee->w.r.debug_information_part, |
3343 |
SEEK_SET) != 0) |
SEEK_SET) != 0) |
3344 |
return false; |
return FALSE; |
3345 |
relocate_debug (abfd, entry); |
relocate_debug (abfd, entry); |
3346 |
} |
} |
3347 |
|
|
3348 |
chain = chain->next; |
chain = chain->next; |
3349 |
} |
} |
3350 |
|
|
3351 |
if (some_debug) |
if (some_debug) |
3352 |
{ |
ieee->w.r.debug_information_part = here; |
|
ieee->w.r.debug_information_part = here; |
|
|
} |
|
3353 |
else |
else |
3354 |
{ |
ieee->w.r.debug_information_part = 0; |
|
ieee->w.r.debug_information_part = 0; |
|
|
} |
|
3355 |
|
|
3356 |
flush (); |
flush (); |
3357 |
} |
} |
3358 |
|
|
3359 |
return true; |
return TRUE; |
3360 |
} |
} |
3361 |
|
|
3362 |
/* Write the data in an ieee way. */ |
/* Write the data in an ieee way. */ |
3363 |
|
|
3364 |
static boolean |
static bfd_boolean |
3365 |
ieee_write_data_part (abfd) |
ieee_write_data_part (abfd) |
3366 |
bfd *abfd; |
bfd *abfd; |
3367 |
{ |
{ |
3368 |
asection *s; |
asection *s; |
3369 |
|
|
3370 |
ieee_data_type *ieee = IEEE_DATA (abfd); |
ieee_data_type *ieee = IEEE_DATA (abfd); |
3371 |
ieee->w.r.data_part = bfd_tell (abfd); |
ieee->w.r.data_part = bfd_tell (abfd); |
3372 |
|
|
3373 |
for (s = abfd->sections; s != (asection *) NULL; s = s->next) |
for (s = abfd->sections; s != (asection *) NULL; s = s->next) |
3374 |
{ |
{ |
3375 |
/* Skip sections that have no loadable contents (.bss, |
/* Skip sections that have no loadable contents (.bss, |
3382 |
if (s->reloc_count != 0) |
if (s->reloc_count != 0) |
3383 |
{ |
{ |
3384 |
if (! do_with_relocs (abfd, s)) |
if (! do_with_relocs (abfd, s)) |
3385 |
return false; |
return FALSE; |
3386 |
} |
} |
3387 |
else |
else |
3388 |
{ |
{ |
3389 |
if (! do_without_relocs (abfd, s)) |
if (! do_without_relocs (abfd, s)) |
3390 |
return false; |
return FALSE; |
3391 |
} |
} |
3392 |
} |
} |
3393 |
|
|
3394 |
return true; |
return TRUE; |
3395 |
} |
} |
3396 |
|
|
3397 |
|
|
3398 |
static boolean |
static bfd_boolean |
3399 |
init_for_output (abfd) |
init_for_output (abfd) |
3400 |
bfd *abfd; |
bfd *abfd; |
3401 |
{ |
{ |
3402 |
asection *s; |
asection *s; |
3403 |
|
|
3404 |
for (s = abfd->sections; s != (asection *) NULL; s = s->next) |
for (s = abfd->sections; s != (asection *) NULL; s = s->next) |
3405 |
{ |
{ |
3406 |
if ((s->flags & SEC_DEBUGGING) != 0) |
if ((s->flags & SEC_DEBUGGING) != 0) |
3407 |
continue; |
continue; |
3408 |
if (s->_raw_size != 0) |
if (s->size != 0) |
3409 |
{ |
{ |
3410 |
bfd_size_type size = s->_raw_size; |
bfd_size_type size = s->size; |
3411 |
ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, size)); |
ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, size)); |
3412 |
if (!ieee_per_section (s)->data) |
if (!ieee_per_section (s)->data) |
3413 |
return false; |
return FALSE; |
3414 |
} |
} |
3415 |
} |
} |
3416 |
return true; |
return TRUE; |
3417 |
} |
} |
3418 |
|
|
3419 |
/** exec and core file sections */ |
/* Exec and core file sections. */ |
3420 |
|
|
3421 |
/* set section contents is complicated with IEEE since the format is |
/* Set section contents is complicated with IEEE since the format is |
3422 |
* not a byte image, but a record stream. |
not a byte image, but a record stream. */ |
3423 |
*/ |
|
3424 |
static boolean |
static bfd_boolean |
3425 |
ieee_set_section_contents (abfd, section, location, offset, count) |
ieee_set_section_contents (abfd, section, location, offset, count) |
3426 |
bfd *abfd; |
bfd *abfd; |
3427 |
sec_ptr section; |
sec_ptr section; |
3428 |
PTR location; |
const PTR location; |
3429 |
file_ptr offset; |
file_ptr offset; |
3430 |
bfd_size_type count; |
bfd_size_type count; |
3431 |
{ |
{ |
3433 |
{ |
{ |
3434 |
if (section->contents == NULL) |
if (section->contents == NULL) |
3435 |
{ |
{ |
3436 |
bfd_size_type size = section->_raw_size; |
bfd_size_type size = section->size; |
3437 |
section->contents = (unsigned char *) bfd_alloc (abfd, size); |
section->contents = (unsigned char *) bfd_alloc (abfd, size); |
3438 |
if (section->contents == NULL) |
if (section->contents == NULL) |
3439 |
return false; |
return FALSE; |
3440 |
} |
} |
3441 |
/* bfd_set_section_contents has already checked that everything |
/* bfd_set_section_contents has already checked that everything |
3442 |
is within range. */ |
is within range. */ |
3443 |
memcpy (section->contents + offset, location, (size_t) count); |
memcpy (section->contents + offset, location, (size_t) count); |
3444 |
return true; |
return TRUE; |
3445 |
} |
} |
3446 |
|
|
3447 |
if (ieee_per_section (section)->data == (bfd_byte *) NULL) |
if (ieee_per_section (section)->data == (bfd_byte *) NULL) |
3448 |
{ |
{ |
3449 |
if (!init_for_output (abfd)) |
if (!init_for_output (abfd)) |
3450 |
return false; |
return FALSE; |
3451 |
} |
} |
3452 |
memcpy ((PTR) (ieee_per_section (section)->data + offset), |
memcpy ((PTR) (ieee_per_section (section)->data + offset), |
3453 |
(PTR) location, |
(PTR) location, |
3454 |
(unsigned int) count); |
(unsigned int) count); |
3455 |
return true; |
return TRUE; |
3456 |
} |
} |
3457 |
|
|
3458 |
/* Write the external symbols of a file. IEEE considers two sorts of |
/* Write the external symbols of a file. IEEE considers two sorts of |
3460 |
forms to index them as well. When we write them out we turn their |
forms to index them as well. When we write them out we turn their |
3461 |
symbol values into indexes from the right base. */ |
symbol values into indexes from the right base. */ |
3462 |
|
|
3463 |
static boolean |
static bfd_boolean |
3464 |
ieee_write_external_part (abfd) |
ieee_write_external_part (abfd) |
3465 |
bfd *abfd; |
bfd *abfd; |
3466 |
{ |
{ |
3467 |
asymbol **q; |
asymbol **q; |
3468 |
ieee_data_type *ieee = IEEE_DATA (abfd); |
ieee_data_type *ieee = IEEE_DATA (abfd); |
|
|
|
3469 |
unsigned int reference_index = IEEE_REFERENCE_BASE; |
unsigned int reference_index = IEEE_REFERENCE_BASE; |
3470 |
unsigned int public_index = IEEE_PUBLIC_BASE + 2; |
unsigned int public_index = IEEE_PUBLIC_BASE + 2; |
3471 |
file_ptr here = bfd_tell (abfd); |
file_ptr here = bfd_tell (abfd); |
3472 |
boolean hadone = false; |
bfd_boolean hadone = FALSE; |
3473 |
|
|
3474 |
if (abfd->outsymbols != (asymbol **) NULL) |
if (abfd->outsymbols != (asymbol **) NULL) |
3475 |
{ |
{ |
3476 |
|
|
3477 |
for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++) |
for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++) |
3478 |
{ |
{ |
3479 |
asymbol *p = *q; |
asymbol *p = *q; |
3480 |
|
|
3481 |
if (bfd_is_und_section (p->section)) |
if (bfd_is_und_section (p->section)) |
3482 |
{ |
{ |
3483 |
/* This must be a symbol reference .. */ |
/* This must be a symbol reference. */ |
3484 |
if (! ieee_write_byte (abfd, ieee_external_reference_enum) |
if (! ieee_write_byte (abfd, ieee_external_reference_enum) |
3485 |
|| ! ieee_write_int (abfd, (bfd_vma) reference_index) |
|| ! ieee_write_int (abfd, (bfd_vma) reference_index) |
3486 |
|| ! ieee_write_id (abfd, p->name)) |
|| ! ieee_write_id (abfd, p->name)) |
3487 |
return false; |
return FALSE; |
3488 |
p->value = reference_index; |
p->value = reference_index; |
3489 |
reference_index++; |
reference_index++; |
3490 |
hadone = true; |
hadone = TRUE; |
3491 |
} |
} |
3492 |
else if (bfd_is_com_section (p->section)) |
else if (bfd_is_com_section (p->section)) |
3493 |
{ |
{ |
3494 |
/* This is a weak reference */ |
/* This is a weak reference. */ |
3495 |
if (! ieee_write_byte (abfd, ieee_external_reference_enum) |
if (! ieee_write_byte (abfd, ieee_external_reference_enum) |
3496 |
|| ! ieee_write_int (abfd, (bfd_vma) reference_index) |
|| ! ieee_write_int (abfd, (bfd_vma) reference_index) |
3497 |
|| ! ieee_write_id (abfd, p->name) |
|| ! ieee_write_id (abfd, p->name) |
3499 |
ieee_weak_external_reference_enum) |
ieee_weak_external_reference_enum) |
3500 |
|| ! ieee_write_int (abfd, (bfd_vma) reference_index) |
|| ! ieee_write_int (abfd, (bfd_vma) reference_index) |
3501 |
|| ! ieee_write_int (abfd, p->value)) |
|| ! ieee_write_int (abfd, p->value)) |
3502 |
return false; |
return FALSE; |
3503 |
p->value = reference_index; |
p->value = reference_index; |
3504 |
reference_index++; |
reference_index++; |
3505 |
hadone = true; |
hadone = TRUE; |
3506 |
} |
} |
3507 |
else if (p->flags & BSF_GLOBAL) |
else if (p->flags & BSF_GLOBAL) |
3508 |
{ |
{ |
3509 |
/* This must be a symbol definition */ |
/* This must be a symbol definition. */ |
|
|
|
3510 |
if (! ieee_write_byte (abfd, ieee_external_symbol_enum) |
if (! ieee_write_byte (abfd, ieee_external_symbol_enum) |
3511 |
|| ! ieee_write_int (abfd, (bfd_vma) public_index) |
|| ! ieee_write_int (abfd, (bfd_vma) public_index) |
3512 |
|| ! ieee_write_id (abfd, p->name) |
|| ! ieee_write_id (abfd, p->name) |
3515 |
|| ! ieee_write_byte (abfd, 15) /* instruction address */ |
|| ! ieee_write_byte (abfd, 15) /* instruction address */ |
3516 |
|| ! ieee_write_byte (abfd, 19) /* static symbol */ |
|| ! ieee_write_byte (abfd, 19) /* static symbol */ |
3517 |
|| ! ieee_write_byte (abfd, 1)) /* one of them */ |
|| ! ieee_write_byte (abfd, 1)) /* one of them */ |
3518 |
return false; |
return FALSE; |
3519 |
|
|
3520 |
/* Write out the value */ |
/* Write out the value. */ |
3521 |
if (! ieee_write_2bytes (abfd, ieee_value_record_enum) |
if (! ieee_write_2bytes (abfd, ieee_value_record_enum) |
3522 |
|| ! ieee_write_int (abfd, (bfd_vma) public_index)) |
|| ! ieee_write_int (abfd, (bfd_vma) public_index)) |
3523 |
return false; |
return FALSE; |
3524 |
if (! bfd_is_abs_section (p->section)) |
if (! bfd_is_abs_section (p->section)) |
3525 |
{ |
{ |
3526 |
if (abfd->flags & EXEC_P) |
if (abfd->flags & EXEC_P) |
3527 |
{ |
{ |
3528 |
/* If fully linked, then output all symbols |
/* If fully linked, then output all symbols |
3529 |
relocated */ |
relocated. */ |
3530 |
if (! (ieee_write_int |
if (! (ieee_write_int |
3531 |
(abfd, |
(abfd, |
3532 |
(p->value |
(p->value |
3533 |
+ p->section->output_offset |
+ p->section->output_offset |
3534 |
+ p->section->output_section->vma)))) |
+ p->section->output_section->vma)))) |
3535 |
return false; |
return FALSE; |
3536 |
} |
} |
3537 |
else |
else |
3538 |
{ |
{ |
3540 |
(abfd, |
(abfd, |
3541 |
p->value + p->section->output_offset, |
p->value + p->section->output_offset, |
3542 |
p->section->output_section->symbol, |
p->section->output_section->symbol, |
3543 |
false, 0))) |
FALSE, 0))) |
3544 |
return false; |
return FALSE; |
3545 |
} |
} |
3546 |
} |
} |
3547 |
else |
else |
3549 |
if (! ieee_write_expression (abfd, |
if (! ieee_write_expression (abfd, |
3550 |
p->value, |
p->value, |
3551 |
bfd_abs_section_ptr->symbol, |
bfd_abs_section_ptr->symbol, |
3552 |
false, 0)) |
FALSE, 0)) |
3553 |
return false; |
return FALSE; |
3554 |
} |
} |
3555 |
p->value = public_index; |
p->value = public_index; |
3556 |
public_index++; |
public_index++; |
3557 |
hadone = true; |
hadone = TRUE; |
3558 |
} |
} |
3559 |
else |
else |
3560 |
{ |
{ |
3561 |
/* This can happen - when there are gaps in the symbols read */ |
/* This can happen - when there are gaps in the symbols read |
3562 |
/* from an input ieee file */ |
from an input ieee file. */ |
3563 |
} |
} |
3564 |
} |
} |
3565 |
} |
} |
3566 |
if (hadone) |
if (hadone) |
3567 |
ieee->w.r.external_part = here; |
ieee->w.r.external_part = here; |
3568 |
|
|
3569 |
return true; |
return TRUE; |
3570 |
} |
} |
3571 |
|
|
3572 |
|
|
3573 |
static const unsigned char exten[] = |
static const unsigned char exten[] = |
3574 |
{ |
{ |
3575 |
0xf0, 0x20, 0x00, |
0xf0, 0x20, 0x00, |
3576 |
0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */ |
0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3. */ |
3577 |
0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */ |
0xf1, 0xce, 0x20, 0x00, 39, 2, /* Keep symbol in original case. */ |
3578 |
0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */ |
0xf1, 0xce, 0x20, 0x00, 38 /* Set object type relocatable to x. */ |
3579 |
}; |
}; |
3580 |
|
|
3581 |
static const unsigned char envi[] = |
static const unsigned char envi[] = |
3591 |
/* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */ |
/* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */ |
3592 |
}; |
}; |
3593 |
|
|
3594 |
static boolean |
static bfd_boolean |
3595 |
ieee_write_me_part (abfd) |
ieee_write_me_part (abfd) |
3596 |
bfd *abfd; |
bfd *abfd; |
3597 |
{ |
{ |
3603 |
|| ! ieee_write_byte (abfd, ieee_function_either_open_b_enum) |
|| ! ieee_write_byte (abfd, ieee_function_either_open_b_enum) |
3604 |
|| ! ieee_write_int (abfd, abfd->start_address) |
|| ! ieee_write_int (abfd, abfd->start_address) |
3605 |
|| ! ieee_write_byte (abfd, ieee_function_either_close_b_enum)) |
|| ! ieee_write_byte (abfd, ieee_function_either_close_b_enum)) |
3606 |
return false; |
return FALSE; |
3607 |
} |
} |
3608 |
ieee->w.r.me_record = bfd_tell (abfd); |
ieee->w.r.me_record = bfd_tell (abfd); |
3609 |
if (! ieee_write_byte (abfd, ieee_module_end_enum)) |
if (! ieee_write_byte (abfd, ieee_module_end_enum)) |
3610 |
return false; |
return FALSE; |
3611 |
return true; |
return TRUE; |
3612 |
} |
} |
3613 |
|
|
3614 |
/* Write out the IEEE processor ID. */ |
/* Write out the IEEE processor ID. */ |
3615 |
|
|
3616 |
static boolean |
static bfd_boolean |
3617 |
ieee_write_processor (abfd) |
ieee_write_processor (abfd) |
3618 |
bfd *abfd; |
bfd *abfd; |
3619 |
{ |
{ |
3624 |
{ |
{ |
3625 |
default: |
default: |
3626 |
if (! ieee_write_id (abfd, bfd_printable_name (abfd))) |
if (! ieee_write_id (abfd, bfd_printable_name (abfd))) |
3627 |
return false; |
return FALSE; |
3628 |
break; |
break; |
3629 |
|
|
3630 |
case bfd_arch_a29k: |
case bfd_arch_a29k: |
3631 |
if (! ieee_write_id (abfd, "29000")) |
if (! ieee_write_id (abfd, "29000")) |
3632 |
return false; |
return FALSE; |
3633 |
break; |
break; |
3634 |
|
|
3635 |
case bfd_arch_h8300: |
case bfd_arch_h8300: |
3636 |
if (! ieee_write_id (abfd, "H8/300")) |
if (! ieee_write_id (abfd, "H8/300")) |
3637 |
return false; |
return FALSE; |
3638 |
break; |
break; |
3639 |
|
|
3640 |
case bfd_arch_h8500: |
case bfd_arch_h8500: |
3641 |
if (! ieee_write_id (abfd, "H8/500")) |
if (! ieee_write_id (abfd, "H8/500")) |
3642 |
return false; |
return FALSE; |
3643 |
break; |
break; |
3644 |
|
|
3645 |
case bfd_arch_i960: |
case bfd_arch_i960: |
3649 |
case bfd_mach_i960_core: |
case bfd_mach_i960_core: |
3650 |
case bfd_mach_i960_ka_sa: |
case bfd_mach_i960_ka_sa: |
3651 |
if (! ieee_write_id (abfd, "80960KA")) |
if (! ieee_write_id (abfd, "80960KA")) |
3652 |
return false; |
return FALSE; |
3653 |
break; |
break; |
3654 |
|
|
3655 |
case bfd_mach_i960_kb_sb: |
case bfd_mach_i960_kb_sb: |
3656 |
if (! ieee_write_id (abfd, "80960KB")) |
if (! ieee_write_id (abfd, "80960KB")) |
3657 |
return false; |
return FALSE; |
3658 |
break; |
break; |
3659 |
|
|
3660 |
case bfd_mach_i960_ca: |
case bfd_mach_i960_ca: |
3661 |
if (! ieee_write_id (abfd, "80960CA")) |
if (! ieee_write_id (abfd, "80960CA")) |
3662 |
return false; |
return FALSE; |
3663 |
break; |
break; |
3664 |
|
|
3665 |
case bfd_mach_i960_mc: |
case bfd_mach_i960_mc: |
3666 |
case bfd_mach_i960_xa: |
case bfd_mach_i960_xa: |
3667 |
if (! ieee_write_id (abfd, "80960MC")) |
if (! ieee_write_id (abfd, "80960MC")) |
3668 |
return false; |
return FALSE; |
3669 |
break; |
break; |
3670 |
} |
} |
3671 |
break; |
break; |
3689 |
case bfd_mach_mcf5206e:id = "5206e"; break; |
case bfd_mach_mcf5206e:id = "5206e"; break; |
3690 |
case bfd_mach_mcf5307:id = "5307"; break; |
case bfd_mach_mcf5307:id = "5307"; break; |
3691 |
case bfd_mach_mcf5407:id = "5407"; break; |
case bfd_mach_mcf5407:id = "5407"; break; |
3692 |
|
case bfd_mach_mcf528x:id = "5282"; break; |
3693 |
} |
} |
3694 |
|
|
3695 |
if (! ieee_write_id (abfd, id)) |
if (! ieee_write_id (abfd, id)) |
3696 |
return false; |
return FALSE; |
3697 |
} |
} |
3698 |
break; |
break; |
3699 |
} |
} |
3700 |
|
|
3701 |
return true; |
return TRUE; |
3702 |
} |
} |
3703 |
|
|
3704 |
static boolean |
static bfd_boolean |
3705 |
ieee_write_object_contents (abfd) |
ieee_write_object_contents (abfd) |
3706 |
bfd *abfd; |
bfd *abfd; |
3707 |
{ |
{ |
3709 |
unsigned int i; |
unsigned int i; |
3710 |
file_ptr old; |
file_ptr old; |
3711 |
|
|
3712 |
/* Fast forward over the header area */ |
/* Fast forward over the header area. */ |
3713 |
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
3714 |
return false; |
return FALSE; |
3715 |
|
|
3716 |
if (! ieee_write_byte (abfd, ieee_module_beginning_enum) |
if (! ieee_write_byte (abfd, ieee_module_beginning_enum) |
3717 |
|| ! ieee_write_processor (abfd) |
|| ! ieee_write_processor (abfd) |
3718 |
|| ! ieee_write_id (abfd, abfd->filename)) |
|| ! ieee_write_id (abfd, abfd->filename)) |
3719 |
return false; |
return FALSE; |
3720 |
|
|
3721 |
/* Fast forward over the variable bits */ |
/* Fast forward over the variable bits. */ |
3722 |
if (! ieee_write_byte (abfd, ieee_address_descriptor_enum)) |
if (! ieee_write_byte (abfd, ieee_address_descriptor_enum)) |
3723 |
return false; |
return FALSE; |
3724 |
|
|
3725 |
/* Bits per MAU */ |
/* Bits per MAU. */ |
3726 |
if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd)))) |
if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd)))) |
3727 |
return false; |
return FALSE; |
3728 |
/* MAU's per address */ |
/* MAU's per address. */ |
3729 |
if (! ieee_write_byte (abfd, |
if (! ieee_write_byte (abfd, |
3730 |
(bfd_byte) (bfd_arch_bits_per_address (abfd) |
(bfd_byte) (bfd_arch_bits_per_address (abfd) |
3731 |
/ bfd_arch_bits_per_byte (abfd)))) |
/ bfd_arch_bits_per_byte (abfd)))) |
3732 |
return false; |
return FALSE; |
3733 |
|
|
3734 |
old = bfd_tell (abfd); |
old = bfd_tell (abfd); |
3735 |
if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0) |
if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0) |
3736 |
return false; |
return FALSE; |
3737 |
|
|
3738 |
ieee->w.r.extension_record = bfd_tell (abfd); |
ieee->w.r.extension_record = bfd_tell (abfd); |
3739 |
if (bfd_bwrite ((char *) exten, (bfd_size_type) sizeof (exten), abfd) |
if (bfd_bwrite ((char *) exten, (bfd_size_type) sizeof (exten), abfd) |
3740 |
!= sizeof (exten)) |
!= sizeof (exten)) |
3741 |
return false; |
return FALSE; |
3742 |
if (abfd->flags & EXEC_P) |
if (abfd->flags & EXEC_P) |
3743 |
{ |
{ |
3744 |
if (! ieee_write_byte (abfd, 0x1)) /* Absolute */ |
if (! ieee_write_byte (abfd, 0x1)) /* Absolute */ |
3745 |
return false; |
return FALSE; |
3746 |
} |
} |
3747 |
else |
else |
3748 |
{ |
{ |
3749 |
if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */ |
if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */ |
3750 |
return false; |
return FALSE; |
3751 |
} |
} |
3752 |
|
|
3753 |
ieee->w.r.environmental_record = bfd_tell (abfd); |
ieee->w.r.environmental_record = bfd_tell (abfd); |
3754 |
if (bfd_bwrite ((char *) envi, (bfd_size_type) sizeof (envi), abfd) |
if (bfd_bwrite ((char *) envi, (bfd_size_type) sizeof (envi), abfd) |
3755 |
!= sizeof (envi)) |
!= sizeof (envi)) |
3756 |
return false; |
return FALSE; |
3757 |
|
|
3758 |
/* The HP emulator database requires a timestamp in the file. */ |
/* The HP emulator database requires a timestamp in the file. */ |
3759 |
{ |
{ |
3772 |
|| ! ieee_write_int (abfd, (bfd_vma) t->tm_hour) |
|| ! ieee_write_int (abfd, (bfd_vma) t->tm_hour) |
3773 |
|| ! ieee_write_int (abfd, (bfd_vma) t->tm_min) |
|| ! ieee_write_int (abfd, (bfd_vma) t->tm_min) |
3774 |
|| ! ieee_write_int (abfd, (bfd_vma) t->tm_sec)) |
|| ! ieee_write_int (abfd, (bfd_vma) t->tm_sec)) |
3775 |
return false; |
return FALSE; |
3776 |
} |
} |
3777 |
|
|
3778 |
output_bfd = abfd; |
output_bfd = abfd; |
3780 |
flush (); |
flush (); |
3781 |
|
|
3782 |
if (! ieee_write_section_part (abfd)) |
if (! ieee_write_section_part (abfd)) |
3783 |
return false; |
return FALSE; |
3784 |
/* First write the symbols. This changes their values into table |
/* First write the symbols. This changes their values into table |
3785 |
indeces so we cant use it after this point. */ |
indeces so we cant use it after this point. */ |
3786 |
if (! ieee_write_external_part (abfd)) |
if (! ieee_write_external_part (abfd)) |
3787 |
return false; |
return FALSE; |
|
|
|
|
/* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ |
|
|
|
|
|
/* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ |
|
|
|
|
3788 |
|
|
3789 |
/* Write any debugs we have been told about. */ |
/* Write any debugs we have been told about. */ |
3790 |
if (! ieee_write_debug_part (abfd)) |
if (! ieee_write_debug_part (abfd)) |
3791 |
return false; |
return FALSE; |
3792 |
|
|
3793 |
/* Can only write the data once the symbols have been written, since |
/* Can only write the data once the symbols have been written, since |
3794 |
the data contains relocation information which points to the |
the data contains relocation information which points to the |
3795 |
symbols. */ |
symbols. */ |
3796 |
if (! ieee_write_data_part (abfd)) |
if (! ieee_write_data_part (abfd)) |
3797 |
return false; |
return FALSE; |
3798 |
|
|
3799 |
/* At the end we put the end! */ |
/* At the end we put the end! */ |
3800 |
if (! ieee_write_me_part (abfd)) |
if (! ieee_write_me_part (abfd)) |
3801 |
return false; |
return FALSE; |
3802 |
|
|
3803 |
/* Generate the header */ |
/* Generate the header. */ |
3804 |
if (bfd_seek (abfd, old, SEEK_SET) != 0) |
if (bfd_seek (abfd, old, SEEK_SET) != 0) |
3805 |
return false; |
return FALSE; |
3806 |
|
|
3807 |
for (i = 0; i < N_W_VARIABLES; i++) |
for (i = 0; i < N_W_VARIABLES; i++) |
3808 |
{ |
{ |
3809 |
if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum) |
if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum) |
3810 |
|| ! ieee_write_byte (abfd, (bfd_byte) i) |
|| ! ieee_write_byte (abfd, (bfd_byte) i) |
3811 |
|| ! ieee_write_int5_out (abfd, (bfd_vma) ieee->w.offset[i])) |
|| ! ieee_write_int5_out (abfd, (bfd_vma) ieee->w.offset[i])) |
3812 |
return false; |
return FALSE; |
3813 |
} |
} |
3814 |
|
|
3815 |
return true; |
return TRUE; |
3816 |
} |
} |
3817 |
|
|
3818 |
/* Native-level interface to symbols. */ |
/* Native-level interface to symbols. */ |
3819 |
|
|
3820 |
/* We read the symbols into a buffer, which is discarded when this |
/* We read the symbols into a buffer, which is discarded when this |
3821 |
function exits. We read the strings into a buffer large enough to |
function exits. We read the strings into a buffer large enough to |
3822 |
hold them all plus all the cached symbol entries. */ |
hold them all plus all the cached symbol entries. */ |
3823 |
|
|
3824 |
static asymbol * |
static asymbol * |
3825 |
ieee_make_empty_symbol (abfd) |
ieee_make_empty_symbol (abfd) |
3827 |
{ |
{ |
3828 |
bfd_size_type amt = sizeof (ieee_symbol_type); |
bfd_size_type amt = sizeof (ieee_symbol_type); |
3829 |
ieee_symbol_type *new = (ieee_symbol_type *) bfd_zalloc (abfd, amt); |
ieee_symbol_type *new = (ieee_symbol_type *) bfd_zalloc (abfd, amt); |
3830 |
|
|
3831 |
if (!new) |
if (!new) |
3832 |
return NULL; |
return NULL; |
3833 |
new->symbol.the_bfd = abfd; |
new->symbol.the_bfd = abfd; |
3840 |
bfd *prev; |
bfd *prev; |
3841 |
{ |
{ |
3842 |
ieee_ar_data_type *ar = IEEE_AR_DATA (arch); |
ieee_ar_data_type *ar = IEEE_AR_DATA (arch); |
3843 |
/* take the next one from the arch state, or reset */ |
|
3844 |
|
/* Take the next one from the arch state, or reset. */ |
3845 |
if (prev == (bfd *) NULL) |
if (prev == (bfd *) NULL) |
3846 |
{ |
/* Reset the index - the first two entries are bogus. */ |
3847 |
/* Reset the index - the first two entries are bogus*/ |
ar->element_index = 2; |
3848 |
ar->element_index = 2; |
|
3849 |
} |
while (TRUE) |
|
while (true) |
|
3850 |
{ |
{ |
3851 |
ieee_ar_obstack_type *p = ar->elements + ar->element_index; |
ieee_ar_obstack_type *p = ar->elements + ar->element_index; |
3852 |
|
|
3853 |
ar->element_index++; |
ar->element_index++; |
3854 |
if (ar->element_index <= ar->element_count) |
if (ar->element_index <= ar->element_count) |
3855 |
{ |
{ |
3868 |
bfd_set_error (bfd_error_no_more_archived_files); |
bfd_set_error (bfd_error_no_more_archived_files); |
3869 |
return (bfd *) NULL; |
return (bfd *) NULL; |
3870 |
} |
} |
|
|
|
3871 |
} |
} |
3872 |
} |
} |
3873 |
|
|
3874 |
static boolean |
static bfd_boolean |
3875 |
ieee_find_nearest_line (abfd, section, symbols, offset, filename_ptr, |
ieee_find_nearest_line (abfd, section, symbols, offset, filename_ptr, |
3876 |
functionname_ptr, line_ptr) |
functionname_ptr, line_ptr) |
3877 |
bfd *abfd ATTRIBUTE_UNUSED; |
bfd *abfd ATTRIBUTE_UNUSED; |
3882 |
const char **functionname_ptr ATTRIBUTE_UNUSED; |
const char **functionname_ptr ATTRIBUTE_UNUSED; |
3883 |
unsigned int *line_ptr ATTRIBUTE_UNUSED; |
unsigned int *line_ptr ATTRIBUTE_UNUSED; |
3884 |
{ |
{ |
3885 |
return false; |
return FALSE; |
3886 |
} |
} |
3887 |
|
|
3888 |
static int |
static int |
3920 |
static int |
static int |
3921 |
ieee_sizeof_headers (abfd, x) |
ieee_sizeof_headers (abfd, x) |
3922 |
bfd *abfd ATTRIBUTE_UNUSED; |
bfd *abfd ATTRIBUTE_UNUSED; |
3923 |
boolean x ATTRIBUTE_UNUSED; |
bfd_boolean x ATTRIBUTE_UNUSED; |
3924 |
{ |
{ |
3925 |
return 0; |
return 0; |
3926 |
} |
} |
3927 |
|
|
|
|
|
|
/* The debug info routines are never used. */ |
|
|
#if 0 |
|
|
|
|
|
static void |
|
|
ieee_bfd_debug_info_start (abfd) |
|
|
bfd *abfd; |
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
static void |
|
|
ieee_bfd_debug_info_end (abfd) |
|
|
bfd *abfd; |
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* Add this section to the list of sections we have debug info for, to |
|
|
be ready to output it at close time |
|
|
*/ |
|
|
static void |
|
|
ieee_bfd_debug_info_accumulate (abfd, section) |
|
|
bfd *abfd; |
|
|
asection *section; |
|
|
{ |
|
|
ieee_data_type *ieee = IEEE_DATA (section->owner); |
|
|
ieee_data_type *output_ieee = IEEE_DATA (abfd); |
|
|
/* can only accumulate data from other ieee bfds */ |
|
|
if (section->owner->xvec != abfd->xvec) |
|
|
return; |
|
|
/* Only bother once per bfd */ |
|
|
if (ieee->done_debug) |
|
|
return; |
|
|
ieee->done_debug = true; |
|
|
|
|
|
/* Don't bother if there is no debug info */ |
|
|
if (ieee->w.r.debug_information_part == 0) |
|
|
return; |
|
|
|
|
|
|
|
|
/* Add to chain */ |
|
|
{ |
|
|
bfd_size_type amt = sizeof (bfd_chain_type); |
|
|
bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, amt); |
|
|
if (!n) |
|
|
abort (); /* FIXME */ |
|
|
n->this = section->owner; |
|
|
n->next = (bfd_chain_type *) NULL; |
|
|
|
|
|
if (output_ieee->chain_head) |
|
|
{ |
|
|
output_ieee->chain_head->next = n; |
|
|
} |
|
|
else |
|
|
{ |
|
|
output_ieee->chain_root = n; |
|
|
|
|
|
} |
|
|
output_ieee->chain_head = n; |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
3928 |
#define ieee_close_and_cleanup _bfd_generic_close_and_cleanup |
#define ieee_close_and_cleanup _bfd_generic_close_and_cleanup |
3929 |
#define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info |
#define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info |
3930 |
|
|
3931 |
#define ieee_slurp_armap bfd_true |
#define ieee_slurp_armap bfd_true |
3932 |
#define ieee_slurp_extended_name_table bfd_true |
#define ieee_slurp_extended_name_table bfd_true |
3933 |
#define ieee_construct_extended_name_table \ |
#define ieee_construct_extended_name_table \ |
3934 |
((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \ |
((bfd_boolean (*) \ |
3935 |
|
PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \ |
3936 |
bfd_true) |
bfd_true) |
3937 |
#define ieee_truncate_arname bfd_dont_truncate_arname |
#define ieee_truncate_arname bfd_dont_truncate_arname |
3938 |
#define ieee_write_armap \ |
#define ieee_write_armap \ |
3939 |
((boolean (*) \ |
((bfd_boolean (*) \ |
3940 |
PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \ |
PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \ |
3941 |
bfd_true) |
bfd_true) |
3942 |
#define ieee_read_ar_hdr bfd_nullvoidptr |
#define ieee_read_ar_hdr bfd_nullvoidptr |
3943 |
#define ieee_update_armap_timestamp bfd_true |
#define ieee_update_armap_timestamp bfd_true |
3944 |
#define ieee_get_elt_at_index _bfd_generic_get_elt_at_index |
#define ieee_get_elt_at_index _bfd_generic_get_elt_at_index |
3945 |
|
|
3946 |
|
#define ieee_bfd_is_target_special_symbol \ |
3947 |
|
((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) |
3948 |
#define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name |
#define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name |
3949 |
#define ieee_get_lineno _bfd_nosymbols_get_lineno |
#define ieee_get_lineno _bfd_nosymbols_get_lineno |
3950 |
#define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol |
#define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol |
3962 |
#define ieee_bfd_relax_section bfd_generic_relax_section |
#define ieee_bfd_relax_section bfd_generic_relax_section |
3963 |
#define ieee_bfd_gc_sections bfd_generic_gc_sections |
#define ieee_bfd_gc_sections bfd_generic_gc_sections |
3964 |
#define ieee_bfd_merge_sections bfd_generic_merge_sections |
#define ieee_bfd_merge_sections bfd_generic_merge_sections |
3965 |
|
#define ieee_bfd_is_group_section bfd_generic_is_group_section |
3966 |
#define ieee_bfd_discard_group bfd_generic_discard_group |
#define ieee_bfd_discard_group bfd_generic_discard_group |
3967 |
|
#define ieee_section_already_linked \ |
3968 |
|
_bfd_generic_section_already_linked |
3969 |
#define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
#define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
3970 |
#define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
3971 |
#define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols |
#define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols |
3973 |
#define ieee_bfd_final_link _bfd_generic_final_link |
#define ieee_bfd_final_link _bfd_generic_final_link |
3974 |
#define ieee_bfd_link_split_section _bfd_generic_link_split_section |
#define ieee_bfd_link_split_section _bfd_generic_link_split_section |
3975 |
|
|
|
/*SUPPRESS 460 */ |
|
3976 |
const bfd_target ieee_vec = |
const bfd_target ieee_vec = |
3977 |
{ |
{ |
3978 |
"ieee", /* name */ |
"ieee", /* name */ |
4026 |
ieee_update_armap_timestamp */ |
ieee_update_armap_timestamp */ |
4027 |
BFD_JUMP_TABLE_ARCHIVE (ieee), |
BFD_JUMP_TABLE_ARCHIVE (ieee), |
4028 |
|
|
4029 |
/* ieee_get_symtab_upper_bound, ieee_get_symtab, ieee_make_empty_symbol, |
/* ieee_get_symtab_upper_bound, ieee_canonicalize_symtab, |
4030 |
ieee_print_symbol, ieee_get_symbol_info, ieee_bfd_is_local_label_name, |
ieee_make_empty_symbol, ieee_print_symbol, ieee_get_symbol_info, |
4031 |
ieee_get_lineno, ieee_find_nearest_line, ieee_bfd_make_debug_symbol, |
ieee_bfd_is_local_label_name, ieee_get_lineno, |
4032 |
ieee_read_minisymbols, ieee_minisymbol_to_symbol */ |
ieee_find_nearest_line, ieee_bfd_make_debug_symbol, |
4033 |
|
ieee_read_minisymbols, ieee_minisymbol_to_symbol */ |
4034 |
BFD_JUMP_TABLE_SYMBOLS (ieee), |
BFD_JUMP_TABLE_SYMBOLS (ieee), |
4035 |
|
|
4036 |
/* ieee_get_reloc_upper_bound, ieee_canonicalize_reloc, |
/* ieee_get_reloc_upper_bound, ieee_canonicalize_reloc, |