1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
|
/* All the swapping routines:
*/
static void
DEFUN(swap_reloc_in,(abfd, reloc_src, reloc_dst),
bfd *abfd AND
RELOC *reloc_src AND
struct internal_reloc *reloc_dst)
{
reloc_dst->r_vaddr = bfd_h_getlong(abfd, reloc_src->r_vaddr);
reloc_dst->r_symndx = bfd_h_getlong(abfd, reloc_src->r_symndx);
reloc_dst->r_type = bfd_h_getshort(abfd, reloc_src->r_type);
#if M88
reloc_dst->r_offset = bfd_h_getshort(abfd, reloc_src->r_offset);
#endif
}
static void
DEFUN(swap_reloc_out,(abfd, reloc_src, reloc_dst),
bfd *abfd AND
struct internal_reloc *reloc_src AND
struct external_reloc *reloc_dst)
{
bfd_h_putlong(abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
bfd_h_putlong(abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
bfd_h_putshort(abfd, reloc_src->r_type, reloc_dst->r_type);
#if M88
bfd_h_putshort(abfd, reloc_src->r_offset, reloc_dst->r_offset);
#endif
}
static void
DEFUN(swap_filehdr_in,(abfd, filehdr_src, filehdr_dst),
bfd *abfd AND
FILHDR *filehdr_src AND
struct internal_filehdr *filehdr_dst)
{
filehdr_dst->f_magic = bfd_h_get_x(abfd, filehdr_src->f_magic);
filehdr_dst->f_nscns = bfd_h_get_x(abfd,filehdr_src-> f_nscns);
filehdr_dst->f_timdat = bfd_h_get_x(abfd,filehdr_src-> f_timdat);
filehdr_dst->f_symptr = bfd_h_get_x(abfd,filehdr_src-> f_symptr);
filehdr_dst->f_nsyms = bfd_h_get_x(abfd,filehdr_src-> f_nsyms);
filehdr_dst->f_opthdr = bfd_h_get_x(abfd,filehdr_src-> f_opthdr);
filehdr_dst->f_flags = bfd_h_get_x(abfd,filehdr_src-> f_flags);
}
static void
DEFUN(swap_filehdr_out,(abfd, filehdr_in, filehdr_out),
bfd *abfd AND
struct internal_filehdr *filehdr_in AND
FILHDR *filehdr_out)
{
bfd_h_put_x(abfd, filehdr_in->f_magic, filehdr_out->f_magic);
bfd_h_put_x(abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
bfd_h_put_x(abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
bfd_h_put_x(abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
bfd_h_put_x(abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
bfd_h_put_x(abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
bfd_h_put_x(abfd, filehdr_in->f_flags, filehdr_out->f_flags);
}
static void
DEFUN(bfd_coff_swap_sym_in,(abfd, ext, in),
bfd *abfd AND
SYMENT *ext AND
struct internal_syment *in)
{
if( ext->e.e_name[0] == 0) {
in->_n._n_n._n_zeroes = 0;
in->_n._n_n._n_offset = bfd_h_getlong(abfd, ext->e.e.e_offset);
}
else {
memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
}
in->n_value = bfd_h_get_x(abfd, ext->e_value);
in->n_scnum = bfd_h_get_x(abfd, ext->e_scnum);
in->n_type = bfd_h_get_x(abfd, ext->e_type);
in->n_sclass = bfd_h_get_x(abfd, ext->e_sclass);
in->n_numaux = bfd_h_get_x(abfd, ext->e_numaux);
}
static void
DEFUN(bfd_coff_swap_sym_out,(abfd,in, ext),
bfd *abfd AND
struct internal_syment *in AND
SYMENT *ext)
{
if(in->_n._n_name[0] == 0) {
bfd_h_putlong(abfd, 0, ext->e.e.e_zeroes);
bfd_h_putlong(abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
}
else {
memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
}
bfd_h_put_x(abfd, in->n_value , ext->e_value);
bfd_h_put_x(abfd, in->n_scnum , ext->e_scnum);
bfd_h_put_x(abfd, in->n_type , ext->e_type);
bfd_h_put_x(abfd, in->n_sclass , ext->e_sclass);
bfd_h_put_x(abfd, in->n_numaux , ext->e_numaux);
}
static void
DEFUN(bfd_coff_swap_aux_in,(abfd, ext, type, class, in),
bfd *abfd AND
AUXENT *ext AND
int type AND
int class AND
union internal_auxent *in)
{
switch (class) {
case C_FILE:
if (ext->x_file.x_fname[0] == 0) {
in->x_file.x_n.x_zeroes = 0;
in->x_file.x_n.x_offset = bfd_h_getlong(abfd, ext->x_file.x_n.x_offset);
}
break;
case C_STAT:
#ifdef C_LEAFSTAT
case C_LEAFSTAT:
#endif
case C_HIDDEN:
if (type == T_NULL) {
in->x_scn.x_scnlen = bfd_h_get_x(abfd, ext->x_scn.x_scnlen);
in->x_scn.x_nreloc = bfd_h_get_x(abfd, ext->x_scn.x_nreloc);
in->x_scn.x_nlinno = bfd_h_get_x(abfd, ext->x_scn.x_nlinno);
break;
}
default:
in->x_sym.x_tagndx = bfd_h_get_x(abfd, ext->x_sym.x_tagndx);
in->x_sym.x_tvndx = bfd_h_get_x(abfd, ext->x_sym.x_tvndx);
if (ISARY(type) || class == C_BLOCK) {
in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
else {
in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
in->x_sym.x_fcnary.x_fcn.x_endndx = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
}
if (ISFCN(type)) {
in->x_sym.x_misc.x_fsize = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_fsize);
}
else {
in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_lnno);
in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_size);
}
}
}
static void
DEFUN(bfd_coff_swap_aux_out,(abfd, in, type, class, ext),
bfd *abfd AND
union internal_auxent *in AND
int type AND
int class AND
AUXENT *ext)
{
switch (class) {
case C_FILE:
if (in->x_file.x_fname[0] == 0) {
bfd_h_put_x(abfd, 0, ext->x_file.x_n.x_zeroes );
bfd_h_put_x(abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
}
break;
case C_STAT:
#ifdef C_LEAFSTAT
case C_LEAFSTAT:
#endif
case C_HIDDEN:
if (type == T_NULL) {
bfd_h_put_x(abfd, in->x_scn.x_scnlen, ext->x_scn.x_scnlen);
bfd_h_put_x(abfd, in->x_scn.x_nreloc, ext->x_scn.x_nreloc);
bfd_h_put_x(abfd, in->x_scn.x_nlinno, ext->x_scn.x_nlinno);
break;
}
default:
bfd_h_put_x(abfd, in->x_sym.x_tagndx, ext->x_sym.x_tagndx);
bfd_h_put_x(abfd, in->x_sym.x_tvndx , ext->x_sym.x_tvndx);
if (ISARY(type) || class == C_BLOCK) {
bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
else {
bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx, ext->x_sym.x_fcnary.x_fcn.x_endndx);
}
if (ISFCN(type)) {
bfd_h_put_x(abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
}
else {
bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext->x_sym.x_misc.x_lnsz.x_lnno);
bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext->x_sym.x_misc.x_lnsz.x_size);
}
}
}
static void
DEFUN(bfd_coff_swap_lineno_in,(abfd, ext, in),
bfd *abfd AND
LINENO *ext AND
struct internal_lineno *in)
{
in->l_addr.l_symndx = bfd_h_get_x(abfd, ext->l_addr.l_symndx);
in->l_lnno = bfd_h_get_x(abfd, ext->l_lnno);
}
static void
DEFUN(bfd_coff_swap_lineno_out,(abfd, in, ext),
bfd *abfd AND
struct internal_lineno *in AND
struct external_lineno *ext)
{
bfd_h_put_x(abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
bfd_h_put_x(abfd, in->l_lnno, ext->l_lnno);
}
static void
DEFUN(swap_aouthdr_in,(abfd, aouthdr_ext, aouthdr_int),
bfd *abfd AND
AOUTHDR *aouthdr_ext AND
struct internal_aouthdr *aouthdr_int)
{
aouthdr_int->magic = bfd_h_get_x(abfd, aouthdr_ext->magic);
aouthdr_int->vstamp = bfd_h_get_x(abfd, aouthdr_ext->vstamp);
aouthdr_int->tsize = bfd_h_get_x(abfd, aouthdr_ext->tsize);
aouthdr_int->dsize = bfd_h_get_x(abfd, aouthdr_ext->dsize);
aouthdr_int->bsize = bfd_h_get_x(abfd, aouthdr_ext->bsize);
aouthdr_int->entry = bfd_h_get_x(abfd, aouthdr_ext->entry);
aouthdr_int->text_start = bfd_h_get_x(abfd, aouthdr_ext->text_start);
aouthdr_int->data_start = bfd_h_get_x(abfd, aouthdr_ext->data_start);
#ifdef I960
aouthdr_int->tagentries = bfd_h_get_x(abfd, aouthdr_ext->tagentries);
#endif
}
static void
DEFUN(swap_aouthdr_out,(abfd, aouthdr_in, aouthdr_out),
bfd *abfd AND
struct internal_aouthdr *aouthdr_in AND
AOUTHDR *aouthdr_out)
{
bfd_h_put_x(abfd, aouthdr_in->magic, aouthdr_out->magic);
bfd_h_put_x(abfd, aouthdr_in->vstamp, aouthdr_out->vstamp);
bfd_h_put_x(abfd, aouthdr_in->tsize, aouthdr_out->tsize);
bfd_h_put_x(abfd, aouthdr_in->dsize, aouthdr_out->dsize);
bfd_h_put_x(abfd, aouthdr_in->bsize, aouthdr_out->bsize);
bfd_h_put_x(abfd, aouthdr_in->entry, aouthdr_out->entry);
bfd_h_put_x(abfd, aouthdr_in->text_start, aouthdr_out->text_start);
bfd_h_put_x(abfd, aouthdr_in->data_start, aouthdr_out->data_start);
#ifdef I960
bfd_h_put_x(abfd, aouthdr_in->tagentries, aouthdr_out->tagentries);
#endif
}
static void
DEFUN(swap_scnhdr_in,(abfd, scnhdr_ext, scnhdr_int),
bfd *abfd AND
SCNHDR *scnhdr_ext AND
struct internal_scnhdr *scnhdr_int)
{
memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
scnhdr_int->s_vaddr = bfd_h_get_x(abfd, scnhdr_ext->s_vaddr);
scnhdr_int->s_paddr = bfd_h_get_x(abfd, scnhdr_ext->s_paddr);
scnhdr_int->s_size = bfd_h_get_x(abfd, scnhdr_ext->s_size);
scnhdr_int->s_scnptr = bfd_h_get_x(abfd, scnhdr_ext->s_scnptr);
scnhdr_int->s_relptr = bfd_h_get_x(abfd, scnhdr_ext->s_relptr);
scnhdr_int->s_lnnoptr = bfd_h_get_x(abfd, scnhdr_ext->s_lnnoptr);
scnhdr_int->s_nreloc = bfd_h_get_x(abfd, scnhdr_ext->s_nreloc);
scnhdr_int->s_nlnno = bfd_h_get_x(abfd, scnhdr_ext->s_nlnno);
scnhdr_int->s_flags = bfd_h_get_x(abfd, scnhdr_ext->s_flags);
#ifdef I960
scnhdr_int->s_align = bfd_h_get_x(abfd, scnhdr_ext->s_align);
#endif
}
static void
DEFUN(swap_scnhdr_out,(abfd, scnhdr_int, scnhdr_ext),
bfd *abfd AND
struct internal_scnhdr *scnhdr_int AND
SCNHDR *scnhdr_ext)
{
memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
bfd_h_put_x(abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr);
bfd_h_put_x(abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr);
bfd_h_put_x(abfd, scnhdr_int->s_size, scnhdr_ext->s_size);
bfd_h_put_x(abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr);
bfd_h_put_x(abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr);
bfd_h_put_x(abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr);
bfd_h_put_x(abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
bfd_h_put_x(abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
bfd_h_put_x(abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
#ifdef I960
bfd_h_put_x(abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
#endif
}
/*
initialize a section structure with information peculiar to this
particular implementation of coff
*/
static boolean
DEFUN(coff_new_section_hook,(abfd_ignore, section_ignore),
bfd *abfd_ignore AND
asection *section_ignore)
{
#ifdef MC88MAGIC
/* FIXME, shouldn't this ifdef be on something that says we are
actually COMPILING FOR an 88K coff file, rather than simply
knowing its magic number? */
/* Align to at least 16 bytes */
section_ignore->alignment_power = 4;
#endif
#if M68
section_ignore->alignment_power = 3;
#endif
return true;
}
/* Take a section header read from a coff file (in HOST byte order),
and make a BFD "section" out of it. */
static boolean
DEFUN(make_a_section_from_file,(abfd, hdr),
bfd *abfd AND
struct internal_scnhdr *hdr)
{
asection *return_section;
{
/* Assorted wastage to null-terminate the name, thanks AT&T! */
char *name = bfd_alloc(abfd, sizeof (hdr->s_name)+1);
if (name == NULL) {
bfd_error = no_memory;
return false;
}
strncpy(name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
name[sizeof (hdr->s_name)] = 0;
return_section = bfd_make_section(abfd, name);
}
/* s_paddr is presumed to be = to s_vaddr */
#define assign(to, from) return_section->to = hdr->from
assign(vma, s_vaddr);
/* assign (vma, s_vaddr); */
assign(size, s_size);
assign(filepos, s_scnptr);
assign(rel_filepos, s_relptr);
assign(reloc_count, s_nreloc);
#ifdef I960
{
/* FIXME, use a temp var rather than alignment_power */
assign(alignment_power, s_align);
{
unsigned int i;
for (i = 0; i < 32; i++) {
if ((1 << i) >= (int) (return_section->alignment_power)) {
return_section->alignment_power = i;
break;
}
}
}
}
#endif
assign(line_filepos, s_lnnoptr);
/*
return_section->linesize = hdr->s_nlnno * sizeof (struct lineno);
*/
#undef assign
return_section->lineno_count = hdr->s_nlnno;
return_section->userdata = NULL;
return_section->next = (asection *) NULL;
if ((hdr->s_flags & STYP_TEXT) || (hdr->s_flags & STYP_DATA))
return_section->flags = (SEC_LOAD | SEC_ALLOC);
else if (hdr->s_flags & STYP_BSS)
return_section->flags = SEC_ALLOC;
if (hdr->s_nreloc != 0)
return_section->flags |= SEC_RELOC;
if (hdr->s_scnptr != 0)
return_section->flags |= SEC_HAS_CONTENTS;
return true;
}
static boolean
DEFUN(coff_mkobject,(abfd),
bfd *abfd)
{
set_tdata (abfd, bfd_zalloc (abfd,sizeof(coff_data_type)));
if (coff_data(abfd) == 0) {
bfd_error = no_memory;
return false;
}
coff_data(abfd)->relocbase = 0;
return true;
}
static
bfd_target *
DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a),
bfd *abfd AND
unsigned nscns AND
struct internal_filehdr *internal_f AND
struct internal_aouthdr *internal_a)
{
coff_data_type *coff;
size_t readsize; /* length of file_info */
SCNHDR *external_sections;
/* Build a play area */
if (coff_mkobject(abfd) != true)
return 0;
coff = coff_data(abfd);
external_sections = (SCNHDR *)bfd_alloc(abfd, readsize = (nscns * SCNHSZ));
if (bfd_read((PTR)external_sections, 1, readsize, abfd) != readsize) {
goto fail;
}
/* Now copy data as required; construct all asections etc */
coff->symbol_index_slew = 0;
coff->relocbase =0;
coff->raw_syment_count = 0;
coff->raw_linenos = 0;
coff->raw_syments = 0;
coff->sym_filepos =0;
coff->flags = internal_f->f_flags;
if (nscns != 0) {
unsigned int i;
for (i = 0; i < nscns; i++) {
struct internal_scnhdr tmp;
swap_scnhdr_in(abfd, external_sections + i, &tmp);
make_a_section_from_file(abfd,&tmp);
}
}
/* Determine the machine architecture and type. */
abfd->obj_machine = 0;
switch (internal_f->f_magic) {
#ifdef MIPS
#ifdef MIPSEBMAGIC
case SMIPSEBMAGIC:
case SMIPSELMAGIC:
case MIPSEBUMAGIC:
case MIPSELUMAGIC:
case MIPSEBMAGIC:
case MIPSELMAGIC:
abfd->obj_arch = bfd_arch_mips;
abfd->obj_machine = 0;
break;
#endif
#endif
#ifdef MC68MAGIC
case MC68MAGIC:
case M68MAGIC:
abfd->obj_arch = bfd_arch_m68k;
abfd->obj_machine = 68020;
break;
#endif
#ifdef MC88MAGIC
case MC88MAGIC:
case MC88DMAGIC:
case MC88OMAGIC:
abfd->obj_arch = bfd_arch_m88k;
abfd->obj_machine = 88100;
break;
#endif
#ifdef I960
#ifdef I960ROMAGIC
case I960ROMAGIC:
case I960RWMAGIC:
abfd->obj_arch = bfd_arch_i960;
switch (F_I960TYPE & internal_f->f_flags)
{
default:
case F_I960CORE:
abfd->obj_machine = bfd_mach_i960_core;
break;
case F_I960KB:
abfd->obj_machine = bfd_mach_i960_kb_sb;
break;
case F_I960MC:
abfd->obj_machine = bfd_mach_i960_mc;
break;
case F_I960XA:
abfd->obj_machine = bfd_mach_i960_xa;
break;
case F_I960CA:
abfd->obj_machine = bfd_mach_i960_ca;
break;
case F_I960KA:
abfd->obj_machine = bfd_mach_i960_ka_sa;
break;
}
break;
#endif
#endif
default: /* Unreadable input file type */
abfd->obj_arch = bfd_arch_obscure;
break;
}
if (!(internal_f->f_flags & F_RELFLG))
abfd->flags |= HAS_RELOC;
if ((internal_f->f_flags & F_EXEC))
abfd->flags |= EXEC_P;
if (!(internal_f->f_flags & F_LNNO))
abfd->flags |= HAS_LINENO;
if (!(internal_f->f_flags & F_LSYMS))
abfd->flags |= HAS_LOCALS;
bfd_get_symcount(abfd) = internal_f->f_nsyms;
if (internal_f->f_nsyms)
abfd->flags |= HAS_SYMS;
coff->sym_filepos = internal_f->f_symptr;
coff->symbols = (coff_symbol_type *) NULL;
bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0;
return abfd->xvec;
fail:
bfd_release(abfd, coff);
return (bfd_target *)NULL;
}
static bfd_target *
DEFUN(coff_object_p,(abfd),
bfd *abfd)
{
int nscns;
FILHDR filehdr;
AOUTHDR opthdr;
struct internal_filehdr internal_f;
struct internal_aouthdr internal_a;
bfd_error = system_call_error;
/* figure out how much to read */
if (bfd_read((PTR) &filehdr, 1, FILHSZ, abfd) != FILHSZ)
return 0;
swap_filehdr_in(abfd, &filehdr, &internal_f);
if (BADMAG(internal_f)) {
bfd_error = wrong_format;
return 0;
}
nscns =internal_f.f_nscns;
if (internal_f.f_opthdr) {
if (bfd_read((PTR) &opthdr, 1,AOUTSZ, abfd) != AOUTSZ) {
return 0;
}
swap_aouthdr_in(abfd, &opthdr, &internal_a);
}
/* Seek past the opt hdr stuff */
bfd_seek(abfd, internal_f.f_opthdr + FILHSZ, SEEK_SET);
/* if the optional header is NULL or not the correct size then
quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
and Intel 960 readwrite headers (I960WRMAGIC) is that the
optional header is of a different size.
But the mips keeps extra stuff in it's opthdr, so dont check
when doing that
*/
#ifndef MIPS
if (internal_f.f_opthdr != 0 && AOUTSZ != internal_f.f_opthdr)
return (bfd_target *)NULL;
#endif
return coff_real_object_p(abfd, nscns, &internal_f, &internal_a);
}
|