1*3d8817e4Smiod /* BFD back-end for ieee-695 objects.
2*3d8817e4Smiod Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3*3d8817e4Smiod 2000, 2001, 2002, 2003, 2004, 2005, 2006
4*3d8817e4Smiod Free Software Foundation, Inc.
5*3d8817e4Smiod
6*3d8817e4Smiod Written by Steve Chamberlain of Cygnus Support.
7*3d8817e4Smiod
8*3d8817e4Smiod This file is part of BFD, the Binary File Descriptor library.
9*3d8817e4Smiod
10*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
11*3d8817e4Smiod it under the terms of the GNU General Public License as published by
12*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or
13*3d8817e4Smiod (at your option) any later version.
14*3d8817e4Smiod
15*3d8817e4Smiod This program is distributed in the hope that it will be useful,
16*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
17*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18*3d8817e4Smiod GNU General Public License for more details.
19*3d8817e4Smiod
20*3d8817e4Smiod You should have received a copy of the GNU General Public License
21*3d8817e4Smiod along with this program; if not, write to the Free Software
22*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
23*3d8817e4Smiod
24*3d8817e4Smiod #define KEEPMINUSPCININST 0
25*3d8817e4Smiod
26*3d8817e4Smiod /* IEEE 695 format is a stream of records, which we parse using a simple one-
27*3d8817e4Smiod token (which is one byte in this lexicon) lookahead recursive decent
28*3d8817e4Smiod parser. */
29*3d8817e4Smiod
30*3d8817e4Smiod #include "bfd.h"
31*3d8817e4Smiod #include "sysdep.h"
32*3d8817e4Smiod #include "libbfd.h"
33*3d8817e4Smiod #include "ieee.h"
34*3d8817e4Smiod #include "libieee.h"
35*3d8817e4Smiod #include "safe-ctype.h"
36*3d8817e4Smiod
37*3d8817e4Smiod struct output_buffer_struct
38*3d8817e4Smiod {
39*3d8817e4Smiod unsigned char *ptrp;
40*3d8817e4Smiod int buffer;
41*3d8817e4Smiod };
42*3d8817e4Smiod
43*3d8817e4Smiod static unsigned char *output_ptr_start;
44*3d8817e4Smiod static unsigned char *output_ptr;
45*3d8817e4Smiod static unsigned char *output_ptr_end;
46*3d8817e4Smiod static unsigned char *input_ptr_start;
47*3d8817e4Smiod static unsigned char *input_ptr;
48*3d8817e4Smiod static unsigned char *input_ptr_end;
49*3d8817e4Smiod static bfd *input_bfd;
50*3d8817e4Smiod static bfd *output_bfd;
51*3d8817e4Smiod static int output_buffer;
52*3d8817e4Smiod
53*3d8817e4Smiod
54*3d8817e4Smiod static void block (void);
55*3d8817e4Smiod
56*3d8817e4Smiod /* Functions for writing to ieee files in the strange way that the
57*3d8817e4Smiod standard requires. */
58*3d8817e4Smiod
59*3d8817e4Smiod static bfd_boolean
ieee_write_byte(bfd * abfd,int barg)60*3d8817e4Smiod ieee_write_byte (bfd *abfd, int barg)
61*3d8817e4Smiod {
62*3d8817e4Smiod bfd_byte byte;
63*3d8817e4Smiod
64*3d8817e4Smiod byte = barg;
65*3d8817e4Smiod if (bfd_bwrite ((void *) &byte, (bfd_size_type) 1, abfd) != 1)
66*3d8817e4Smiod return FALSE;
67*3d8817e4Smiod return TRUE;
68*3d8817e4Smiod }
69*3d8817e4Smiod
70*3d8817e4Smiod static bfd_boolean
ieee_write_2bytes(bfd * abfd,int bytes)71*3d8817e4Smiod ieee_write_2bytes (bfd *abfd, int bytes)
72*3d8817e4Smiod {
73*3d8817e4Smiod bfd_byte buffer[2];
74*3d8817e4Smiod
75*3d8817e4Smiod buffer[0] = bytes >> 8;
76*3d8817e4Smiod buffer[1] = bytes & 0xff;
77*3d8817e4Smiod if (bfd_bwrite ((void *) buffer, (bfd_size_type) 2, abfd) != 2)
78*3d8817e4Smiod return FALSE;
79*3d8817e4Smiod return TRUE;
80*3d8817e4Smiod }
81*3d8817e4Smiod
82*3d8817e4Smiod static bfd_boolean
ieee_write_int(bfd * abfd,bfd_vma value)83*3d8817e4Smiod ieee_write_int (bfd *abfd, bfd_vma value)
84*3d8817e4Smiod {
85*3d8817e4Smiod if (value <= 127)
86*3d8817e4Smiod {
87*3d8817e4Smiod if (! ieee_write_byte (abfd, (bfd_byte) value))
88*3d8817e4Smiod return FALSE;
89*3d8817e4Smiod }
90*3d8817e4Smiod else
91*3d8817e4Smiod {
92*3d8817e4Smiod unsigned int length;
93*3d8817e4Smiod
94*3d8817e4Smiod /* How many significant bytes ? */
95*3d8817e4Smiod /* FIXME FOR LONGER INTS. */
96*3d8817e4Smiod if (value & 0xff000000)
97*3d8817e4Smiod length = 4;
98*3d8817e4Smiod else if (value & 0x00ff0000)
99*3d8817e4Smiod length = 3;
100*3d8817e4Smiod else if (value & 0x0000ff00)
101*3d8817e4Smiod length = 2;
102*3d8817e4Smiod else
103*3d8817e4Smiod length = 1;
104*3d8817e4Smiod
105*3d8817e4Smiod if (! ieee_write_byte (abfd,
106*3d8817e4Smiod (bfd_byte) ((int) ieee_number_repeat_start_enum
107*3d8817e4Smiod + length)))
108*3d8817e4Smiod return FALSE;
109*3d8817e4Smiod switch (length)
110*3d8817e4Smiod {
111*3d8817e4Smiod case 4:
112*3d8817e4Smiod if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24)))
113*3d8817e4Smiod return FALSE;
114*3d8817e4Smiod /* Fall through. */
115*3d8817e4Smiod case 3:
116*3d8817e4Smiod if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16)))
117*3d8817e4Smiod return FALSE;
118*3d8817e4Smiod /* Fall through. */
119*3d8817e4Smiod case 2:
120*3d8817e4Smiod if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8)))
121*3d8817e4Smiod return FALSE;
122*3d8817e4Smiod /* Fall through. */
123*3d8817e4Smiod case 1:
124*3d8817e4Smiod if (! ieee_write_byte (abfd, (bfd_byte) (value)))
125*3d8817e4Smiod return FALSE;
126*3d8817e4Smiod }
127*3d8817e4Smiod }
128*3d8817e4Smiod
129*3d8817e4Smiod return TRUE;
130*3d8817e4Smiod }
131*3d8817e4Smiod
132*3d8817e4Smiod static bfd_boolean
ieee_write_id(bfd * abfd,const char * id)133*3d8817e4Smiod ieee_write_id (bfd *abfd, const char *id)
134*3d8817e4Smiod {
135*3d8817e4Smiod size_t length = strlen (id);
136*3d8817e4Smiod
137*3d8817e4Smiod if (length <= 127)
138*3d8817e4Smiod {
139*3d8817e4Smiod if (! ieee_write_byte (abfd, (bfd_byte) length))
140*3d8817e4Smiod return FALSE;
141*3d8817e4Smiod }
142*3d8817e4Smiod else if (length < 255)
143*3d8817e4Smiod {
144*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_extension_length_1_enum)
145*3d8817e4Smiod || ! ieee_write_byte (abfd, (bfd_byte) length))
146*3d8817e4Smiod return FALSE;
147*3d8817e4Smiod }
148*3d8817e4Smiod else if (length < 65535)
149*3d8817e4Smiod {
150*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_extension_length_2_enum)
151*3d8817e4Smiod || ! ieee_write_2bytes (abfd, (int) length))
152*3d8817e4Smiod return FALSE;
153*3d8817e4Smiod }
154*3d8817e4Smiod else
155*3d8817e4Smiod {
156*3d8817e4Smiod (*_bfd_error_handler)
157*3d8817e4Smiod (_("%s: string too long (%d chars, max 65535)"),
158*3d8817e4Smiod bfd_get_filename (abfd), length);
159*3d8817e4Smiod bfd_set_error (bfd_error_invalid_operation);
160*3d8817e4Smiod return FALSE;
161*3d8817e4Smiod }
162*3d8817e4Smiod
163*3d8817e4Smiod if (bfd_bwrite ((void *) id, (bfd_size_type) length, abfd) != length)
164*3d8817e4Smiod return FALSE;
165*3d8817e4Smiod return TRUE;
166*3d8817e4Smiod }
167*3d8817e4Smiod
168*3d8817e4Smiod /* Functions for reading from ieee files in the strange way that the
169*3d8817e4Smiod standard requires. */
170*3d8817e4Smiod
171*3d8817e4Smiod #define this_byte(ieee) *((ieee)->input_p)
172*3d8817e4Smiod #define next_byte(ieee) ((ieee)->input_p++)
173*3d8817e4Smiod #define this_byte_and_next(ieee) (*((ieee)->input_p++))
174*3d8817e4Smiod
175*3d8817e4Smiod static unsigned short
read_2bytes(common_header_type * ieee)176*3d8817e4Smiod read_2bytes (common_header_type *ieee)
177*3d8817e4Smiod {
178*3d8817e4Smiod unsigned char c1 = this_byte_and_next (ieee);
179*3d8817e4Smiod unsigned char c2 = this_byte_and_next (ieee);
180*3d8817e4Smiod
181*3d8817e4Smiod return (c1 << 8) | c2;
182*3d8817e4Smiod }
183*3d8817e4Smiod
184*3d8817e4Smiod static void
bfd_get_string(common_header_type * ieee,char * string,size_t length)185*3d8817e4Smiod bfd_get_string (common_header_type *ieee, char *string, size_t length)
186*3d8817e4Smiod {
187*3d8817e4Smiod size_t i;
188*3d8817e4Smiod
189*3d8817e4Smiod for (i = 0; i < length; i++)
190*3d8817e4Smiod string[i] = this_byte_and_next (ieee);
191*3d8817e4Smiod }
192*3d8817e4Smiod
193*3d8817e4Smiod static char *
read_id(common_header_type * ieee)194*3d8817e4Smiod read_id (common_header_type *ieee)
195*3d8817e4Smiod {
196*3d8817e4Smiod size_t length;
197*3d8817e4Smiod char *string;
198*3d8817e4Smiod
199*3d8817e4Smiod length = this_byte_and_next (ieee);
200*3d8817e4Smiod if (length <= 0x7f)
201*3d8817e4Smiod /* Simple string of length 0 to 127. */
202*3d8817e4Smiod ;
203*3d8817e4Smiod
204*3d8817e4Smiod else if (length == 0xde)
205*3d8817e4Smiod /* Length is next byte, allowing 0..255. */
206*3d8817e4Smiod length = this_byte_and_next (ieee);
207*3d8817e4Smiod
208*3d8817e4Smiod else if (length == 0xdf)
209*3d8817e4Smiod {
210*3d8817e4Smiod /* Length is next two bytes, allowing 0..65535. */
211*3d8817e4Smiod length = this_byte_and_next (ieee);
212*3d8817e4Smiod length = (length * 256) + this_byte_and_next (ieee);
213*3d8817e4Smiod }
214*3d8817e4Smiod
215*3d8817e4Smiod /* Buy memory and read string. */
216*3d8817e4Smiod string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1);
217*3d8817e4Smiod if (!string)
218*3d8817e4Smiod return NULL;
219*3d8817e4Smiod bfd_get_string (ieee, string, length);
220*3d8817e4Smiod string[length] = 0;
221*3d8817e4Smiod return string;
222*3d8817e4Smiod }
223*3d8817e4Smiod
224*3d8817e4Smiod static bfd_boolean
ieee_write_expression(bfd * abfd,bfd_vma value,asymbol * symbol,bfd_boolean pcrel,unsigned int index)225*3d8817e4Smiod ieee_write_expression (bfd *abfd,
226*3d8817e4Smiod bfd_vma value,
227*3d8817e4Smiod asymbol *symbol,
228*3d8817e4Smiod bfd_boolean pcrel,
229*3d8817e4Smiod unsigned int index)
230*3d8817e4Smiod {
231*3d8817e4Smiod unsigned int term_count = 0;
232*3d8817e4Smiod
233*3d8817e4Smiod if (value != 0)
234*3d8817e4Smiod {
235*3d8817e4Smiod if (! ieee_write_int (abfd, value))
236*3d8817e4Smiod return FALSE;
237*3d8817e4Smiod term_count++;
238*3d8817e4Smiod }
239*3d8817e4Smiod
240*3d8817e4Smiod /* Badly formatted binaries can have a missing symbol,
241*3d8817e4Smiod so test here to prevent a seg fault. */
242*3d8817e4Smiod if (symbol != NULL)
243*3d8817e4Smiod {
244*3d8817e4Smiod if (bfd_is_com_section (symbol->section)
245*3d8817e4Smiod || bfd_is_und_section (symbol->section))
246*3d8817e4Smiod {
247*3d8817e4Smiod /* Def of a common symbol. */
248*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_X_enum)
249*3d8817e4Smiod || ! ieee_write_int (abfd, symbol->value))
250*3d8817e4Smiod return FALSE;
251*3d8817e4Smiod term_count ++;
252*3d8817e4Smiod }
253*3d8817e4Smiod else if (! bfd_is_abs_section (symbol->section))
254*3d8817e4Smiod {
255*3d8817e4Smiod /* Ref to defined symbol - */
256*3d8817e4Smiod if (symbol->flags & BSF_GLOBAL)
257*3d8817e4Smiod {
258*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_I_enum)
259*3d8817e4Smiod || ! ieee_write_int (abfd, symbol->value))
260*3d8817e4Smiod return FALSE;
261*3d8817e4Smiod term_count++;
262*3d8817e4Smiod }
263*3d8817e4Smiod else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))
264*3d8817e4Smiod {
265*3d8817e4Smiod /* This is a reference to a defined local symbol. We can
266*3d8817e4Smiod easily do a local as a section+offset. */
267*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_R_enum)
268*3d8817e4Smiod || ! ieee_write_byte (abfd,
269*3d8817e4Smiod (bfd_byte) (symbol->section->index
270*3d8817e4Smiod + IEEE_SECTION_NUMBER_BASE)))
271*3d8817e4Smiod return FALSE;
272*3d8817e4Smiod
273*3d8817e4Smiod term_count++;
274*3d8817e4Smiod if (symbol->value != 0)
275*3d8817e4Smiod {
276*3d8817e4Smiod if (! ieee_write_int (abfd, symbol->value))
277*3d8817e4Smiod return FALSE;
278*3d8817e4Smiod term_count++;
279*3d8817e4Smiod }
280*3d8817e4Smiod }
281*3d8817e4Smiod else
282*3d8817e4Smiod {
283*3d8817e4Smiod (*_bfd_error_handler)
284*3d8817e4Smiod (_("%s: unrecognized symbol `%s' flags 0x%x"),
285*3d8817e4Smiod bfd_get_filename (abfd), bfd_asymbol_name (symbol),
286*3d8817e4Smiod symbol->flags);
287*3d8817e4Smiod bfd_set_error (bfd_error_invalid_operation);
288*3d8817e4Smiod return FALSE;
289*3d8817e4Smiod }
290*3d8817e4Smiod }
291*3d8817e4Smiod }
292*3d8817e4Smiod
293*3d8817e4Smiod if (pcrel)
294*3d8817e4Smiod {
295*3d8817e4Smiod /* Subtract the pc from here by asking for PC of this section. */
296*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_P_enum)
297*3d8817e4Smiod || ! ieee_write_byte (abfd,
298*3d8817e4Smiod (bfd_byte) (index + IEEE_SECTION_NUMBER_BASE))
299*3d8817e4Smiod || ! ieee_write_byte (abfd, ieee_function_minus_enum))
300*3d8817e4Smiod return FALSE;
301*3d8817e4Smiod }
302*3d8817e4Smiod
303*3d8817e4Smiod /* Handle the degenerate case of a 0 address. */
304*3d8817e4Smiod if (term_count == 0)
305*3d8817e4Smiod if (! ieee_write_int (abfd, (bfd_vma) 0))
306*3d8817e4Smiod return FALSE;
307*3d8817e4Smiod
308*3d8817e4Smiod while (term_count > 1)
309*3d8817e4Smiod {
310*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_function_plus_enum))
311*3d8817e4Smiod return FALSE;
312*3d8817e4Smiod term_count--;
313*3d8817e4Smiod }
314*3d8817e4Smiod
315*3d8817e4Smiod return TRUE;
316*3d8817e4Smiod }
317*3d8817e4Smiod
318*3d8817e4Smiod /* Writes any integer into the buffer supplied and always takes 5 bytes. */
319*3d8817e4Smiod
320*3d8817e4Smiod static void
ieee_write_int5(bfd_byte * buffer,bfd_vma value)321*3d8817e4Smiod ieee_write_int5 (bfd_byte *buffer, bfd_vma value)
322*3d8817e4Smiod {
323*3d8817e4Smiod buffer[0] = (bfd_byte) ieee_number_repeat_4_enum;
324*3d8817e4Smiod buffer[1] = (value >> 24) & 0xff;
325*3d8817e4Smiod buffer[2] = (value >> 16) & 0xff;
326*3d8817e4Smiod buffer[3] = (value >> 8) & 0xff;
327*3d8817e4Smiod buffer[4] = (value >> 0) & 0xff;
328*3d8817e4Smiod }
329*3d8817e4Smiod
330*3d8817e4Smiod static bfd_boolean
ieee_write_int5_out(bfd * abfd,bfd_vma value)331*3d8817e4Smiod ieee_write_int5_out (bfd *abfd, bfd_vma value)
332*3d8817e4Smiod {
333*3d8817e4Smiod bfd_byte b[5];
334*3d8817e4Smiod
335*3d8817e4Smiod ieee_write_int5 (b, value);
336*3d8817e4Smiod if (bfd_bwrite ((void *) b, (bfd_size_type) 5, abfd) != 5)
337*3d8817e4Smiod return FALSE;
338*3d8817e4Smiod return TRUE;
339*3d8817e4Smiod }
340*3d8817e4Smiod
341*3d8817e4Smiod static bfd_boolean
parse_int(common_header_type * ieee,bfd_vma * value_ptr)342*3d8817e4Smiod parse_int (common_header_type *ieee, bfd_vma *value_ptr)
343*3d8817e4Smiod {
344*3d8817e4Smiod int value = this_byte (ieee);
345*3d8817e4Smiod int result;
346*3d8817e4Smiod
347*3d8817e4Smiod if (value >= 0 && value <= 127)
348*3d8817e4Smiod {
349*3d8817e4Smiod *value_ptr = value;
350*3d8817e4Smiod next_byte (ieee);
351*3d8817e4Smiod return TRUE;
352*3d8817e4Smiod }
353*3d8817e4Smiod else if (value >= 0x80 && value <= 0x88)
354*3d8817e4Smiod {
355*3d8817e4Smiod unsigned int count = value & 0xf;
356*3d8817e4Smiod
357*3d8817e4Smiod result = 0;
358*3d8817e4Smiod next_byte (ieee);
359*3d8817e4Smiod while (count)
360*3d8817e4Smiod {
361*3d8817e4Smiod result = (result << 8) | this_byte_and_next (ieee);
362*3d8817e4Smiod count--;
363*3d8817e4Smiod }
364*3d8817e4Smiod *value_ptr = result;
365*3d8817e4Smiod return TRUE;
366*3d8817e4Smiod }
367*3d8817e4Smiod return FALSE;
368*3d8817e4Smiod }
369*3d8817e4Smiod
370*3d8817e4Smiod static int
parse_i(common_header_type * ieee,bfd_boolean * ok)371*3d8817e4Smiod parse_i (common_header_type *ieee, bfd_boolean *ok)
372*3d8817e4Smiod {
373*3d8817e4Smiod bfd_vma x;
374*3d8817e4Smiod *ok = parse_int (ieee, &x);
375*3d8817e4Smiod return x;
376*3d8817e4Smiod }
377*3d8817e4Smiod
378*3d8817e4Smiod static bfd_vma
must_parse_int(common_header_type * ieee)379*3d8817e4Smiod must_parse_int (common_header_type *ieee)
380*3d8817e4Smiod {
381*3d8817e4Smiod bfd_vma result;
382*3d8817e4Smiod BFD_ASSERT (parse_int (ieee, &result));
383*3d8817e4Smiod return result;
384*3d8817e4Smiod }
385*3d8817e4Smiod
386*3d8817e4Smiod typedef struct
387*3d8817e4Smiod {
388*3d8817e4Smiod bfd_vma value;
389*3d8817e4Smiod asection *section;
390*3d8817e4Smiod ieee_symbol_index_type symbol;
391*3d8817e4Smiod } ieee_value_type;
392*3d8817e4Smiod
393*3d8817e4Smiod
394*3d8817e4Smiod #if KEEPMINUSPCININST
395*3d8817e4Smiod
396*3d8817e4Smiod #define SRC_MASK(arg) arg
397*3d8817e4Smiod #define PCREL_OFFSET FALSE
398*3d8817e4Smiod
399*3d8817e4Smiod #else
400*3d8817e4Smiod
401*3d8817e4Smiod #define SRC_MASK(arg) 0
402*3d8817e4Smiod #define PCREL_OFFSET TRUE
403*3d8817e4Smiod
404*3d8817e4Smiod #endif
405*3d8817e4Smiod
406*3d8817e4Smiod static reloc_howto_type abs32_howto =
407*3d8817e4Smiod HOWTO (1,
408*3d8817e4Smiod 0,
409*3d8817e4Smiod 2,
410*3d8817e4Smiod 32,
411*3d8817e4Smiod FALSE,
412*3d8817e4Smiod 0,
413*3d8817e4Smiod complain_overflow_bitfield,
414*3d8817e4Smiod 0,
415*3d8817e4Smiod "abs32",
416*3d8817e4Smiod TRUE,
417*3d8817e4Smiod 0xffffffff,
418*3d8817e4Smiod 0xffffffff,
419*3d8817e4Smiod FALSE);
420*3d8817e4Smiod
421*3d8817e4Smiod static reloc_howto_type abs16_howto =
422*3d8817e4Smiod HOWTO (1,
423*3d8817e4Smiod 0,
424*3d8817e4Smiod 1,
425*3d8817e4Smiod 16,
426*3d8817e4Smiod FALSE,
427*3d8817e4Smiod 0,
428*3d8817e4Smiod complain_overflow_bitfield,
429*3d8817e4Smiod 0,
430*3d8817e4Smiod "abs16",
431*3d8817e4Smiod TRUE,
432*3d8817e4Smiod 0x0000ffff,
433*3d8817e4Smiod 0x0000ffff,
434*3d8817e4Smiod FALSE);
435*3d8817e4Smiod
436*3d8817e4Smiod static reloc_howto_type abs8_howto =
437*3d8817e4Smiod HOWTO (1,
438*3d8817e4Smiod 0,
439*3d8817e4Smiod 0,
440*3d8817e4Smiod 8,
441*3d8817e4Smiod FALSE,
442*3d8817e4Smiod 0,
443*3d8817e4Smiod complain_overflow_bitfield,
444*3d8817e4Smiod 0,
445*3d8817e4Smiod "abs8",
446*3d8817e4Smiod TRUE,
447*3d8817e4Smiod 0x000000ff,
448*3d8817e4Smiod 0x000000ff,
449*3d8817e4Smiod FALSE);
450*3d8817e4Smiod
451*3d8817e4Smiod static reloc_howto_type rel32_howto =
452*3d8817e4Smiod HOWTO (1,
453*3d8817e4Smiod 0,
454*3d8817e4Smiod 2,
455*3d8817e4Smiod 32,
456*3d8817e4Smiod TRUE,
457*3d8817e4Smiod 0,
458*3d8817e4Smiod complain_overflow_signed,
459*3d8817e4Smiod 0,
460*3d8817e4Smiod "rel32",
461*3d8817e4Smiod TRUE,
462*3d8817e4Smiod SRC_MASK (0xffffffff),
463*3d8817e4Smiod 0xffffffff,
464*3d8817e4Smiod PCREL_OFFSET);
465*3d8817e4Smiod
466*3d8817e4Smiod static reloc_howto_type rel16_howto =
467*3d8817e4Smiod HOWTO (1,
468*3d8817e4Smiod 0,
469*3d8817e4Smiod 1,
470*3d8817e4Smiod 16,
471*3d8817e4Smiod TRUE,
472*3d8817e4Smiod 0,
473*3d8817e4Smiod complain_overflow_signed,
474*3d8817e4Smiod 0,
475*3d8817e4Smiod "rel16",
476*3d8817e4Smiod TRUE,
477*3d8817e4Smiod SRC_MASK (0x0000ffff),
478*3d8817e4Smiod 0x0000ffff,
479*3d8817e4Smiod PCREL_OFFSET);
480*3d8817e4Smiod
481*3d8817e4Smiod static reloc_howto_type rel8_howto =
482*3d8817e4Smiod HOWTO (1,
483*3d8817e4Smiod 0,
484*3d8817e4Smiod 0,
485*3d8817e4Smiod 8,
486*3d8817e4Smiod TRUE,
487*3d8817e4Smiod 0,
488*3d8817e4Smiod complain_overflow_signed,
489*3d8817e4Smiod 0,
490*3d8817e4Smiod "rel8",
491*3d8817e4Smiod TRUE,
492*3d8817e4Smiod SRC_MASK (0x000000ff),
493*3d8817e4Smiod 0x000000ff,
494*3d8817e4Smiod PCREL_OFFSET);
495*3d8817e4Smiod
496*3d8817e4Smiod static ieee_symbol_index_type NOSYMBOL = {0, 0};
497*3d8817e4Smiod
498*3d8817e4Smiod static void
parse_expression(ieee_data_type * ieee,bfd_vma * value,ieee_symbol_index_type * symbol,bfd_boolean * pcrel,unsigned int * extra,asection ** section)499*3d8817e4Smiod parse_expression (ieee_data_type *ieee,
500*3d8817e4Smiod bfd_vma *value,
501*3d8817e4Smiod ieee_symbol_index_type *symbol,
502*3d8817e4Smiod bfd_boolean *pcrel,
503*3d8817e4Smiod unsigned int *extra,
504*3d8817e4Smiod asection **section)
505*3d8817e4Smiod
506*3d8817e4Smiod {
507*3d8817e4Smiod bfd_boolean loop = TRUE;
508*3d8817e4Smiod ieee_value_type stack[10];
509*3d8817e4Smiod ieee_value_type *sp = stack;
510*3d8817e4Smiod asection *dummy;
511*3d8817e4Smiod
512*3d8817e4Smiod #define POS sp[1]
513*3d8817e4Smiod #define TOS sp[0]
514*3d8817e4Smiod #define NOS sp[-1]
515*3d8817e4Smiod #define INC sp++;
516*3d8817e4Smiod #define DEC sp--;
517*3d8817e4Smiod
518*3d8817e4Smiod /* The stack pointer always points to the next unused location. */
519*3d8817e4Smiod #define PUSH(x,y,z) TOS.symbol = x; TOS.section = y; TOS.value = z; INC;
520*3d8817e4Smiod #define POP(x,y,z) DEC; x = TOS.symbol; y = TOS.section; z = TOS.value;
521*3d8817e4Smiod
522*3d8817e4Smiod while (loop && ieee->h.input_p < ieee->h.last_byte)
523*3d8817e4Smiod {
524*3d8817e4Smiod switch (this_byte (&(ieee->h)))
525*3d8817e4Smiod {
526*3d8817e4Smiod case ieee_variable_P_enum:
527*3d8817e4Smiod /* P variable, current program counter for section n. */
528*3d8817e4Smiod {
529*3d8817e4Smiod int section_n;
530*3d8817e4Smiod
531*3d8817e4Smiod next_byte (&(ieee->h));
532*3d8817e4Smiod *pcrel = TRUE;
533*3d8817e4Smiod section_n = must_parse_int (&(ieee->h));
534*3d8817e4Smiod PUSH (NOSYMBOL, bfd_abs_section_ptr, 0);
535*3d8817e4Smiod break;
536*3d8817e4Smiod }
537*3d8817e4Smiod case ieee_variable_L_enum:
538*3d8817e4Smiod /* L variable address of section N. */
539*3d8817e4Smiod next_byte (&(ieee->h));
540*3d8817e4Smiod PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
541*3d8817e4Smiod break;
542*3d8817e4Smiod case ieee_variable_R_enum:
543*3d8817e4Smiod /* R variable, logical address of section module. */
544*3d8817e4Smiod /* FIXME, this should be different to L. */
545*3d8817e4Smiod next_byte (&(ieee->h));
546*3d8817e4Smiod PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
547*3d8817e4Smiod break;
548*3d8817e4Smiod case ieee_variable_S_enum:
549*3d8817e4Smiod /* S variable, size in MAUS of section module. */
550*3d8817e4Smiod next_byte (&(ieee->h));
551*3d8817e4Smiod PUSH (NOSYMBOL,
552*3d8817e4Smiod 0,
553*3d8817e4Smiod ieee->section_table[must_parse_int (&(ieee->h))]->size);
554*3d8817e4Smiod break;
555*3d8817e4Smiod case ieee_variable_I_enum:
556*3d8817e4Smiod /* Push the address of variable n. */
557*3d8817e4Smiod {
558*3d8817e4Smiod ieee_symbol_index_type sy;
559*3d8817e4Smiod
560*3d8817e4Smiod next_byte (&(ieee->h));
561*3d8817e4Smiod sy.index = (int) must_parse_int (&(ieee->h));
562*3d8817e4Smiod sy.letter = 'I';
563*3d8817e4Smiod
564*3d8817e4Smiod PUSH (sy, bfd_abs_section_ptr, 0);
565*3d8817e4Smiod }
566*3d8817e4Smiod break;
567*3d8817e4Smiod case ieee_variable_X_enum:
568*3d8817e4Smiod /* Push the address of external variable n. */
569*3d8817e4Smiod {
570*3d8817e4Smiod ieee_symbol_index_type sy;
571*3d8817e4Smiod
572*3d8817e4Smiod next_byte (&(ieee->h));
573*3d8817e4Smiod sy.index = (int) (must_parse_int (&(ieee->h)));
574*3d8817e4Smiod sy.letter = 'X';
575*3d8817e4Smiod
576*3d8817e4Smiod PUSH (sy, bfd_und_section_ptr, 0);
577*3d8817e4Smiod }
578*3d8817e4Smiod break;
579*3d8817e4Smiod case ieee_function_minus_enum:
580*3d8817e4Smiod {
581*3d8817e4Smiod bfd_vma value1, value2;
582*3d8817e4Smiod asection *section1, *section_dummy;
583*3d8817e4Smiod ieee_symbol_index_type sy;
584*3d8817e4Smiod
585*3d8817e4Smiod next_byte (&(ieee->h));
586*3d8817e4Smiod
587*3d8817e4Smiod POP (sy, section1, value1);
588*3d8817e4Smiod POP (sy, section_dummy, value2);
589*3d8817e4Smiod PUSH (sy, section1 ? section1 : section_dummy, value2 - value1);
590*3d8817e4Smiod }
591*3d8817e4Smiod break;
592*3d8817e4Smiod case ieee_function_plus_enum:
593*3d8817e4Smiod {
594*3d8817e4Smiod bfd_vma value1, value2;
595*3d8817e4Smiod asection *section1;
596*3d8817e4Smiod asection *section2;
597*3d8817e4Smiod ieee_symbol_index_type sy1;
598*3d8817e4Smiod ieee_symbol_index_type sy2;
599*3d8817e4Smiod
600*3d8817e4Smiod next_byte (&(ieee->h));
601*3d8817e4Smiod
602*3d8817e4Smiod POP (sy1, section1, value1);
603*3d8817e4Smiod POP (sy2, section2, value2);
604*3d8817e4Smiod PUSH (sy1.letter ? sy1 : sy2,
605*3d8817e4Smiod bfd_is_abs_section (section1) ? section2 : section1,
606*3d8817e4Smiod value1 + value2);
607*3d8817e4Smiod }
608*3d8817e4Smiod break;
609*3d8817e4Smiod default:
610*3d8817e4Smiod {
611*3d8817e4Smiod bfd_vma va;
612*3d8817e4Smiod
613*3d8817e4Smiod BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum
614*3d8817e4Smiod || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum);
615*3d8817e4Smiod if (parse_int (&(ieee->h), &va))
616*3d8817e4Smiod {
617*3d8817e4Smiod PUSH (NOSYMBOL, bfd_abs_section_ptr, va);
618*3d8817e4Smiod }
619*3d8817e4Smiod else
620*3d8817e4Smiod /* Thats all that we can understand. */
621*3d8817e4Smiod loop = FALSE;
622*3d8817e4Smiod }
623*3d8817e4Smiod }
624*3d8817e4Smiod }
625*3d8817e4Smiod
626*3d8817e4Smiod /* As far as I can see there is a bug in the Microtec IEEE output
627*3d8817e4Smiod which I'm using to scan, whereby the comma operator is omitted
628*3d8817e4Smiod sometimes in an expression, giving expressions with too many
629*3d8817e4Smiod terms. We can tell if that's the case by ensuring that
630*3d8817e4Smiod sp == stack here. If not, then we've pushed something too far,
631*3d8817e4Smiod so we keep adding. */
632*3d8817e4Smiod while (sp != stack + 1)
633*3d8817e4Smiod {
634*3d8817e4Smiod asection *section1;
635*3d8817e4Smiod ieee_symbol_index_type sy1;
636*3d8817e4Smiod
637*3d8817e4Smiod POP (sy1, section1, *extra);
638*3d8817e4Smiod }
639*3d8817e4Smiod
640*3d8817e4Smiod POP (*symbol, dummy, *value);
641*3d8817e4Smiod if (section)
642*3d8817e4Smiod *section = dummy;
643*3d8817e4Smiod }
644*3d8817e4Smiod
645*3d8817e4Smiod
646*3d8817e4Smiod #define ieee_seek(ieee, offset) \
647*3d8817e4Smiod do \
648*3d8817e4Smiod { \
649*3d8817e4Smiod ieee->h.input_p = ieee->h.first_byte + offset; \
650*3d8817e4Smiod ieee->h.last_byte = (ieee->h.first_byte \
651*3d8817e4Smiod + ieee_part_after (ieee, offset)); \
652*3d8817e4Smiod } \
653*3d8817e4Smiod while (0)
654*3d8817e4Smiod
655*3d8817e4Smiod #define ieee_pos(ieee) \
656*3d8817e4Smiod (ieee->h.input_p - ieee->h.first_byte)
657*3d8817e4Smiod
658*3d8817e4Smiod /* Find the first part of the ieee file after HERE. */
659*3d8817e4Smiod
660*3d8817e4Smiod static file_ptr
ieee_part_after(ieee_data_type * ieee,file_ptr here)661*3d8817e4Smiod ieee_part_after (ieee_data_type *ieee, file_ptr here)
662*3d8817e4Smiod {
663*3d8817e4Smiod int part;
664*3d8817e4Smiod file_ptr after = ieee->w.r.me_record;
665*3d8817e4Smiod
666*3d8817e4Smiod /* File parts can come in any order, except that module end is
667*3d8817e4Smiod guaranteed to be last (and the header first). */
668*3d8817e4Smiod for (part = 0; part < N_W_VARIABLES; part++)
669*3d8817e4Smiod if (ieee->w.offset[part] > here && after > ieee->w.offset[part])
670*3d8817e4Smiod after = ieee->w.offset[part];
671*3d8817e4Smiod
672*3d8817e4Smiod return after;
673*3d8817e4Smiod }
674*3d8817e4Smiod
675*3d8817e4Smiod static unsigned int last_index;
676*3d8817e4Smiod static char last_type; /* Is the index for an X or a D. */
677*3d8817e4Smiod
678*3d8817e4Smiod static ieee_symbol_type *
get_symbol(bfd * abfd ATTRIBUTE_UNUSED,ieee_data_type * ieee,ieee_symbol_type * last_symbol,unsigned int * symbol_count,ieee_symbol_type *** pptr,unsigned int * max_index,int this_type)679*3d8817e4Smiod get_symbol (bfd *abfd ATTRIBUTE_UNUSED,
680*3d8817e4Smiod ieee_data_type *ieee,
681*3d8817e4Smiod ieee_symbol_type *last_symbol,
682*3d8817e4Smiod unsigned int *symbol_count,
683*3d8817e4Smiod ieee_symbol_type ***pptr,
684*3d8817e4Smiod unsigned int *max_index,
685*3d8817e4Smiod int this_type)
686*3d8817e4Smiod {
687*3d8817e4Smiod /* Need a new symbol. */
688*3d8817e4Smiod unsigned int new_index = must_parse_int (&(ieee->h));
689*3d8817e4Smiod
690*3d8817e4Smiod if (new_index != last_index || this_type != last_type)
691*3d8817e4Smiod {
692*3d8817e4Smiod ieee_symbol_type *new_symbol;
693*3d8817e4Smiod bfd_size_type amt = sizeof (ieee_symbol_type);
694*3d8817e4Smiod
695*3d8817e4Smiod new_symbol = bfd_alloc (ieee->h.abfd, amt);
696*3d8817e4Smiod if (!new_symbol)
697*3d8817e4Smiod return NULL;
698*3d8817e4Smiod
699*3d8817e4Smiod new_symbol->index = new_index;
700*3d8817e4Smiod last_index = new_index;
701*3d8817e4Smiod (*symbol_count)++;
702*3d8817e4Smiod **pptr = new_symbol;
703*3d8817e4Smiod *pptr = &new_symbol->next;
704*3d8817e4Smiod if (new_index > *max_index)
705*3d8817e4Smiod *max_index = new_index;
706*3d8817e4Smiod
707*3d8817e4Smiod last_type = this_type;
708*3d8817e4Smiod new_symbol->symbol.section = bfd_abs_section_ptr;
709*3d8817e4Smiod return new_symbol;
710*3d8817e4Smiod }
711*3d8817e4Smiod return last_symbol;
712*3d8817e4Smiod }
713*3d8817e4Smiod
714*3d8817e4Smiod static bfd_boolean
ieee_slurp_external_symbols(bfd * abfd)715*3d8817e4Smiod ieee_slurp_external_symbols (bfd *abfd)
716*3d8817e4Smiod {
717*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
718*3d8817e4Smiod file_ptr offset = ieee->w.r.external_part;
719*3d8817e4Smiod
720*3d8817e4Smiod ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols;
721*3d8817e4Smiod ieee_symbol_type **prev_reference_ptr = &ieee->external_reference;
722*3d8817e4Smiod ieee_symbol_type *symbol = NULL;
723*3d8817e4Smiod unsigned int symbol_count = 0;
724*3d8817e4Smiod bfd_boolean loop = TRUE;
725*3d8817e4Smiod
726*3d8817e4Smiod last_index = 0xffffff;
727*3d8817e4Smiod ieee->symbol_table_full = TRUE;
728*3d8817e4Smiod
729*3d8817e4Smiod ieee_seek (ieee, offset);
730*3d8817e4Smiod
731*3d8817e4Smiod while (loop)
732*3d8817e4Smiod {
733*3d8817e4Smiod switch (this_byte (&(ieee->h)))
734*3d8817e4Smiod {
735*3d8817e4Smiod case ieee_nn_record:
736*3d8817e4Smiod next_byte (&(ieee->h));
737*3d8817e4Smiod
738*3d8817e4Smiod symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
739*3d8817e4Smiod & prev_symbols_ptr,
740*3d8817e4Smiod & ieee->external_symbol_max_index, 'I');
741*3d8817e4Smiod if (symbol == NULL)
742*3d8817e4Smiod return FALSE;
743*3d8817e4Smiod
744*3d8817e4Smiod symbol->symbol.the_bfd = abfd;
745*3d8817e4Smiod symbol->symbol.name = read_id (&(ieee->h));
746*3d8817e4Smiod symbol->symbol.udata.p = NULL;
747*3d8817e4Smiod symbol->symbol.flags = BSF_NO_FLAGS;
748*3d8817e4Smiod break;
749*3d8817e4Smiod case ieee_external_symbol_enum:
750*3d8817e4Smiod next_byte (&(ieee->h));
751*3d8817e4Smiod
752*3d8817e4Smiod symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
753*3d8817e4Smiod &prev_symbols_ptr,
754*3d8817e4Smiod &ieee->external_symbol_max_index, 'D');
755*3d8817e4Smiod if (symbol == NULL)
756*3d8817e4Smiod return FALSE;
757*3d8817e4Smiod
758*3d8817e4Smiod BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
759*3d8817e4Smiod
760*3d8817e4Smiod symbol->symbol.the_bfd = abfd;
761*3d8817e4Smiod symbol->symbol.name = read_id (&(ieee->h));
762*3d8817e4Smiod symbol->symbol.udata.p = NULL;
763*3d8817e4Smiod symbol->symbol.flags = BSF_NO_FLAGS;
764*3d8817e4Smiod break;
765*3d8817e4Smiod case ieee_attribute_record_enum >> 8:
766*3d8817e4Smiod {
767*3d8817e4Smiod unsigned int symbol_name_index;
768*3d8817e4Smiod unsigned int symbol_type_index;
769*3d8817e4Smiod unsigned int symbol_attribute_def;
770*3d8817e4Smiod bfd_vma value;
771*3d8817e4Smiod
772*3d8817e4Smiod switch (read_2bytes (&ieee->h))
773*3d8817e4Smiod {
774*3d8817e4Smiod case ieee_attribute_record_enum:
775*3d8817e4Smiod symbol_name_index = must_parse_int (&(ieee->h));
776*3d8817e4Smiod symbol_type_index = must_parse_int (&(ieee->h));
777*3d8817e4Smiod symbol_attribute_def = must_parse_int (&(ieee->h));
778*3d8817e4Smiod switch (symbol_attribute_def)
779*3d8817e4Smiod {
780*3d8817e4Smiod case 8:
781*3d8817e4Smiod case 19:
782*3d8817e4Smiod parse_int (&ieee->h, &value);
783*3d8817e4Smiod break;
784*3d8817e4Smiod default:
785*3d8817e4Smiod (*_bfd_error_handler)
786*3d8817e4Smiod (_("%B: unimplemented ATI record %u for symbol %u"),
787*3d8817e4Smiod abfd, symbol_attribute_def, symbol_name_index);
788*3d8817e4Smiod bfd_set_error (bfd_error_bad_value);
789*3d8817e4Smiod return FALSE;
790*3d8817e4Smiod break;
791*3d8817e4Smiod }
792*3d8817e4Smiod break;
793*3d8817e4Smiod case ieee_external_reference_info_record_enum:
794*3d8817e4Smiod /* Skip over ATX record. */
795*3d8817e4Smiod parse_int (&(ieee->h), &value);
796*3d8817e4Smiod parse_int (&(ieee->h), &value);
797*3d8817e4Smiod parse_int (&(ieee->h), &value);
798*3d8817e4Smiod parse_int (&(ieee->h), &value);
799*3d8817e4Smiod break;
800*3d8817e4Smiod case ieee_atn_record_enum:
801*3d8817e4Smiod /* We may get call optimization information here,
802*3d8817e4Smiod which we just ignore. The format is
803*3d8817e4Smiod {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs}. */
804*3d8817e4Smiod parse_int (&ieee->h, &value);
805*3d8817e4Smiod parse_int (&ieee->h, &value);
806*3d8817e4Smiod parse_int (&ieee->h, &value);
807*3d8817e4Smiod if (value != 0x3f)
808*3d8817e4Smiod {
809*3d8817e4Smiod (*_bfd_error_handler)
810*3d8817e4Smiod (_("%B: unexpected ATN type %d in external part"),
811*3d8817e4Smiod abfd, (int) value);
812*3d8817e4Smiod bfd_set_error (bfd_error_bad_value);
813*3d8817e4Smiod return FALSE;
814*3d8817e4Smiod }
815*3d8817e4Smiod parse_int (&ieee->h, &value);
816*3d8817e4Smiod parse_int (&ieee->h, &value);
817*3d8817e4Smiod while (value > 0)
818*3d8817e4Smiod {
819*3d8817e4Smiod bfd_vma val1;
820*3d8817e4Smiod
821*3d8817e4Smiod --value;
822*3d8817e4Smiod
823*3d8817e4Smiod switch (read_2bytes (&ieee->h))
824*3d8817e4Smiod {
825*3d8817e4Smiod case ieee_asn_record_enum:
826*3d8817e4Smiod parse_int (&ieee->h, &val1);
827*3d8817e4Smiod parse_int (&ieee->h, &val1);
828*3d8817e4Smiod break;
829*3d8817e4Smiod
830*3d8817e4Smiod default:
831*3d8817e4Smiod (*_bfd_error_handler)
832*3d8817e4Smiod (_("%B: unexpected type after ATN"), abfd);
833*3d8817e4Smiod bfd_set_error (bfd_error_bad_value);
834*3d8817e4Smiod return FALSE;
835*3d8817e4Smiod }
836*3d8817e4Smiod }
837*3d8817e4Smiod }
838*3d8817e4Smiod }
839*3d8817e4Smiod break;
840*3d8817e4Smiod case ieee_value_record_enum >> 8:
841*3d8817e4Smiod {
842*3d8817e4Smiod unsigned int symbol_name_index;
843*3d8817e4Smiod ieee_symbol_index_type symbol_ignore;
844*3d8817e4Smiod bfd_boolean pcrel_ignore;
845*3d8817e4Smiod unsigned int extra;
846*3d8817e4Smiod
847*3d8817e4Smiod next_byte (&(ieee->h));
848*3d8817e4Smiod next_byte (&(ieee->h));
849*3d8817e4Smiod
850*3d8817e4Smiod symbol_name_index = must_parse_int (&(ieee->h));
851*3d8817e4Smiod parse_expression (ieee,
852*3d8817e4Smiod &symbol->symbol.value,
853*3d8817e4Smiod &symbol_ignore,
854*3d8817e4Smiod &pcrel_ignore,
855*3d8817e4Smiod &extra,
856*3d8817e4Smiod &symbol->symbol.section);
857*3d8817e4Smiod
858*3d8817e4Smiod /* Fully linked IEEE-695 files tend to give every symbol
859*3d8817e4Smiod an absolute value. Try to convert that back into a
860*3d8817e4Smiod section relative value. FIXME: This won't always to
861*3d8817e4Smiod the right thing. */
862*3d8817e4Smiod if (bfd_is_abs_section (symbol->symbol.section)
863*3d8817e4Smiod && (abfd->flags & HAS_RELOC) == 0)
864*3d8817e4Smiod {
865*3d8817e4Smiod bfd_vma val;
866*3d8817e4Smiod asection *s;
867*3d8817e4Smiod
868*3d8817e4Smiod val = symbol->symbol.value;
869*3d8817e4Smiod for (s = abfd->sections; s != NULL; s = s->next)
870*3d8817e4Smiod {
871*3d8817e4Smiod if (val >= s->vma && val < s->vma + s->size)
872*3d8817e4Smiod {
873*3d8817e4Smiod symbol->symbol.section = s;
874*3d8817e4Smiod symbol->symbol.value -= s->vma;
875*3d8817e4Smiod break;
876*3d8817e4Smiod }
877*3d8817e4Smiod }
878*3d8817e4Smiod }
879*3d8817e4Smiod
880*3d8817e4Smiod symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
881*3d8817e4Smiod
882*3d8817e4Smiod }
883*3d8817e4Smiod break;
884*3d8817e4Smiod case ieee_weak_external_reference_enum:
885*3d8817e4Smiod {
886*3d8817e4Smiod bfd_vma size;
887*3d8817e4Smiod bfd_vma value;
888*3d8817e4Smiod
889*3d8817e4Smiod next_byte (&(ieee->h));
890*3d8817e4Smiod /* Throw away the external reference index. */
891*3d8817e4Smiod (void) must_parse_int (&(ieee->h));
892*3d8817e4Smiod /* Fetch the default size if not resolved. */
893*3d8817e4Smiod size = must_parse_int (&(ieee->h));
894*3d8817e4Smiod /* Fetch the default value if available. */
895*3d8817e4Smiod if (! parse_int (&(ieee->h), &value))
896*3d8817e4Smiod value = 0;
897*3d8817e4Smiod /* This turns into a common. */
898*3d8817e4Smiod symbol->symbol.section = bfd_com_section_ptr;
899*3d8817e4Smiod symbol->symbol.value = size;
900*3d8817e4Smiod }
901*3d8817e4Smiod break;
902*3d8817e4Smiod
903*3d8817e4Smiod case ieee_external_reference_enum:
904*3d8817e4Smiod next_byte (&(ieee->h));
905*3d8817e4Smiod
906*3d8817e4Smiod symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
907*3d8817e4Smiod &prev_reference_ptr,
908*3d8817e4Smiod &ieee->external_reference_max_index, 'X');
909*3d8817e4Smiod if (symbol == NULL)
910*3d8817e4Smiod return FALSE;
911*3d8817e4Smiod
912*3d8817e4Smiod symbol->symbol.the_bfd = abfd;
913*3d8817e4Smiod symbol->symbol.name = read_id (&(ieee->h));
914*3d8817e4Smiod symbol->symbol.udata.p = NULL;
915*3d8817e4Smiod symbol->symbol.section = bfd_und_section_ptr;
916*3d8817e4Smiod symbol->symbol.value = (bfd_vma) 0;
917*3d8817e4Smiod symbol->symbol.flags = 0;
918*3d8817e4Smiod
919*3d8817e4Smiod BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
920*3d8817e4Smiod break;
921*3d8817e4Smiod
922*3d8817e4Smiod default:
923*3d8817e4Smiod loop = FALSE;
924*3d8817e4Smiod }
925*3d8817e4Smiod }
926*3d8817e4Smiod
927*3d8817e4Smiod if (ieee->external_symbol_max_index != 0)
928*3d8817e4Smiod {
929*3d8817e4Smiod ieee->external_symbol_count =
930*3d8817e4Smiod ieee->external_symbol_max_index -
931*3d8817e4Smiod ieee->external_symbol_min_index + 1;
932*3d8817e4Smiod }
933*3d8817e4Smiod else
934*3d8817e4Smiod ieee->external_symbol_count = 0;
935*3d8817e4Smiod
936*3d8817e4Smiod if (ieee->external_reference_max_index != 0)
937*3d8817e4Smiod {
938*3d8817e4Smiod ieee->external_reference_count =
939*3d8817e4Smiod ieee->external_reference_max_index -
940*3d8817e4Smiod ieee->external_reference_min_index + 1;
941*3d8817e4Smiod }
942*3d8817e4Smiod else
943*3d8817e4Smiod ieee->external_reference_count = 0;
944*3d8817e4Smiod
945*3d8817e4Smiod abfd->symcount =
946*3d8817e4Smiod ieee->external_reference_count + ieee->external_symbol_count;
947*3d8817e4Smiod
948*3d8817e4Smiod if (symbol_count != abfd->symcount)
949*3d8817e4Smiod /* There are gaps in the table -- */
950*3d8817e4Smiod ieee->symbol_table_full = FALSE;
951*3d8817e4Smiod
952*3d8817e4Smiod *prev_symbols_ptr = NULL;
953*3d8817e4Smiod *prev_reference_ptr = NULL;
954*3d8817e4Smiod
955*3d8817e4Smiod return TRUE;
956*3d8817e4Smiod }
957*3d8817e4Smiod
958*3d8817e4Smiod static bfd_boolean
ieee_slurp_symbol_table(bfd * abfd)959*3d8817e4Smiod ieee_slurp_symbol_table (bfd *abfd)
960*3d8817e4Smiod {
961*3d8817e4Smiod if (! IEEE_DATA (abfd)->read_symbols)
962*3d8817e4Smiod {
963*3d8817e4Smiod if (! ieee_slurp_external_symbols (abfd))
964*3d8817e4Smiod return FALSE;
965*3d8817e4Smiod IEEE_DATA (abfd)->read_symbols = TRUE;
966*3d8817e4Smiod }
967*3d8817e4Smiod return TRUE;
968*3d8817e4Smiod }
969*3d8817e4Smiod
970*3d8817e4Smiod static long
ieee_get_symtab_upper_bound(bfd * abfd)971*3d8817e4Smiod ieee_get_symtab_upper_bound (bfd *abfd)
972*3d8817e4Smiod {
973*3d8817e4Smiod if (! ieee_slurp_symbol_table (abfd))
974*3d8817e4Smiod return -1;
975*3d8817e4Smiod
976*3d8817e4Smiod return (abfd->symcount != 0) ?
977*3d8817e4Smiod (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0;
978*3d8817e4Smiod }
979*3d8817e4Smiod
980*3d8817e4Smiod /* Move from our internal lists to the canon table, and insert in
981*3d8817e4Smiod symbol index order. */
982*3d8817e4Smiod
983*3d8817e4Smiod extern const bfd_target ieee_vec;
984*3d8817e4Smiod
985*3d8817e4Smiod static long
ieee_canonicalize_symtab(bfd * abfd,asymbol ** location)986*3d8817e4Smiod ieee_canonicalize_symtab (bfd *abfd, asymbol **location)
987*3d8817e4Smiod {
988*3d8817e4Smiod ieee_symbol_type *symp;
989*3d8817e4Smiod static bfd dummy_bfd;
990*3d8817e4Smiod static asymbol empty_symbol =
991*3d8817e4Smiod {
992*3d8817e4Smiod &dummy_bfd,
993*3d8817e4Smiod " ieee empty",
994*3d8817e4Smiod (symvalue) 0,
995*3d8817e4Smiod BSF_DEBUGGING,
996*3d8817e4Smiod bfd_abs_section_ptr
997*3d8817e4Smiod #ifdef __STDC__
998*3d8817e4Smiod /* K&R compilers can't initialise unions. */
999*3d8817e4Smiod , { 0 }
1000*3d8817e4Smiod #endif
1001*3d8817e4Smiod };
1002*3d8817e4Smiod
1003*3d8817e4Smiod if (abfd->symcount)
1004*3d8817e4Smiod {
1005*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
1006*3d8817e4Smiod
1007*3d8817e4Smiod dummy_bfd.xvec = &ieee_vec;
1008*3d8817e4Smiod if (! ieee_slurp_symbol_table (abfd))
1009*3d8817e4Smiod return -1;
1010*3d8817e4Smiod
1011*3d8817e4Smiod if (! ieee->symbol_table_full)
1012*3d8817e4Smiod {
1013*3d8817e4Smiod /* Arrgh - there are gaps in the table, run through and fill them
1014*3d8817e4Smiod up with pointers to a null place. */
1015*3d8817e4Smiod unsigned int i;
1016*3d8817e4Smiod
1017*3d8817e4Smiod for (i = 0; i < abfd->symcount; i++)
1018*3d8817e4Smiod location[i] = &empty_symbol;
1019*3d8817e4Smiod }
1020*3d8817e4Smiod
1021*3d8817e4Smiod ieee->external_symbol_base_offset = -ieee->external_symbol_min_index;
1022*3d8817e4Smiod for (symp = IEEE_DATA (abfd)->external_symbols;
1023*3d8817e4Smiod symp != (ieee_symbol_type *) NULL;
1024*3d8817e4Smiod symp = symp->next)
1025*3d8817e4Smiod /* Place into table at correct index locations. */
1026*3d8817e4Smiod location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
1027*3d8817e4Smiod
1028*3d8817e4Smiod /* The external refs are indexed in a bit. */
1029*3d8817e4Smiod ieee->external_reference_base_offset =
1030*3d8817e4Smiod -ieee->external_reference_min_index + ieee->external_symbol_count;
1031*3d8817e4Smiod
1032*3d8817e4Smiod for (symp = IEEE_DATA (abfd)->external_reference;
1033*3d8817e4Smiod symp != (ieee_symbol_type *) NULL;
1034*3d8817e4Smiod symp = symp->next)
1035*3d8817e4Smiod location[symp->index + ieee->external_reference_base_offset] =
1036*3d8817e4Smiod &symp->symbol;
1037*3d8817e4Smiod }
1038*3d8817e4Smiod
1039*3d8817e4Smiod if (abfd->symcount)
1040*3d8817e4Smiod location[abfd->symcount] = (asymbol *) NULL;
1041*3d8817e4Smiod
1042*3d8817e4Smiod return abfd->symcount;
1043*3d8817e4Smiod }
1044*3d8817e4Smiod
1045*3d8817e4Smiod static asection *
get_section_entry(bfd * abfd,ieee_data_type * ieee,unsigned int index)1046*3d8817e4Smiod get_section_entry (bfd *abfd, ieee_data_type *ieee, unsigned int index)
1047*3d8817e4Smiod {
1048*3d8817e4Smiod if (index >= ieee->section_table_size)
1049*3d8817e4Smiod {
1050*3d8817e4Smiod unsigned int c, i;
1051*3d8817e4Smiod asection **n;
1052*3d8817e4Smiod bfd_size_type amt;
1053*3d8817e4Smiod
1054*3d8817e4Smiod c = ieee->section_table_size;
1055*3d8817e4Smiod if (c == 0)
1056*3d8817e4Smiod c = 20;
1057*3d8817e4Smiod while (c <= index)
1058*3d8817e4Smiod c *= 2;
1059*3d8817e4Smiod
1060*3d8817e4Smiod amt = c;
1061*3d8817e4Smiod amt *= sizeof (asection *);
1062*3d8817e4Smiod n = bfd_realloc (ieee->section_table, amt);
1063*3d8817e4Smiod if (n == NULL)
1064*3d8817e4Smiod return NULL;
1065*3d8817e4Smiod
1066*3d8817e4Smiod for (i = ieee->section_table_size; i < c; i++)
1067*3d8817e4Smiod n[i] = NULL;
1068*3d8817e4Smiod
1069*3d8817e4Smiod ieee->section_table = n;
1070*3d8817e4Smiod ieee->section_table_size = c;
1071*3d8817e4Smiod }
1072*3d8817e4Smiod
1073*3d8817e4Smiod if (ieee->section_table[index] == (asection *) NULL)
1074*3d8817e4Smiod {
1075*3d8817e4Smiod char *tmp = bfd_alloc (abfd, (bfd_size_type) 11);
1076*3d8817e4Smiod asection *section;
1077*3d8817e4Smiod
1078*3d8817e4Smiod if (!tmp)
1079*3d8817e4Smiod return NULL;
1080*3d8817e4Smiod sprintf (tmp, " fsec%4d", index);
1081*3d8817e4Smiod section = bfd_make_section (abfd, tmp);
1082*3d8817e4Smiod ieee->section_table[index] = section;
1083*3d8817e4Smiod section->flags = SEC_NO_FLAGS;
1084*3d8817e4Smiod section->target_index = index;
1085*3d8817e4Smiod ieee->section_table[index] = section;
1086*3d8817e4Smiod }
1087*3d8817e4Smiod return ieee->section_table[index];
1088*3d8817e4Smiod }
1089*3d8817e4Smiod
1090*3d8817e4Smiod static void
ieee_slurp_sections(bfd * abfd)1091*3d8817e4Smiod ieee_slurp_sections (bfd *abfd)
1092*3d8817e4Smiod {
1093*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
1094*3d8817e4Smiod file_ptr offset = ieee->w.r.section_part;
1095*3d8817e4Smiod char *name;
1096*3d8817e4Smiod
1097*3d8817e4Smiod if (offset != 0)
1098*3d8817e4Smiod {
1099*3d8817e4Smiod bfd_byte section_type[3];
1100*3d8817e4Smiod
1101*3d8817e4Smiod ieee_seek (ieee, offset);
1102*3d8817e4Smiod while (TRUE)
1103*3d8817e4Smiod {
1104*3d8817e4Smiod switch (this_byte (&(ieee->h)))
1105*3d8817e4Smiod {
1106*3d8817e4Smiod case ieee_section_type_enum:
1107*3d8817e4Smiod {
1108*3d8817e4Smiod asection *section;
1109*3d8817e4Smiod unsigned int section_index;
1110*3d8817e4Smiod
1111*3d8817e4Smiod next_byte (&(ieee->h));
1112*3d8817e4Smiod section_index = must_parse_int (&(ieee->h));
1113*3d8817e4Smiod
1114*3d8817e4Smiod section = get_section_entry (abfd, ieee, section_index);
1115*3d8817e4Smiod
1116*3d8817e4Smiod section_type[0] = this_byte_and_next (&(ieee->h));
1117*3d8817e4Smiod
1118*3d8817e4Smiod /* Set minimal section attributes. Attributes are
1119*3d8817e4Smiod extended later, based on section contents. */
1120*3d8817e4Smiod switch (section_type[0])
1121*3d8817e4Smiod {
1122*3d8817e4Smiod case 0xC1:
1123*3d8817e4Smiod /* Normal attributes for absolute sections. */
1124*3d8817e4Smiod section_type[1] = this_byte (&(ieee->h));
1125*3d8817e4Smiod section->flags = SEC_ALLOC;
1126*3d8817e4Smiod switch (section_type[1])
1127*3d8817e4Smiod {
1128*3d8817e4Smiod /* AS Absolute section attributes. */
1129*3d8817e4Smiod case 0xD3:
1130*3d8817e4Smiod next_byte (&(ieee->h));
1131*3d8817e4Smiod section_type[2] = this_byte (&(ieee->h));
1132*3d8817e4Smiod switch (section_type[2])
1133*3d8817e4Smiod {
1134*3d8817e4Smiod case 0xD0:
1135*3d8817e4Smiod /* Normal code. */
1136*3d8817e4Smiod next_byte (&(ieee->h));
1137*3d8817e4Smiod section->flags |= SEC_CODE;
1138*3d8817e4Smiod break;
1139*3d8817e4Smiod case 0xC4:
1140*3d8817e4Smiod /* Normal data. */
1141*3d8817e4Smiod next_byte (&(ieee->h));
1142*3d8817e4Smiod section->flags |= SEC_DATA;
1143*3d8817e4Smiod break;
1144*3d8817e4Smiod case 0xD2:
1145*3d8817e4Smiod next_byte (&(ieee->h));
1146*3d8817e4Smiod /* Normal rom data. */
1147*3d8817e4Smiod section->flags |= SEC_ROM | SEC_DATA;
1148*3d8817e4Smiod break;
1149*3d8817e4Smiod default:
1150*3d8817e4Smiod break;
1151*3d8817e4Smiod }
1152*3d8817e4Smiod }
1153*3d8817e4Smiod break;
1154*3d8817e4Smiod
1155*3d8817e4Smiod /* Named relocatable sections (type C). */
1156*3d8817e4Smiod case 0xC3:
1157*3d8817e4Smiod section_type[1] = this_byte (&(ieee->h));
1158*3d8817e4Smiod section->flags = SEC_ALLOC;
1159*3d8817e4Smiod switch (section_type[1])
1160*3d8817e4Smiod {
1161*3d8817e4Smiod case 0xD0: /* Normal code (CP). */
1162*3d8817e4Smiod next_byte (&(ieee->h));
1163*3d8817e4Smiod section->flags |= SEC_CODE;
1164*3d8817e4Smiod break;
1165*3d8817e4Smiod case 0xC4: /* Normal data (CD). */
1166*3d8817e4Smiod next_byte (&(ieee->h));
1167*3d8817e4Smiod section->flags |= SEC_DATA;
1168*3d8817e4Smiod break;
1169*3d8817e4Smiod case 0xD2: /* Normal rom data (CR). */
1170*3d8817e4Smiod next_byte (&(ieee->h));
1171*3d8817e4Smiod section->flags |= SEC_ROM | SEC_DATA;
1172*3d8817e4Smiod break;
1173*3d8817e4Smiod default:
1174*3d8817e4Smiod break;
1175*3d8817e4Smiod }
1176*3d8817e4Smiod }
1177*3d8817e4Smiod
1178*3d8817e4Smiod /* Read section name, use it if non empty. */
1179*3d8817e4Smiod name = read_id (&ieee->h);
1180*3d8817e4Smiod if (name[0])
1181*3d8817e4Smiod section->name = name;
1182*3d8817e4Smiod
1183*3d8817e4Smiod /* Skip these fields, which we don't care about. */
1184*3d8817e4Smiod {
1185*3d8817e4Smiod bfd_vma parent, brother, context;
1186*3d8817e4Smiod
1187*3d8817e4Smiod parse_int (&(ieee->h), &parent);
1188*3d8817e4Smiod parse_int (&(ieee->h), &brother);
1189*3d8817e4Smiod parse_int (&(ieee->h), &context);
1190*3d8817e4Smiod }
1191*3d8817e4Smiod }
1192*3d8817e4Smiod break;
1193*3d8817e4Smiod case ieee_section_alignment_enum:
1194*3d8817e4Smiod {
1195*3d8817e4Smiod unsigned int section_index;
1196*3d8817e4Smiod bfd_vma value;
1197*3d8817e4Smiod asection *section;
1198*3d8817e4Smiod
1199*3d8817e4Smiod next_byte (&(ieee->h));
1200*3d8817e4Smiod section_index = must_parse_int (&ieee->h);
1201*3d8817e4Smiod section = get_section_entry (abfd, ieee, section_index);
1202*3d8817e4Smiod if (section_index > ieee->section_count)
1203*3d8817e4Smiod ieee->section_count = section_index;
1204*3d8817e4Smiod
1205*3d8817e4Smiod section->alignment_power =
1206*3d8817e4Smiod bfd_log2 (must_parse_int (&ieee->h));
1207*3d8817e4Smiod (void) parse_int (&(ieee->h), &value);
1208*3d8817e4Smiod }
1209*3d8817e4Smiod break;
1210*3d8817e4Smiod case ieee_e2_first_byte_enum:
1211*3d8817e4Smiod {
1212*3d8817e4Smiod asection *section;
1213*3d8817e4Smiod ieee_record_enum_type t;
1214*3d8817e4Smiod
1215*3d8817e4Smiod t = (ieee_record_enum_type) (read_2bytes (&(ieee->h)));
1216*3d8817e4Smiod switch (t)
1217*3d8817e4Smiod {
1218*3d8817e4Smiod case ieee_section_size_enum:
1219*3d8817e4Smiod section = ieee->section_table[must_parse_int (&(ieee->h))];
1220*3d8817e4Smiod section->size = must_parse_int (&(ieee->h));
1221*3d8817e4Smiod break;
1222*3d8817e4Smiod case ieee_physical_region_size_enum:
1223*3d8817e4Smiod section = ieee->section_table[must_parse_int (&(ieee->h))];
1224*3d8817e4Smiod section->size = must_parse_int (&(ieee->h));
1225*3d8817e4Smiod break;
1226*3d8817e4Smiod case ieee_region_base_address_enum:
1227*3d8817e4Smiod section = ieee->section_table[must_parse_int (&(ieee->h))];
1228*3d8817e4Smiod section->vma = must_parse_int (&(ieee->h));
1229*3d8817e4Smiod section->lma = section->vma;
1230*3d8817e4Smiod break;
1231*3d8817e4Smiod case ieee_mau_size_enum:
1232*3d8817e4Smiod must_parse_int (&(ieee->h));
1233*3d8817e4Smiod must_parse_int (&(ieee->h));
1234*3d8817e4Smiod break;
1235*3d8817e4Smiod case ieee_m_value_enum:
1236*3d8817e4Smiod must_parse_int (&(ieee->h));
1237*3d8817e4Smiod must_parse_int (&(ieee->h));
1238*3d8817e4Smiod break;
1239*3d8817e4Smiod case ieee_section_base_address_enum:
1240*3d8817e4Smiod section = ieee->section_table[must_parse_int (&(ieee->h))];
1241*3d8817e4Smiod section->vma = must_parse_int (&(ieee->h));
1242*3d8817e4Smiod section->lma = section->vma;
1243*3d8817e4Smiod break;
1244*3d8817e4Smiod case ieee_section_offset_enum:
1245*3d8817e4Smiod (void) must_parse_int (&(ieee->h));
1246*3d8817e4Smiod (void) must_parse_int (&(ieee->h));
1247*3d8817e4Smiod break;
1248*3d8817e4Smiod default:
1249*3d8817e4Smiod return;
1250*3d8817e4Smiod }
1251*3d8817e4Smiod }
1252*3d8817e4Smiod break;
1253*3d8817e4Smiod default:
1254*3d8817e4Smiod return;
1255*3d8817e4Smiod }
1256*3d8817e4Smiod }
1257*3d8817e4Smiod }
1258*3d8817e4Smiod }
1259*3d8817e4Smiod
1260*3d8817e4Smiod /* Make a section for the debugging information, if any. We don't try
1261*3d8817e4Smiod to interpret the debugging information; we just point the section
1262*3d8817e4Smiod at the area in the file so that program which understand can dig it
1263*3d8817e4Smiod out. */
1264*3d8817e4Smiod
1265*3d8817e4Smiod static bfd_boolean
ieee_slurp_debug(bfd * abfd)1266*3d8817e4Smiod ieee_slurp_debug (bfd *abfd)
1267*3d8817e4Smiod {
1268*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
1269*3d8817e4Smiod asection *sec;
1270*3d8817e4Smiod file_ptr debug_end;
1271*3d8817e4Smiod
1272*3d8817e4Smiod if (ieee->w.r.debug_information_part == 0)
1273*3d8817e4Smiod return TRUE;
1274*3d8817e4Smiod
1275*3d8817e4Smiod sec = bfd_make_section (abfd, ".debug");
1276*3d8817e4Smiod if (sec == NULL)
1277*3d8817e4Smiod return FALSE;
1278*3d8817e4Smiod sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS;
1279*3d8817e4Smiod sec->filepos = ieee->w.r.debug_information_part;
1280*3d8817e4Smiod
1281*3d8817e4Smiod debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part);
1282*3d8817e4Smiod sec->size = debug_end - ieee->w.r.debug_information_part;
1283*3d8817e4Smiod
1284*3d8817e4Smiod return TRUE;
1285*3d8817e4Smiod }
1286*3d8817e4Smiod
1287*3d8817e4Smiod /* Archive stuff. */
1288*3d8817e4Smiod
1289*3d8817e4Smiod static const bfd_target *
ieee_archive_p(bfd * abfd)1290*3d8817e4Smiod ieee_archive_p (bfd *abfd)
1291*3d8817e4Smiod {
1292*3d8817e4Smiod char *library;
1293*3d8817e4Smiod unsigned int i;
1294*3d8817e4Smiod unsigned char buffer[512];
1295*3d8817e4Smiod file_ptr buffer_offset = 0;
1296*3d8817e4Smiod ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
1297*3d8817e4Smiod ieee_ar_data_type *ieee;
1298*3d8817e4Smiod bfd_size_type alc_elts;
1299*3d8817e4Smiod ieee_ar_obstack_type *elts = NULL;
1300*3d8817e4Smiod bfd_size_type amt = sizeof (ieee_ar_data_type);
1301*3d8817e4Smiod
1302*3d8817e4Smiod abfd->tdata.ieee_ar_data = bfd_alloc (abfd, amt);
1303*3d8817e4Smiod if (!abfd->tdata.ieee_ar_data)
1304*3d8817e4Smiod goto error_ret_restore;
1305*3d8817e4Smiod ieee = IEEE_AR_DATA (abfd);
1306*3d8817e4Smiod
1307*3d8817e4Smiod /* Ignore the return value here. It doesn't matter if we don't read
1308*3d8817e4Smiod the entire buffer. We might have a very small ieee file. */
1309*3d8817e4Smiod bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd);
1310*3d8817e4Smiod
1311*3d8817e4Smiod ieee->h.first_byte = buffer;
1312*3d8817e4Smiod ieee->h.input_p = buffer;
1313*3d8817e4Smiod
1314*3d8817e4Smiod ieee->h.abfd = abfd;
1315*3d8817e4Smiod
1316*3d8817e4Smiod if (this_byte (&(ieee->h)) != Module_Beginning)
1317*3d8817e4Smiod goto got_wrong_format_error;
1318*3d8817e4Smiod
1319*3d8817e4Smiod next_byte (&(ieee->h));
1320*3d8817e4Smiod library = read_id (&(ieee->h));
1321*3d8817e4Smiod if (strcmp (library, "LIBRARY") != 0)
1322*3d8817e4Smiod goto got_wrong_format_error;
1323*3d8817e4Smiod
1324*3d8817e4Smiod /* Throw away the filename. */
1325*3d8817e4Smiod read_id (&(ieee->h));
1326*3d8817e4Smiod
1327*3d8817e4Smiod ieee->element_count = 0;
1328*3d8817e4Smiod ieee->element_index = 0;
1329*3d8817e4Smiod
1330*3d8817e4Smiod next_byte (&(ieee->h)); /* Drop the ad part. */
1331*3d8817e4Smiod must_parse_int (&(ieee->h)); /* And the two dummy numbers. */
1332*3d8817e4Smiod must_parse_int (&(ieee->h));
1333*3d8817e4Smiod
1334*3d8817e4Smiod alc_elts = 10;
1335*3d8817e4Smiod elts = bfd_malloc (alc_elts * sizeof *elts);
1336*3d8817e4Smiod if (elts == NULL)
1337*3d8817e4Smiod goto error_return;
1338*3d8817e4Smiod
1339*3d8817e4Smiod /* Read the index of the BB table. */
1340*3d8817e4Smiod while (1)
1341*3d8817e4Smiod {
1342*3d8817e4Smiod int rec;
1343*3d8817e4Smiod ieee_ar_obstack_type *t;
1344*3d8817e4Smiod
1345*3d8817e4Smiod rec = read_2bytes (&(ieee->h));
1346*3d8817e4Smiod if (rec != (int) ieee_assign_value_to_variable_enum)
1347*3d8817e4Smiod break;
1348*3d8817e4Smiod
1349*3d8817e4Smiod if (ieee->element_count >= alc_elts)
1350*3d8817e4Smiod {
1351*3d8817e4Smiod ieee_ar_obstack_type *n;
1352*3d8817e4Smiod
1353*3d8817e4Smiod alc_elts *= 2;
1354*3d8817e4Smiod n = bfd_realloc (elts, alc_elts * sizeof (* elts));
1355*3d8817e4Smiod if (n == NULL)
1356*3d8817e4Smiod goto error_return;
1357*3d8817e4Smiod elts = n;
1358*3d8817e4Smiod }
1359*3d8817e4Smiod
1360*3d8817e4Smiod t = &elts[ieee->element_count];
1361*3d8817e4Smiod ieee->element_count++;
1362*3d8817e4Smiod
1363*3d8817e4Smiod must_parse_int (&(ieee->h));
1364*3d8817e4Smiod t->file_offset = must_parse_int (&(ieee->h));
1365*3d8817e4Smiod t->abfd = (bfd *) NULL;
1366*3d8817e4Smiod
1367*3d8817e4Smiod /* Make sure that we don't go over the end of the buffer. */
1368*3d8817e4Smiod if ((size_t) ieee_pos (IEEE_DATA (abfd)) > sizeof (buffer) / 2)
1369*3d8817e4Smiod {
1370*3d8817e4Smiod /* Past half way, reseek and reprime. */
1371*3d8817e4Smiod buffer_offset += ieee_pos (IEEE_DATA (abfd));
1372*3d8817e4Smiod if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
1373*3d8817e4Smiod goto error_return;
1374*3d8817e4Smiod
1375*3d8817e4Smiod /* Again ignore return value of bfd_bread. */
1376*3d8817e4Smiod bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd);
1377*3d8817e4Smiod ieee->h.first_byte = buffer;
1378*3d8817e4Smiod ieee->h.input_p = buffer;
1379*3d8817e4Smiod }
1380*3d8817e4Smiod }
1381*3d8817e4Smiod
1382*3d8817e4Smiod amt = ieee->element_count;
1383*3d8817e4Smiod amt *= sizeof *ieee->elements;
1384*3d8817e4Smiod ieee->elements = bfd_alloc (abfd, amt);
1385*3d8817e4Smiod if (ieee->elements == NULL)
1386*3d8817e4Smiod goto error_return;
1387*3d8817e4Smiod
1388*3d8817e4Smiod memcpy (ieee->elements, elts, (size_t) amt);
1389*3d8817e4Smiod free (elts);
1390*3d8817e4Smiod elts = NULL;
1391*3d8817e4Smiod
1392*3d8817e4Smiod /* Now scan the area again, and replace BB offsets with file offsets. */
1393*3d8817e4Smiod for (i = 2; i < ieee->element_count; i++)
1394*3d8817e4Smiod {
1395*3d8817e4Smiod if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
1396*3d8817e4Smiod goto error_return;
1397*3d8817e4Smiod
1398*3d8817e4Smiod /* Again ignore return value of bfd_bread. */
1399*3d8817e4Smiod bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd);
1400*3d8817e4Smiod ieee->h.first_byte = buffer;
1401*3d8817e4Smiod ieee->h.input_p = buffer;
1402*3d8817e4Smiod
1403*3d8817e4Smiod next_byte (&(ieee->h)); /* Drop F8. */
1404*3d8817e4Smiod next_byte (&(ieee->h)); /* Drop 14. */
1405*3d8817e4Smiod must_parse_int (&(ieee->h)); /* Drop size of block. */
1406*3d8817e4Smiod
1407*3d8817e4Smiod if (must_parse_int (&(ieee->h)) != 0)
1408*3d8817e4Smiod /* This object has been deleted. */
1409*3d8817e4Smiod ieee->elements[i].file_offset = 0;
1410*3d8817e4Smiod else
1411*3d8817e4Smiod ieee->elements[i].file_offset = must_parse_int (&(ieee->h));
1412*3d8817e4Smiod }
1413*3d8817e4Smiod
1414*3d8817e4Smiod /* abfd->has_armap = ;*/
1415*3d8817e4Smiod
1416*3d8817e4Smiod return abfd->xvec;
1417*3d8817e4Smiod
1418*3d8817e4Smiod got_wrong_format_error:
1419*3d8817e4Smiod bfd_set_error (bfd_error_wrong_format);
1420*3d8817e4Smiod error_return:
1421*3d8817e4Smiod if (elts != NULL)
1422*3d8817e4Smiod free (elts);
1423*3d8817e4Smiod bfd_release (abfd, ieee);
1424*3d8817e4Smiod error_ret_restore:
1425*3d8817e4Smiod abfd->tdata.ieee_ar_data = save;
1426*3d8817e4Smiod
1427*3d8817e4Smiod return NULL;
1428*3d8817e4Smiod }
1429*3d8817e4Smiod
1430*3d8817e4Smiod static bfd_boolean
ieee_mkobject(bfd * abfd)1431*3d8817e4Smiod ieee_mkobject (bfd *abfd)
1432*3d8817e4Smiod {
1433*3d8817e4Smiod bfd_size_type amt;
1434*3d8817e4Smiod
1435*3d8817e4Smiod output_ptr_start = NULL;
1436*3d8817e4Smiod output_ptr = NULL;
1437*3d8817e4Smiod output_ptr_end = NULL;
1438*3d8817e4Smiod input_ptr_start = NULL;
1439*3d8817e4Smiod input_ptr = NULL;
1440*3d8817e4Smiod input_ptr_end = NULL;
1441*3d8817e4Smiod input_bfd = NULL;
1442*3d8817e4Smiod output_bfd = NULL;
1443*3d8817e4Smiod output_buffer = 0;
1444*3d8817e4Smiod amt = sizeof (ieee_data_type);
1445*3d8817e4Smiod abfd->tdata.ieee_data = bfd_zalloc (abfd, amt);
1446*3d8817e4Smiod return abfd->tdata.ieee_data != NULL;
1447*3d8817e4Smiod }
1448*3d8817e4Smiod
1449*3d8817e4Smiod static bfd_boolean
do_one(ieee_data_type * ieee,ieee_per_section_type * current_map,unsigned char * location_ptr,asection * s,int iterations)1450*3d8817e4Smiod do_one (ieee_data_type *ieee,
1451*3d8817e4Smiod ieee_per_section_type *current_map,
1452*3d8817e4Smiod unsigned char *location_ptr,
1453*3d8817e4Smiod asection *s,
1454*3d8817e4Smiod int iterations)
1455*3d8817e4Smiod {
1456*3d8817e4Smiod switch (this_byte (&(ieee->h)))
1457*3d8817e4Smiod {
1458*3d8817e4Smiod case ieee_load_constant_bytes_enum:
1459*3d8817e4Smiod {
1460*3d8817e4Smiod unsigned int number_of_maus;
1461*3d8817e4Smiod unsigned int i;
1462*3d8817e4Smiod
1463*3d8817e4Smiod next_byte (&(ieee->h));
1464*3d8817e4Smiod number_of_maus = must_parse_int (&(ieee->h));
1465*3d8817e4Smiod
1466*3d8817e4Smiod for (i = 0; i < number_of_maus; i++)
1467*3d8817e4Smiod {
1468*3d8817e4Smiod location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1469*3d8817e4Smiod next_byte (&(ieee->h));
1470*3d8817e4Smiod }
1471*3d8817e4Smiod }
1472*3d8817e4Smiod break;
1473*3d8817e4Smiod
1474*3d8817e4Smiod case ieee_load_with_relocation_enum:
1475*3d8817e4Smiod {
1476*3d8817e4Smiod bfd_boolean loop = TRUE;
1477*3d8817e4Smiod
1478*3d8817e4Smiod next_byte (&(ieee->h));
1479*3d8817e4Smiod while (loop)
1480*3d8817e4Smiod {
1481*3d8817e4Smiod switch (this_byte (&(ieee->h)))
1482*3d8817e4Smiod {
1483*3d8817e4Smiod case ieee_variable_R_enum:
1484*3d8817e4Smiod
1485*3d8817e4Smiod case ieee_function_signed_open_b_enum:
1486*3d8817e4Smiod case ieee_function_unsigned_open_b_enum:
1487*3d8817e4Smiod case ieee_function_either_open_b_enum:
1488*3d8817e4Smiod {
1489*3d8817e4Smiod unsigned int extra = 4;
1490*3d8817e4Smiod bfd_boolean pcrel = FALSE;
1491*3d8817e4Smiod asection *section;
1492*3d8817e4Smiod ieee_reloc_type *r;
1493*3d8817e4Smiod
1494*3d8817e4Smiod r = bfd_alloc (ieee->h.abfd, sizeof (* r));
1495*3d8817e4Smiod if (!r)
1496*3d8817e4Smiod return FALSE;
1497*3d8817e4Smiod
1498*3d8817e4Smiod *(current_map->reloc_tail_ptr) = r;
1499*3d8817e4Smiod current_map->reloc_tail_ptr = &r->next;
1500*3d8817e4Smiod r->next = (ieee_reloc_type *) NULL;
1501*3d8817e4Smiod next_byte (&(ieee->h));
1502*3d8817e4Smiod /* abort();*/
1503*3d8817e4Smiod r->relent.sym_ptr_ptr = 0;
1504*3d8817e4Smiod parse_expression (ieee,
1505*3d8817e4Smiod &r->relent.addend,
1506*3d8817e4Smiod &r->symbol,
1507*3d8817e4Smiod &pcrel, &extra, §ion);
1508*3d8817e4Smiod r->relent.address = current_map->pc;
1509*3d8817e4Smiod s->flags |= SEC_RELOC;
1510*3d8817e4Smiod s->owner->flags |= HAS_RELOC;
1511*3d8817e4Smiod s->reloc_count++;
1512*3d8817e4Smiod if (r->relent.sym_ptr_ptr == NULL && section != NULL)
1513*3d8817e4Smiod r->relent.sym_ptr_ptr = section->symbol_ptr_ptr;
1514*3d8817e4Smiod
1515*3d8817e4Smiod if (this_byte (&(ieee->h)) == (int) ieee_comma)
1516*3d8817e4Smiod {
1517*3d8817e4Smiod next_byte (&(ieee->h));
1518*3d8817e4Smiod /* Fetch number of bytes to pad. */
1519*3d8817e4Smiod extra = must_parse_int (&(ieee->h));
1520*3d8817e4Smiod };
1521*3d8817e4Smiod
1522*3d8817e4Smiod switch (this_byte (&(ieee->h)))
1523*3d8817e4Smiod {
1524*3d8817e4Smiod case ieee_function_signed_close_b_enum:
1525*3d8817e4Smiod next_byte (&(ieee->h));
1526*3d8817e4Smiod break;
1527*3d8817e4Smiod case ieee_function_unsigned_close_b_enum:
1528*3d8817e4Smiod next_byte (&(ieee->h));
1529*3d8817e4Smiod break;
1530*3d8817e4Smiod case ieee_function_either_close_b_enum:
1531*3d8817e4Smiod next_byte (&(ieee->h));
1532*3d8817e4Smiod break;
1533*3d8817e4Smiod default:
1534*3d8817e4Smiod break;
1535*3d8817e4Smiod }
1536*3d8817e4Smiod /* Build a relocation entry for this type. */
1537*3d8817e4Smiod /* If pc rel then stick -ve pc into instruction
1538*3d8817e4Smiod and take out of reloc ..
1539*3d8817e4Smiod
1540*3d8817e4Smiod I've changed this. It's all too complicated. I
1541*3d8817e4Smiod keep 0 in the instruction now. */
1542*3d8817e4Smiod
1543*3d8817e4Smiod switch (extra)
1544*3d8817e4Smiod {
1545*3d8817e4Smiod case 0:
1546*3d8817e4Smiod case 4:
1547*3d8817e4Smiod
1548*3d8817e4Smiod if (pcrel)
1549*3d8817e4Smiod {
1550*3d8817e4Smiod #if KEEPMINUSPCININST
1551*3d8817e4Smiod bfd_put_32 (ieee->h.abfd, -current_map->pc,
1552*3d8817e4Smiod location_ptr + current_map->pc);
1553*3d8817e4Smiod r->relent.howto = &rel32_howto;
1554*3d8817e4Smiod r->relent.addend -= current_map->pc;
1555*3d8817e4Smiod #else
1556*3d8817e4Smiod bfd_put_32 (ieee->h.abfd, (bfd_vma) 0, location_ptr +
1557*3d8817e4Smiod current_map->pc);
1558*3d8817e4Smiod r->relent.howto = &rel32_howto;
1559*3d8817e4Smiod #endif
1560*3d8817e4Smiod }
1561*3d8817e4Smiod else
1562*3d8817e4Smiod {
1563*3d8817e4Smiod bfd_put_32 (ieee->h.abfd, (bfd_vma) 0,
1564*3d8817e4Smiod location_ptr + current_map->pc);
1565*3d8817e4Smiod r->relent.howto = &abs32_howto;
1566*3d8817e4Smiod }
1567*3d8817e4Smiod current_map->pc += 4;
1568*3d8817e4Smiod break;
1569*3d8817e4Smiod case 2:
1570*3d8817e4Smiod if (pcrel)
1571*3d8817e4Smiod {
1572*3d8817e4Smiod #if KEEPMINUSPCININST
1573*3d8817e4Smiod bfd_put_16 (ieee->h.abfd, (bfd_vma) -current_map->pc,
1574*3d8817e4Smiod location_ptr + current_map->pc);
1575*3d8817e4Smiod r->relent.addend -= current_map->pc;
1576*3d8817e4Smiod r->relent.howto = &rel16_howto;
1577*3d8817e4Smiod #else
1578*3d8817e4Smiod
1579*3d8817e4Smiod bfd_put_16 (ieee->h.abfd, (bfd_vma) 0,
1580*3d8817e4Smiod location_ptr + current_map->pc);
1581*3d8817e4Smiod r->relent.howto = &rel16_howto;
1582*3d8817e4Smiod #endif
1583*3d8817e4Smiod }
1584*3d8817e4Smiod
1585*3d8817e4Smiod else
1586*3d8817e4Smiod {
1587*3d8817e4Smiod bfd_put_16 (ieee->h.abfd, (bfd_vma) 0,
1588*3d8817e4Smiod location_ptr + current_map->pc);
1589*3d8817e4Smiod r->relent.howto = &abs16_howto;
1590*3d8817e4Smiod }
1591*3d8817e4Smiod current_map->pc += 2;
1592*3d8817e4Smiod break;
1593*3d8817e4Smiod case 1:
1594*3d8817e4Smiod if (pcrel)
1595*3d8817e4Smiod {
1596*3d8817e4Smiod #if KEEPMINUSPCININST
1597*3d8817e4Smiod bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
1598*3d8817e4Smiod r->relent.addend -= current_map->pc;
1599*3d8817e4Smiod r->relent.howto = &rel8_howto;
1600*3d8817e4Smiod #else
1601*3d8817e4Smiod bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1602*3d8817e4Smiod r->relent.howto = &rel8_howto;
1603*3d8817e4Smiod #endif
1604*3d8817e4Smiod }
1605*3d8817e4Smiod else
1606*3d8817e4Smiod {
1607*3d8817e4Smiod bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1608*3d8817e4Smiod r->relent.howto = &abs8_howto;
1609*3d8817e4Smiod }
1610*3d8817e4Smiod current_map->pc += 1;
1611*3d8817e4Smiod break;
1612*3d8817e4Smiod
1613*3d8817e4Smiod default:
1614*3d8817e4Smiod BFD_FAIL ();
1615*3d8817e4Smiod return FALSE;
1616*3d8817e4Smiod }
1617*3d8817e4Smiod }
1618*3d8817e4Smiod break;
1619*3d8817e4Smiod default:
1620*3d8817e4Smiod {
1621*3d8817e4Smiod bfd_vma this_size;
1622*3d8817e4Smiod
1623*3d8817e4Smiod if (parse_int (&(ieee->h), &this_size))
1624*3d8817e4Smiod {
1625*3d8817e4Smiod unsigned int i;
1626*3d8817e4Smiod
1627*3d8817e4Smiod for (i = 0; i < this_size; i++)
1628*3d8817e4Smiod {
1629*3d8817e4Smiod location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1630*3d8817e4Smiod next_byte (&(ieee->h));
1631*3d8817e4Smiod }
1632*3d8817e4Smiod }
1633*3d8817e4Smiod else
1634*3d8817e4Smiod loop = FALSE;
1635*3d8817e4Smiod }
1636*3d8817e4Smiod }
1637*3d8817e4Smiod
1638*3d8817e4Smiod /* Prevent more than the first load-item of an LR record
1639*3d8817e4Smiod from being repeated (MRI convention). */
1640*3d8817e4Smiod if (iterations != 1)
1641*3d8817e4Smiod loop = FALSE;
1642*3d8817e4Smiod }
1643*3d8817e4Smiod }
1644*3d8817e4Smiod }
1645*3d8817e4Smiod return TRUE;
1646*3d8817e4Smiod }
1647*3d8817e4Smiod
1648*3d8817e4Smiod /* Read in all the section data and relocation stuff too. */
1649*3d8817e4Smiod
1650*3d8817e4Smiod static bfd_boolean
ieee_slurp_section_data(bfd * abfd)1651*3d8817e4Smiod ieee_slurp_section_data (bfd *abfd)
1652*3d8817e4Smiod {
1653*3d8817e4Smiod bfd_byte *location_ptr = (bfd_byte *) NULL;
1654*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
1655*3d8817e4Smiod unsigned int section_number;
1656*3d8817e4Smiod ieee_per_section_type *current_map = NULL;
1657*3d8817e4Smiod asection *s;
1658*3d8817e4Smiod
1659*3d8817e4Smiod /* Seek to the start of the data area. */
1660*3d8817e4Smiod if (ieee->read_data)
1661*3d8817e4Smiod return TRUE;
1662*3d8817e4Smiod ieee->read_data = TRUE;
1663*3d8817e4Smiod ieee_seek (ieee, ieee->w.r.data_part);
1664*3d8817e4Smiod
1665*3d8817e4Smiod /* Allocate enough space for all the section contents. */
1666*3d8817e4Smiod for (s = abfd->sections; s != (asection *) NULL; s = s->next)
1667*3d8817e4Smiod {
1668*3d8817e4Smiod ieee_per_section_type *per = ieee_per_section (s);
1669*3d8817e4Smiod arelent **relpp;
1670*3d8817e4Smiod
1671*3d8817e4Smiod if ((s->flags & SEC_DEBUGGING) != 0)
1672*3d8817e4Smiod continue;
1673*3d8817e4Smiod per->data = bfd_alloc (ieee->h.abfd, s->size);
1674*3d8817e4Smiod if (!per->data)
1675*3d8817e4Smiod return FALSE;
1676*3d8817e4Smiod relpp = &s->relocation;
1677*3d8817e4Smiod per->reloc_tail_ptr = (ieee_reloc_type **) relpp;
1678*3d8817e4Smiod }
1679*3d8817e4Smiod
1680*3d8817e4Smiod while (TRUE)
1681*3d8817e4Smiod {
1682*3d8817e4Smiod switch (this_byte (&(ieee->h)))
1683*3d8817e4Smiod {
1684*3d8817e4Smiod /* IF we see anything strange then quit. */
1685*3d8817e4Smiod default:
1686*3d8817e4Smiod return TRUE;
1687*3d8817e4Smiod
1688*3d8817e4Smiod case ieee_set_current_section_enum:
1689*3d8817e4Smiod next_byte (&(ieee->h));
1690*3d8817e4Smiod section_number = must_parse_int (&(ieee->h));
1691*3d8817e4Smiod s = ieee->section_table[section_number];
1692*3d8817e4Smiod s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
1693*3d8817e4Smiod current_map = ieee_per_section (s);
1694*3d8817e4Smiod location_ptr = current_map->data - s->vma;
1695*3d8817e4Smiod /* The document I have says that Microtec's compilers reset
1696*3d8817e4Smiod this after a sec section, even though the standard says not
1697*3d8817e4Smiod to, SO... */
1698*3d8817e4Smiod current_map->pc = s->vma;
1699*3d8817e4Smiod break;
1700*3d8817e4Smiod
1701*3d8817e4Smiod case ieee_e2_first_byte_enum:
1702*3d8817e4Smiod next_byte (&(ieee->h));
1703*3d8817e4Smiod switch (this_byte (&(ieee->h)))
1704*3d8817e4Smiod {
1705*3d8817e4Smiod case ieee_set_current_pc_enum & 0xff:
1706*3d8817e4Smiod {
1707*3d8817e4Smiod bfd_vma value;
1708*3d8817e4Smiod ieee_symbol_index_type symbol;
1709*3d8817e4Smiod unsigned int extra;
1710*3d8817e4Smiod bfd_boolean pcrel;
1711*3d8817e4Smiod
1712*3d8817e4Smiod next_byte (&(ieee->h));
1713*3d8817e4Smiod must_parse_int (&(ieee->h)); /* Throw away section #. */
1714*3d8817e4Smiod parse_expression (ieee, &value,
1715*3d8817e4Smiod &symbol,
1716*3d8817e4Smiod &pcrel, &extra,
1717*3d8817e4Smiod 0);
1718*3d8817e4Smiod current_map->pc = value;
1719*3d8817e4Smiod BFD_ASSERT ((unsigned) (value - s->vma) <= s->size);
1720*3d8817e4Smiod }
1721*3d8817e4Smiod break;
1722*3d8817e4Smiod
1723*3d8817e4Smiod case ieee_value_starting_address_enum & 0xff:
1724*3d8817e4Smiod next_byte (&(ieee->h));
1725*3d8817e4Smiod if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum)
1726*3d8817e4Smiod next_byte (&(ieee->h));
1727*3d8817e4Smiod abfd->start_address = must_parse_int (&(ieee->h));
1728*3d8817e4Smiod /* We've got to the end of the data now - */
1729*3d8817e4Smiod return TRUE;
1730*3d8817e4Smiod default:
1731*3d8817e4Smiod BFD_FAIL ();
1732*3d8817e4Smiod return FALSE;
1733*3d8817e4Smiod }
1734*3d8817e4Smiod break;
1735*3d8817e4Smiod case ieee_repeat_data_enum:
1736*3d8817e4Smiod {
1737*3d8817e4Smiod /* Repeat the following LD or LR n times - we do this by
1738*3d8817e4Smiod remembering the stream pointer before running it and
1739*3d8817e4Smiod resetting it and running it n times. We special case
1740*3d8817e4Smiod the repetition of a repeat_data/load_constant. */
1741*3d8817e4Smiod unsigned int iterations;
1742*3d8817e4Smiod unsigned char *start;
1743*3d8817e4Smiod
1744*3d8817e4Smiod next_byte (&(ieee->h));
1745*3d8817e4Smiod iterations = must_parse_int (&(ieee->h));
1746*3d8817e4Smiod start = ieee->h.input_p;
1747*3d8817e4Smiod if (start[0] == (int) ieee_load_constant_bytes_enum
1748*3d8817e4Smiod && start[1] == 1)
1749*3d8817e4Smiod {
1750*3d8817e4Smiod while (iterations != 0)
1751*3d8817e4Smiod {
1752*3d8817e4Smiod location_ptr[current_map->pc++] = start[2];
1753*3d8817e4Smiod iterations--;
1754*3d8817e4Smiod }
1755*3d8817e4Smiod next_byte (&(ieee->h));
1756*3d8817e4Smiod next_byte (&(ieee->h));
1757*3d8817e4Smiod next_byte (&(ieee->h));
1758*3d8817e4Smiod }
1759*3d8817e4Smiod else
1760*3d8817e4Smiod {
1761*3d8817e4Smiod while (iterations != 0)
1762*3d8817e4Smiod {
1763*3d8817e4Smiod ieee->h.input_p = start;
1764*3d8817e4Smiod if (!do_one (ieee, current_map, location_ptr, s,
1765*3d8817e4Smiod (int) iterations))
1766*3d8817e4Smiod return FALSE;
1767*3d8817e4Smiod iterations--;
1768*3d8817e4Smiod }
1769*3d8817e4Smiod }
1770*3d8817e4Smiod }
1771*3d8817e4Smiod break;
1772*3d8817e4Smiod case ieee_load_constant_bytes_enum:
1773*3d8817e4Smiod case ieee_load_with_relocation_enum:
1774*3d8817e4Smiod if (!do_one (ieee, current_map, location_ptr, s, 1))
1775*3d8817e4Smiod return FALSE;
1776*3d8817e4Smiod }
1777*3d8817e4Smiod }
1778*3d8817e4Smiod }
1779*3d8817e4Smiod
1780*3d8817e4Smiod static const bfd_target *
ieee_object_p(bfd * abfd)1781*3d8817e4Smiod ieee_object_p (bfd *abfd)
1782*3d8817e4Smiod {
1783*3d8817e4Smiod char *processor;
1784*3d8817e4Smiod unsigned int part;
1785*3d8817e4Smiod ieee_data_type *ieee;
1786*3d8817e4Smiod unsigned char buffer[300];
1787*3d8817e4Smiod ieee_data_type *save = IEEE_DATA (abfd);
1788*3d8817e4Smiod bfd_size_type amt;
1789*3d8817e4Smiod
1790*3d8817e4Smiod abfd->tdata.ieee_data = 0;
1791*3d8817e4Smiod ieee_mkobject (abfd);
1792*3d8817e4Smiod
1793*3d8817e4Smiod ieee = IEEE_DATA (abfd);
1794*3d8817e4Smiod if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
1795*3d8817e4Smiod goto fail;
1796*3d8817e4Smiod /* Read the first few bytes in to see if it makes sense. Ignore
1797*3d8817e4Smiod bfd_bread return value; The file might be very small. */
1798*3d8817e4Smiod bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd);
1799*3d8817e4Smiod
1800*3d8817e4Smiod ieee->h.input_p = buffer;
1801*3d8817e4Smiod if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
1802*3d8817e4Smiod goto got_wrong_format;
1803*3d8817e4Smiod
1804*3d8817e4Smiod ieee->read_symbols = FALSE;
1805*3d8817e4Smiod ieee->read_data = FALSE;
1806*3d8817e4Smiod ieee->section_count = 0;
1807*3d8817e4Smiod ieee->external_symbol_max_index = 0;
1808*3d8817e4Smiod ieee->external_symbol_min_index = IEEE_PUBLIC_BASE;
1809*3d8817e4Smiod ieee->external_reference_min_index = IEEE_REFERENCE_BASE;
1810*3d8817e4Smiod ieee->external_reference_max_index = 0;
1811*3d8817e4Smiod ieee->h.abfd = abfd;
1812*3d8817e4Smiod ieee->section_table = NULL;
1813*3d8817e4Smiod ieee->section_table_size = 0;
1814*3d8817e4Smiod
1815*3d8817e4Smiod processor = ieee->mb.processor = read_id (&(ieee->h));
1816*3d8817e4Smiod if (strcmp (processor, "LIBRARY") == 0)
1817*3d8817e4Smiod goto got_wrong_format;
1818*3d8817e4Smiod ieee->mb.module_name = read_id (&(ieee->h));
1819*3d8817e4Smiod if (abfd->filename == (const char *) NULL)
1820*3d8817e4Smiod abfd->filename = ieee->mb.module_name;
1821*3d8817e4Smiod
1822*3d8817e4Smiod /* Determine the architecture and machine type of the object file. */
1823*3d8817e4Smiod {
1824*3d8817e4Smiod const bfd_arch_info_type *arch;
1825*3d8817e4Smiod char family[10];
1826*3d8817e4Smiod
1827*3d8817e4Smiod /* IEEE does not specify the format of the processor identification
1828*3d8817e4Smiod string, so the compiler is free to put in it whatever it wants.
1829*3d8817e4Smiod We try here to recognize different processors belonging to the
1830*3d8817e4Smiod m68k family. Code for other processors can be added here. */
1831*3d8817e4Smiod if ((processor[0] == '6') && (processor[1] == '8'))
1832*3d8817e4Smiod {
1833*3d8817e4Smiod if (processor[2] == '3') /* 683xx integrated processors. */
1834*3d8817e4Smiod {
1835*3d8817e4Smiod switch (processor[3])
1836*3d8817e4Smiod {
1837*3d8817e4Smiod case '0': /* 68302, 68306, 68307 */
1838*3d8817e4Smiod case '2': /* 68322, 68328 */
1839*3d8817e4Smiod case '5': /* 68356 */
1840*3d8817e4Smiod strcpy (family, "68000"); /* MC68000-based controllers. */
1841*3d8817e4Smiod break;
1842*3d8817e4Smiod
1843*3d8817e4Smiod case '3': /* 68330, 68331, 68332, 68333,
1844*3d8817e4Smiod 68334, 68335, 68336, 68338 */
1845*3d8817e4Smiod case '6': /* 68360 */
1846*3d8817e4Smiod case '7': /* 68376 */
1847*3d8817e4Smiod strcpy (family, "68332"); /* CPU32 and CPU32+ */
1848*3d8817e4Smiod break;
1849*3d8817e4Smiod
1850*3d8817e4Smiod case '4':
1851*3d8817e4Smiod if (processor[4] == '9') /* 68349 */
1852*3d8817e4Smiod strcpy (family, "68030"); /* CPU030 */
1853*3d8817e4Smiod else /* 68340, 68341 */
1854*3d8817e4Smiod strcpy (family, "68332"); /* CPU32 and CPU32+ */
1855*3d8817e4Smiod break;
1856*3d8817e4Smiod
1857*3d8817e4Smiod default: /* Does not exist yet. */
1858*3d8817e4Smiod strcpy (family, "68332"); /* Guess it will be CPU32 */
1859*3d8817e4Smiod }
1860*3d8817e4Smiod }
1861*3d8817e4Smiod else if (TOUPPER (processor[3]) == 'F') /* 68F333 */
1862*3d8817e4Smiod strcpy (family, "68332"); /* CPU32 */
1863*3d8817e4Smiod else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers. */
1864*3d8817e4Smiod && ((TOUPPER (processor[2]) == 'E')
1865*3d8817e4Smiod || (TOUPPER (processor[2]) == 'H')
1866*3d8817e4Smiod || (TOUPPER (processor[2]) == 'L')))
1867*3d8817e4Smiod {
1868*3d8817e4Smiod strcpy (family, "68");
1869*3d8817e4Smiod strncat (family, processor + 4, 7);
1870*3d8817e4Smiod family[9] = '\0';
1871*3d8817e4Smiod }
1872*3d8817e4Smiod else /* "Regular" processors. */
1873*3d8817e4Smiod {
1874*3d8817e4Smiod strncpy (family, processor, 9);
1875*3d8817e4Smiod family[9] = '\0';
1876*3d8817e4Smiod }
1877*3d8817e4Smiod }
1878*3d8817e4Smiod else if ((strncmp (processor, "cpu32", 5) == 0) /* CPU32 and CPU32+ */
1879*3d8817e4Smiod || (strncmp (processor, "CPU32", 5) == 0))
1880*3d8817e4Smiod strcpy (family, "68332");
1881*3d8817e4Smiod else
1882*3d8817e4Smiod {
1883*3d8817e4Smiod strncpy (family, processor, 9);
1884*3d8817e4Smiod family[9] = '\0';
1885*3d8817e4Smiod }
1886*3d8817e4Smiod
1887*3d8817e4Smiod arch = bfd_scan_arch (family);
1888*3d8817e4Smiod if (arch == 0)
1889*3d8817e4Smiod goto got_wrong_format;
1890*3d8817e4Smiod abfd->arch_info = arch;
1891*3d8817e4Smiod }
1892*3d8817e4Smiod
1893*3d8817e4Smiod if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum)
1894*3d8817e4Smiod goto fail;
1895*3d8817e4Smiod
1896*3d8817e4Smiod next_byte (&(ieee->h));
1897*3d8817e4Smiod
1898*3d8817e4Smiod if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau))
1899*3d8817e4Smiod goto fail;
1900*3d8817e4Smiod
1901*3d8817e4Smiod if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address))
1902*3d8817e4Smiod goto fail;
1903*3d8817e4Smiod
1904*3d8817e4Smiod /* If there is a byte order info, take it. */
1905*3d8817e4Smiod if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum
1906*3d8817e4Smiod || this_byte (&(ieee->h)) == (int) ieee_variable_M_enum)
1907*3d8817e4Smiod next_byte (&(ieee->h));
1908*3d8817e4Smiod
1909*3d8817e4Smiod for (part = 0; part < N_W_VARIABLES; part++)
1910*3d8817e4Smiod {
1911*3d8817e4Smiod bfd_boolean ok;
1912*3d8817e4Smiod
1913*3d8817e4Smiod if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum)
1914*3d8817e4Smiod goto fail;
1915*3d8817e4Smiod
1916*3d8817e4Smiod if (this_byte_and_next (&(ieee->h)) != part)
1917*3d8817e4Smiod goto fail;
1918*3d8817e4Smiod
1919*3d8817e4Smiod ieee->w.offset[part] = parse_i (&(ieee->h), &ok);
1920*3d8817e4Smiod if (! ok)
1921*3d8817e4Smiod goto fail;
1922*3d8817e4Smiod }
1923*3d8817e4Smiod
1924*3d8817e4Smiod if (ieee->w.r.external_part != 0)
1925*3d8817e4Smiod abfd->flags = HAS_SYMS;
1926*3d8817e4Smiod
1927*3d8817e4Smiod /* By now we know that this is a real IEEE file, we're going to read
1928*3d8817e4Smiod the whole thing into memory so that we can run up and down it
1929*3d8817e4Smiod quickly. We can work out how big the file is from the trailer
1930*3d8817e4Smiod record. */
1931*3d8817e4Smiod
1932*3d8817e4Smiod amt = ieee->w.r.me_record + 1;
1933*3d8817e4Smiod IEEE_DATA (abfd)->h.first_byte = bfd_alloc (ieee->h.abfd, amt);
1934*3d8817e4Smiod if (!IEEE_DATA (abfd)->h.first_byte)
1935*3d8817e4Smiod goto fail;
1936*3d8817e4Smiod if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
1937*3d8817e4Smiod goto fail;
1938*3d8817e4Smiod /* FIXME: Check return value. I'm not sure whether it needs to read
1939*3d8817e4Smiod the entire buffer or not. */
1940*3d8817e4Smiod bfd_bread ((void *) (IEEE_DATA (abfd)->h.first_byte),
1941*3d8817e4Smiod (bfd_size_type) ieee->w.r.me_record + 1, abfd);
1942*3d8817e4Smiod
1943*3d8817e4Smiod ieee_slurp_sections (abfd);
1944*3d8817e4Smiod
1945*3d8817e4Smiod if (! ieee_slurp_debug (abfd))
1946*3d8817e4Smiod goto fail;
1947*3d8817e4Smiod
1948*3d8817e4Smiod /* Parse section data to activate file and section flags implied by
1949*3d8817e4Smiod section contents. */
1950*3d8817e4Smiod if (! ieee_slurp_section_data (abfd))
1951*3d8817e4Smiod goto fail;
1952*3d8817e4Smiod
1953*3d8817e4Smiod return abfd->xvec;
1954*3d8817e4Smiod got_wrong_format:
1955*3d8817e4Smiod bfd_set_error (bfd_error_wrong_format);
1956*3d8817e4Smiod fail:
1957*3d8817e4Smiod bfd_release (abfd, ieee);
1958*3d8817e4Smiod abfd->tdata.ieee_data = save;
1959*3d8817e4Smiod return (const bfd_target *) NULL;
1960*3d8817e4Smiod }
1961*3d8817e4Smiod
1962*3d8817e4Smiod static void
ieee_get_symbol_info(bfd * ignore_abfd ATTRIBUTE_UNUSED,asymbol * symbol,symbol_info * ret)1963*3d8817e4Smiod ieee_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
1964*3d8817e4Smiod asymbol *symbol,
1965*3d8817e4Smiod symbol_info *ret)
1966*3d8817e4Smiod {
1967*3d8817e4Smiod bfd_symbol_info (symbol, ret);
1968*3d8817e4Smiod if (symbol->name[0] == ' ')
1969*3d8817e4Smiod ret->name = "* empty table entry ";
1970*3d8817e4Smiod if (!symbol->section)
1971*3d8817e4Smiod ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
1972*3d8817e4Smiod }
1973*3d8817e4Smiod
1974*3d8817e4Smiod static void
ieee_print_symbol(bfd * abfd,void * afile,asymbol * symbol,bfd_print_symbol_type how)1975*3d8817e4Smiod ieee_print_symbol (bfd *abfd,
1976*3d8817e4Smiod void * afile,
1977*3d8817e4Smiod asymbol *symbol,
1978*3d8817e4Smiod bfd_print_symbol_type how)
1979*3d8817e4Smiod {
1980*3d8817e4Smiod FILE *file = (FILE *) afile;
1981*3d8817e4Smiod
1982*3d8817e4Smiod switch (how)
1983*3d8817e4Smiod {
1984*3d8817e4Smiod case bfd_print_symbol_name:
1985*3d8817e4Smiod fprintf (file, "%s", symbol->name);
1986*3d8817e4Smiod break;
1987*3d8817e4Smiod case bfd_print_symbol_more:
1988*3d8817e4Smiod BFD_FAIL ();
1989*3d8817e4Smiod break;
1990*3d8817e4Smiod case bfd_print_symbol_all:
1991*3d8817e4Smiod {
1992*3d8817e4Smiod const char *section_name =
1993*3d8817e4Smiod (symbol->section == (asection *) NULL
1994*3d8817e4Smiod ? "*abs"
1995*3d8817e4Smiod : symbol->section->name);
1996*3d8817e4Smiod
1997*3d8817e4Smiod if (symbol->name[0] == ' ')
1998*3d8817e4Smiod fprintf (file, "* empty table entry ");
1999*3d8817e4Smiod else
2000*3d8817e4Smiod {
2001*3d8817e4Smiod bfd_print_symbol_vandf (abfd, (void *) file, symbol);
2002*3d8817e4Smiod
2003*3d8817e4Smiod fprintf (file, " %-5s %04x %02x %s",
2004*3d8817e4Smiod section_name,
2005*3d8817e4Smiod (unsigned) ieee_symbol (symbol)->index,
2006*3d8817e4Smiod (unsigned) 0,
2007*3d8817e4Smiod symbol->name);
2008*3d8817e4Smiod }
2009*3d8817e4Smiod }
2010*3d8817e4Smiod break;
2011*3d8817e4Smiod }
2012*3d8817e4Smiod }
2013*3d8817e4Smiod
2014*3d8817e4Smiod static bfd_boolean
ieee_new_section_hook(bfd * abfd,asection * newsect)2015*3d8817e4Smiod ieee_new_section_hook (bfd *abfd, asection *newsect)
2016*3d8817e4Smiod {
2017*3d8817e4Smiod newsect->used_by_bfd = bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type));
2018*3d8817e4Smiod if (!newsect->used_by_bfd)
2019*3d8817e4Smiod return FALSE;
2020*3d8817e4Smiod ieee_per_section (newsect)->data = NULL;
2021*3d8817e4Smiod ieee_per_section (newsect)->section = newsect;
2022*3d8817e4Smiod return TRUE;
2023*3d8817e4Smiod }
2024*3d8817e4Smiod
2025*3d8817e4Smiod static long
ieee_get_reloc_upper_bound(bfd * abfd,sec_ptr asect)2026*3d8817e4Smiod ieee_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
2027*3d8817e4Smiod {
2028*3d8817e4Smiod if ((asect->flags & SEC_DEBUGGING) != 0)
2029*3d8817e4Smiod return 0;
2030*3d8817e4Smiod if (! ieee_slurp_section_data (abfd))
2031*3d8817e4Smiod return -1;
2032*3d8817e4Smiod return (asect->reloc_count + 1) * sizeof (arelent *);
2033*3d8817e4Smiod }
2034*3d8817e4Smiod
2035*3d8817e4Smiod static bfd_boolean
ieee_get_section_contents(bfd * abfd,sec_ptr section,void * location,file_ptr offset,bfd_size_type count)2036*3d8817e4Smiod ieee_get_section_contents (bfd *abfd,
2037*3d8817e4Smiod sec_ptr section,
2038*3d8817e4Smiod void * location,
2039*3d8817e4Smiod file_ptr offset,
2040*3d8817e4Smiod bfd_size_type count)
2041*3d8817e4Smiod {
2042*3d8817e4Smiod ieee_per_section_type *p = ieee_per_section (section);
2043*3d8817e4Smiod if ((section->flags & SEC_DEBUGGING) != 0)
2044*3d8817e4Smiod return _bfd_generic_get_section_contents (abfd, section, location,
2045*3d8817e4Smiod offset, count);
2046*3d8817e4Smiod ieee_slurp_section_data (abfd);
2047*3d8817e4Smiod (void) memcpy ((void *) location, (void *) (p->data + offset), (unsigned) count);
2048*3d8817e4Smiod return TRUE;
2049*3d8817e4Smiod }
2050*3d8817e4Smiod
2051*3d8817e4Smiod static long
ieee_canonicalize_reloc(bfd * abfd,sec_ptr section,arelent ** relptr,asymbol ** symbols)2052*3d8817e4Smiod ieee_canonicalize_reloc (bfd *abfd,
2053*3d8817e4Smiod sec_ptr section,
2054*3d8817e4Smiod arelent **relptr,
2055*3d8817e4Smiod asymbol **symbols)
2056*3d8817e4Smiod {
2057*3d8817e4Smiod ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation);
2058*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
2059*3d8817e4Smiod
2060*3d8817e4Smiod if ((section->flags & SEC_DEBUGGING) != 0)
2061*3d8817e4Smiod return 0;
2062*3d8817e4Smiod
2063*3d8817e4Smiod while (src != (ieee_reloc_type *) NULL)
2064*3d8817e4Smiod {
2065*3d8817e4Smiod /* Work out which symbol to attach it this reloc to. */
2066*3d8817e4Smiod switch (src->symbol.letter)
2067*3d8817e4Smiod {
2068*3d8817e4Smiod case 'I':
2069*3d8817e4Smiod src->relent.sym_ptr_ptr =
2070*3d8817e4Smiod symbols + src->symbol.index + ieee->external_symbol_base_offset;
2071*3d8817e4Smiod break;
2072*3d8817e4Smiod case 'X':
2073*3d8817e4Smiod src->relent.sym_ptr_ptr =
2074*3d8817e4Smiod symbols + src->symbol.index + ieee->external_reference_base_offset;
2075*3d8817e4Smiod break;
2076*3d8817e4Smiod case 0:
2077*3d8817e4Smiod if (src->relent.sym_ptr_ptr != NULL)
2078*3d8817e4Smiod src->relent.sym_ptr_ptr =
2079*3d8817e4Smiod src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr;
2080*3d8817e4Smiod break;
2081*3d8817e4Smiod default:
2082*3d8817e4Smiod
2083*3d8817e4Smiod BFD_FAIL ();
2084*3d8817e4Smiod }
2085*3d8817e4Smiod *relptr++ = &src->relent;
2086*3d8817e4Smiod src = src->next;
2087*3d8817e4Smiod }
2088*3d8817e4Smiod *relptr = NULL;
2089*3d8817e4Smiod return section->reloc_count;
2090*3d8817e4Smiod }
2091*3d8817e4Smiod
2092*3d8817e4Smiod static int
comp(const void * ap,const void * bp)2093*3d8817e4Smiod comp (const void * ap, const void * bp)
2094*3d8817e4Smiod {
2095*3d8817e4Smiod arelent *a = *((arelent **) ap);
2096*3d8817e4Smiod arelent *b = *((arelent **) bp);
2097*3d8817e4Smiod return a->address - b->address;
2098*3d8817e4Smiod }
2099*3d8817e4Smiod
2100*3d8817e4Smiod /* Write the section headers. */
2101*3d8817e4Smiod
2102*3d8817e4Smiod static bfd_boolean
ieee_write_section_part(bfd * abfd)2103*3d8817e4Smiod ieee_write_section_part (bfd *abfd)
2104*3d8817e4Smiod {
2105*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
2106*3d8817e4Smiod asection *s;
2107*3d8817e4Smiod
2108*3d8817e4Smiod ieee->w.r.section_part = bfd_tell (abfd);
2109*3d8817e4Smiod for (s = abfd->sections; s != (asection *) NULL; s = s->next)
2110*3d8817e4Smiod {
2111*3d8817e4Smiod if (! bfd_is_abs_section (s)
2112*3d8817e4Smiod && (s->flags & SEC_DEBUGGING) == 0)
2113*3d8817e4Smiod {
2114*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_section_type_enum)
2115*3d8817e4Smiod || ! ieee_write_byte (abfd,
2116*3d8817e4Smiod (bfd_byte) (s->index
2117*3d8817e4Smiod + IEEE_SECTION_NUMBER_BASE)))
2118*3d8817e4Smiod return FALSE;
2119*3d8817e4Smiod
2120*3d8817e4Smiod if (abfd->flags & EXEC_P)
2121*3d8817e4Smiod {
2122*3d8817e4Smiod /* This image is executable, so output absolute sections. */
2123*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_A_enum)
2124*3d8817e4Smiod || ! ieee_write_byte (abfd, ieee_variable_S_enum))
2125*3d8817e4Smiod return FALSE;
2126*3d8817e4Smiod }
2127*3d8817e4Smiod else
2128*3d8817e4Smiod {
2129*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_C_enum))
2130*3d8817e4Smiod return FALSE;
2131*3d8817e4Smiod }
2132*3d8817e4Smiod
2133*3d8817e4Smiod switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM))
2134*3d8817e4Smiod {
2135*3d8817e4Smiod case SEC_CODE | SEC_LOAD:
2136*3d8817e4Smiod case SEC_CODE:
2137*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_P_enum))
2138*3d8817e4Smiod return FALSE;
2139*3d8817e4Smiod break;
2140*3d8817e4Smiod case SEC_DATA:
2141*3d8817e4Smiod default:
2142*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_D_enum))
2143*3d8817e4Smiod return FALSE;
2144*3d8817e4Smiod break;
2145*3d8817e4Smiod case SEC_ROM:
2146*3d8817e4Smiod case SEC_ROM | SEC_DATA:
2147*3d8817e4Smiod case SEC_ROM | SEC_LOAD:
2148*3d8817e4Smiod case SEC_ROM | SEC_DATA | SEC_LOAD:
2149*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_variable_R_enum))
2150*3d8817e4Smiod return FALSE;
2151*3d8817e4Smiod }
2152*3d8817e4Smiod
2153*3d8817e4Smiod
2154*3d8817e4Smiod if (! ieee_write_id (abfd, s->name))
2155*3d8817e4Smiod return FALSE;
2156*3d8817e4Smiod /* Alignment. */
2157*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_section_alignment_enum)
2158*3d8817e4Smiod || ! ieee_write_byte (abfd,
2159*3d8817e4Smiod (bfd_byte) (s->index
2160*3d8817e4Smiod + IEEE_SECTION_NUMBER_BASE))
2161*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) 1 << s->alignment_power))
2162*3d8817e4Smiod return FALSE;
2163*3d8817e4Smiod
2164*3d8817e4Smiod /* Size. */
2165*3d8817e4Smiod if (! ieee_write_2bytes (abfd, ieee_section_size_enum)
2166*3d8817e4Smiod || ! ieee_write_byte (abfd,
2167*3d8817e4Smiod (bfd_byte) (s->index
2168*3d8817e4Smiod + IEEE_SECTION_NUMBER_BASE))
2169*3d8817e4Smiod || ! ieee_write_int (abfd, s->size))
2170*3d8817e4Smiod return FALSE;
2171*3d8817e4Smiod if (abfd->flags & EXEC_P)
2172*3d8817e4Smiod {
2173*3d8817e4Smiod /* Relocateable sections don't have asl records. */
2174*3d8817e4Smiod /* Vma. */
2175*3d8817e4Smiod if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum)
2176*3d8817e4Smiod || ! ieee_write_byte (abfd,
2177*3d8817e4Smiod ((bfd_byte)
2178*3d8817e4Smiod (s->index
2179*3d8817e4Smiod + IEEE_SECTION_NUMBER_BASE)))
2180*3d8817e4Smiod || ! ieee_write_int (abfd, s->lma))
2181*3d8817e4Smiod return FALSE;
2182*3d8817e4Smiod }
2183*3d8817e4Smiod }
2184*3d8817e4Smiod }
2185*3d8817e4Smiod
2186*3d8817e4Smiod return TRUE;
2187*3d8817e4Smiod }
2188*3d8817e4Smiod
2189*3d8817e4Smiod static bfd_boolean
do_with_relocs(bfd * abfd,asection * s)2190*3d8817e4Smiod do_with_relocs (bfd *abfd, asection *s)
2191*3d8817e4Smiod {
2192*3d8817e4Smiod unsigned int number_of_maus_in_address =
2193*3d8817e4Smiod bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd);
2194*3d8817e4Smiod unsigned int relocs_to_go = s->reloc_count;
2195*3d8817e4Smiod bfd_byte *stream = ieee_per_section (s)->data;
2196*3d8817e4Smiod arelent **p = s->orelocation;
2197*3d8817e4Smiod bfd_size_type current_byte_index = 0;
2198*3d8817e4Smiod
2199*3d8817e4Smiod qsort (s->orelocation,
2200*3d8817e4Smiod relocs_to_go,
2201*3d8817e4Smiod sizeof (arelent **),
2202*3d8817e4Smiod comp);
2203*3d8817e4Smiod
2204*3d8817e4Smiod /* Output the section preheader. */
2205*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
2206*3d8817e4Smiod || ! ieee_write_byte (abfd,
2207*3d8817e4Smiod (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))
2208*3d8817e4Smiod || ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum)
2209*3d8817e4Smiod || ! ieee_write_byte (abfd,
2210*3d8817e4Smiod (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)))
2211*3d8817e4Smiod return FALSE;
2212*3d8817e4Smiod
2213*3d8817e4Smiod if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0)
2214*3d8817e4Smiod {
2215*3d8817e4Smiod if (! ieee_write_int (abfd, s->lma))
2216*3d8817e4Smiod return FALSE;
2217*3d8817e4Smiod }
2218*3d8817e4Smiod else
2219*3d8817e4Smiod {
2220*3d8817e4Smiod if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0))
2221*3d8817e4Smiod return FALSE;
2222*3d8817e4Smiod }
2223*3d8817e4Smiod
2224*3d8817e4Smiod if (relocs_to_go == 0)
2225*3d8817e4Smiod {
2226*3d8817e4Smiod /* If there aren't any relocations then output the load constant
2227*3d8817e4Smiod byte opcode rather than the load with relocation opcode. */
2228*3d8817e4Smiod while (current_byte_index < s->size)
2229*3d8817e4Smiod {
2230*3d8817e4Smiod bfd_size_type run;
2231*3d8817e4Smiod unsigned int MAXRUN = 127;
2232*3d8817e4Smiod
2233*3d8817e4Smiod run = MAXRUN;
2234*3d8817e4Smiod if (run > s->size - current_byte_index)
2235*3d8817e4Smiod run = s->size - current_byte_index;
2236*3d8817e4Smiod
2237*3d8817e4Smiod if (run != 0)
2238*3d8817e4Smiod {
2239*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum))
2240*3d8817e4Smiod return FALSE;
2241*3d8817e4Smiod /* Output a stream of bytes. */
2242*3d8817e4Smiod if (! ieee_write_int (abfd, run))
2243*3d8817e4Smiod return FALSE;
2244*3d8817e4Smiod if (bfd_bwrite ((void *) (stream + current_byte_index), run, abfd)
2245*3d8817e4Smiod != run)
2246*3d8817e4Smiod return FALSE;
2247*3d8817e4Smiod current_byte_index += run;
2248*3d8817e4Smiod }
2249*3d8817e4Smiod }
2250*3d8817e4Smiod }
2251*3d8817e4Smiod else
2252*3d8817e4Smiod {
2253*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum))
2254*3d8817e4Smiod return FALSE;
2255*3d8817e4Smiod
2256*3d8817e4Smiod /* Output the data stream as the longest sequence of bytes
2257*3d8817e4Smiod possible, allowing for the a reasonable packet size and
2258*3d8817e4Smiod relocation stuffs. */
2259*3d8817e4Smiod if (stream == NULL)
2260*3d8817e4Smiod {
2261*3d8817e4Smiod /* Outputting a section without data, fill it up. */
2262*3d8817e4Smiod stream = bfd_zalloc (abfd, s->size);
2263*3d8817e4Smiod if (!stream)
2264*3d8817e4Smiod return FALSE;
2265*3d8817e4Smiod }
2266*3d8817e4Smiod while (current_byte_index < s->size)
2267*3d8817e4Smiod {
2268*3d8817e4Smiod bfd_size_type run;
2269*3d8817e4Smiod unsigned int MAXRUN = 127;
2270*3d8817e4Smiod
2271*3d8817e4Smiod if (relocs_to_go)
2272*3d8817e4Smiod {
2273*3d8817e4Smiod run = (*p)->address - current_byte_index;
2274*3d8817e4Smiod if (run > MAXRUN)
2275*3d8817e4Smiod run = MAXRUN;
2276*3d8817e4Smiod }
2277*3d8817e4Smiod else
2278*3d8817e4Smiod run = MAXRUN;
2279*3d8817e4Smiod
2280*3d8817e4Smiod if (run > s->size - current_byte_index)
2281*3d8817e4Smiod run = s->size - current_byte_index;
2282*3d8817e4Smiod
2283*3d8817e4Smiod if (run != 0)
2284*3d8817e4Smiod {
2285*3d8817e4Smiod /* Output a stream of bytes. */
2286*3d8817e4Smiod if (! ieee_write_int (abfd, run))
2287*3d8817e4Smiod return FALSE;
2288*3d8817e4Smiod if (bfd_bwrite ((void *) (stream + current_byte_index), run, abfd)
2289*3d8817e4Smiod != run)
2290*3d8817e4Smiod return FALSE;
2291*3d8817e4Smiod current_byte_index += run;
2292*3d8817e4Smiod }
2293*3d8817e4Smiod
2294*3d8817e4Smiod /* Output any relocations here. */
2295*3d8817e4Smiod if (relocs_to_go && (*p) && (*p)->address == current_byte_index)
2296*3d8817e4Smiod {
2297*3d8817e4Smiod while (relocs_to_go
2298*3d8817e4Smiod && (*p) && (*p)->address == current_byte_index)
2299*3d8817e4Smiod {
2300*3d8817e4Smiod arelent *r = *p;
2301*3d8817e4Smiod bfd_signed_vma ov;
2302*3d8817e4Smiod switch (r->howto->size)
2303*3d8817e4Smiod {
2304*3d8817e4Smiod case 2:
2305*3d8817e4Smiod ov = bfd_get_signed_32 (abfd,
2306*3d8817e4Smiod stream + current_byte_index);
2307*3d8817e4Smiod current_byte_index += 4;
2308*3d8817e4Smiod break;
2309*3d8817e4Smiod case 1:
2310*3d8817e4Smiod ov = bfd_get_signed_16 (abfd,
2311*3d8817e4Smiod stream + current_byte_index);
2312*3d8817e4Smiod current_byte_index += 2;
2313*3d8817e4Smiod break;
2314*3d8817e4Smiod case 0:
2315*3d8817e4Smiod ov = bfd_get_signed_8 (abfd,
2316*3d8817e4Smiod stream + current_byte_index);
2317*3d8817e4Smiod current_byte_index++;
2318*3d8817e4Smiod break;
2319*3d8817e4Smiod default:
2320*3d8817e4Smiod ov = 0;
2321*3d8817e4Smiod BFD_FAIL ();
2322*3d8817e4Smiod return FALSE;
2323*3d8817e4Smiod }
2324*3d8817e4Smiod
2325*3d8817e4Smiod ov &= r->howto->src_mask;
2326*3d8817e4Smiod
2327*3d8817e4Smiod if (r->howto->pc_relative
2328*3d8817e4Smiod && ! r->howto->pcrel_offset)
2329*3d8817e4Smiod ov += r->address;
2330*3d8817e4Smiod
2331*3d8817e4Smiod if (! ieee_write_byte (abfd,
2332*3d8817e4Smiod ieee_function_either_open_b_enum))
2333*3d8817e4Smiod return FALSE;
2334*3d8817e4Smiod
2335*3d8817e4Smiod if (r->sym_ptr_ptr != (asymbol **) NULL)
2336*3d8817e4Smiod {
2337*3d8817e4Smiod if (! ieee_write_expression (abfd, r->addend + ov,
2338*3d8817e4Smiod *(r->sym_ptr_ptr),
2339*3d8817e4Smiod r->howto->pc_relative,
2340*3d8817e4Smiod (unsigned) s->index))
2341*3d8817e4Smiod return FALSE;
2342*3d8817e4Smiod }
2343*3d8817e4Smiod else
2344*3d8817e4Smiod {
2345*3d8817e4Smiod if (! ieee_write_expression (abfd, r->addend + ov,
2346*3d8817e4Smiod (asymbol *) NULL,
2347*3d8817e4Smiod r->howto->pc_relative,
2348*3d8817e4Smiod (unsigned) s->index))
2349*3d8817e4Smiod return FALSE;
2350*3d8817e4Smiod }
2351*3d8817e4Smiod
2352*3d8817e4Smiod if (number_of_maus_in_address
2353*3d8817e4Smiod != bfd_get_reloc_size (r->howto))
2354*3d8817e4Smiod {
2355*3d8817e4Smiod bfd_vma rsize = bfd_get_reloc_size (r->howto);
2356*3d8817e4Smiod if (! ieee_write_int (abfd, rsize))
2357*3d8817e4Smiod return FALSE;
2358*3d8817e4Smiod }
2359*3d8817e4Smiod if (! ieee_write_byte (abfd,
2360*3d8817e4Smiod ieee_function_either_close_b_enum))
2361*3d8817e4Smiod return FALSE;
2362*3d8817e4Smiod
2363*3d8817e4Smiod relocs_to_go--;
2364*3d8817e4Smiod p++;
2365*3d8817e4Smiod }
2366*3d8817e4Smiod
2367*3d8817e4Smiod }
2368*3d8817e4Smiod }
2369*3d8817e4Smiod }
2370*3d8817e4Smiod
2371*3d8817e4Smiod return TRUE;
2372*3d8817e4Smiod }
2373*3d8817e4Smiod
2374*3d8817e4Smiod /* If there are no relocations in the output section then we can be
2375*3d8817e4Smiod clever about how we write. We block items up into a max of 127
2376*3d8817e4Smiod bytes. */
2377*3d8817e4Smiod
2378*3d8817e4Smiod static bfd_boolean
do_as_repeat(bfd * abfd,asection * s)2379*3d8817e4Smiod do_as_repeat (bfd *abfd, asection *s)
2380*3d8817e4Smiod {
2381*3d8817e4Smiod if (s->size)
2382*3d8817e4Smiod {
2383*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
2384*3d8817e4Smiod || ! ieee_write_byte (abfd,
2385*3d8817e4Smiod (bfd_byte) (s->index
2386*3d8817e4Smiod + IEEE_SECTION_NUMBER_BASE))
2387*3d8817e4Smiod || ! ieee_write_byte (abfd, ieee_set_current_pc_enum >> 8)
2388*3d8817e4Smiod || ! ieee_write_byte (abfd, ieee_set_current_pc_enum & 0xff)
2389*3d8817e4Smiod || ! ieee_write_byte (abfd,
2390*3d8817e4Smiod (bfd_byte) (s->index
2391*3d8817e4Smiod + IEEE_SECTION_NUMBER_BASE)))
2392*3d8817e4Smiod return FALSE;
2393*3d8817e4Smiod
2394*3d8817e4Smiod if ((abfd->flags & EXEC_P) != 0)
2395*3d8817e4Smiod {
2396*3d8817e4Smiod if (! ieee_write_int (abfd, s->lma))
2397*3d8817e4Smiod return FALSE;
2398*3d8817e4Smiod }
2399*3d8817e4Smiod else
2400*3d8817e4Smiod {
2401*3d8817e4Smiod if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0))
2402*3d8817e4Smiod return FALSE;
2403*3d8817e4Smiod }
2404*3d8817e4Smiod
2405*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_repeat_data_enum)
2406*3d8817e4Smiod || ! ieee_write_int (abfd, s->size)
2407*3d8817e4Smiod || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)
2408*3d8817e4Smiod || ! ieee_write_byte (abfd, 1)
2409*3d8817e4Smiod || ! ieee_write_byte (abfd, 0))
2410*3d8817e4Smiod return FALSE;
2411*3d8817e4Smiod }
2412*3d8817e4Smiod
2413*3d8817e4Smiod return TRUE;
2414*3d8817e4Smiod }
2415*3d8817e4Smiod
2416*3d8817e4Smiod static bfd_boolean
do_without_relocs(bfd * abfd,asection * s)2417*3d8817e4Smiod do_without_relocs (bfd *abfd, asection *s)
2418*3d8817e4Smiod {
2419*3d8817e4Smiod bfd_byte *stream = ieee_per_section (s)->data;
2420*3d8817e4Smiod
2421*3d8817e4Smiod if (stream == 0 || ((s->flags & SEC_LOAD) == 0))
2422*3d8817e4Smiod {
2423*3d8817e4Smiod if (! do_as_repeat (abfd, s))
2424*3d8817e4Smiod return FALSE;
2425*3d8817e4Smiod }
2426*3d8817e4Smiod else
2427*3d8817e4Smiod {
2428*3d8817e4Smiod unsigned int i;
2429*3d8817e4Smiod
2430*3d8817e4Smiod for (i = 0; i < s->size; i++)
2431*3d8817e4Smiod {
2432*3d8817e4Smiod if (stream[i] != 0)
2433*3d8817e4Smiod {
2434*3d8817e4Smiod if (! do_with_relocs (abfd, s))
2435*3d8817e4Smiod return FALSE;
2436*3d8817e4Smiod return TRUE;
2437*3d8817e4Smiod }
2438*3d8817e4Smiod }
2439*3d8817e4Smiod if (! do_as_repeat (abfd, s))
2440*3d8817e4Smiod return FALSE;
2441*3d8817e4Smiod }
2442*3d8817e4Smiod
2443*3d8817e4Smiod return TRUE;
2444*3d8817e4Smiod }
2445*3d8817e4Smiod
2446*3d8817e4Smiod static void
fill(void)2447*3d8817e4Smiod fill (void)
2448*3d8817e4Smiod {
2449*3d8817e4Smiod bfd_size_type amt = input_ptr_end - input_ptr_start;
2450*3d8817e4Smiod /* FIXME: Check return value. I'm not sure whether it needs to read
2451*3d8817e4Smiod the entire buffer or not. */
2452*3d8817e4Smiod bfd_bread ((void *) input_ptr_start, amt, input_bfd);
2453*3d8817e4Smiod input_ptr = input_ptr_start;
2454*3d8817e4Smiod }
2455*3d8817e4Smiod
2456*3d8817e4Smiod static void
flush(void)2457*3d8817e4Smiod flush (void)
2458*3d8817e4Smiod {
2459*3d8817e4Smiod bfd_size_type amt = output_ptr - output_ptr_start;
2460*3d8817e4Smiod
2461*3d8817e4Smiod if (bfd_bwrite ((void *) (output_ptr_start), amt, output_bfd) != amt)
2462*3d8817e4Smiod abort ();
2463*3d8817e4Smiod output_ptr = output_ptr_start;
2464*3d8817e4Smiod output_buffer++;
2465*3d8817e4Smiod }
2466*3d8817e4Smiod
2467*3d8817e4Smiod #define THIS() ( *input_ptr )
2468*3d8817e4Smiod #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill (); }
2469*3d8817e4Smiod #define OUT(x) { *output_ptr++ = (x); if (output_ptr == output_ptr_end) flush (); }
2470*3d8817e4Smiod
2471*3d8817e4Smiod static void
write_int(int value)2472*3d8817e4Smiod write_int (int value)
2473*3d8817e4Smiod {
2474*3d8817e4Smiod if (value >= 0 && value <= 127)
2475*3d8817e4Smiod {
2476*3d8817e4Smiod OUT (value);
2477*3d8817e4Smiod }
2478*3d8817e4Smiod else
2479*3d8817e4Smiod {
2480*3d8817e4Smiod unsigned int length;
2481*3d8817e4Smiod
2482*3d8817e4Smiod /* How many significant bytes ? */
2483*3d8817e4Smiod /* FIXME FOR LONGER INTS. */
2484*3d8817e4Smiod if (value & 0xff000000)
2485*3d8817e4Smiod length = 4;
2486*3d8817e4Smiod else if (value & 0x00ff0000)
2487*3d8817e4Smiod length = 3;
2488*3d8817e4Smiod else if (value & 0x0000ff00)
2489*3d8817e4Smiod length = 2;
2490*3d8817e4Smiod else
2491*3d8817e4Smiod length = 1;
2492*3d8817e4Smiod
2493*3d8817e4Smiod OUT ((int) ieee_number_repeat_start_enum + length);
2494*3d8817e4Smiod switch (length)
2495*3d8817e4Smiod {
2496*3d8817e4Smiod case 4:
2497*3d8817e4Smiod OUT (value >> 24);
2498*3d8817e4Smiod case 3:
2499*3d8817e4Smiod OUT (value >> 16);
2500*3d8817e4Smiod case 2:
2501*3d8817e4Smiod OUT (value >> 8);
2502*3d8817e4Smiod case 1:
2503*3d8817e4Smiod OUT (value);
2504*3d8817e4Smiod }
2505*3d8817e4Smiod }
2506*3d8817e4Smiod }
2507*3d8817e4Smiod
2508*3d8817e4Smiod static void
copy_id(void)2509*3d8817e4Smiod copy_id (void)
2510*3d8817e4Smiod {
2511*3d8817e4Smiod int length = THIS ();
2512*3d8817e4Smiod char ch;
2513*3d8817e4Smiod
2514*3d8817e4Smiod OUT (length);
2515*3d8817e4Smiod NEXT ();
2516*3d8817e4Smiod while (length--)
2517*3d8817e4Smiod {
2518*3d8817e4Smiod ch = THIS ();
2519*3d8817e4Smiod OUT (ch);
2520*3d8817e4Smiod NEXT ();
2521*3d8817e4Smiod }
2522*3d8817e4Smiod }
2523*3d8817e4Smiod
2524*3d8817e4Smiod #define VAR(x) ((x | 0x80))
2525*3d8817e4Smiod static void
copy_expression(void)2526*3d8817e4Smiod copy_expression (void)
2527*3d8817e4Smiod {
2528*3d8817e4Smiod int stack[10];
2529*3d8817e4Smiod int *tos = stack;
2530*3d8817e4Smiod int value;
2531*3d8817e4Smiod
2532*3d8817e4Smiod while (1)
2533*3d8817e4Smiod {
2534*3d8817e4Smiod switch (THIS ())
2535*3d8817e4Smiod {
2536*3d8817e4Smiod case 0x84:
2537*3d8817e4Smiod NEXT ();
2538*3d8817e4Smiod value = THIS ();
2539*3d8817e4Smiod NEXT ();
2540*3d8817e4Smiod value = (value << 8) | THIS ();
2541*3d8817e4Smiod NEXT ();
2542*3d8817e4Smiod value = (value << 8) | THIS ();
2543*3d8817e4Smiod NEXT ();
2544*3d8817e4Smiod value = (value << 8) | THIS ();
2545*3d8817e4Smiod NEXT ();
2546*3d8817e4Smiod *tos++ = value;
2547*3d8817e4Smiod break;
2548*3d8817e4Smiod case 0x83:
2549*3d8817e4Smiod NEXT ();
2550*3d8817e4Smiod value = THIS ();
2551*3d8817e4Smiod NEXT ();
2552*3d8817e4Smiod value = (value << 8) | THIS ();
2553*3d8817e4Smiod NEXT ();
2554*3d8817e4Smiod value = (value << 8) | THIS ();
2555*3d8817e4Smiod NEXT ();
2556*3d8817e4Smiod *tos++ = value;
2557*3d8817e4Smiod break;
2558*3d8817e4Smiod case 0x82:
2559*3d8817e4Smiod NEXT ();
2560*3d8817e4Smiod value = THIS ();
2561*3d8817e4Smiod NEXT ();
2562*3d8817e4Smiod value = (value << 8) | THIS ();
2563*3d8817e4Smiod NEXT ();
2564*3d8817e4Smiod *tos++ = value;
2565*3d8817e4Smiod break;
2566*3d8817e4Smiod case 0x81:
2567*3d8817e4Smiod NEXT ();
2568*3d8817e4Smiod value = THIS ();
2569*3d8817e4Smiod NEXT ();
2570*3d8817e4Smiod *tos++ = value;
2571*3d8817e4Smiod break;
2572*3d8817e4Smiod case 0x80:
2573*3d8817e4Smiod NEXT ();
2574*3d8817e4Smiod *tos++ = 0;
2575*3d8817e4Smiod break;
2576*3d8817e4Smiod default:
2577*3d8817e4Smiod if (THIS () > 0x84)
2578*3d8817e4Smiod {
2579*3d8817e4Smiod /* Not a number, just bug out with the answer. */
2580*3d8817e4Smiod write_int (*(--tos));
2581*3d8817e4Smiod return;
2582*3d8817e4Smiod }
2583*3d8817e4Smiod *tos++ = THIS ();
2584*3d8817e4Smiod NEXT ();
2585*3d8817e4Smiod break;
2586*3d8817e4Smiod case 0xa5:
2587*3d8817e4Smiod /* PLUS anything. */
2588*3d8817e4Smiod value = *(--tos);
2589*3d8817e4Smiod value += *(--tos);
2590*3d8817e4Smiod *tos++ = value;
2591*3d8817e4Smiod NEXT ();
2592*3d8817e4Smiod break;
2593*3d8817e4Smiod case VAR ('R'):
2594*3d8817e4Smiod {
2595*3d8817e4Smiod int section_number;
2596*3d8817e4Smiod ieee_data_type *ieee;
2597*3d8817e4Smiod asection *s;
2598*3d8817e4Smiod
2599*3d8817e4Smiod NEXT ();
2600*3d8817e4Smiod section_number = THIS ();
2601*3d8817e4Smiod
2602*3d8817e4Smiod NEXT ();
2603*3d8817e4Smiod ieee = IEEE_DATA (input_bfd);
2604*3d8817e4Smiod s = ieee->section_table[section_number];
2605*3d8817e4Smiod value = 0;
2606*3d8817e4Smiod if (s->output_section)
2607*3d8817e4Smiod value = s->output_section->lma;
2608*3d8817e4Smiod value += s->output_offset;
2609*3d8817e4Smiod *tos++ = value;
2610*3d8817e4Smiod }
2611*3d8817e4Smiod break;
2612*3d8817e4Smiod case 0x90:
2613*3d8817e4Smiod {
2614*3d8817e4Smiod NEXT ();
2615*3d8817e4Smiod write_int (*(--tos));
2616*3d8817e4Smiod OUT (0x90);
2617*3d8817e4Smiod return;
2618*3d8817e4Smiod }
2619*3d8817e4Smiod }
2620*3d8817e4Smiod }
2621*3d8817e4Smiod }
2622*3d8817e4Smiod
2623*3d8817e4Smiod /* Drop the int in the buffer, and copy a null into the gap, which we
2624*3d8817e4Smiod will overwrite later. */
2625*3d8817e4Smiod
2626*3d8817e4Smiod static void
fill_int(struct output_buffer_struct * buf)2627*3d8817e4Smiod fill_int (struct output_buffer_struct *buf)
2628*3d8817e4Smiod {
2629*3d8817e4Smiod if (buf->buffer == output_buffer)
2630*3d8817e4Smiod {
2631*3d8817e4Smiod /* Still a chance to output the size. */
2632*3d8817e4Smiod int value = output_ptr - buf->ptrp + 3;
2633*3d8817e4Smiod buf->ptrp[0] = value >> 24;
2634*3d8817e4Smiod buf->ptrp[1] = value >> 16;
2635*3d8817e4Smiod buf->ptrp[2] = value >> 8;
2636*3d8817e4Smiod buf->ptrp[3] = value >> 0;
2637*3d8817e4Smiod }
2638*3d8817e4Smiod }
2639*3d8817e4Smiod
2640*3d8817e4Smiod static void
drop_int(struct output_buffer_struct * buf)2641*3d8817e4Smiod drop_int (struct output_buffer_struct *buf)
2642*3d8817e4Smiod {
2643*3d8817e4Smiod int type = THIS ();
2644*3d8817e4Smiod int ch;
2645*3d8817e4Smiod
2646*3d8817e4Smiod if (type <= 0x84)
2647*3d8817e4Smiod {
2648*3d8817e4Smiod NEXT ();
2649*3d8817e4Smiod switch (type)
2650*3d8817e4Smiod {
2651*3d8817e4Smiod case 0x84:
2652*3d8817e4Smiod ch = THIS ();
2653*3d8817e4Smiod NEXT ();
2654*3d8817e4Smiod case 0x83:
2655*3d8817e4Smiod ch = THIS ();
2656*3d8817e4Smiod NEXT ();
2657*3d8817e4Smiod case 0x82:
2658*3d8817e4Smiod ch = THIS ();
2659*3d8817e4Smiod NEXT ();
2660*3d8817e4Smiod case 0x81:
2661*3d8817e4Smiod ch = THIS ();
2662*3d8817e4Smiod NEXT ();
2663*3d8817e4Smiod case 0x80:
2664*3d8817e4Smiod break;
2665*3d8817e4Smiod }
2666*3d8817e4Smiod }
2667*3d8817e4Smiod OUT (0x84);
2668*3d8817e4Smiod buf->ptrp = output_ptr;
2669*3d8817e4Smiod buf->buffer = output_buffer;
2670*3d8817e4Smiod OUT (0);
2671*3d8817e4Smiod OUT (0);
2672*3d8817e4Smiod OUT (0);
2673*3d8817e4Smiod OUT (0);
2674*3d8817e4Smiod }
2675*3d8817e4Smiod
2676*3d8817e4Smiod static void
copy_int(void)2677*3d8817e4Smiod copy_int (void)
2678*3d8817e4Smiod {
2679*3d8817e4Smiod int type = THIS ();
2680*3d8817e4Smiod int ch;
2681*3d8817e4Smiod if (type <= 0x84)
2682*3d8817e4Smiod {
2683*3d8817e4Smiod OUT (type);
2684*3d8817e4Smiod NEXT ();
2685*3d8817e4Smiod switch (type)
2686*3d8817e4Smiod {
2687*3d8817e4Smiod case 0x84:
2688*3d8817e4Smiod ch = THIS ();
2689*3d8817e4Smiod NEXT ();
2690*3d8817e4Smiod OUT (ch);
2691*3d8817e4Smiod case 0x83:
2692*3d8817e4Smiod ch = THIS ();
2693*3d8817e4Smiod NEXT ();
2694*3d8817e4Smiod OUT (ch);
2695*3d8817e4Smiod case 0x82:
2696*3d8817e4Smiod ch = THIS ();
2697*3d8817e4Smiod NEXT ();
2698*3d8817e4Smiod OUT (ch);
2699*3d8817e4Smiod case 0x81:
2700*3d8817e4Smiod ch = THIS ();
2701*3d8817e4Smiod NEXT ();
2702*3d8817e4Smiod OUT (ch);
2703*3d8817e4Smiod case 0x80:
2704*3d8817e4Smiod break;
2705*3d8817e4Smiod }
2706*3d8817e4Smiod }
2707*3d8817e4Smiod }
2708*3d8817e4Smiod
2709*3d8817e4Smiod #define ID copy_id ()
2710*3d8817e4Smiod #define INT copy_int ()
2711*3d8817e4Smiod #define EXP copy_expression ()
2712*3d8817e4Smiod #define INTn(q) copy_int ()
2713*3d8817e4Smiod #define EXPn(q) copy_expression ()
2714*3d8817e4Smiod
2715*3d8817e4Smiod static void
copy_till_end(void)2716*3d8817e4Smiod copy_till_end (void)
2717*3d8817e4Smiod {
2718*3d8817e4Smiod int ch = THIS ();
2719*3d8817e4Smiod
2720*3d8817e4Smiod while (1)
2721*3d8817e4Smiod {
2722*3d8817e4Smiod while (ch <= 0x80)
2723*3d8817e4Smiod {
2724*3d8817e4Smiod OUT (ch);
2725*3d8817e4Smiod NEXT ();
2726*3d8817e4Smiod ch = THIS ();
2727*3d8817e4Smiod }
2728*3d8817e4Smiod switch (ch)
2729*3d8817e4Smiod {
2730*3d8817e4Smiod case 0x84:
2731*3d8817e4Smiod OUT (THIS ());
2732*3d8817e4Smiod NEXT ();
2733*3d8817e4Smiod case 0x83:
2734*3d8817e4Smiod OUT (THIS ());
2735*3d8817e4Smiod NEXT ();
2736*3d8817e4Smiod case 0x82:
2737*3d8817e4Smiod OUT (THIS ());
2738*3d8817e4Smiod NEXT ();
2739*3d8817e4Smiod case 0x81:
2740*3d8817e4Smiod OUT (THIS ());
2741*3d8817e4Smiod NEXT ();
2742*3d8817e4Smiod OUT (THIS ());
2743*3d8817e4Smiod NEXT ();
2744*3d8817e4Smiod
2745*3d8817e4Smiod ch = THIS ();
2746*3d8817e4Smiod break;
2747*3d8817e4Smiod default:
2748*3d8817e4Smiod return;
2749*3d8817e4Smiod }
2750*3d8817e4Smiod }
2751*3d8817e4Smiod
2752*3d8817e4Smiod }
2753*3d8817e4Smiod
2754*3d8817e4Smiod static void
f1_record(void)2755*3d8817e4Smiod f1_record (void)
2756*3d8817e4Smiod {
2757*3d8817e4Smiod int ch;
2758*3d8817e4Smiod
2759*3d8817e4Smiod /* ATN record. */
2760*3d8817e4Smiod NEXT ();
2761*3d8817e4Smiod ch = THIS ();
2762*3d8817e4Smiod switch (ch)
2763*3d8817e4Smiod {
2764*3d8817e4Smiod default:
2765*3d8817e4Smiod OUT (0xf1);
2766*3d8817e4Smiod OUT (ch);
2767*3d8817e4Smiod break;
2768*3d8817e4Smiod case 0xc9:
2769*3d8817e4Smiod NEXT ();
2770*3d8817e4Smiod OUT (0xf1);
2771*3d8817e4Smiod OUT (0xc9);
2772*3d8817e4Smiod INT;
2773*3d8817e4Smiod INT;
2774*3d8817e4Smiod ch = THIS ();
2775*3d8817e4Smiod switch (ch)
2776*3d8817e4Smiod {
2777*3d8817e4Smiod case 0x16:
2778*3d8817e4Smiod NEXT ();
2779*3d8817e4Smiod break;
2780*3d8817e4Smiod case 0x01:
2781*3d8817e4Smiod NEXT ();
2782*3d8817e4Smiod break;
2783*3d8817e4Smiod case 0x00:
2784*3d8817e4Smiod NEXT ();
2785*3d8817e4Smiod INT;
2786*3d8817e4Smiod break;
2787*3d8817e4Smiod case 0x03:
2788*3d8817e4Smiod NEXT ();
2789*3d8817e4Smiod INT;
2790*3d8817e4Smiod break;
2791*3d8817e4Smiod case 0x13:
2792*3d8817e4Smiod EXPn (instruction address);
2793*3d8817e4Smiod break;
2794*3d8817e4Smiod default:
2795*3d8817e4Smiod break;
2796*3d8817e4Smiod }
2797*3d8817e4Smiod break;
2798*3d8817e4Smiod case 0xd8:
2799*3d8817e4Smiod /* EXternal ref. */
2800*3d8817e4Smiod NEXT ();
2801*3d8817e4Smiod OUT (0xf1);
2802*3d8817e4Smiod OUT (0xd8);
2803*3d8817e4Smiod EXP;
2804*3d8817e4Smiod EXP;
2805*3d8817e4Smiod EXP;
2806*3d8817e4Smiod EXP;
2807*3d8817e4Smiod break;
2808*3d8817e4Smiod case 0xce:
2809*3d8817e4Smiod NEXT ();
2810*3d8817e4Smiod OUT (0xf1);
2811*3d8817e4Smiod OUT (0xce);
2812*3d8817e4Smiod INT;
2813*3d8817e4Smiod INT;
2814*3d8817e4Smiod ch = THIS ();
2815*3d8817e4Smiod INT;
2816*3d8817e4Smiod switch (ch)
2817*3d8817e4Smiod {
2818*3d8817e4Smiod case 0x01:
2819*3d8817e4Smiod INT;
2820*3d8817e4Smiod INT;
2821*3d8817e4Smiod break;
2822*3d8817e4Smiod case 0x02:
2823*3d8817e4Smiod INT;
2824*3d8817e4Smiod break;
2825*3d8817e4Smiod case 0x04:
2826*3d8817e4Smiod EXPn (external function);
2827*3d8817e4Smiod break;
2828*3d8817e4Smiod case 0x05:
2829*3d8817e4Smiod break;
2830*3d8817e4Smiod case 0x07:
2831*3d8817e4Smiod INTn (line number);
2832*3d8817e4Smiod INT;
2833*3d8817e4Smiod case 0x08:
2834*3d8817e4Smiod break;
2835*3d8817e4Smiod case 0x0a:
2836*3d8817e4Smiod INTn (locked register);
2837*3d8817e4Smiod INT;
2838*3d8817e4Smiod break;
2839*3d8817e4Smiod case 0x3f:
2840*3d8817e4Smiod copy_till_end ();
2841*3d8817e4Smiod break;
2842*3d8817e4Smiod case 0x3e:
2843*3d8817e4Smiod copy_till_end ();
2844*3d8817e4Smiod break;
2845*3d8817e4Smiod case 0x40:
2846*3d8817e4Smiod copy_till_end ();
2847*3d8817e4Smiod break;
2848*3d8817e4Smiod case 0x41:
2849*3d8817e4Smiod ID;
2850*3d8817e4Smiod break;
2851*3d8817e4Smiod }
2852*3d8817e4Smiod }
2853*3d8817e4Smiod }
2854*3d8817e4Smiod
2855*3d8817e4Smiod static void
f0_record(void)2856*3d8817e4Smiod f0_record (void)
2857*3d8817e4Smiod {
2858*3d8817e4Smiod /* Attribute record. */
2859*3d8817e4Smiod NEXT ();
2860*3d8817e4Smiod OUT (0xf0);
2861*3d8817e4Smiod INTn (Symbol name);
2862*3d8817e4Smiod ID;
2863*3d8817e4Smiod }
2864*3d8817e4Smiod
2865*3d8817e4Smiod static void
f2_record(void)2866*3d8817e4Smiod f2_record (void)
2867*3d8817e4Smiod {
2868*3d8817e4Smiod NEXT ();
2869*3d8817e4Smiod OUT (0xf2);
2870*3d8817e4Smiod INT;
2871*3d8817e4Smiod NEXT ();
2872*3d8817e4Smiod OUT (0xce);
2873*3d8817e4Smiod INT;
2874*3d8817e4Smiod copy_till_end ();
2875*3d8817e4Smiod }
2876*3d8817e4Smiod
2877*3d8817e4Smiod static void
f8_record(void)2878*3d8817e4Smiod f8_record (void)
2879*3d8817e4Smiod {
2880*3d8817e4Smiod int ch;
2881*3d8817e4Smiod NEXT ();
2882*3d8817e4Smiod ch = THIS ();
2883*3d8817e4Smiod switch (ch)
2884*3d8817e4Smiod {
2885*3d8817e4Smiod case 0x01:
2886*3d8817e4Smiod case 0x02:
2887*3d8817e4Smiod case 0x03:
2888*3d8817e4Smiod /* Unique typedefs for module. */
2889*3d8817e4Smiod /* GLobal typedefs. */
2890*3d8817e4Smiod /* High level module scope beginning. */
2891*3d8817e4Smiod {
2892*3d8817e4Smiod struct output_buffer_struct ob;
2893*3d8817e4Smiod
2894*3d8817e4Smiod NEXT ();
2895*3d8817e4Smiod OUT (0xf8);
2896*3d8817e4Smiod OUT (ch);
2897*3d8817e4Smiod drop_int (&ob);
2898*3d8817e4Smiod ID;
2899*3d8817e4Smiod
2900*3d8817e4Smiod block ();
2901*3d8817e4Smiod
2902*3d8817e4Smiod NEXT ();
2903*3d8817e4Smiod fill_int (&ob);
2904*3d8817e4Smiod OUT (0xf9);
2905*3d8817e4Smiod }
2906*3d8817e4Smiod break;
2907*3d8817e4Smiod case 0x04:
2908*3d8817e4Smiod /* Global function. */
2909*3d8817e4Smiod {
2910*3d8817e4Smiod struct output_buffer_struct ob;
2911*3d8817e4Smiod
2912*3d8817e4Smiod NEXT ();
2913*3d8817e4Smiod OUT (0xf8);
2914*3d8817e4Smiod OUT (0x04);
2915*3d8817e4Smiod drop_int (&ob);
2916*3d8817e4Smiod ID;
2917*3d8817e4Smiod INTn (stack size);
2918*3d8817e4Smiod INTn (ret val);
2919*3d8817e4Smiod EXPn (offset);
2920*3d8817e4Smiod
2921*3d8817e4Smiod block ();
2922*3d8817e4Smiod
2923*3d8817e4Smiod NEXT ();
2924*3d8817e4Smiod OUT (0xf9);
2925*3d8817e4Smiod EXPn (size of block);
2926*3d8817e4Smiod fill_int (&ob);
2927*3d8817e4Smiod }
2928*3d8817e4Smiod break;
2929*3d8817e4Smiod
2930*3d8817e4Smiod case 0x05:
2931*3d8817e4Smiod /* File name for source line numbers. */
2932*3d8817e4Smiod {
2933*3d8817e4Smiod struct output_buffer_struct ob;
2934*3d8817e4Smiod
2935*3d8817e4Smiod NEXT ();
2936*3d8817e4Smiod OUT (0xf8);
2937*3d8817e4Smiod OUT (0x05);
2938*3d8817e4Smiod drop_int (&ob);
2939*3d8817e4Smiod ID;
2940*3d8817e4Smiod INTn (year);
2941*3d8817e4Smiod INTn (month);
2942*3d8817e4Smiod INTn (day);
2943*3d8817e4Smiod INTn (hour);
2944*3d8817e4Smiod INTn (monute);
2945*3d8817e4Smiod INTn (second);
2946*3d8817e4Smiod block ();
2947*3d8817e4Smiod NEXT ();
2948*3d8817e4Smiod OUT (0xf9);
2949*3d8817e4Smiod fill_int (&ob);
2950*3d8817e4Smiod }
2951*3d8817e4Smiod break;
2952*3d8817e4Smiod
2953*3d8817e4Smiod case 0x06:
2954*3d8817e4Smiod /* Local function. */
2955*3d8817e4Smiod {
2956*3d8817e4Smiod struct output_buffer_struct ob;
2957*3d8817e4Smiod
2958*3d8817e4Smiod NEXT ();
2959*3d8817e4Smiod OUT (0xf8);
2960*3d8817e4Smiod OUT (0x06);
2961*3d8817e4Smiod drop_int (&ob);
2962*3d8817e4Smiod ID;
2963*3d8817e4Smiod INTn (stack size);
2964*3d8817e4Smiod INTn (type return);
2965*3d8817e4Smiod EXPn (offset);
2966*3d8817e4Smiod block ();
2967*3d8817e4Smiod NEXT ();
2968*3d8817e4Smiod OUT (0xf9);
2969*3d8817e4Smiod EXPn (size);
2970*3d8817e4Smiod fill_int (&ob);
2971*3d8817e4Smiod }
2972*3d8817e4Smiod break;
2973*3d8817e4Smiod
2974*3d8817e4Smiod case 0x0a:
2975*3d8817e4Smiod /* Assembler module scope beginning - */
2976*3d8817e4Smiod {
2977*3d8817e4Smiod struct output_buffer_struct ob;
2978*3d8817e4Smiod
2979*3d8817e4Smiod NEXT ();
2980*3d8817e4Smiod OUT (0xf8);
2981*3d8817e4Smiod OUT (0x0a);
2982*3d8817e4Smiod drop_int (&ob);
2983*3d8817e4Smiod ID;
2984*3d8817e4Smiod ID;
2985*3d8817e4Smiod INT;
2986*3d8817e4Smiod ID;
2987*3d8817e4Smiod INT;
2988*3d8817e4Smiod INT;
2989*3d8817e4Smiod INT;
2990*3d8817e4Smiod INT;
2991*3d8817e4Smiod INT;
2992*3d8817e4Smiod INT;
2993*3d8817e4Smiod
2994*3d8817e4Smiod block ();
2995*3d8817e4Smiod
2996*3d8817e4Smiod NEXT ();
2997*3d8817e4Smiod OUT (0xf9);
2998*3d8817e4Smiod fill_int (&ob);
2999*3d8817e4Smiod }
3000*3d8817e4Smiod break;
3001*3d8817e4Smiod case 0x0b:
3002*3d8817e4Smiod {
3003*3d8817e4Smiod struct output_buffer_struct ob;
3004*3d8817e4Smiod
3005*3d8817e4Smiod NEXT ();
3006*3d8817e4Smiod OUT (0xf8);
3007*3d8817e4Smiod OUT (0x0b);
3008*3d8817e4Smiod drop_int (&ob);
3009*3d8817e4Smiod ID;
3010*3d8817e4Smiod INT;
3011*3d8817e4Smiod INTn (section index);
3012*3d8817e4Smiod EXPn (offset);
3013*3d8817e4Smiod INTn (stuff);
3014*3d8817e4Smiod
3015*3d8817e4Smiod block ();
3016*3d8817e4Smiod
3017*3d8817e4Smiod OUT (0xf9);
3018*3d8817e4Smiod NEXT ();
3019*3d8817e4Smiod EXPn (Size in Maus);
3020*3d8817e4Smiod fill_int (&ob);
3021*3d8817e4Smiod }
3022*3d8817e4Smiod break;
3023*3d8817e4Smiod }
3024*3d8817e4Smiod }
3025*3d8817e4Smiod
3026*3d8817e4Smiod static void
e2_record(void)3027*3d8817e4Smiod e2_record (void)
3028*3d8817e4Smiod {
3029*3d8817e4Smiod OUT (0xe2);
3030*3d8817e4Smiod NEXT ();
3031*3d8817e4Smiod OUT (0xce);
3032*3d8817e4Smiod NEXT ();
3033*3d8817e4Smiod INT;
3034*3d8817e4Smiod EXP;
3035*3d8817e4Smiod }
3036*3d8817e4Smiod
3037*3d8817e4Smiod static void
block(void)3038*3d8817e4Smiod block (void)
3039*3d8817e4Smiod {
3040*3d8817e4Smiod int ch;
3041*3d8817e4Smiod
3042*3d8817e4Smiod while (1)
3043*3d8817e4Smiod {
3044*3d8817e4Smiod ch = THIS ();
3045*3d8817e4Smiod switch (ch)
3046*3d8817e4Smiod {
3047*3d8817e4Smiod case 0xe1:
3048*3d8817e4Smiod case 0xe5:
3049*3d8817e4Smiod return;
3050*3d8817e4Smiod case 0xf9:
3051*3d8817e4Smiod return;
3052*3d8817e4Smiod case 0xf0:
3053*3d8817e4Smiod f0_record ();
3054*3d8817e4Smiod break;
3055*3d8817e4Smiod case 0xf1:
3056*3d8817e4Smiod f1_record ();
3057*3d8817e4Smiod break;
3058*3d8817e4Smiod case 0xf2:
3059*3d8817e4Smiod f2_record ();
3060*3d8817e4Smiod break;
3061*3d8817e4Smiod case 0xf8:
3062*3d8817e4Smiod f8_record ();
3063*3d8817e4Smiod break;
3064*3d8817e4Smiod case 0xe2:
3065*3d8817e4Smiod e2_record ();
3066*3d8817e4Smiod break;
3067*3d8817e4Smiod
3068*3d8817e4Smiod }
3069*3d8817e4Smiod }
3070*3d8817e4Smiod }
3071*3d8817e4Smiod
3072*3d8817e4Smiod /* Moves all the debug information from the source bfd to the output
3073*3d8817e4Smiod bfd, and relocates any expressions it finds. */
3074*3d8817e4Smiod
3075*3d8817e4Smiod static void
relocate_debug(bfd * output ATTRIBUTE_UNUSED,bfd * input)3076*3d8817e4Smiod relocate_debug (bfd *output ATTRIBUTE_UNUSED,
3077*3d8817e4Smiod bfd *input)
3078*3d8817e4Smiod {
3079*3d8817e4Smiod #define IBS 400
3080*3d8817e4Smiod #define OBS 400
3081*3d8817e4Smiod unsigned char input_buffer[IBS];
3082*3d8817e4Smiod
3083*3d8817e4Smiod input_ptr_start = input_ptr = input_buffer;
3084*3d8817e4Smiod input_ptr_end = input_buffer + IBS;
3085*3d8817e4Smiod input_bfd = input;
3086*3d8817e4Smiod /* FIXME: Check return value. I'm not sure whether it needs to read
3087*3d8817e4Smiod the entire buffer or not. */
3088*3d8817e4Smiod bfd_bread ((void *) input_ptr_start, (bfd_size_type) IBS, input);
3089*3d8817e4Smiod block ();
3090*3d8817e4Smiod }
3091*3d8817e4Smiod
3092*3d8817e4Smiod /* Gather together all the debug information from each input BFD into
3093*3d8817e4Smiod one place, relocating it and emitting it as we go. */
3094*3d8817e4Smiod
3095*3d8817e4Smiod static bfd_boolean
ieee_write_debug_part(bfd * abfd)3096*3d8817e4Smiod ieee_write_debug_part (bfd *abfd)
3097*3d8817e4Smiod {
3098*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
3099*3d8817e4Smiod bfd_chain_type *chain = ieee->chain_root;
3100*3d8817e4Smiod unsigned char obuff[OBS];
3101*3d8817e4Smiod bfd_boolean some_debug = FALSE;
3102*3d8817e4Smiod file_ptr here = bfd_tell (abfd);
3103*3d8817e4Smiod
3104*3d8817e4Smiod output_ptr_start = output_ptr = obuff;
3105*3d8817e4Smiod output_ptr_end = obuff + OBS;
3106*3d8817e4Smiod output_ptr = obuff;
3107*3d8817e4Smiod output_bfd = abfd;
3108*3d8817e4Smiod
3109*3d8817e4Smiod if (chain == (bfd_chain_type *) NULL)
3110*3d8817e4Smiod {
3111*3d8817e4Smiod asection *s;
3112*3d8817e4Smiod
3113*3d8817e4Smiod for (s = abfd->sections; s != NULL; s = s->next)
3114*3d8817e4Smiod if ((s->flags & SEC_DEBUGGING) != 0)
3115*3d8817e4Smiod break;
3116*3d8817e4Smiod if (s == NULL)
3117*3d8817e4Smiod {
3118*3d8817e4Smiod ieee->w.r.debug_information_part = 0;
3119*3d8817e4Smiod return TRUE;
3120*3d8817e4Smiod }
3121*3d8817e4Smiod
3122*3d8817e4Smiod ieee->w.r.debug_information_part = here;
3123*3d8817e4Smiod if (bfd_bwrite (s->contents, s->size, abfd) != s->size)
3124*3d8817e4Smiod return FALSE;
3125*3d8817e4Smiod }
3126*3d8817e4Smiod else
3127*3d8817e4Smiod {
3128*3d8817e4Smiod while (chain != (bfd_chain_type *) NULL)
3129*3d8817e4Smiod {
3130*3d8817e4Smiod bfd *entry = chain->this;
3131*3d8817e4Smiod ieee_data_type *entry_ieee = IEEE_DATA (entry);
3132*3d8817e4Smiod
3133*3d8817e4Smiod if (entry_ieee->w.r.debug_information_part)
3134*3d8817e4Smiod {
3135*3d8817e4Smiod if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
3136*3d8817e4Smiod SEEK_SET) != 0)
3137*3d8817e4Smiod return FALSE;
3138*3d8817e4Smiod relocate_debug (abfd, entry);
3139*3d8817e4Smiod }
3140*3d8817e4Smiod
3141*3d8817e4Smiod chain = chain->next;
3142*3d8817e4Smiod }
3143*3d8817e4Smiod
3144*3d8817e4Smiod if (some_debug)
3145*3d8817e4Smiod ieee->w.r.debug_information_part = here;
3146*3d8817e4Smiod else
3147*3d8817e4Smiod ieee->w.r.debug_information_part = 0;
3148*3d8817e4Smiod
3149*3d8817e4Smiod flush ();
3150*3d8817e4Smiod }
3151*3d8817e4Smiod
3152*3d8817e4Smiod return TRUE;
3153*3d8817e4Smiod }
3154*3d8817e4Smiod
3155*3d8817e4Smiod /* Write the data in an ieee way. */
3156*3d8817e4Smiod
3157*3d8817e4Smiod static bfd_boolean
ieee_write_data_part(bfd * abfd)3158*3d8817e4Smiod ieee_write_data_part (bfd *abfd)
3159*3d8817e4Smiod {
3160*3d8817e4Smiod asection *s;
3161*3d8817e4Smiod
3162*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
3163*3d8817e4Smiod ieee->w.r.data_part = bfd_tell (abfd);
3164*3d8817e4Smiod
3165*3d8817e4Smiod for (s = abfd->sections; s != (asection *) NULL; s = s->next)
3166*3d8817e4Smiod {
3167*3d8817e4Smiod /* Skip sections that have no loadable contents (.bss,
3168*3d8817e4Smiod debugging, etc.) */
3169*3d8817e4Smiod if ((s->flags & SEC_LOAD) == 0)
3170*3d8817e4Smiod continue;
3171*3d8817e4Smiod
3172*3d8817e4Smiod /* Sort the reloc records so we can insert them in the correct
3173*3d8817e4Smiod places. */
3174*3d8817e4Smiod if (s->reloc_count != 0)
3175*3d8817e4Smiod {
3176*3d8817e4Smiod if (! do_with_relocs (abfd, s))
3177*3d8817e4Smiod return FALSE;
3178*3d8817e4Smiod }
3179*3d8817e4Smiod else
3180*3d8817e4Smiod {
3181*3d8817e4Smiod if (! do_without_relocs (abfd, s))
3182*3d8817e4Smiod return FALSE;
3183*3d8817e4Smiod }
3184*3d8817e4Smiod }
3185*3d8817e4Smiod
3186*3d8817e4Smiod return TRUE;
3187*3d8817e4Smiod }
3188*3d8817e4Smiod
3189*3d8817e4Smiod static bfd_boolean
init_for_output(bfd * abfd)3190*3d8817e4Smiod init_for_output (bfd *abfd)
3191*3d8817e4Smiod {
3192*3d8817e4Smiod asection *s;
3193*3d8817e4Smiod
3194*3d8817e4Smiod for (s = abfd->sections; s != (asection *) NULL; s = s->next)
3195*3d8817e4Smiod {
3196*3d8817e4Smiod if ((s->flags & SEC_DEBUGGING) != 0)
3197*3d8817e4Smiod continue;
3198*3d8817e4Smiod if (s->size != 0)
3199*3d8817e4Smiod {
3200*3d8817e4Smiod bfd_size_type size = s->size;
3201*3d8817e4Smiod ieee_per_section (s)->data = bfd_alloc (abfd, size);
3202*3d8817e4Smiod if (!ieee_per_section (s)->data)
3203*3d8817e4Smiod return FALSE;
3204*3d8817e4Smiod }
3205*3d8817e4Smiod }
3206*3d8817e4Smiod return TRUE;
3207*3d8817e4Smiod }
3208*3d8817e4Smiod
3209*3d8817e4Smiod /* Exec and core file sections. */
3210*3d8817e4Smiod
3211*3d8817e4Smiod /* Set section contents is complicated with IEEE since the format is
3212*3d8817e4Smiod not a byte image, but a record stream. */
3213*3d8817e4Smiod
3214*3d8817e4Smiod static bfd_boolean
ieee_set_section_contents(bfd * abfd,sec_ptr section,const void * location,file_ptr offset,bfd_size_type count)3215*3d8817e4Smiod ieee_set_section_contents (bfd *abfd,
3216*3d8817e4Smiod sec_ptr section,
3217*3d8817e4Smiod const void * location,
3218*3d8817e4Smiod file_ptr offset,
3219*3d8817e4Smiod bfd_size_type count)
3220*3d8817e4Smiod {
3221*3d8817e4Smiod if ((section->flags & SEC_DEBUGGING) != 0)
3222*3d8817e4Smiod {
3223*3d8817e4Smiod if (section->contents == NULL)
3224*3d8817e4Smiod {
3225*3d8817e4Smiod bfd_size_type size = section->size;
3226*3d8817e4Smiod section->contents = bfd_alloc (abfd, size);
3227*3d8817e4Smiod if (section->contents == NULL)
3228*3d8817e4Smiod return FALSE;
3229*3d8817e4Smiod }
3230*3d8817e4Smiod /* bfd_set_section_contents has already checked that everything
3231*3d8817e4Smiod is within range. */
3232*3d8817e4Smiod memcpy (section->contents + offset, location, (size_t) count);
3233*3d8817e4Smiod return TRUE;
3234*3d8817e4Smiod }
3235*3d8817e4Smiod
3236*3d8817e4Smiod if (ieee_per_section (section)->data == (bfd_byte *) NULL)
3237*3d8817e4Smiod {
3238*3d8817e4Smiod if (!init_for_output (abfd))
3239*3d8817e4Smiod return FALSE;
3240*3d8817e4Smiod }
3241*3d8817e4Smiod memcpy ((void *) (ieee_per_section (section)->data + offset),
3242*3d8817e4Smiod (void *) location,
3243*3d8817e4Smiod (unsigned int) count);
3244*3d8817e4Smiod return TRUE;
3245*3d8817e4Smiod }
3246*3d8817e4Smiod
3247*3d8817e4Smiod /* Write the external symbols of a file. IEEE considers two sorts of
3248*3d8817e4Smiod external symbols, public, and referenced. It uses to internal
3249*3d8817e4Smiod forms to index them as well. When we write them out we turn their
3250*3d8817e4Smiod symbol values into indexes from the right base. */
3251*3d8817e4Smiod
3252*3d8817e4Smiod static bfd_boolean
ieee_write_external_part(bfd * abfd)3253*3d8817e4Smiod ieee_write_external_part (bfd *abfd)
3254*3d8817e4Smiod {
3255*3d8817e4Smiod asymbol **q;
3256*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
3257*3d8817e4Smiod unsigned int reference_index = IEEE_REFERENCE_BASE;
3258*3d8817e4Smiod unsigned int public_index = IEEE_PUBLIC_BASE + 2;
3259*3d8817e4Smiod file_ptr here = bfd_tell (abfd);
3260*3d8817e4Smiod bfd_boolean hadone = FALSE;
3261*3d8817e4Smiod
3262*3d8817e4Smiod if (abfd->outsymbols != (asymbol **) NULL)
3263*3d8817e4Smiod {
3264*3d8817e4Smiod
3265*3d8817e4Smiod for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++)
3266*3d8817e4Smiod {
3267*3d8817e4Smiod asymbol *p = *q;
3268*3d8817e4Smiod
3269*3d8817e4Smiod if (bfd_is_und_section (p->section))
3270*3d8817e4Smiod {
3271*3d8817e4Smiod /* This must be a symbol reference. */
3272*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_external_reference_enum)
3273*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) reference_index)
3274*3d8817e4Smiod || ! ieee_write_id (abfd, p->name))
3275*3d8817e4Smiod return FALSE;
3276*3d8817e4Smiod p->value = reference_index;
3277*3d8817e4Smiod reference_index++;
3278*3d8817e4Smiod hadone = TRUE;
3279*3d8817e4Smiod }
3280*3d8817e4Smiod else if (bfd_is_com_section (p->section))
3281*3d8817e4Smiod {
3282*3d8817e4Smiod /* This is a weak reference. */
3283*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_external_reference_enum)
3284*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) reference_index)
3285*3d8817e4Smiod || ! ieee_write_id (abfd, p->name)
3286*3d8817e4Smiod || ! ieee_write_byte (abfd,
3287*3d8817e4Smiod ieee_weak_external_reference_enum)
3288*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) reference_index)
3289*3d8817e4Smiod || ! ieee_write_int (abfd, p->value))
3290*3d8817e4Smiod return FALSE;
3291*3d8817e4Smiod p->value = reference_index;
3292*3d8817e4Smiod reference_index++;
3293*3d8817e4Smiod hadone = TRUE;
3294*3d8817e4Smiod }
3295*3d8817e4Smiod else if (p->flags & BSF_GLOBAL)
3296*3d8817e4Smiod {
3297*3d8817e4Smiod /* This must be a symbol definition. */
3298*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_external_symbol_enum)
3299*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) public_index)
3300*3d8817e4Smiod || ! ieee_write_id (abfd, p->name)
3301*3d8817e4Smiod || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum)
3302*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) public_index)
3303*3d8817e4Smiod || ! ieee_write_byte (abfd, 15) /* Instruction address. */
3304*3d8817e4Smiod || ! ieee_write_byte (abfd, 19) /* Static symbol. */
3305*3d8817e4Smiod || ! ieee_write_byte (abfd, 1)) /* One of them. */
3306*3d8817e4Smiod return FALSE;
3307*3d8817e4Smiod
3308*3d8817e4Smiod /* Write out the value. */
3309*3d8817e4Smiod if (! ieee_write_2bytes (abfd, ieee_value_record_enum)
3310*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) public_index))
3311*3d8817e4Smiod return FALSE;
3312*3d8817e4Smiod if (! bfd_is_abs_section (p->section))
3313*3d8817e4Smiod {
3314*3d8817e4Smiod if (abfd->flags & EXEC_P)
3315*3d8817e4Smiod {
3316*3d8817e4Smiod /* If fully linked, then output all symbols
3317*3d8817e4Smiod relocated. */
3318*3d8817e4Smiod if (! (ieee_write_int
3319*3d8817e4Smiod (abfd,
3320*3d8817e4Smiod (p->value
3321*3d8817e4Smiod + p->section->output_offset
3322*3d8817e4Smiod + p->section->output_section->vma))))
3323*3d8817e4Smiod return FALSE;
3324*3d8817e4Smiod }
3325*3d8817e4Smiod else
3326*3d8817e4Smiod {
3327*3d8817e4Smiod if (! (ieee_write_expression
3328*3d8817e4Smiod (abfd,
3329*3d8817e4Smiod p->value + p->section->output_offset,
3330*3d8817e4Smiod p->section->output_section->symbol,
3331*3d8817e4Smiod FALSE, 0)))
3332*3d8817e4Smiod return FALSE;
3333*3d8817e4Smiod }
3334*3d8817e4Smiod }
3335*3d8817e4Smiod else
3336*3d8817e4Smiod {
3337*3d8817e4Smiod if (! ieee_write_expression (abfd,
3338*3d8817e4Smiod p->value,
3339*3d8817e4Smiod bfd_abs_section_ptr->symbol,
3340*3d8817e4Smiod FALSE, 0))
3341*3d8817e4Smiod return FALSE;
3342*3d8817e4Smiod }
3343*3d8817e4Smiod p->value = public_index;
3344*3d8817e4Smiod public_index++;
3345*3d8817e4Smiod hadone = TRUE;
3346*3d8817e4Smiod }
3347*3d8817e4Smiod else
3348*3d8817e4Smiod {
3349*3d8817e4Smiod /* This can happen - when there are gaps in the symbols read
3350*3d8817e4Smiod from an input ieee file. */
3351*3d8817e4Smiod }
3352*3d8817e4Smiod }
3353*3d8817e4Smiod }
3354*3d8817e4Smiod if (hadone)
3355*3d8817e4Smiod ieee->w.r.external_part = here;
3356*3d8817e4Smiod
3357*3d8817e4Smiod return TRUE;
3358*3d8817e4Smiod }
3359*3d8817e4Smiod
3360*3d8817e4Smiod
3361*3d8817e4Smiod static const unsigned char exten[] =
3362*3d8817e4Smiod {
3363*3d8817e4Smiod 0xf0, 0x20, 0x00,
3364*3d8817e4Smiod 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3. */
3365*3d8817e4Smiod 0xf1, 0xce, 0x20, 0x00, 39, 2, /* Keep symbol in original case. */
3366*3d8817e4Smiod 0xf1, 0xce, 0x20, 0x00, 38 /* Set object type relocatable to x. */
3367*3d8817e4Smiod };
3368*3d8817e4Smiod
3369*3d8817e4Smiod static const unsigned char envi[] =
3370*3d8817e4Smiod {
3371*3d8817e4Smiod 0xf0, 0x21, 0x00,
3372*3d8817e4Smiod
3373*3d8817e4Smiod /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11,
3374*3d8817e4Smiod 0x19, 0x2c,
3375*3d8817e4Smiod */
3376*3d8817e4Smiod 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok. */
3377*3d8817e4Smiod
3378*3d8817e4Smiod 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix. */
3379*3d8817e4Smiod /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */
3380*3d8817e4Smiod };
3381*3d8817e4Smiod
3382*3d8817e4Smiod static bfd_boolean
ieee_write_me_part(bfd * abfd)3383*3d8817e4Smiod ieee_write_me_part (bfd *abfd)
3384*3d8817e4Smiod {
3385*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
3386*3d8817e4Smiod ieee->w.r.trailer_part = bfd_tell (abfd);
3387*3d8817e4Smiod if (abfd->start_address)
3388*3d8817e4Smiod {
3389*3d8817e4Smiod if (! ieee_write_2bytes (abfd, ieee_value_starting_address_enum)
3390*3d8817e4Smiod || ! ieee_write_byte (abfd, ieee_function_either_open_b_enum)
3391*3d8817e4Smiod || ! ieee_write_int (abfd, abfd->start_address)
3392*3d8817e4Smiod || ! ieee_write_byte (abfd, ieee_function_either_close_b_enum))
3393*3d8817e4Smiod return FALSE;
3394*3d8817e4Smiod }
3395*3d8817e4Smiod ieee->w.r.me_record = bfd_tell (abfd);
3396*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_module_end_enum))
3397*3d8817e4Smiod return FALSE;
3398*3d8817e4Smiod return TRUE;
3399*3d8817e4Smiod }
3400*3d8817e4Smiod
3401*3d8817e4Smiod /* Write out the IEEE processor ID. */
3402*3d8817e4Smiod
3403*3d8817e4Smiod static bfd_boolean
ieee_write_processor(bfd * abfd)3404*3d8817e4Smiod ieee_write_processor (bfd *abfd)
3405*3d8817e4Smiod {
3406*3d8817e4Smiod const bfd_arch_info_type *arch;
3407*3d8817e4Smiod
3408*3d8817e4Smiod arch = bfd_get_arch_info (abfd);
3409*3d8817e4Smiod switch (arch->arch)
3410*3d8817e4Smiod {
3411*3d8817e4Smiod default:
3412*3d8817e4Smiod if (! ieee_write_id (abfd, bfd_printable_name (abfd)))
3413*3d8817e4Smiod return FALSE;
3414*3d8817e4Smiod break;
3415*3d8817e4Smiod
3416*3d8817e4Smiod case bfd_arch_h8300:
3417*3d8817e4Smiod if (! ieee_write_id (abfd, "H8/300"))
3418*3d8817e4Smiod return FALSE;
3419*3d8817e4Smiod break;
3420*3d8817e4Smiod
3421*3d8817e4Smiod case bfd_arch_h8500:
3422*3d8817e4Smiod if (! ieee_write_id (abfd, "H8/500"))
3423*3d8817e4Smiod return FALSE;
3424*3d8817e4Smiod break;
3425*3d8817e4Smiod
3426*3d8817e4Smiod case bfd_arch_i960:
3427*3d8817e4Smiod switch (arch->mach)
3428*3d8817e4Smiod {
3429*3d8817e4Smiod default:
3430*3d8817e4Smiod case bfd_mach_i960_core:
3431*3d8817e4Smiod case bfd_mach_i960_ka_sa:
3432*3d8817e4Smiod if (! ieee_write_id (abfd, "80960KA"))
3433*3d8817e4Smiod return FALSE;
3434*3d8817e4Smiod break;
3435*3d8817e4Smiod
3436*3d8817e4Smiod case bfd_mach_i960_kb_sb:
3437*3d8817e4Smiod if (! ieee_write_id (abfd, "80960KB"))
3438*3d8817e4Smiod return FALSE;
3439*3d8817e4Smiod break;
3440*3d8817e4Smiod
3441*3d8817e4Smiod case bfd_mach_i960_ca:
3442*3d8817e4Smiod if (! ieee_write_id (abfd, "80960CA"))
3443*3d8817e4Smiod return FALSE;
3444*3d8817e4Smiod break;
3445*3d8817e4Smiod
3446*3d8817e4Smiod case bfd_mach_i960_mc:
3447*3d8817e4Smiod case bfd_mach_i960_xa:
3448*3d8817e4Smiod if (! ieee_write_id (abfd, "80960MC"))
3449*3d8817e4Smiod return FALSE;
3450*3d8817e4Smiod break;
3451*3d8817e4Smiod }
3452*3d8817e4Smiod break;
3453*3d8817e4Smiod
3454*3d8817e4Smiod case bfd_arch_m68k:
3455*3d8817e4Smiod {
3456*3d8817e4Smiod const char *id;
3457*3d8817e4Smiod
3458*3d8817e4Smiod switch (arch->mach)
3459*3d8817e4Smiod {
3460*3d8817e4Smiod default: id = "68020"; break;
3461*3d8817e4Smiod case bfd_mach_m68000: id = "68000"; break;
3462*3d8817e4Smiod case bfd_mach_m68008: id = "68008"; break;
3463*3d8817e4Smiod case bfd_mach_m68010: id = "68010"; break;
3464*3d8817e4Smiod case bfd_mach_m68020: id = "68020"; break;
3465*3d8817e4Smiod case bfd_mach_m68030: id = "68030"; break;
3466*3d8817e4Smiod case bfd_mach_m68040: id = "68040"; break;
3467*3d8817e4Smiod case bfd_mach_m68060: id = "68060"; break;
3468*3d8817e4Smiod case bfd_mach_cpu32: id = "cpu32"; break;
3469*3d8817e4Smiod case bfd_mach_mcf_isa_a_nodiv: id = "isa-a:nodiv"; break;
3470*3d8817e4Smiod case bfd_mach_mcf_isa_a: id = "isa-a"; break;
3471*3d8817e4Smiod case bfd_mach_mcf_isa_a_mac: id = "isa-a:mac"; break;
3472*3d8817e4Smiod case bfd_mach_mcf_isa_a_emac: id = "isa-a:emac"; break;
3473*3d8817e4Smiod case bfd_mach_mcf_isa_aplus: id = "isa-aplus"; break;
3474*3d8817e4Smiod case bfd_mach_mcf_isa_aplus_mac: id = "isa-aplus:mac"; break;
3475*3d8817e4Smiod case bfd_mach_mcf_isa_aplus_emac: id = "isa-aplus:mac"; break;
3476*3d8817e4Smiod case bfd_mach_mcf_isa_b_nousp: id = "isa-b:nousp"; break;
3477*3d8817e4Smiod case bfd_mach_mcf_isa_b_nousp_mac: id = "isa-b:nousp:mac"; break;
3478*3d8817e4Smiod case bfd_mach_mcf_isa_b_nousp_emac: id = "isa-b:nousp:emac"; break;
3479*3d8817e4Smiod case bfd_mach_mcf_isa_b: id = "isa-b"; break;
3480*3d8817e4Smiod case bfd_mach_mcf_isa_b_mac: id = "isa-b:mac"; break;
3481*3d8817e4Smiod case bfd_mach_mcf_isa_b_emac: id = "isa-b:emac"; break;
3482*3d8817e4Smiod case bfd_mach_mcf_isa_b_float: id = "isa-b:float"; break;
3483*3d8817e4Smiod case bfd_mach_mcf_isa_b_float_mac: id = "isa-b:float:mac"; break;
3484*3d8817e4Smiod case bfd_mach_mcf_isa_b_float_emac: id = "isa-b:float:emac"; break;
3485*3d8817e4Smiod }
3486*3d8817e4Smiod
3487*3d8817e4Smiod if (! ieee_write_id (abfd, id))
3488*3d8817e4Smiod return FALSE;
3489*3d8817e4Smiod }
3490*3d8817e4Smiod break;
3491*3d8817e4Smiod }
3492*3d8817e4Smiod
3493*3d8817e4Smiod return TRUE;
3494*3d8817e4Smiod }
3495*3d8817e4Smiod
3496*3d8817e4Smiod static bfd_boolean
ieee_write_object_contents(bfd * abfd)3497*3d8817e4Smiod ieee_write_object_contents (bfd *abfd)
3498*3d8817e4Smiod {
3499*3d8817e4Smiod ieee_data_type *ieee = IEEE_DATA (abfd);
3500*3d8817e4Smiod unsigned int i;
3501*3d8817e4Smiod file_ptr old;
3502*3d8817e4Smiod
3503*3d8817e4Smiod /* Fast forward over the header area. */
3504*3d8817e4Smiod if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
3505*3d8817e4Smiod return FALSE;
3506*3d8817e4Smiod
3507*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_module_beginning_enum)
3508*3d8817e4Smiod || ! ieee_write_processor (abfd)
3509*3d8817e4Smiod || ! ieee_write_id (abfd, abfd->filename))
3510*3d8817e4Smiod return FALSE;
3511*3d8817e4Smiod
3512*3d8817e4Smiod /* Fast forward over the variable bits. */
3513*3d8817e4Smiod if (! ieee_write_byte (abfd, ieee_address_descriptor_enum))
3514*3d8817e4Smiod return FALSE;
3515*3d8817e4Smiod
3516*3d8817e4Smiod /* Bits per MAU. */
3517*3d8817e4Smiod if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd))))
3518*3d8817e4Smiod return FALSE;
3519*3d8817e4Smiod /* MAU's per address. */
3520*3d8817e4Smiod if (! ieee_write_byte (abfd,
3521*3d8817e4Smiod (bfd_byte) (bfd_arch_bits_per_address (abfd)
3522*3d8817e4Smiod / bfd_arch_bits_per_byte (abfd))))
3523*3d8817e4Smiod return FALSE;
3524*3d8817e4Smiod
3525*3d8817e4Smiod old = bfd_tell (abfd);
3526*3d8817e4Smiod if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0)
3527*3d8817e4Smiod return FALSE;
3528*3d8817e4Smiod
3529*3d8817e4Smiod ieee->w.r.extension_record = bfd_tell (abfd);
3530*3d8817e4Smiod if (bfd_bwrite ((char *) exten, (bfd_size_type) sizeof (exten), abfd)
3531*3d8817e4Smiod != sizeof (exten))
3532*3d8817e4Smiod return FALSE;
3533*3d8817e4Smiod if (abfd->flags & EXEC_P)
3534*3d8817e4Smiod {
3535*3d8817e4Smiod if (! ieee_write_byte (abfd, 0x1)) /* Absolute. */
3536*3d8817e4Smiod return FALSE;
3537*3d8817e4Smiod }
3538*3d8817e4Smiod else
3539*3d8817e4Smiod {
3540*3d8817e4Smiod if (! ieee_write_byte (abfd, 0x2)) /* Relocateable. */
3541*3d8817e4Smiod return FALSE;
3542*3d8817e4Smiod }
3543*3d8817e4Smiod
3544*3d8817e4Smiod ieee->w.r.environmental_record = bfd_tell (abfd);
3545*3d8817e4Smiod if (bfd_bwrite ((char *) envi, (bfd_size_type) sizeof (envi), abfd)
3546*3d8817e4Smiod != sizeof (envi))
3547*3d8817e4Smiod return FALSE;
3548*3d8817e4Smiod
3549*3d8817e4Smiod /* The HP emulator database requires a timestamp in the file. */
3550*3d8817e4Smiod {
3551*3d8817e4Smiod time_t now;
3552*3d8817e4Smiod const struct tm *t;
3553*3d8817e4Smiod
3554*3d8817e4Smiod time (&now);
3555*3d8817e4Smiod t = (struct tm *) localtime (&now);
3556*3d8817e4Smiod if (! ieee_write_2bytes (abfd, (int) ieee_atn_record_enum)
3557*3d8817e4Smiod || ! ieee_write_byte (abfd, 0x21)
3558*3d8817e4Smiod || ! ieee_write_byte (abfd, 0)
3559*3d8817e4Smiod || ! ieee_write_byte (abfd, 50)
3560*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) (t->tm_year + 1900))
3561*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) (t->tm_mon + 1))
3562*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) t->tm_mday)
3563*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) t->tm_hour)
3564*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) t->tm_min)
3565*3d8817e4Smiod || ! ieee_write_int (abfd, (bfd_vma) t->tm_sec))
3566*3d8817e4Smiod return FALSE;
3567*3d8817e4Smiod }
3568*3d8817e4Smiod
3569*3d8817e4Smiod output_bfd = abfd;
3570*3d8817e4Smiod
3571*3d8817e4Smiod flush ();
3572*3d8817e4Smiod
3573*3d8817e4Smiod if (! ieee_write_section_part (abfd))
3574*3d8817e4Smiod return FALSE;
3575*3d8817e4Smiod /* First write the symbols. This changes their values into table
3576*3d8817e4Smiod indeces so we cant use it after this point. */
3577*3d8817e4Smiod if (! ieee_write_external_part (abfd))
3578*3d8817e4Smiod return FALSE;
3579*3d8817e4Smiod
3580*3d8817e4Smiod /* Write any debugs we have been told about. */
3581*3d8817e4Smiod if (! ieee_write_debug_part (abfd))
3582*3d8817e4Smiod return FALSE;
3583*3d8817e4Smiod
3584*3d8817e4Smiod /* Can only write the data once the symbols have been written, since
3585*3d8817e4Smiod the data contains relocation information which points to the
3586*3d8817e4Smiod symbols. */
3587*3d8817e4Smiod if (! ieee_write_data_part (abfd))
3588*3d8817e4Smiod return FALSE;
3589*3d8817e4Smiod
3590*3d8817e4Smiod /* At the end we put the end! */
3591*3d8817e4Smiod if (! ieee_write_me_part (abfd))
3592*3d8817e4Smiod return FALSE;
3593*3d8817e4Smiod
3594*3d8817e4Smiod /* Generate the header. */
3595*3d8817e4Smiod if (bfd_seek (abfd, old, SEEK_SET) != 0)
3596*3d8817e4Smiod return FALSE;
3597*3d8817e4Smiod
3598*3d8817e4Smiod for (i = 0; i < N_W_VARIABLES; i++)
3599*3d8817e4Smiod {
3600*3d8817e4Smiod if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum)
3601*3d8817e4Smiod || ! ieee_write_byte (abfd, (bfd_byte) i)
3602*3d8817e4Smiod || ! ieee_write_int5_out (abfd, (bfd_vma) ieee->w.offset[i]))
3603*3d8817e4Smiod return FALSE;
3604*3d8817e4Smiod }
3605*3d8817e4Smiod
3606*3d8817e4Smiod return TRUE;
3607*3d8817e4Smiod }
3608*3d8817e4Smiod
3609*3d8817e4Smiod /* Native-level interface to symbols. */
3610*3d8817e4Smiod
3611*3d8817e4Smiod /* We read the symbols into a buffer, which is discarded when this
3612*3d8817e4Smiod function exits. We read the strings into a buffer large enough to
3613*3d8817e4Smiod hold them all plus all the cached symbol entries. */
3614*3d8817e4Smiod
3615*3d8817e4Smiod static asymbol *
ieee_make_empty_symbol(bfd * abfd)3616*3d8817e4Smiod ieee_make_empty_symbol (bfd *abfd)
3617*3d8817e4Smiod {
3618*3d8817e4Smiod bfd_size_type amt = sizeof (ieee_symbol_type);
3619*3d8817e4Smiod ieee_symbol_type *new = bfd_zalloc (abfd, amt);
3620*3d8817e4Smiod
3621*3d8817e4Smiod if (!new)
3622*3d8817e4Smiod return NULL;
3623*3d8817e4Smiod new->symbol.the_bfd = abfd;
3624*3d8817e4Smiod return &new->symbol;
3625*3d8817e4Smiod }
3626*3d8817e4Smiod
3627*3d8817e4Smiod static bfd *
ieee_openr_next_archived_file(bfd * arch,bfd * prev)3628*3d8817e4Smiod ieee_openr_next_archived_file (bfd *arch, bfd *prev)
3629*3d8817e4Smiod {
3630*3d8817e4Smiod ieee_ar_data_type *ar = IEEE_AR_DATA (arch);
3631*3d8817e4Smiod
3632*3d8817e4Smiod /* Take the next one from the arch state, or reset. */
3633*3d8817e4Smiod if (prev == (bfd *) NULL)
3634*3d8817e4Smiod /* Reset the index - the first two entries are bogus. */
3635*3d8817e4Smiod ar->element_index = 2;
3636*3d8817e4Smiod
3637*3d8817e4Smiod while (TRUE)
3638*3d8817e4Smiod {
3639*3d8817e4Smiod ieee_ar_obstack_type *p = ar->elements + ar->element_index;
3640*3d8817e4Smiod
3641*3d8817e4Smiod ar->element_index++;
3642*3d8817e4Smiod if (ar->element_index <= ar->element_count)
3643*3d8817e4Smiod {
3644*3d8817e4Smiod if (p->file_offset != (file_ptr) 0)
3645*3d8817e4Smiod {
3646*3d8817e4Smiod if (p->abfd == (bfd *) NULL)
3647*3d8817e4Smiod {
3648*3d8817e4Smiod p->abfd = _bfd_create_empty_archive_element_shell (arch);
3649*3d8817e4Smiod p->abfd->origin = p->file_offset;
3650*3d8817e4Smiod }
3651*3d8817e4Smiod return p->abfd;
3652*3d8817e4Smiod }
3653*3d8817e4Smiod }
3654*3d8817e4Smiod else
3655*3d8817e4Smiod {
3656*3d8817e4Smiod bfd_set_error (bfd_error_no_more_archived_files);
3657*3d8817e4Smiod return NULL;
3658*3d8817e4Smiod }
3659*3d8817e4Smiod }
3660*3d8817e4Smiod }
3661*3d8817e4Smiod
3662*3d8817e4Smiod static bfd_boolean
ieee_find_nearest_line(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED,asymbol ** symbols ATTRIBUTE_UNUSED,bfd_vma offset ATTRIBUTE_UNUSED,const char ** filename_ptr ATTRIBUTE_UNUSED,const char ** functionname_ptr ATTRIBUTE_UNUSED,unsigned int * line_ptr ATTRIBUTE_UNUSED)3663*3d8817e4Smiod ieee_find_nearest_line (bfd *abfd ATTRIBUTE_UNUSED,
3664*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED,
3665*3d8817e4Smiod asymbol **symbols ATTRIBUTE_UNUSED,
3666*3d8817e4Smiod bfd_vma offset ATTRIBUTE_UNUSED,
3667*3d8817e4Smiod const char **filename_ptr ATTRIBUTE_UNUSED,
3668*3d8817e4Smiod const char **functionname_ptr ATTRIBUTE_UNUSED,
3669*3d8817e4Smiod unsigned int *line_ptr ATTRIBUTE_UNUSED)
3670*3d8817e4Smiod {
3671*3d8817e4Smiod return FALSE;
3672*3d8817e4Smiod }
3673*3d8817e4Smiod
3674*3d8817e4Smiod static bfd_boolean
ieee_find_inliner_info(bfd * abfd ATTRIBUTE_UNUSED,const char ** filename_ptr ATTRIBUTE_UNUSED,const char ** functionname_ptr ATTRIBUTE_UNUSED,unsigned int * line_ptr ATTRIBUTE_UNUSED)3675*3d8817e4Smiod ieee_find_inliner_info (bfd *abfd ATTRIBUTE_UNUSED,
3676*3d8817e4Smiod const char **filename_ptr ATTRIBUTE_UNUSED,
3677*3d8817e4Smiod const char **functionname_ptr ATTRIBUTE_UNUSED,
3678*3d8817e4Smiod unsigned int *line_ptr ATTRIBUTE_UNUSED)
3679*3d8817e4Smiod {
3680*3d8817e4Smiod return FALSE;
3681*3d8817e4Smiod }
3682*3d8817e4Smiod
3683*3d8817e4Smiod static int
ieee_generic_stat_arch_elt(bfd * abfd,struct stat * buf)3684*3d8817e4Smiod ieee_generic_stat_arch_elt (bfd *abfd, struct stat *buf)
3685*3d8817e4Smiod {
3686*3d8817e4Smiod ieee_ar_data_type *ar = (ieee_ar_data_type *) NULL;
3687*3d8817e4Smiod ieee_data_type *ieee;
3688*3d8817e4Smiod
3689*3d8817e4Smiod if (abfd->my_archive != NULL)
3690*3d8817e4Smiod ar = abfd->my_archive->tdata.ieee_ar_data;
3691*3d8817e4Smiod if (ar == (ieee_ar_data_type *) NULL)
3692*3d8817e4Smiod {
3693*3d8817e4Smiod bfd_set_error (bfd_error_invalid_operation);
3694*3d8817e4Smiod return -1;
3695*3d8817e4Smiod }
3696*3d8817e4Smiod
3697*3d8817e4Smiod if (IEEE_DATA (abfd) == NULL)
3698*3d8817e4Smiod {
3699*3d8817e4Smiod if (ieee_object_p (abfd) == NULL)
3700*3d8817e4Smiod {
3701*3d8817e4Smiod bfd_set_error (bfd_error_wrong_format);
3702*3d8817e4Smiod return -1;
3703*3d8817e4Smiod }
3704*3d8817e4Smiod }
3705*3d8817e4Smiod
3706*3d8817e4Smiod ieee = IEEE_DATA (abfd);
3707*3d8817e4Smiod
3708*3d8817e4Smiod buf->st_size = ieee->w.r.me_record + 1;
3709*3d8817e4Smiod buf->st_mode = 0644;
3710*3d8817e4Smiod return 0;
3711*3d8817e4Smiod }
3712*3d8817e4Smiod
3713*3d8817e4Smiod static int
ieee_sizeof_headers(bfd * abfd ATTRIBUTE_UNUSED,bfd_boolean x ATTRIBUTE_UNUSED)3714*3d8817e4Smiod ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
3715*3d8817e4Smiod bfd_boolean x ATTRIBUTE_UNUSED)
3716*3d8817e4Smiod {
3717*3d8817e4Smiod return 0;
3718*3d8817e4Smiod }
3719*3d8817e4Smiod
3720*3d8817e4Smiod #define ieee_close_and_cleanup _bfd_generic_close_and_cleanup
3721*3d8817e4Smiod #define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
3722*3d8817e4Smiod
3723*3d8817e4Smiod #define ieee_slurp_armap bfd_true
3724*3d8817e4Smiod #define ieee_slurp_extended_name_table bfd_true
3725*3d8817e4Smiod #define ieee_construct_extended_name_table \
3726*3d8817e4Smiod ((bfd_boolean (*) \
3727*3d8817e4Smiod (bfd *, char **, bfd_size_type *, const char **)) \
3728*3d8817e4Smiod bfd_true)
3729*3d8817e4Smiod #define ieee_truncate_arname bfd_dont_truncate_arname
3730*3d8817e4Smiod #define ieee_write_armap \
3731*3d8817e4Smiod ((bfd_boolean (*) \
3732*3d8817e4Smiod (bfd *, unsigned int, struct orl *, unsigned int, int)) \
3733*3d8817e4Smiod bfd_true)
3734*3d8817e4Smiod #define ieee_read_ar_hdr bfd_nullvoidptr
3735*3d8817e4Smiod #define ieee_update_armap_timestamp bfd_true
3736*3d8817e4Smiod #define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
3737*3d8817e4Smiod
3738*3d8817e4Smiod #define ieee_bfd_is_target_special_symbol \
3739*3d8817e4Smiod ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
3740*3d8817e4Smiod #define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name
3741*3d8817e4Smiod #define ieee_get_lineno _bfd_nosymbols_get_lineno
3742*3d8817e4Smiod #define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
3743*3d8817e4Smiod #define ieee_read_minisymbols _bfd_generic_read_minisymbols
3744*3d8817e4Smiod #define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
3745*3d8817e4Smiod
3746*3d8817e4Smiod #define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
3747*3d8817e4Smiod
3748*3d8817e4Smiod #define ieee_set_arch_mach _bfd_generic_set_arch_mach
3749*3d8817e4Smiod
3750*3d8817e4Smiod #define ieee_get_section_contents_in_window \
3751*3d8817e4Smiod _bfd_generic_get_section_contents_in_window
3752*3d8817e4Smiod #define ieee_bfd_get_relocated_section_contents \
3753*3d8817e4Smiod bfd_generic_get_relocated_section_contents
3754*3d8817e4Smiod #define ieee_bfd_relax_section bfd_generic_relax_section
3755*3d8817e4Smiod #define ieee_bfd_gc_sections bfd_generic_gc_sections
3756*3d8817e4Smiod #define ieee_bfd_merge_sections bfd_generic_merge_sections
3757*3d8817e4Smiod #define ieee_bfd_is_group_section bfd_generic_is_group_section
3758*3d8817e4Smiod #define ieee_bfd_discard_group bfd_generic_discard_group
3759*3d8817e4Smiod #define ieee_section_already_linked \
3760*3d8817e4Smiod _bfd_generic_section_already_linked
3761*3d8817e4Smiod #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
3762*3d8817e4Smiod #define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
3763*3d8817e4Smiod #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
3764*3d8817e4Smiod #define ieee_bfd_link_just_syms _bfd_generic_link_just_syms
3765*3d8817e4Smiod #define ieee_bfd_final_link _bfd_generic_final_link
3766*3d8817e4Smiod #define ieee_bfd_link_split_section _bfd_generic_link_split_section
3767*3d8817e4Smiod
3768*3d8817e4Smiod const bfd_target ieee_vec =
3769*3d8817e4Smiod {
3770*3d8817e4Smiod "ieee", /* Name. */
3771*3d8817e4Smiod bfd_target_ieee_flavour,
3772*3d8817e4Smiod BFD_ENDIAN_UNKNOWN, /* Target byte order. */
3773*3d8817e4Smiod BFD_ENDIAN_UNKNOWN, /* Target headers byte order. */
3774*3d8817e4Smiod (HAS_RELOC | EXEC_P | /* Object flags. */
3775*3d8817e4Smiod HAS_LINENO | HAS_DEBUG |
3776*3d8817e4Smiod HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
3777*3d8817e4Smiod (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
3778*3d8817e4Smiod | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
3779*3d8817e4Smiod '_', /* Leading underscore. */
3780*3d8817e4Smiod ' ', /* AR_pad_char. */
3781*3d8817e4Smiod 16, /* AR_max_namelen. */
3782*3d8817e4Smiod bfd_getb64, bfd_getb_signed_64, bfd_putb64,
3783*3d8817e4Smiod bfd_getb32, bfd_getb_signed_32, bfd_putb32,
3784*3d8817e4Smiod bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
3785*3d8817e4Smiod bfd_getb64, bfd_getb_signed_64, bfd_putb64,
3786*3d8817e4Smiod bfd_getb32, bfd_getb_signed_32, bfd_putb32,
3787*3d8817e4Smiod bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */
3788*3d8817e4Smiod
3789*3d8817e4Smiod {_bfd_dummy_target,
3790*3d8817e4Smiod ieee_object_p, /* bfd_check_format. */
3791*3d8817e4Smiod ieee_archive_p,
3792*3d8817e4Smiod _bfd_dummy_target,
3793*3d8817e4Smiod },
3794*3d8817e4Smiod {
3795*3d8817e4Smiod bfd_false,
3796*3d8817e4Smiod ieee_mkobject,
3797*3d8817e4Smiod _bfd_generic_mkarchive,
3798*3d8817e4Smiod bfd_false
3799*3d8817e4Smiod },
3800*3d8817e4Smiod {
3801*3d8817e4Smiod bfd_false,
3802*3d8817e4Smiod ieee_write_object_contents,
3803*3d8817e4Smiod _bfd_write_archive_contents,
3804*3d8817e4Smiod bfd_false,
3805*3d8817e4Smiod },
3806*3d8817e4Smiod
3807*3d8817e4Smiod /* ieee_close_and_cleanup, ieee_bfd_free_cached_info, ieee_new_section_hook,
3808*3d8817e4Smiod ieee_get_section_contents, ieee_get_section_contents_in_window. */
3809*3d8817e4Smiod BFD_JUMP_TABLE_GENERIC (ieee),
3810*3d8817e4Smiod
3811*3d8817e4Smiod BFD_JUMP_TABLE_COPY (_bfd_generic),
3812*3d8817e4Smiod BFD_JUMP_TABLE_CORE (_bfd_nocore),
3813*3d8817e4Smiod
3814*3d8817e4Smiod /* ieee_slurp_armap, ieee_slurp_extended_name_table,
3815*3d8817e4Smiod ieee_construct_extended_name_table, ieee_truncate_arname,
3816*3d8817e4Smiod ieee_write_armap, ieee_read_ar_hdr, ieee_openr_next_archived_file,
3817*3d8817e4Smiod ieee_get_elt_at_index, ieee_generic_stat_arch_elt,
3818*3d8817e4Smiod ieee_update_armap_timestamp. */
3819*3d8817e4Smiod BFD_JUMP_TABLE_ARCHIVE (ieee),
3820*3d8817e4Smiod
3821*3d8817e4Smiod /* ieee_get_symtab_upper_bound, ieee_canonicalize_symtab,
3822*3d8817e4Smiod ieee_make_empty_symbol, ieee_print_symbol, ieee_get_symbol_info,
3823*3d8817e4Smiod ieee_bfd_is_local_label_name, ieee_get_lineno,
3824*3d8817e4Smiod ieee_find_nearest_line, ieee_bfd_make_debug_symbol,
3825*3d8817e4Smiod ieee_read_minisymbols, ieee_minisymbol_to_symbol. */
3826*3d8817e4Smiod BFD_JUMP_TABLE_SYMBOLS (ieee),
3827*3d8817e4Smiod
3828*3d8817e4Smiod /* ieee_get_reloc_upper_bound, ieee_canonicalize_reloc,
3829*3d8817e4Smiod ieee_bfd_reloc_type_lookup. */
3830*3d8817e4Smiod BFD_JUMP_TABLE_RELOCS (ieee),
3831*3d8817e4Smiod
3832*3d8817e4Smiod /* ieee_set_arch_mach, ieee_set_section_contents. */
3833*3d8817e4Smiod BFD_JUMP_TABLE_WRITE (ieee),
3834*3d8817e4Smiod
3835*3d8817e4Smiod /* ieee_sizeof_headers, ieee_bfd_get_relocated_section_contents,
3836*3d8817e4Smiod ieee_bfd_relax_section, ieee_bfd_link_hash_table_create,
3837*3d8817e4Smiod _bfd_generic_link_hash_table_free,
3838*3d8817e4Smiod ieee_bfd_link_add_symbols, ieee_bfd_final_link,
3839*3d8817e4Smiod ieee_bfd_link_split_section, ieee_bfd_gc_sections,
3840*3d8817e4Smiod ieee_bfd_merge_sections. */
3841*3d8817e4Smiod BFD_JUMP_TABLE_LINK (ieee),
3842*3d8817e4Smiod
3843*3d8817e4Smiod BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
3844*3d8817e4Smiod
3845*3d8817e4Smiod NULL,
3846*3d8817e4Smiod
3847*3d8817e4Smiod NULL
3848*3d8817e4Smiod };
3849