first cut at new maybe-64bit-handling configuration
[deliverable/binutils-gdb.git] / bfd / oasys.c
CommitLineData
3039e8ee 1/* BFD back-end for oasys objects.
8feff717 2 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3039e8ee 3 Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
87f86b4e 4
c618de01 5This file is part of BFD, the Binary File Descriptor library.
87f86b4e 6
c618de01 7This program is free software; you can redistribute it and/or modify
1e6d5d30 8it under the terms of the GNU General Public License as published by
c618de01
SC
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
87f86b4e 11
c618de01 12This program is distributed in the hope that it will be useful,
1e6d5d30
JG
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
87f86b4e 16
1e6d5d30 17You should have received a copy of the GNU General Public License
c618de01
SC
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
87f86b4e 20
1e6d5d30 21#define UNDERSCORE_HACK 1
87f86b4e 22#include "bfd.h"
e98e6ec1 23#include "sysdep.h"
87f86b4e 24#include "libbfd.h"
87f86b4e
DHW
25#include "oasys.h"
26#include "liboasys.h"
6f715d66 27
fb3be09b
JG
28/* XXX - FIXME. offsetof belongs in the system-specific files in
29 ../include/sys. */
5e4953bc
SG
30/* Define offsetof for those systems which lack it */
31
32#ifndef offsetof
33#define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier)
34#endif
6f715d66
SC
35
36/* Read in all the section data and relocation stuff too */
37PROTO(static boolean,oasys_slurp_section_data,(bfd *CONST abfd));
38
3e9aade1
SC
39static void
40DEFUN(oasys_read_record,(abfd, record),
41 bfd *CONST abfd AND
87f86b4e
DHW
42 oasys_record_union_type *record)
43{
44
d0ec7a8e 45 bfd_read((PTR)record, 1, sizeof(record->header), abfd);
87f86b4e 46
6f48f7f1
JK
47 if ((size_t) record->header.length <= (size_t) sizeof (record->header))
48 return;
d0ec7a8e 49 bfd_read((PTR)(((char *)record )+ sizeof(record->header)),
87f86b4e
DHW
50 1, record->header.length - sizeof(record->header),
51 abfd);
52}
53static size_t
3e9aade1
SC
54DEFUN(oasys_string_length,(record),
55 oasys_record_union_type *record)
87f86b4e
DHW
56{
57return record->header.length
58 - ((char *)record->symbol.name - (char *)record);
59}
60
61/*****************************************************************************/
62
63/*
64
65Slurp the symbol table by reading in all the records at the start file
66till we get to the first section record.
67
3e9aade1
SC
68We'll sort the symbolss into two lists, defined and undefined. The
69undefined symbols will be placed into the table according to their
70refno.
71
72We do this by placing all undefined symbols at the front of the table
73moving in, and the defined symbols at the end of the table moving back.
87f86b4e
DHW
74
75*/
76
77static boolean
3e9aade1
SC
78DEFUN(oasys_slurp_symbol_table,(abfd),
79 bfd * CONST abfd)
87f86b4e
DHW
80{
81 oasys_record_union_type record;
e98e6ec1 82 oasys_data_type *data = OASYS_DATA(abfd);
87f86b4e 83 boolean loop = true;
87f86b4e
DHW
84 asymbol *dest_defined;
85 asymbol *dest;
86 char *string_ptr;
87
88
89 if (data->symbols != (asymbol *)NULL) {
90 return true;
91 }
92 /* Buy enough memory for all the symbols and all the names */
93 data->symbols =
9872a49c 94 (asymbol *)bfd_alloc(abfd, sizeof(asymbol) * abfd->symcount);
de7c1ff6
SC
95#ifdef UNDERSCORE_HACK
96 /* buy 1 more char for each symbol to keep the underscore in*/
9872a49c 97 data->strings = bfd_alloc(abfd, data->symbol_string_length +
d0ec7a8e 98 abfd->symcount);
de7c1ff6 99#else
9872a49c 100 data->strings = bfd_alloc(abfd, data->symbol_string_length);
de7c1ff6 101#endif
87f86b4e 102
d0ec7a8e 103
87f86b4e
DHW
104 dest_defined = data->symbols + abfd->symcount -1;
105
106 string_ptr = data->strings;
107 bfd_seek(abfd, (file_ptr)0, SEEK_SET);
108 while (loop) {
de7c1ff6 109
87f86b4e
DHW
110 oasys_read_record(abfd, &record);
111 switch (record.header.type) {
112 case oasys_record_is_header_enum:
113 break;
114 case oasys_record_is_local_enum:
115 case oasys_record_is_symbol_enum:
116 {
e98e6ec1 117 int flag = record.header.type == (int)oasys_record_is_local_enum ?
de7c1ff6
SC
118 (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
119
120
87f86b4e 121 size_t length = oasys_string_length(&record);
3e9aade1 122 switch (record.symbol.relb & RELOCATION_TYPE_BITS) {
87f86b4e
DHW
123 case RELOCATION_TYPE_ABS:
124 dest = dest_defined--;
e98e6ec1
SC
125 dest->section = &bfd_abs_section;
126 dest->flags = 0;
127
87f86b4e
DHW
128 break;
129 case RELOCATION_TYPE_REL:
130 dest = dest_defined--;
131 dest->section =
e98e6ec1 132 OASYS_DATA(abfd)->sections[record.symbol.relb &
87f86b4e 133 RELOCATION_SECT_BITS];
e98e6ec1 134 if (record.header.type == (int)oasys_record_is_local_enum)
87f86b4e 135 {
de7c1ff6 136 dest->flags = BSF_LOCAL;
6f715d66
SC
137 if (dest->section ==(asection *)(~0)) {
138 /* It seems that sometimes internal symbols are tied up, but
139 still get output, even though there is no
140 section */
141 dest->section = 0;
142 }
87f86b4e
DHW
143 }
144 else {
145
de7c1ff6 146 dest->flags = flag;
87f86b4e
DHW
147 }
148 break;
149 case RELOCATION_TYPE_UND:
7ed4093a 150 dest = data->symbols + bfd_h_get_16(abfd, (bfd_byte *)&record.symbol.refno[0]);
e98e6ec1 151 dest->section = &bfd_und_section;
87f86b4e
DHW
152 break;
153 case RELOCATION_TYPE_COM:
154 dest = dest_defined--;
155 dest->name = string_ptr;
156 dest->the_bfd = abfd;
157
e98e6ec1
SC
158 dest->section = &bfd_com_section;
159
87f86b4e 160 break;
8cc8fd69
SG
161 default:
162 dest = dest_defined--;
163 BFD_ASSERT(0);
164 break;
87f86b4e
DHW
165 }
166 dest->name = string_ptr;
167 dest->the_bfd = abfd;
3e9aade1 168 dest->udata = (PTR)NULL;
c618de01 169 dest->value = bfd_h_get_32(abfd, (bfd_byte *)&record.symbol.value[0]);
3e9aade1
SC
170
171#ifdef UNDERSCORE_HACK
172 if (record.symbol.name[0] != '_') {
173 string_ptr[0] = '_';
174 string_ptr++;
175 }
de7c1ff6 176#endif
87f86b4e 177 memcpy(string_ptr, record.symbol.name, length);
de7c1ff6
SC
178
179
87f86b4e
DHW
180 string_ptr[length] =0;
181 string_ptr += length +1;
182 }
183 break;
184 default:
185 loop = false;
186 }
187 }
188 return true;
87f86b4e
DHW
189}
190
d0ec7a8e 191static unsigned int
3e9aade1
SC
192DEFUN(oasys_get_symtab_upper_bound,(abfd),
193 bfd *CONST abfd)
87f86b4e
DHW
194{
195 oasys_slurp_symbol_table (abfd);
196
de7c1ff6 197 return (abfd->symcount+1) * (sizeof (oasys_symbol_type *));
87f86b4e
DHW
198}
199
200/*
201*/
202
203extern bfd_target oasys_vec;
204
205unsigned int
3e9aade1
SC
206DEFUN(oasys_get_symtab,(abfd, location),
207 bfd *abfd AND
208 asymbol **location)
87f86b4e
DHW
209{
210 asymbol *symbase ;
211 unsigned int counter ;
212 if (oasys_slurp_symbol_table(abfd) == false) {
213 return 0;
214 }
e98e6ec1 215 symbase = OASYS_DATA(abfd)->symbols;
87f86b4e
DHW
216 for (counter = 0; counter < abfd->symcount; counter++) {
217 *(location++) = symbase++;
218 }
219 *location = 0;
220 return abfd->symcount;
221}
222
223/***********************************************************************
224* archive stuff
225*/
4b3720f4 226
3e9aade1
SC
227static bfd_target *
228DEFUN(oasys_archive_p,(abfd),
229 bfd *abfd)
87f86b4e
DHW
230{
231 oasys_archive_header_type header;
c618de01 232 oasys_extarchive_header_type header_ext;
87f86b4e 233 unsigned int i;
357a1f38 234 file_ptr filepos;
87f86b4e
DHW
235 bfd_seek(abfd, (file_ptr) 0, false);
236
237
8e3c8f47 238 bfd_read((PTR)&header_ext, 1, sizeof(header_ext), abfd);
87f86b4e 239
8e3c8f47 240
c618de01
SC
241 header.version = bfd_h_get_32(abfd, (bfd_byte *)header_ext.version);
242 header.mod_count = bfd_h_get_32(abfd, (bfd_byte *)header_ext.mod_count);
243 header.mod_tbl_offset = bfd_h_get_32(abfd, (bfd_byte *)header_ext.mod_tbl_offset);
244 header.sym_tbl_size = bfd_h_get_32(abfd, (bfd_byte *)header_ext.sym_tbl_size);
245 header.sym_count = bfd_h_get_32(abfd, (bfd_byte *)header_ext.sym_count);
246 header.sym_tbl_offset = bfd_h_get_32(abfd, (bfd_byte *)header_ext.sym_tbl_offset);
247 header.xref_count = bfd_h_get_32(abfd, (bfd_byte *)header_ext.xref_count);
248 header.xref_lst_offset = bfd_h_get_32(abfd, (bfd_byte *)header_ext.xref_lst_offset);
87f86b4e
DHW
249
250 /*
8e3c8f47
SC
251 There isn't a magic number in an Oasys archive, so the best we
252 can do to verify reasnableness is to make sure that the values in
253 the header are too weird
254 */
87f86b4e
DHW
255
256 if (header.version>10000 ||
257 header.mod_count>10000 ||
258 header.sym_count>100000 ||
259 header.xref_count > 100000) return (bfd_target *)NULL;
260
261 /*
8e3c8f47
SC
262 That all worked, lets buy the space for the header and read in
263 the headers.
264 */
265 {
266 oasys_ar_data_type *ar =
267 (oasys_ar_data_type*) bfd_alloc(abfd, sizeof(oasys_ar_data_type));
268
269
270 oasys_module_info_type *module =
271 (oasys_module_info_type*)
272 bfd_alloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
273
357a1f38 274
8e3c8f47 275 oasys_module_table_type record;
6f715d66 276
8e3c8f47 277
e98e6ec1 278 abfd->tdata.oasys_ar_data = ar;
8e3c8f47
SC
279 ar->module = module;
280 ar->module_count = header.mod_count;
281
357a1f38
SC
282
283 filepos = header.mod_tbl_offset;
8e3c8f47 284 for (i = 0; i < header.mod_count; i++) {
f8e01940 285 bfd_seek(abfd, filepos, SEEK_SET);
6f715d66
SC
286
287 /* There are two ways of specifying the archive header */
288
289 if (0) {
c618de01 290 oasys_extmodule_table_type_a_type record_ext;
6f715d66 291 bfd_read((PTR)&record_ext, 1, sizeof(record_ext), abfd);
8e3c8f47 292
c618de01 293 record.mod_size = bfd_h_get_32(abfd, (bfd_byte *)record_ext.mod_size);
6f715d66 294 record.file_offset = bfd_h_get_32(abfd,
c618de01 295 (bfd_byte *) record_ext.file_offset);
6f715d66 296
c618de01
SC
297 record.dep_count = bfd_h_get_32(abfd, (bfd_byte *)record_ext.dep_count);
298 record.depee_count = bfd_h_get_32(abfd,(bfd_byte *) record_ext.depee_count);
299 record.sect_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.sect_count);
357a1f38 300
357a1f38 301
6f715d66 302 module[i].name = bfd_alloc(abfd,33);
357a1f38 303
6f715d66
SC
304 memcpy(module[i].name, record_ext.mod_name, 33);
305 filepos +=
306 sizeof(record_ext) +
307 record.dep_count * 4 +
308 record.depee_count * 4 +
309 record.sect_count * 8 + 187;
310 }
311 else {
c618de01 312 oasys_extmodule_table_type_b_type record_ext;
6f715d66
SC
313 bfd_read((PTR)&record_ext, 1, sizeof(record_ext), abfd);
314
c618de01 315 record.mod_size = bfd_h_get_32(abfd, (bfd_byte *) record_ext.mod_size);
6f715d66 316 record.file_offset = bfd_h_get_32(abfd,
c618de01 317 (bfd_byte *)record_ext.file_offset);
6f715d66 318
c618de01
SC
319 record.dep_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.dep_count);
320 record.depee_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.depee_count);
321 record.sect_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.sect_count);
322 record.module_name_size = bfd_h_get_32(abfd, (bfd_byte *) record_ext.mod_name_length);
6f715d66
SC
323
324 module[i].name = bfd_alloc(abfd,record.module_name_size + 1);
325 bfd_read((PTR)module[i].name, 1, record.module_name_size, abfd);
326 module[i].name[record.module_name_size] = 0;
327 filepos +=
328 sizeof(record_ext) +
329 record.dep_count * 4 +
330 record.module_name_size + 1;
8e3c8f47 331
6f715d66 332 }
8e3c8f47 333
8e3c8f47
SC
334
335 module[i].size = record.mod_size;
336 module[i].pos = record.file_offset;
357a1f38 337 module[i].abfd = 0;
8e3c8f47 338 }
87f86b4e 339
8e3c8f47 340 }
87f86b4e
DHW
341 return abfd->xvec;
342}
343
3e9aade1
SC
344static boolean
345DEFUN(oasys_mkobject,(abfd),
346 bfd *abfd)
87f86b4e 347{
9872a49c 348
e98e6ec1 349 abfd->tdata.oasys_obj_data = (oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type));
3e9aade1
SC
350 return true;
351}
87f86b4e 352
3e9aade1
SC
353#define MAX_SECS 16
354static bfd_target *
355DEFUN(oasys_object_p,(abfd),
356 bfd *abfd)
357{
358 oasys_data_type *oasys;
e98e6ec1 359 oasys_data_type *save = OASYS_DATA(abfd);
87f86b4e 360 boolean loop = true;
87f86b4e 361 boolean had_usefull = false;
1e6d5d30 362
e98e6ec1 363 abfd->tdata.oasys_obj_data = 0;
3e9aade1 364 oasys_mkobject(abfd);
e98e6ec1 365 oasys = OASYS_DATA(abfd);
3e9aade1 366 memset((PTR)oasys->sections, 0xff, sizeof(oasys->sections));
87f86b4e
DHW
367
368 /* Point to the start of the file */
369 bfd_seek(abfd, (file_ptr)0, SEEK_SET);
3e9aade1 370 oasys->symbol_string_length = 0;
87f86b4e
DHW
371 /* Inspect the records, but only keep the section info -
372 remember the size of the symbols
373 */
3e9aade1 374 oasys->first_data_record = 0;
87f86b4e
DHW
375 while (loop) {
376 oasys_record_union_type record;
377 oasys_read_record(abfd, &record);
301dfc71 378 if ((size_t)record.header.length < (size_t)sizeof(record.header))
3e9aade1
SC
379 goto fail;
380
87f86b4e
DHW
381
382 switch ((oasys_record_enum_type)(record.header.type)) {
383 case oasys_record_is_header_enum:
384 had_usefull = true;
385 break;
386 case oasys_record_is_symbol_enum:
387 case oasys_record_is_local_enum:
388 /* Count symbols and remember their size for a future malloc */
389 abfd->symcount++;
3e9aade1 390 oasys->symbol_string_length += 1 + oasys_string_length(&record);
87f86b4e
DHW
391 had_usefull = true;
392 break;
393 case oasys_record_is_section_enum:
3e9aade1
SC
394 {
395 asection *s;
396 char *buffer;
397 unsigned int section_number;
398 if (record.section.header.length != sizeof(record.section))
399 {
400 goto fail;
401 }
9872a49c 402 buffer = bfd_alloc(abfd, 3);
3e9aade1
SC
403 section_number= record.section.relb & RELOCATION_SECT_BITS;
404 sprintf(buffer,"%u", section_number);
405 s = bfd_make_section(abfd,buffer);
406 oasys->sections[section_number] = s;
407 switch (record.section.relb & RELOCATION_TYPE_BITS) {
408 case RELOCATION_TYPE_ABS:
409 case RELOCATION_TYPE_REL:
410 break;
411 case RELOCATION_TYPE_UND:
412 case RELOCATION_TYPE_COM:
413 BFD_FAIL();
87f86b4e 414 }
87f86b4e 415
e98e6ec1 416 s->_raw_size = bfd_h_get_32(abfd, (bfd_byte *) & record.section.value[0]) ;
c618de01 417 s->vma = bfd_h_get_32(abfd, (bfd_byte *)&record.section.vma[0]);
6f715d66 418 s->flags= 0;
3e9aade1
SC
419 had_usefull = true;
420 }
87f86b4e
DHW
421 break;
422 case oasys_record_is_data_enum:
3e9aade1 423 oasys->first_data_record = bfd_tell(abfd) - record.header.length;
87f86b4e
DHW
424 case oasys_record_is_debug_enum:
425 case oasys_record_is_module_enum:
426 case oasys_record_is_named_section_enum:
427 case oasys_record_is_end_enum:
3e9aade1 428 if (had_usefull == false) goto fail;
87f86b4e
DHW
429 loop = false;
430 break;
431 default:
3e9aade1 432 goto fail;
87f86b4e
DHW
433 }
434 }
87f86b4e
DHW
435 oasys->symbols = (asymbol *)NULL;
436 /*
3e9aade1
SC
437 Oasys support several architectures, but I can't see a simple way
438 to discover which one is in a particular file - we'll guess
439 */
e98e6ec1 440 bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0);
87f86b4e
DHW
441 if (abfd->symcount != 0) {
442 abfd->flags |= HAS_SYMS;
443 }
6f715d66
SC
444
445 /*
446 We don't know if a section has data until we've read it..
447 */
448
449 oasys_slurp_section_data(abfd);
450
451
87f86b4e 452 return abfd->xvec;
3e9aade1
SC
453
454 fail:
9872a49c 455 (void) bfd_release(abfd, oasys);
e98e6ec1 456 abfd->tdata.oasys_obj_data = save;
3e9aade1 457 return (bfd_target *)NULL;
87f86b4e
DHW
458}
459
460
3e9aade1 461static void
2b1d8a50 462DEFUN(oasys_print_symbol,(ignore_abfd, afile, symbol, how),
3e9aade1 463 bfd *ignore_abfd AND
2b1d8a50 464 PTR afile AND
3e9aade1 465 asymbol *symbol AND
e98e6ec1 466 bfd_print_symbol_type how)
87f86b4e 467{
2b1d8a50
JG
468 FILE *file = (FILE *)afile;
469
87f86b4e 470 switch (how) {
e98e6ec1
SC
471 case bfd_print_symbol_name:
472 case bfd_print_symbol_more:
87f86b4e
DHW
473 fprintf(file,"%s", symbol->name);
474 break;
e98e6ec1
SC
475 case bfd_print_symbol_all:
476 case bfd_print_symbol_nm:
87f86b4e 477 {
e98e6ec1
SC
478 CONST char *section_name = symbol->section == (asection *)NULL ?
479 (CONST char *) "*abs" : symbol->section->name;
87f86b4e 480
3e9aade1 481 bfd_print_symbol_vandf((PTR)file,symbol);
87f86b4e
DHW
482
483 fprintf(file," %-5s %s",
484 section_name,
485 symbol->name);
486 }
487 break;
488 }
489}
490/*
491 The howto table is build using the top two bits of a reloc byte to
492 index into it. The bits are PCREL,WORD/LONG
493*/
494static reloc_howto_type howto_table[]=
495{
87f86b4e 496
4cddd1c9
SC
497HOWTO( 0, 0, 1, 16, false,0, true,true,0,"abs16",true,0x0000ffff, 0x0000ffff,false),
498HOWTO( 0, 0, 2, 32, false,0, true,true,0,"abs32",true,0xffffffff, 0xffffffff,false),
499HOWTO( 0, 0, 1, 16, true,0, true,true,0,"pcrel16",true,0x0000ffff, 0x0000ffff,false),
500HOWTO( 0, 0, 2, 32, true,0, true,true,0,"pcrel32",true,0xffffffff, 0xffffffff,false)
87f86b4e
DHW
501};
502
503/* Read in all the section data and relocation stuff too */
3e9aade1
SC
504static boolean
505DEFUN(oasys_slurp_section_data,(abfd),
506 bfd *CONST abfd)
87f86b4e
DHW
507{
508 oasys_record_union_type record;
e98e6ec1 509 oasys_data_type *data = OASYS_DATA(abfd);
87f86b4e
DHW
510 boolean loop = true;
511
512 oasys_per_section_type *per ;
513
514 asection *s;
515
6f715d66 516 /* See if the data has been slurped already .. */
87f86b4e
DHW
517 for (s = abfd->sections; s != (asection *)NULL; s= s->next) {
518 per = oasys_per_section(s);
6f715d66
SC
519 if (per->initialized == true)
520 return true;
87f86b4e
DHW
521 }
522
de7c1ff6 523 if (data->first_data_record == 0) return true;
6f715d66 524
87f86b4e
DHW
525 bfd_seek(abfd, data->first_data_record, SEEK_SET);
526 while (loop) {
527 oasys_read_record(abfd, &record);
6f715d66 528 switch (record.header.type)
de7c1ff6 529 {
6f715d66
SC
530 case oasys_record_is_header_enum:
531 break;
532 case oasys_record_is_data_enum:
533 {
534
535 uint8e_type *src = record.data.data;
536 uint8e_type *end_src = ((uint8e_type *)&record) +
537 record.header.length;
538 unsigned int relbit;
539 bfd_byte *dst_ptr ;
540 bfd_byte *dst_base_ptr ;
541 unsigned int count;
542 asection * section =
543 data->sections[record.data.relb & RELOCATION_SECT_BITS];
544 bfd_vma dst_offset ;
545 per = oasys_per_section(section);
546
547
548 if (per->initialized == false)
549 {
e98e6ec1 550 per->data = (bfd_byte *) bfd_zalloc(abfd, section->_raw_size);
6f715d66
SC
551 per->reloc_tail_ptr = (oasys_reloc_type **)&(section->relocation);
552 per->had_vma = false;
553 per->initialized = true;
554 section->reloc_count = 0;
555 section->flags = SEC_ALLOC;
556 }
87f86b4e 557
6f715d66
SC
558 dst_offset = bfd_h_get_32(abfd, record.data.addr) ;
559 if (per->had_vma == false) {
560 /* Take the first vma we see as the base */
3e9aade1 561
6f715d66
SC
562 section->vma = dst_offset;
563 per->had_vma = true;
564 }
3e9aade1 565
dcf22de9 566
6f715d66 567 dst_offset -= section->vma;
dcf22de9 568
6f715d66
SC
569
570 dst_base_ptr = oasys_per_section(section)->data;
571 dst_ptr = oasys_per_section(section)->data +
572 dst_offset;
573
574 if (src < end_src) {
575 section->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
576 }
577 while (src < end_src) {
578 uint8e_type mod_byte = *src++;
579 uint32_type gap = end_src - src;
580
581 count = 8;
582 if (mod_byte == 0 && gap >= 8) {
583 dst_ptr[0] = src[0];
584 dst_ptr[1] = src[1];
585 dst_ptr[2] = src[2];
586 dst_ptr[3] = src[3];
587 dst_ptr[4] = src[4];
588 dst_ptr[5] = src[5];
589 dst_ptr[6] = src[6];
590 dst_ptr[7] = src[7];
591 dst_ptr+= 8;
592 src += 8;
593 }
594 else {
595 for (relbit = 1; count-- != 0 && src < end_src; relbit <<=1)
596 {
597 if (relbit & mod_byte)
598 {
599 uint8e_type reloc = *src;
600 /* This item needs to be relocated */
601 switch (reloc & RELOCATION_TYPE_BITS) {
602 case RELOCATION_TYPE_ABS:
603
604 break;
605
606 case RELOCATION_TYPE_REL:
607 {
608 /* Relocate the item relative to the section */
609 oasys_reloc_type *r =
610 (oasys_reloc_type *)
611 bfd_alloc(abfd,
612 sizeof(oasys_reloc_type));
613 *(per->reloc_tail_ptr) = r;
614 per->reloc_tail_ptr = &r->next;
615 r->next= (oasys_reloc_type *)NULL;
616 /* Reference to undefined symbol */
617 src++;
618 /* There is no symbol */
619 r->symbol = 0;
620 /* Work out the howto */
e98e6ec1
SC
621 abort();
622#if 0
6f715d66 623 r->relent.section =
e98e6ec1
SC
624 data->sections[reloc &
625 RELOCATION_SECT_BITS];
626
627 r->relent.addend = -
628 r->relent.section->vma;
629#endif
6f715d66
SC
630 r->relent.address = dst_ptr - dst_base_ptr;
631 r->relent.howto = &howto_table[reloc>>6];
632 r->relent.sym_ptr_ptr = (asymbol **)NULL;
633 section->reloc_count++;
634
635 /* Fake up the data to look like it's got the -ve pc in it, this makes
636 it much easier to convert into other formats. This is done by
637 hitting the addend.
638 */
639 if (r->relent.howto->pc_relative == true) {
640 r->relent.addend -= dst_ptr - dst_base_ptr;
641 }
642
643
644 }
645 break;
646
647
648 case RELOCATION_TYPE_UND:
649 {
650 oasys_reloc_type *r =
651 (oasys_reloc_type *)
652 bfd_alloc(abfd,
653 sizeof(oasys_reloc_type));
654 *(per->reloc_tail_ptr) = r;
655 per->reloc_tail_ptr = &r->next;
656 r->next= (oasys_reloc_type *)NULL;
657 /* Reference to undefined symbol */
658 src++;
659 /* Get symbol number */
660 r->symbol = (src[0]<<8) | src[1];
661 /* Work out the howto */
e98e6ec1
SC
662 abort();
663
664#if 0
665 r->relent.section = (asection
666 *)NULL;
667#endif
6f715d66
SC
668 r->relent.addend = 0;
669 r->relent.address = dst_ptr - dst_base_ptr;
670 r->relent.howto = &howto_table[reloc>>6];
671 r->relent.sym_ptr_ptr = (asymbol **)NULL;
672 section->reloc_count++;
673
674 src+=2;
675 /* Fake up the data to look like it's got the -ve pc in it, this makes
676 it much easier to convert into other formats. This is done by
677 hitting the addend.
678 */
679 if (r->relent.howto->pc_relative == true) {
680 r->relent.addend -= dst_ptr - dst_base_ptr;
681 }
dcf22de9
SC
682
683
684
6f715d66
SC
685 }
686 break;
687 case RELOCATION_TYPE_COM:
688 BFD_FAIL();
de7c1ff6 689 }
6f715d66
SC
690 }
691 *dst_ptr++ = *src++;
692 }
693 }
694 }
87f86b4e 695 }
6f715d66
SC
696 break;
697 case oasys_record_is_local_enum:
698 case oasys_record_is_symbol_enum:
699 case oasys_record_is_section_enum:
700 break;
701 default:
702 loop = false;
de7c1ff6 703 }
87f86b4e 704 }
6f715d66 705
87f86b4e
DHW
706 return true;
707
708}
709
710
711
3e9aade1 712bfd_error_vector_type bfd_error_vector;
87f86b4e 713
3e9aade1
SC
714static boolean
715DEFUN(oasys_new_section_hook,(abfd, newsect),
716 bfd *abfd AND
717 asection *newsect)
87f86b4e 718{
a6dab071 719 newsect->used_by_bfd = (PTR)
9872a49c 720 bfd_alloc(abfd, sizeof(oasys_per_section_type));
87f86b4e
DHW
721 oasys_per_section( newsect)->data = (bfd_byte *)NULL;
722 oasys_per_section(newsect)->section = newsect;
723 oasys_per_section(newsect)->offset = 0;
6f715d66
SC
724 oasys_per_section(newsect)->initialized = false;
725 newsect->alignment_power = 1;
3e9aade1
SC
726 /* Turn the section string into an index */
727
728 sscanf(newsect->name,"%u", &newsect->target_index);
729
87f86b4e
DHW
730 return true;
731}
732
733
3e9aade1
SC
734static unsigned int
735DEFUN(oasys_get_reloc_upper_bound, (abfd, asect),
736 bfd *abfd AND
737 sec_ptr asect)
87f86b4e
DHW
738{
739 oasys_slurp_section_data(abfd);
740 return (asect->reloc_count+1) * sizeof(arelent *);
741}
742
743static boolean
3e9aade1
SC
744DEFUN(oasys_get_section_contents,(abfd, section, location, offset, count),
745 bfd *abfd AND
746 sec_ptr section AND
2b1d8a50 747 PTR location AND
3e9aade1 748 file_ptr offset AND
7ed4093a 749 bfd_size_type count)
87f86b4e 750{
a6dab071 751 oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd;
87f86b4e 752 oasys_slurp_section_data(abfd);
6f715d66
SC
753 if (p->initialized == false)
754 {
755 (void) memset(location, 0, (int)count);
756 }
757 else
758 {
c618de01 759 (void) memcpy(location,(PTR)( p->data + offset), (int)count);
6f715d66 760 }
87f86b4e
DHW
761 return true;
762}
763
764
765unsigned int
fb3be09b
JG
766DEFUN(oasys_canonicalize_reloc,(ignore_abfd, section, relptr, symbols),
767 bfd *ignore_abfd AND
3e9aade1
SC
768 sec_ptr section AND
769 arelent **relptr AND
770 asymbol **symbols)
87f86b4e 771{
3e9aade1 772 unsigned int reloc_count = 0;
87f86b4e
DHW
773 oasys_reloc_type *src = (oasys_reloc_type *)(section->relocation);
774 while (src != (oasys_reloc_type *)NULL) {
e98e6ec1
SC
775 abort();
776
777#if 0
3e9aade1
SC
778 if (src->relent.section == (asection *)NULL)
779 {
780 src->relent.sym_ptr_ptr = symbols + src->symbol;
781 }
e98e6ec1
SC
782#endif
783
87f86b4e
DHW
784 *relptr ++ = &src->relent;
785 src = src->next;
3e9aade1 786 reloc_count++;
87f86b4e
DHW
787 }
788 *relptr = (arelent *)NULL;
3e9aade1 789 return section->reloc_count = reloc_count;
87f86b4e
DHW
790}
791
3e9aade1 792
3e9aade1
SC
793
794
795/* Writing */
796
797
798/* Calculate the checksum and write one record */
799static void
800DEFUN(oasys_write_record,(abfd, type, record, size),
801 bfd *CONST abfd AND
802 CONST oasys_record_enum_type type AND
803 oasys_record_union_type *record AND
804 CONST size_t size)
87f86b4e 805{
3e9aade1
SC
806 int checksum;
807 size_t i;
808 uint8e_type *ptr;
809 record->header.length = size;
e98e6ec1 810 record->header.type = (int)type;
3e9aade1
SC
811 record->header.check_sum = 0;
812 record->header.fill = 0;
813 ptr = &record->pad[0];
814 checksum = 0;
815 for (i = 0; i < size; i++) {
816 checksum += *ptr++;
87f86b4e 817 }
3e9aade1
SC
818 record->header.check_sum = 0xff & (- checksum);
819 bfd_write((PTR)record, 1, size, abfd);
820}
87f86b4e 821
3e9aade1
SC
822
823/* Write out all the symbols */
824static void
825DEFUN(oasys_write_syms, (abfd),
826 bfd * CONST abfd)
827{
828 unsigned int count;
829 asymbol **generic = bfd_get_outsymbols(abfd);
830 unsigned int index = 0;
831 for (count = 0; count < bfd_get_symcount(abfd); count++) {
832
833 oasys_symbol_record_type symbol;
834 asymbol * CONST g = generic[count];
835
836 CONST char *src = g->name;
837 char *dst = symbol.name;
838 unsigned int l = 0;
839
3039e8ee 840 if (bfd_is_com_section (g->section)) {
3e9aade1 841 symbol.relb = RELOCATION_TYPE_COM;
7ed4093a 842 bfd_h_put_16(abfd, index, (uint8e_type *)(&symbol.refno[0]));
3e9aade1
SC
843 index++;
844 }
e98e6ec1 845 else if (g->section == & bfd_abs_section) {
3e9aade1 846 symbol.relb = RELOCATION_TYPE_ABS;
7ed4093a 847 bfd_h_put_16(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
3e9aade1
SC
848
849 }
e98e6ec1 850 else if (g->section == &bfd_und_section) {
3e9aade1 851 symbol.relb = RELOCATION_TYPE_UND ;
7ed4093a 852 bfd_h_put_16(abfd, index, (uint8e_type *)(&symbol.refno[0]));
3e9aade1
SC
853 /* Overload the value field with the output index number */
854 index++;
855 }
856 else if (g->flags & BSF_DEBUGGING) {
857 /* throw it away */
858 continue;
859 }
860 else {
6f715d66
SC
861 if (g->section == (asection *)NULL) {
862 /* Sometime, the oasys tools give out a symbol with illegal
863 bits in it, we'll output it in the same broken way */
864
865 symbol.relb = RELOCATION_TYPE_REL | 0;
866 }
867 else {
868 symbol.relb = RELOCATION_TYPE_REL |g->section->output_section->target_index;
869 }
7ed4093a 870 bfd_h_put_16(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
3e9aade1 871 }
294eaca4
SC
872#ifdef UNDERSCORE_HACK
873 if (src[l] == '_')
874 dst[l++] = '.';
875#endif
3e9aade1
SC
876 while (src[l]) {
877 dst[l] = src[l];
878 l++;
879 }
880
c618de01 881 bfd_h_put_32(abfd, g->value, (bfd_byte*) symbol.value);
3e9aade1
SC
882
883
884 if (g->flags & BSF_LOCAL) {
885 oasys_write_record(abfd,
886 oasys_record_is_local_enum,
887 (oasys_record_union_type *) &symbol,
8cc8fd69 888 offsetof(oasys_symbol_record_type, name[0]) + l);
3e9aade1
SC
889 }
890 else {
891 oasys_write_record(abfd,
892 oasys_record_is_symbol_enum,
893 (oasys_record_union_type *) &symbol,
8cc8fd69 894 offsetof(oasys_symbol_record_type, name[0]) + l);
3e9aade1
SC
895 }
896 g->value = index-1;
897 }
898}
899
900
901 /* Write a section header for each section */
902static void
903DEFUN(oasys_write_sections, (abfd),
904 bfd *CONST abfd)
905{
906 asection *s;
907 static oasys_section_record_type out = {0};
908
909 for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
910 if (!isdigit(s->name[0]))
911 {
912 bfd_error_vector.nonrepresentable_section(abfd,
913 s->name);
914 }
915 out.relb = RELOCATION_TYPE_REL | s->target_index;
e98e6ec1 916 bfd_h_put_32(abfd, s->_cooked_size, (bfd_byte *) out.value);
c618de01 917 bfd_h_put_32(abfd, s->vma, (bfd_byte *) out.vma);
3e9aade1
SC
918
919 oasys_write_record(abfd,
920 oasys_record_is_section_enum,
921 (oasys_record_union_type *) &out,
922 sizeof(out));
923 }
87f86b4e
DHW
924}
925
3e9aade1
SC
926static void
927DEFUN(oasys_write_header, (abfd),
928 bfd *CONST abfd)
929{
930 /* Create and write the header */
931 oasys_header_record_type r;
932 size_t length = strlen(abfd->filename);
301dfc71 933 if (length > (size_t)sizeof(r.module_name)) {
3e9aade1
SC
934 length = sizeof(r.module_name);
935 }
87f86b4e 936
3e9aade1
SC
937 (void)memcpy(r.module_name,
938 abfd->filename,
939 length);
940 (void)memset(r.module_name + length,
941 ' ',
942 sizeof(r.module_name) - length);
87f86b4e 943
3e9aade1
SC
944 r.version_number = OASYS_VERSION_NUMBER;
945 r.rev_number = OASYS_REV_NUMBER;
946 oasys_write_record(abfd,
947 oasys_record_is_header_enum,
948 (oasys_record_union_type *)&r,
8cc8fd69 949 offsetof(oasys_header_record_type, description[0]));
87f86b4e
DHW
950
951
952
3e9aade1 953}
87f86b4e
DHW
954
955static void
3e9aade1
SC
956DEFUN(oasys_write_end,(abfd),
957 bfd *CONST abfd)
958{
959 oasys_end_record_type end;
d0ec7a8e 960 uint8e_type null = 0;
3e9aade1 961 end.relb = RELOCATION_TYPE_ABS;
c618de01
SC
962 bfd_h_put_32(abfd, abfd->start_address, (bfd_byte *)end.entry);
963 bfd_h_put_16(abfd, 0, (bfd_byte *)end.fill);
3e9aade1
SC
964 end.zero =0;
965 oasys_write_record(abfd,
966 oasys_record_is_end_enum,
967 (oasys_record_union_type *)&end,
968 sizeof(end));
d0ec7a8e 969 bfd_write((PTR)&null, 1, 1, abfd);
3e9aade1
SC
970}
971
972static int
973DEFUN(comp,(ap, bp),
9872a49c
SC
974 CONST PTR ap AND
975 CONST PTR bp)
3e9aade1 976{
9872a49c
SC
977 arelent *a = *((arelent **)ap);
978 arelent *b = *((arelent **)bp);
3e9aade1
SC
979 return a->address - b->address;
980}
981
982/*
983 Writing data..
984
985*/
986static void
987DEFUN(oasys_write_data, (abfd),
988 bfd *CONST abfd)
87f86b4e 989{
3e9aade1 990 asection *s;
87f86b4e 991 for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
6f715d66
SC
992 if (s->flags & SEC_LOAD) {
993 uint8e_type *raw_data = oasys_per_section(s)->data;
994 oasys_data_record_type processed_data;
995 bfd_size_type current_byte_index = 0;
996 unsigned int relocs_to_go = s->reloc_count;
997 arelent **p = s->orelocation;
998 if (s->reloc_count != 0) {
294eaca4 999/* Sort the reloc records so it's easy to insert the relocs into the
6f715d66 1000 data */
3e9aade1 1001
6f715d66
SC
1002 qsort(s->orelocation,
1003 s->reloc_count,
1004 sizeof(arelent **),
1005 comp);
1006 }
1007 current_byte_index = 0;
1008 processed_data.relb = s->target_index | RELOCATION_TYPE_REL;
3e9aade1 1009
e98e6ec1 1010 while (current_byte_index < s->_cooked_size)
6f715d66
SC
1011 {
1012 /* Scan forwards by eight bytes or however much is left and see if
1013 there are any relocations going on */
1014 uint8e_type *mod = &processed_data.data[0];
1015 uint8e_type *dst = &processed_data.data[1];
3e9aade1 1016
6f715d66 1017 unsigned int i;
294eaca4 1018 *mod = 0;
3e9aade1
SC
1019
1020
294eaca4
SC
1021 bfd_h_put_32(abfd, s->vma + current_byte_index,
1022 processed_data.addr);
1023
1024 /* Don't start a relocation unless you're sure you can finish it
1025 within the same data record. The worst case relocation is a
1026 4-byte relocatable value which is split across two modification
1027 bytes (1 relocation byte + 2 symbol reference bytes + 2 data +
1028 1 modification byte + 2 data = 8 bytes total). That's where
1029 the magic number 8 comes from.
1030 */
1031 while (current_byte_index < s->_raw_size && dst <=
1032 (uint8e_type*)&processed_data.data[sizeof(processed_data.data)-8]) {
1033
6f715d66 1034
6f715d66
SC
1035 if (relocs_to_go != 0) {
1036 arelent *r = *p;
1037 reloc_howto_type *CONST how=r->howto;
1038 /* There is a relocation, is it for this byte ? */
1039 if (r->address == current_byte_index) {
1040 uint8e_type rel_byte;
1041 p++;
1042 relocs_to_go--;
1043
1044 *mod |= (1<<i);
1045 if(how->pc_relative) {
1046 rel_byte = 0x80;
1047
1048 /* Also patch the raw data so that it doesn't have
1049 the -ve stuff any more */
1050 if (how->size != 2) {
1051 bfd_put_16(abfd,
7ed4093a 1052 bfd_get_16(abfd,raw_data) +
dcf22de9 1053 current_byte_index, raw_data);
6f715d66 1054 }
dcf22de9 1055
6f715d66
SC
1056 else {
1057 bfd_put_32(abfd,
1058 bfd_get_32(abfd,raw_data) +
1059 current_byte_index, raw_data);
1060 }
1061 }
dcf22de9 1062 else {
6f715d66
SC
1063 rel_byte = 0;
1064 }
1065 if (how->size ==2) {
1066 rel_byte |= 0x40;
dcf22de9 1067 }
dcf22de9 1068
6f715d66
SC
1069 /* Is this a section relative relocation, or a symbol
1070 relative relocation ? */
e98e6ec1
SC
1071 abort();
1072
1073#if 0
6f715d66
SC
1074 if (r->section != (asection*)NULL)
1075 {
9712c6e2 1076 /* The relent has a section attached, so it must be section
6f715d66 1077 relative */
3e9aade1 1078 rel_byte |= RELOCATION_TYPE_REL;
6f715d66 1079 rel_byte |= r->section->output_section->target_index;
3e9aade1
SC
1080 *dst++ = rel_byte;
1081 }
6f715d66 1082 else
e98e6ec1 1083#endif
6f715d66
SC
1084 {
1085 asymbol *p = *(r->sym_ptr_ptr);
1086
9712c6e2 1087 /* If this symbol has a section attached, then it
6f715d66
SC
1088 has already been resolved. Change from a symbol
1089 ref to a section ref */
1090 if(p->section != (asection *)NULL) {
1091 rel_byte |= RELOCATION_TYPE_REL;
1092 rel_byte |=
1093 p->section->output_section->target_index;
1094 *dst++ = rel_byte;
1095 }
1096 else {
1097 rel_byte |= RELOCATION_TYPE_UND;
3e9aade1
SC
1098
1099
6f715d66
SC
1100 *dst++ = rel_byte;
1101 /* Next two bytes are a symbol index - we can get
1102 this from the symbol value which has been zapped
1103 into the symbol index in the table when the
1104 symbol table was written
1105 */
1106 *dst++ = p->value >> 8;
1107 *dst++ = p->value;
1108 }
3e9aade1 1109
6f715d66 1110 }
294eaca4
SC
1111#define ADVANCE { if (++i >= 8) { i = 0; mod = dst++; *mod = 0; } current_byte_index++; }
1112 /* relocations never occur from an unloadable section,
1113 so we can assume that raw_data is not NULL
1114 */
1115 *dst++ = *raw_data++;
1116 ADVANCE
1117 *dst++ = *raw_data++;
1118 ADVANCE
1119 if (how->size == 2) {
1120 *dst++ = *raw_data++;
1121 ADVANCE
1122 *dst++ = *raw_data++;
1123 ADVANCE
1124 }
1125 continue;
6f715d66 1126 }
3e9aade1 1127 }
6f715d66
SC
1128 /* If this is coming from an unloadable section then copy
1129 zeros */
1130 if (raw_data == (uint8e_type *)NULL) {
1131 *dst++ = 0;
1132 }
1133 else {
1134 *dst++ = *raw_data++;
1135 }
294eaca4
SC
1136 ADVANCE
1137 }
1138
1139 /* Don't write a useless null modification byte */
1140 if (dst == mod+1) {
1141 --dst;
3e9aade1 1142 }
3e9aade1 1143
6f715d66
SC
1144 oasys_write_record(abfd,
1145 oasys_record_is_data_enum,
1146 (oasys_record_union_type *)&processed_data,
1147 dst - (uint8e_type*)&processed_data);
3e9aade1 1148
6f715d66
SC
1149 }
1150 }
87f86b4e
DHW
1151 }
1152}
3e9aade1
SC
1153static boolean
1154DEFUN(oasys_write_object_contents, (abfd),
3039e8ee 1155 bfd *abfd)
3e9aade1
SC
1156{
1157 oasys_write_header(abfd);
1158 oasys_write_syms(abfd);
1159 oasys_write_sections(abfd);
1160 oasys_write_data(abfd);
1161 oasys_write_end(abfd);
1162 return true;
1163}
1164
1165
1166
87f86b4e
DHW
1167
1168/** exec and core file sections */
1169
1170/* set section contents is complicated with OASYS since the format is
1171* not a byte image, but a record stream.
1172*/
3e9aade1
SC
1173static boolean
1174DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count),
1175 bfd *abfd AND
1176 sec_ptr section AND
2b1d8a50 1177 PTR location AND
3e9aade1 1178 file_ptr offset AND
7ed4093a 1179 bfd_size_type count)
87f86b4e 1180{
3e9aade1
SC
1181 if (count != 0) {
1182 if (oasys_per_section(section)->data == (bfd_byte *)NULL )
1183 {
1184 oasys_per_section(section)->data =
e98e6ec1 1185 (bfd_byte *)(bfd_alloc(abfd,section->_cooked_size));
3e9aade1 1186 }
c618de01 1187 (void) memcpy((PTR)(oasys_per_section(section)->data + offset),
3e9aade1
SC
1188 location,
1189 count);
87f86b4e 1190 }
87f86b4e
DHW
1191 return true;
1192}
1193
1194
1195
87f86b4e
DHW
1196/* Native-level interface to symbols. */
1197
1198/* We read the symbols into a buffer, which is discarded when this
1199function exits. We read the strings into a buffer large enough to
1200hold them all plus all the cached symbol entries. */
1201
3e9aade1
SC
1202static asymbol *
1203DEFUN(oasys_make_empty_symbol,(abfd),
1204 bfd *abfd)
87f86b4e
DHW
1205{
1206
1207 oasys_symbol_type *new =
9872a49c 1208 (oasys_symbol_type *)bfd_zalloc (abfd, sizeof (oasys_symbol_type));
87f86b4e
DHW
1209 new->symbol.the_bfd = abfd;
1210 return &new->symbol;
1211
1212}
1213
87f86b4e
DHW
1214
1215\f
87f86b4e
DHW
1216
1217/* User should have checked the file flags; perhaps we should return
1218BFD_NO_MORE_SYMBOLS if there are none? */
1219
87f86b4e
DHW
1220static bfd *
1221oasys_openr_next_archived_file(arch, prev)
1222bfd *arch;
1223bfd *prev;
1224{
e98e6ec1 1225 oasys_ar_data_type *ar = OASYS_AR_DATA(arch);
87f86b4e
DHW
1226 oasys_module_info_type *p;
1227 /* take the next one from the arch state, or reset */
1228 if (prev == (bfd *)NULL) {
1229 /* Reset the index - the first two entries are bogus*/
1230 ar->module_index = 0;
1231 }
1232
1233 p = ar->module + ar->module_index;
1234 ar->module_index++;
1235
1236 if (ar->module_index <= ar->module_count) {
1237 if (p->abfd == (bfd *)NULL) {
1238 p->abfd = _bfd_create_empty_archive_element_shell(arch);
1239 p->abfd->origin = p->pos;
1240 p->abfd->filename = p->name;
1241
1242 /* Fixup a pointer to this element for the member */
3e9aade1 1243 p->abfd->arelt_data = (PTR)p;
87f86b4e
DHW
1244 }
1245 return p->abfd;
1246 }
1247 else {
1248 bfd_error = no_more_archived_files;
1249 return (bfd *)NULL;
1250 }
1251}
1252
1253static boolean
1254oasys_find_nearest_line(abfd,
1255 section,
1256 symbols,
1257 offset,
1258 filename_ptr,
1259 functionname_ptr,
1260 line_ptr)
1261bfd *abfd;
1262asection *section;
1263asymbol **symbols;
1264bfd_vma offset;
1265char **filename_ptr;
1266char **functionname_ptr;
1267unsigned int *line_ptr;
1268{
1269 return false;
1270
1271}
1272
1273static int
dcf22de9
SC
1274DEFUN(oasys_generic_stat_arch_elt,(abfd, buf),
1275 bfd *abfd AND
1276 struct stat *buf)
87f86b4e 1277{
a6dab071 1278 oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data;
87f86b4e
DHW
1279 if (mod == (oasys_module_info_type *)NULL) {
1280 bfd_error = invalid_operation;
1281 return -1;
1282 }
1283 else {
1284 buf->st_size = mod->size;
1285 buf->st_mode = 0666;
dcf22de9 1286 return 0;
87f86b4e 1287 }
39a2ce33 1288}
87f86b4e 1289
39a2ce33 1290static int
d0ec7a8e
SC
1291DEFUN(oasys_sizeof_headers,(abfd, exec),
1292 bfd *abfd AND
1293 boolean exec)
39a2ce33
SC
1294{
1295return 0;
87f86b4e 1296}
6f715d66 1297#define FOO PROTO
d0ec7a8e
SC
1298#define oasys_core_file_failing_command (char *(*)())(bfd_nullvoidptr)
1299#define oasys_core_file_failing_signal (int (*)())bfd_0
6f715d66 1300#define oasys_core_file_matches_executable_p 0
d0ec7a8e
SC
1301#define oasys_slurp_armap bfd_true
1302#define oasys_slurp_extended_name_table bfd_true
1303#define oasys_truncate_arname (void (*)())bfd_nullvoidptr
6f715d66 1304#define oasys_write_armap 0
d0ec7a8e 1305#define oasys_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
2b1d8a50 1306#define oasys_close_and_cleanup bfd_generic_close_and_cleanup
e98e6ec1 1307#define oasys_set_arch_mach bfd_default_set_arch_mach
6f715d66
SC
1308#define oasys_bfd_debug_info_start bfd_void
1309#define oasys_bfd_debug_info_end bfd_void
1310#define oasys_bfd_debug_info_accumulate (FOO(void, (*), (bfd *, asection *)))bfd_void
e98e6ec1 1311#define oasys_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
294eaca4 1312#define oasys_bfd_relax_section bfd_generic_relax_section
3039e8ee 1313#define oasys_bfd_seclet_link bfd_generic_seclet_link
8feff717
ILT
1314#define oasys_bfd_reloc_type_lookup \
1315 ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
1316#define oasys_bfd_make_debug_symbol \
1317 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
3039e8ee 1318
87f86b4e
DHW
1319/*SUPPRESS 460 */
1320bfd_target oasys_vec =
1321{
1322 "oasys", /* name */
e98e6ec1 1323 bfd_target_oasys_flavour,
87f86b4e
DHW
1324 true, /* target byte order */
1325 true, /* target headers byte order */
1326 (HAS_RELOC | EXEC_P | /* object flags */
1327 HAS_LINENO | HAS_DEBUG |
1328 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
1329 (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
1330 |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
294eaca4 1331 0, /* leading underscore */
87f86b4e
DHW
1332 ' ', /* ar_pad_char */
1333 16, /* ar_max_namelen */
c618de01 1334 1, /* minimum alignment */
7ed4093a
SC
1335 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
1336 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
87f86b4e 1337
7ed4093a
SC
1338 {_bfd_dummy_target,
1339 oasys_object_p, /* bfd_check_format */
1340 oasys_archive_p,
1341 _bfd_dummy_target,
87f86b4e 1342 },
7ed4093a
SC
1343 { /* bfd_set_format */
1344 bfd_false,
1345 oasys_mkobject,
1346 _bfd_generic_mkarchive,
1347 bfd_false
1348 },
1349 { /* bfd_write_contents */
1350 bfd_false,
1351 oasys_write_object_contents,
1352 _bfd_write_archive_contents,
1353 bfd_false,
87f86b4e 1354 },
8feff717
ILT
1355 JUMP_TABLE(oasys),
1356 (PTR) 0
c618de01 1357};
This page took 0.171579 seconds and 4 git commands to generate.