]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/srec.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / bfd / srec.c
CommitLineData
4a8db330 1/* BFD back-end for s-record objects.
4aa65bb8
RH
2 Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
3 Free Software Foundation, Inc.
9898b929 4 Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
4a81b561 5
387cbb2b 6This file is part of BFD, the Binary File Descriptor library.
4a81b561 7
387cbb2b 8This program is free software; you can redistribute it and/or modify
4a81b561 9it under the terms of the GNU General Public License as published by
387cbb2b
JG
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
4a81b561 12
387cbb2b 13This program is distributed in the hope that it will be useful,
4a81b561
DHW
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
387cbb2b 19along with this program; if not, write to the Free Software
c3246d9b 20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
4a81b561 21
9898b929
JG
22/*
23SUBSECTION
8f8fefcc 24 S-Record handling
4a81b561 25
9898b929
JG
26DESCRIPTION
27
8f8fefcc
JG
28 Ordinary S-Records cannot hold anything but addresses and
29 data, so that's all that we implement.
9783e04a 30
8f8fefcc 31 The only interesting thing is that S-Records may come out of
9898b929
JG
32 order and there is no header, so an initial scan is required
33 to discover the minimum and maximum addresses used to create
34 the vma and size of the only section we create. We
9783e04a 35 arbitrarily call this section ".text".
9898b929
JG
36
37 When bfd_get_section_contents is called the file is read
38 again, and this time the data is placed into a bfd_alloc'd
39 area.
40
41 Any number of sections may be created for output, we save them
42 up and output them when it's time to close the bfd.
43
44 An s record looks like:
45
46EXAMPLE
294eaca4 47 S<type><length><address><data><checksum>
9898b929
JG
48
49DESCRIPTION
50 Where
51 o length
52 is the number of bytes following upto the checksum. Note that
53 this is not the number of chars following, since it takes two
54 chars to represent a byte.
55 o type
56 is one of:
57 0) header record
58 1) two byte address data record
59 2) three byte address data record
60 3) four byte address data record
61 7) four byte address termination record
62 8) three byte address termination record
63 9) two byte address termination record
64
65 o address
66 is the start address of the data following, or in the case of
67 a termination record, the start address of the image
68 o data
69 is the data.
70 o checksum
71 is the sum of all the raw byte data in the record, from the length
72 upwards, modulo 256 and subtracted from 255.
8f8fefcc
JG
73
74
75SUBSECTION
76 Symbol S-Record handling
77
78DESCRIPTION
79 Some ICE equipment understands an addition to the standard
80 S-Record format; symbols and their addresses can be sent
81 before the data.
82
83 The format of this is:
84 ($$ <modulename>
85 (<space> <symbol> <address>)*)
86 $$
87
88 so a short symbol table could look like:
89
90EXAMPLE
91 $$ flash.x
92 $$ flash.c
93 _port6 $0
94 _delay $4
95 _start $14
96 _etext $8036
97 _edata $8036
98 _end $8036
9783e04a 99 $$
8f8fefcc
JG
100
101DESCRIPTION
102 We allow symbols to be anywhere in the data stream - the module names
103 are always ignored.
104
9898b929 105*/
7ed4093a 106
36773af5 107#include "bfd.h"
9898b929 108#include "sysdep.h"
4a81b561 109#include "libbfd.h"
7f4c005d 110#include "libiberty.h"
b7577823 111#include <ctype.h>
7f4c005d 112
4aa65bb8 113static void srec_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
0103b447
ILT
114static void srec_print_symbol
115 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
7f4c005d
KR
116static void srec_init PARAMS ((void));
117static boolean srec_mkobject PARAMS ((bfd *));
118static int srec_get_byte PARAMS ((bfd *, boolean *));
119static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
120static boolean srec_scan PARAMS ((bfd *));
121static const bfd_target *srec_object_p PARAMS ((bfd *));
122static const bfd_target *symbolsrec_object_p PARAMS ((bfd *));
123static boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *));
4a81b561 124
6d4f7715 125static boolean srec_write_record PARAMS ((bfd *, int, bfd_vma,
7f4c005d
KR
126 const bfd_byte *,
127 const bfd_byte *));
6d4f7715
ILT
128static boolean srec_write_header PARAMS ((bfd *));
129static boolean srec_write_symbols PARAMS ((bfd *));
0103b447
ILT
130static boolean srec_new_symbol PARAMS ((bfd *, const char *, bfd_vma));
131static boolean srec_get_section_contents
132 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
133static boolean srec_set_arch_mach
134 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
135static boolean srec_set_section_contents
136 PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
137static boolean internal_srec_write_object_contents PARAMS ((bfd *, int));
138static boolean srec_write_object_contents PARAMS ((bfd *));
139static boolean symbolsrec_write_object_contents PARAMS ((bfd *));
140static int srec_sizeof_headers PARAMS ((bfd *, boolean));
141static asymbol *srec_make_empty_symbol PARAMS ((bfd *));
142static long srec_get_symtab_upper_bound PARAMS ((bfd *));
143static long srec_get_symtab PARAMS ((bfd *, asymbol **));
6d4f7715 144
4c8d6c9f 145/* Macros for converting between hex and binary. */
4a81b561 146
3039e8ee 147static CONST char digs[] = "0123456789ABCDEF";
5f9ca960 148
7f4c005d 149#define NIBBLE(x) hex_value(x)
9898b929 150#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
5f9ca960
JG
151#define TOHEX(d, x, ch) \
152 d[1] = digs[(x) & 0xf]; \
153 d[0] = digs[((x)>>4)&0xf]; \
154 ch += ((x) & 0xff);
7f4c005d 155#define ISHEX(x) hex_p(x)
4a81b561 156
4c8d6c9f 157/* Initialize by filling in the hex conversion array. */
9898b929 158
e98e6ec1 159static void
57a1867e 160srec_init ()
9898b929 161{
9783e04a
DM
162 static boolean inited = false;
163
164 if (inited == false)
9898b929 165 {
9783e04a 166 inited = true;
7f4c005d 167 hex_init ();
9783e04a 168 }
9898b929
JG
169}
170
4a81b561 171/* The maximum number of bytes on a line is FF */
9783e04a 172#define MAXCHUNK 0xff
4a81b561 173/* The number of bytes we fit onto a line on output */
9898b929
JG
174#define CHUNK 21
175
7f4c005d
KR
176/* When writing an S-record file, the S-records can not be output as
177 they are seen. This structure is used to hold them in memory. */
9898b929
JG
178
179struct srec_data_list_struct
180{
7f4c005d
KR
181 struct srec_data_list_struct *next;
182 bfd_byte *data;
9783e04a
DM
183 bfd_vma where;
184 bfd_size_type size;
7f4c005d 185};
9783e04a 186
7f4c005d 187typedef struct srec_data_list_struct srec_data_list_type;
8f8fefcc 188
7f4c005d
KR
189/* When scanning the S-record file, a linked list of srec_symbol
190 structures is built to represent the symbol table (if there is
191 one). */
192
193struct srec_symbol
194{
195 struct srec_symbol *next;
196 const char *name;
197 bfd_vma val;
9783e04a 198};
9898b929 199
7f4c005d 200/* The S-record tdata information. */
4a81b561 201
9783e04a
DM
202typedef struct srec_data_struct
203 {
204 srec_data_list_type *head;
d4d16683 205 srec_data_list_type *tail;
9898b929 206 unsigned int type;
7f4c005d
KR
207 struct srec_symbol *symbols;
208 struct srec_symbol *symtail;
209 asymbol *csymbols;
9783e04a
DM
210 }
211tdata_type;
9898b929 212
6d4f7715
ILT
213static boolean srec_write_section PARAMS ((bfd *, tdata_type *,
214 srec_data_list_type *));
215static boolean srec_write_terminator PARAMS ((bfd *, tdata_type *));
9898b929 216
7f4c005d 217/* Set up the S-record tdata information. */
9898b929 218
7f4c005d
KR
219static boolean
220srec_mkobject (abfd)
9783e04a 221 bfd *abfd;
9783e04a 222{
7f4c005d 223 srec_init ();
8f8fefcc 224
7f4c005d 225 if (abfd->tdata.srec_data == NULL)
8f8fefcc 226 {
7f4c005d
KR
227 tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
228 if (tdata == NULL)
a9713b91 229 return false;
7f4c005d
KR
230 abfd->tdata.srec_data = tdata;
231 tdata->type = 1;
232 tdata->head = NULL;
233 tdata->tail = NULL;
234 tdata->symbols = NULL;
235 tdata->symtail = NULL;
236 tdata->csymbols = NULL;
9783e04a 237 }
4a81b561 238
7f4c005d
KR
239 return true;
240}
357a1f38 241
7f4c005d
KR
242/* Read a byte from an S record file. Set *ERRORPTR if an error
243 occurred. Return EOF on error or end of file. */
4a81b561 244
7f4c005d
KR
245static int
246srec_get_byte (abfd, errorptr)
57a1867e 247 bfd *abfd;
7f4c005d 248 boolean *errorptr;
9783e04a 249{
7f4c005d
KR
250 bfd_byte c;
251
252 if (bfd_read (&c, 1, 1, abfd) != 1)
9783e04a 253 {
7f4c005d
KR
254 if (bfd_get_error () != bfd_error_file_truncated)
255 *errorptr = true;
256 return EOF;
9783e04a 257 }
7f4c005d
KR
258
259 return (int) (c & 0xff);
4a81b561
DHW
260}
261
7f4c005d
KR
262/* Report a problem in an S record file. FIXME: This probably should
263 not call fprintf, but we really do need some mechanism for printing
264 error messages. */
387cbb2b 265
7f4c005d
KR
266static void
267srec_bad_byte (abfd, lineno, c, error)
9783e04a 268 bfd *abfd;
7f4c005d
KR
269 unsigned int lineno;
270 int c;
271 boolean error;
8f8fefcc 272{
7f4c005d 273 if (c == EOF)
9783e04a 274 {
7f4c005d
KR
275 if (! error)
276 bfd_set_error (bfd_error_file_truncated);
277 }
278 else
279 {
280 char buf[10];
281
282 if (! isprint (c))
283 sprintf (buf, "\\%03o", (unsigned int) c);
284 else
285 {
286 buf[0] = c;
287 buf[1] = '\0';
288 }
a9713b91 289 (*_bfd_error_handler)
4aa65bb8 290 (_("%s:%d: Unexpected character `%s' in S-record file\n"),
a9713b91 291 bfd_get_filename (abfd), lineno, buf);
7f4c005d 292 bfd_set_error (bfd_error_bad_value);
9783e04a 293 }
8f8fefcc
JG
294}
295
7f4c005d
KR
296/* Add a new symbol found in an S-record file. */
297
8f8fefcc 298static boolean
7f4c005d 299srec_new_symbol (abfd, name, val)
57a1867e 300 bfd *abfd;
7f4c005d
KR
301 const char *name;
302 bfd_vma val;
8f8fefcc 303{
7f4c005d
KR
304 struct srec_symbol *n;
305
306 n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
307 if (n == NULL)
a9713b91 308 return false;
9783e04a 309
7f4c005d
KR
310 n->name = name;
311 n->val = val;
312
313 if (abfd->tdata.srec_data->symbols == NULL)
314 abfd->tdata.srec_data->symbols = n;
315 else
316 abfd->tdata.srec_data->symtail->next = n;
317 abfd->tdata.srec_data->symtail = n;
318 n->next = NULL;
319
320 ++abfd->symcount;
321
322 return true;
8f8fefcc
JG
323}
324
7f4c005d
KR
325/* Read the S record file and turn it into sections. We create a new
326 section for each contiguous set of bytes. */
327
328static boolean
329srec_scan (abfd)
4c3721d5 330 bfd *abfd;
4a81b561 331{
7f4c005d
KR
332 int c;
333 unsigned int lineno = 1;
334 boolean error = false;
335 bfd_byte *buf = NULL;
336 size_t bufsize = 0;
337 asection *sec = NULL;
0103b447 338 char *symbuf = NULL;
e98e6ec1 339
6d4f7715 340 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
7f4c005d
KR
341 goto error_return;
342
343 while ((c = srec_get_byte (abfd, &error)) != EOF)
4a81b561 344 {
7f4c005d
KR
345 /* We only build sections from contiguous S-records, so if this
346 is not an S-record, then stop building a section. */
347 if (c != 'S' && c != '\r' && c != '\n')
348 sec = NULL;
349
350 switch (c)
8f8fefcc 351 {
9783e04a 352 default:
7f4c005d
KR
353 srec_bad_byte (abfd, lineno, c, error);
354 goto error_return;
355
356 case '\n':
357 ++lineno;
358 break;
359
360 case '\r':
9783e04a
DM
361 break;
362
363 case '$':
7f4c005d
KR
364 /* Starting a module name, which we ignore. */
365 while ((c = srec_get_byte (abfd, &error)) != '\n'
366 && c != EOF)
367 ;
368 if (c == EOF)
9783e04a 369 {
7f4c005d
KR
370 srec_bad_byte (abfd, lineno, c, error);
371 goto error_return;
9783e04a 372 }
7f4c005d
KR
373
374 ++lineno;
375
9783e04a
DM
376 break;
377
378 case ' ':
0103b447
ILT
379 do
380 {
381 unsigned int alc;
382 char *p, *symname;
383 bfd_vma symval;
4c3721d5 384
0103b447
ILT
385 /* Starting a symbol definition. */
386 while ((c = srec_get_byte (abfd, &error)) != EOF
387 && (c == ' ' || c == '\t'))
388 ;
9783e04a 389
0103b447
ILT
390 if (c == '\n')
391 break;
9783e04a 392
0103b447
ILT
393 if (c == EOF)
394 {
395 srec_bad_byte (abfd, lineno, c, error);
396 goto error_return;
397 }
7f4c005d 398
0103b447
ILT
399 alc = 10;
400 symbuf = (char *) bfd_malloc (alc + 1);
401 if (symbuf == NULL)
402 goto error_return;
7f4c005d 403
0103b447
ILT
404 p = symbuf;
405
406 *p++ = c;
407 while ((c = srec_get_byte (abfd, &error)) != EOF
408 && ! isspace (c))
409 {
4aa65bb8 410 if ((unsigned int) (p - symbuf) >= alc)
0103b447
ILT
411 {
412 char *n;
413
414 alc *= 2;
415 n = (char *) bfd_realloc (symbuf, alc + 1);
416 if (n == NULL)
417 goto error_return;
418 p = n + (p - symbuf);
419 symbuf = n;
420 }
421
422 *p++ = c;
423 }
424
425 if (c == EOF)
426 {
427 srec_bad_byte (abfd, lineno, c, error);
428 goto error_return;
429 }
430
431 *p++ = '\0';
432 symname = bfd_alloc (abfd, p - symbuf);
433 if (symname == NULL)
7f4c005d 434 goto error_return;
0103b447
ILT
435 strcpy (symname, symbuf);
436 free (symbuf);
437 symbuf = NULL;
438
439 while ((c = srec_get_byte (abfd, &error)) != EOF
440 && (c == ' ' || c == '\t'))
441 ;
442 if (c == EOF)
443 {
444 srec_bad_byte (abfd, lineno, c, error);
445 goto error_return;
446 }
447
448 /* Skip a dollar sign before the hex value. */
449 if (c == '$')
450 {
451 c = srec_get_byte (abfd, &error);
452 if (c == EOF)
453 {
454 srec_bad_byte (abfd, lineno, c, error);
455 goto error_return;
456 }
457 }
458
459 symval = 0;
460 while (ISHEX (c))
461 {
462 symval <<= 4;
463 symval += NIBBLE (c);
464 c = srec_get_byte (abfd, &error);
465 }
466
467 if (! srec_new_symbol (abfd, symname, symval))
468 goto error_return;
469 }
470 while (c == ' ' || c == '\t');
7f4c005d 471
0103b447
ILT
472 if (c != '\n')
473 {
474 srec_bad_byte (abfd, lineno, c, error);
7f4c005d 475 goto error_return;
0103b447 476 }
7f4c005d 477
0103b447 478 ++lineno;
7f4c005d 479
9783e04a 480 break;
7f4c005d 481
9783e04a 482 case 'S':
7f4c005d
KR
483 {
484 file_ptr pos;
485 char hdr[3];
486 unsigned int bytes;
487 bfd_vma address;
488 bfd_byte *data;
9783e04a 489
7f4c005d 490 /* Starting an S-record. */
9783e04a 491
7f4c005d 492 pos = bfd_tell (abfd) - 1;
9783e04a 493
7f4c005d
KR
494 if (bfd_read (hdr, 1, 3, abfd) != 3)
495 goto error_return;
9783e04a 496
7f4c005d
KR
497 if (! ISHEX (hdr[1]) || ! ISHEX (hdr[2]))
498 {
499 if (! ISHEX (hdr[1]))
500 c = hdr[1];
501 else
502 c = hdr[2];
503 srec_bad_byte (abfd, lineno, c, error);
504 goto error_return;
505 }
9783e04a 506
7f4c005d
KR
507 bytes = HEX (hdr + 1);
508 if (bytes * 2 > bufsize)
509 {
510 if (buf != NULL)
511 free (buf);
58142f10 512 buf = (bfd_byte *) bfd_malloc (bytes * 2);
7f4c005d 513 if (buf == NULL)
58142f10 514 goto error_return;
7f4c005d
KR
515 bufsize = bytes * 2;
516 }
9783e04a 517
7f4c005d
KR
518 if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
519 goto error_return;
9783e04a 520
7f4c005d
KR
521 /* Ignore the checksum byte. */
522 --bytes;
523
524 address = 0;
525 data = buf;
526 switch (hdr[0])
527 {
528 case '0':
529 case '5':
530 /* Prologue--ignore the file name, but stop building a
531 section at this point. */
532 sec = NULL;
533 break;
534
535 case '3':
536 address = HEX (data);
537 data += 2;
538 --bytes;
539 /* Fall through. */
540 case '2':
541 address = (address << 8) | HEX (data);
542 data += 2;
543 --bytes;
544 /* Fall through. */
545 case '1':
546 address = (address << 8) | HEX (data);
547 data += 2;
548 address = (address << 8) | HEX (data);
549 data += 2;
550 bytes -= 2;
551
552 if (sec != NULL
553 && sec->vma + sec->_raw_size == address)
554 {
555 /* This data goes at the end of the section we are
556 currently building. */
557 sec->_raw_size += bytes;
558 }
559 else
560 {
561 char secbuf[20];
562 char *secname;
563
564 sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
565 secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
566 strcpy (secname, secbuf);
567 sec = bfd_make_section (abfd, secname);
568 if (sec == NULL)
569 goto error_return;
570 sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
571 sec->vma = address;
55ae43ab 572 sec->lma = address;
7f4c005d
KR
573 sec->_raw_size = bytes;
574 sec->filepos = pos;
575 }
576
577 break;
578
579 case '7':
580 address = HEX (data);
581 data += 2;
582 /* Fall through. */
583 case '8':
584 address = (address << 8) | HEX (data);
585 data += 2;
586 /* Fall through. */
587 case '9':
588 address = (address << 8) | HEX (data);
589 data += 2;
590 address = (address << 8) | HEX (data);
591 data += 2;
592
593 /* This is a termination record. */
594 abfd->start_address = address;
595
596 if (buf != NULL)
597 free (buf);
598
599 return true;
600 }
601 }
602 break;
8f8fefcc 603 }
4a81b561 604 }
9898b929 605
7f4c005d
KR
606 if (error)
607 goto error_return;
4a81b561 608
7f4c005d
KR
609 if (buf != NULL)
610 free (buf);
611
612 return true;
613
614 error_return:
0103b447
ILT
615 if (symbuf != NULL)
616 free (symbuf);
7f4c005d
KR
617 if (buf != NULL)
618 free (buf);
619 return false;
8f8fefcc 620}
9898b929 621
7f4c005d
KR
622/* Check whether an existing file is an S-record file. */
623
2f3508ad 624static const bfd_target *
57a1867e
DM
625srec_object_p (abfd)
626 bfd *abfd;
4a81b561 627{
7f4c005d 628 bfd_byte b[4];
8f8fefcc 629
9783e04a 630 srec_init ();
9898b929 631
6d4f7715
ILT
632 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
633 || bfd_read (b, 1, 4, abfd) != 4)
634 return NULL;
9783e04a
DM
635
636 if (b[0] != 'S' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
7f4c005d
KR
637 {
638 bfd_set_error (bfd_error_wrong_format);
639 return NULL;
640 }
9783e04a 641
7f4c005d
KR
642 if (! srec_mkobject (abfd)
643 || ! srec_scan (abfd))
644 return NULL;
4a81b561 645
7f4c005d 646 return abfd->xvec;
8f8fefcc
JG
647}
648
7f4c005d 649/* Check whether an existing file is an S-record file with symbols. */
8f8fefcc 650
2f3508ad 651static const bfd_target *
57a1867e
DM
652symbolsrec_object_p (abfd)
653 bfd *abfd;
8f8fefcc 654{
7f4c005d 655 char b[2];
8f8fefcc 656
9783e04a
DM
657 srec_init ();
658
6d4f7715 659 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
7f4c005d 660 || bfd_read (b, 1, 2, abfd) != 2)
6d4f7715 661 return NULL;
8f8fefcc
JG
662
663 if (b[0] != '$' || b[1] != '$')
7f4c005d
KR
664 {
665 bfd_set_error (bfd_error_wrong_format);
666 return NULL;
667 }
8f8fefcc 668
7f4c005d
KR
669 if (! srec_mkobject (abfd)
670 || ! srec_scan (abfd))
671 return NULL;
672
673 return abfd->xvec;
4a81b561
DHW
674}
675
7f4c005d
KR
676/* Read in the contents of a section in an S-record file. */
677
678static boolean
679srec_read_section (abfd, section, contents)
680 bfd *abfd;
681 asection *section;
682 bfd_byte *contents;
683{
684 int c;
685 bfd_size_type sofar = 0;
686 boolean error = false;
687 bfd_byte *buf = NULL;
688 size_t bufsize = 0;
689
690 if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
691 goto error_return;
692
693 while ((c = srec_get_byte (abfd, &error)) != EOF)
694 {
695 bfd_byte hdr[3];
696 unsigned int bytes;
697 bfd_vma address;
698 bfd_byte *data;
699
700 if (c == '\r' || c == '\n')
701 continue;
702
703 /* This is called after srec_scan has already been called, so we
704 ought to know the exact format. */
705 BFD_ASSERT (c == 'S');
706
707 if (bfd_read (hdr, 1, 3, abfd) != 3)
708 goto error_return;
709
710 BFD_ASSERT (ISHEX (hdr[1]) && ISHEX (hdr[2]));
711
712 bytes = HEX (hdr + 1);
713
714 if (bytes * 2 > bufsize)
715 {
716 if (buf != NULL)
717 free (buf);
58142f10 718 buf = (bfd_byte *) bfd_malloc (bytes * 2);
7f4c005d 719 if (buf == NULL)
58142f10 720 goto error_return;
7f4c005d
KR
721 bufsize = bytes * 2;
722 }
723
724 if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
725 goto error_return;
726
727 address = 0;
728 data = buf;
729 switch (hdr[0])
730 {
731 default:
732 BFD_ASSERT (sofar == section->_raw_size);
733 if (buf != NULL)
734 free (buf);
735 return true;
736
737 case '3':
738 address = HEX (data);
739 data += 2;
740 --bytes;
741 /* Fall through. */
742 case '2':
743 address = (address << 8) | HEX (data);
744 data += 2;
745 --bytes;
746 /* Fall through. */
747 case '1':
748 address = (address << 8) | HEX (data);
749 data += 2;
750 address = (address << 8) | HEX (data);
751 data += 2;
752 bytes -= 2;
753
754 if (address != section->vma + sofar)
755 {
756 /* We've come to the end of this section. */
757 BFD_ASSERT (sofar == section->_raw_size);
758 if (buf != NULL)
759 free (buf);
760 return true;
761 }
762
763 /* Don't consider checksum. */
764 --bytes;
765
766 while (bytes-- != 0)
767 {
768 contents[sofar] = HEX (data);
769 data += 2;
770 ++sofar;
771 }
772
773 break;
774 }
775 }
776
777 if (error)
778 goto error_return;
779
780 BFD_ASSERT (sofar == section->_raw_size);
781
782 if (buf != NULL)
783 free (buf);
784
785 return true;
786
787 error_return:
788 if (buf != NULL)
789 free (buf);
790 return false;
791}
792
793/* Get the contents of a section in an S-record file. */
4a81b561 794
4a81b561 795static boolean
57a1867e
DM
796srec_get_section_contents (abfd, section, location, offset, count)
797 bfd *abfd;
798 asection *section;
799 PTR location;
800 file_ptr offset;
801 bfd_size_type count;
9783e04a 802{
7f4c005d 803 if (section->used_by_bfd == NULL)
9898b929 804 {
7f4c005d
KR
805 section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
806 if (section->used_by_bfd == NULL
807 && section->_raw_size != 0)
a9713b91 808 return false;
9783e04a 809
7f4c005d
KR
810 if (! srec_read_section (abfd, section, section->used_by_bfd))
811 return false;
9898b929 812 }
9783e04a 813
b7577823
ILT
814 memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
815 (size_t) count);
4a81b561 816
7f4c005d 817 return true;
4a81b561
DHW
818}
819
0103b447
ILT
820/* Set the architecture. We accept an unknown architecture here. */
821
822static boolean
823srec_set_arch_mach (abfd, arch, mach)
824 bfd *abfd;
825 enum bfd_architecture arch;
826 unsigned long mach;
827{
828 if (arch == bfd_arch_unknown)
829 {
830 abfd->arch_info = &bfd_default_arch_struct;
831 return true;
832 }
833 return bfd_default_set_arch_mach (abfd, arch, mach);
834}
835
c3246d9b 836/* we have to save up all the Srecords for a splurge before output */
4a81b561 837
9898b929 838static boolean
57a1867e
DM
839srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
840 bfd *abfd;
841 sec_ptr section;
842 PTR location;
843 file_ptr offset;
844 bfd_size_type bytes_to_do;
9783e04a
DM
845{
846 tdata_type *tdata = abfd->tdata.srec_data;
d4d16683 847 register srec_data_list_type *entry;
9783e04a 848
d4d16683
ILT
849 entry = ((srec_data_list_type *)
850 bfd_alloc (abfd, sizeof (srec_data_list_type)));
851 if (entry == NULL)
a9713b91 852 return false;
8f8fefcc 853
c3246d9b
ILT
854 if (bytes_to_do
855 && (section->flags & SEC_ALLOC)
9783e04a 856 && (section->flags & SEC_LOAD))
9898b929 857 {
7f4c005d 858 bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
d4d16683 859 if (data == NULL)
a9713b91 860 return false;
b7577823 861 memcpy ((PTR) data, location, (size_t) bytes_to_do);
9898b929 862
c3246d9b 863 if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
8f8fefcc 864 {
9898b929 865
8f8fefcc 866 }
c3246d9b 867 else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
9783e04a 868 && tdata->type < 2)
8f8fefcc
JG
869 {
870 tdata->type = 2;
871 }
9783e04a 872 else
8f8fefcc
JG
873 {
874 tdata->type = 3;
875 }
876
877 entry->data = data;
878 entry->where = section->lma + offset;
879 entry->size = bytes_to_do;
d4d16683
ILT
880
881 /* Sort the records by address. Optimize for the common case of
882 adding a record to the end of the list. */
883 if (tdata->tail != NULL
884 && entry->where >= tdata->tail->where)
885 {
886 tdata->tail->next = entry;
887 entry->next = NULL;
888 tdata->tail = entry;
889 }
890 else
891 {
892 register srec_data_list_type **look;
893
894 for (look = &tdata->head;
895 *look != NULL && (*look)->where < entry->where;
896 look = &(*look)->next)
897 ;
898 entry->next = *look;
899 *look = entry;
900 if (entry->next == NULL)
901 tdata->tail = entry;
902 }
8f8fefcc 903 }
9783e04a 904 return true;
9898b929
JG
905}
906
907/* Write a record of type, of the supplied number of bytes. The
908 supplied bytes and length don't have a checksum. That's worked out
909 here
910*/
6d4f7715 911static boolean
57a1867e
DM
912srec_write_record (abfd, type, address, data, end)
913 bfd *abfd;
6d4f7715 914 int type;
57a1867e 915 bfd_vma address;
7f4c005d
KR
916 const bfd_byte *data;
917 const bfd_byte *end;
9783e04a
DM
918{
919 char buffer[MAXCHUNK];
9783e04a 920 unsigned int check_sum = 0;
7f4c005d 921 CONST bfd_byte *src = data;
9783e04a
DM
922 char *dst = buffer;
923 char *length;
ae115e51 924 bfd_size_type wrlen;
9783e04a 925
9783e04a
DM
926 *dst++ = 'S';
927 *dst++ = '0' + type;
928
929 length = dst;
930 dst += 2; /* leave room for dst*/
931
932 switch (type)
9898b929 933 {
9783e04a
DM
934 case 3:
935 case 7:
936 TOHEX (dst, (address >> 24), check_sum);
937 dst += 2;
938 case 8:
939 case 2:
940 TOHEX (dst, (address >> 16), check_sum);
941 dst += 2;
942 case 9:
943 case 1:
944 case 0:
945 TOHEX (dst, (address >> 8), check_sum);
946 dst += 2;
947 TOHEX (dst, (address), check_sum);
948 dst += 2;
949 break;
4a81b561 950
4a81b561 951 }
9783e04a 952 for (src = data; src < end; src++)
9898b929 953 {
9783e04a
DM
954 TOHEX (dst, *src, check_sum);
955 dst += 2;
4a81b561
DHW
956 }
957
9783e04a
DM
958 /* Fill in the length */
959 TOHEX (length, (dst - length) / 2, check_sum);
960 check_sum &= 0xff;
961 check_sum = 255 - check_sum;
962 TOHEX (dst, check_sum, check_sum);
963 dst += 2;
964
965 *dst++ = '\r';
966 *dst++ = '\n';
ae115e51
ILT
967 wrlen = dst - buffer;
968 if (bfd_write ((PTR) buffer, 1, wrlen, abfd) != wrlen)
6d4f7715
ILT
969 return false;
970 return true;
9898b929 971}
4a81b561 972
4a81b561 973
4a81b561 974
6d4f7715 975static boolean
57a1867e
DM
976srec_write_header (abfd)
977 bfd *abfd;
9898b929 978{
7f4c005d
KR
979 bfd_byte buffer[MAXCHUNK];
980 bfd_byte *dst = buffer;
9783e04a 981 unsigned int i;
4a81b561 982
9783e04a
DM
983 /* I'll put an arbitary 40 char limit on header size */
984 for (i = 0; i < 40 && abfd->filename[i]; i++)
9898b929 985 {
9783e04a 986 *dst++ = abfd->filename[i];
9898b929 987 }
6d4f7715 988 return srec_write_record (abfd, 0, 0, buffer, dst);
4a81b561
DHW
989}
990
6d4f7715 991static boolean
57a1867e
DM
992srec_write_section (abfd, tdata, list)
993 bfd *abfd;
994 tdata_type *tdata;
995 srec_data_list_type *list;
9898b929 996{
9783e04a 997 unsigned int bytes_written = 0;
7f4c005d 998 bfd_byte *location = list->data;
9898b929 999
9783e04a 1000 while (bytes_written < list->size)
9898b929 1001 {
9783e04a
DM
1002 bfd_vma address;
1003
1004 unsigned int bytes_this_chunk = list->size - bytes_written;
9898b929 1005
9783e04a 1006 if (bytes_this_chunk > CHUNK)
9898b929 1007 {
9783e04a 1008 bytes_this_chunk = CHUNK;
9898b929
JG
1009 }
1010
9783e04a 1011 address = list->where + bytes_written;
9898b929 1012
6d4f7715
ILT
1013 if (! srec_write_record (abfd,
1014 tdata->type,
1015 address,
1016 location,
1017 location + bytes_this_chunk))
1018 return false;
9898b929 1019
9783e04a
DM
1020 bytes_written += bytes_this_chunk;
1021 location += bytes_this_chunk;
9898b929
JG
1022 }
1023
6d4f7715 1024 return true;
9898b929
JG
1025}
1026
6d4f7715 1027static boolean
57a1867e
DM
1028srec_write_terminator (abfd, tdata)
1029 bfd *abfd;
1030 tdata_type *tdata;
9783e04a 1031{
7f4c005d 1032 bfd_byte buffer[2];
9783e04a 1033
6d4f7715
ILT
1034 return srec_write_record (abfd, 10 - tdata->type,
1035 abfd->start_address, buffer, buffer);
9898b929 1036}
3039e8ee 1037
8f8fefcc 1038
9783e04a 1039
6d4f7715 1040static boolean
9783e04a 1041srec_write_symbols (abfd)
2c3b9e47 1042 bfd *abfd;
9898b929 1043{
8f8fefcc
JG
1044 char buffer[MAXCHUNK];
1045 /* Dump out the symbols of a bfd */
1046 int i;
2f3508ad 1047 int count = bfd_get_symcount (abfd);
8f8fefcc 1048
2f3508ad 1049 if (count)
9783e04a 1050 {
6d4f7715 1051 size_t len;
9783e04a
DM
1052 asymbol **table = bfd_get_outsymbols (abfd);
1053 sprintf (buffer, "$$ %s\r\n", abfd->filename);
8f8fefcc 1054
2f3508ad 1055 len = strlen (buffer);
6d4f7715
ILT
1056 if (bfd_write (buffer, len, 1, abfd) != len)
1057 return false;
8f8fefcc 1058
2f3508ad 1059 for (i = 0; i < count; i++)
9783e04a
DM
1060 {
1061 asymbol *s = table[i];
4aa65bb8 1062 if (! bfd_is_local_label (abfd, s))
9783e04a
DM
1063 {
1064 /* Just dump out non debug symbols */
ae115e51 1065 bfd_size_type l;
9783e04a
DM
1066 char buf2[40], *p;
1067
1068 sprintf_vma (buf2,
1069 s->value + s->section->output_section->lma
1070 + s->section->output_offset);
1071 p = buf2;
1072 while (p[0] == '0' && p[1] != 0)
1073 p++;
1074 sprintf (buffer, " %s $%s\r\n", s->name, p);
1075 l = strlen (buffer);
6d4f7715
ILT
1076 if (bfd_write (buffer, l, 1, abfd) != l)
1077 return false;
9783e04a
DM
1078 }
1079 }
1080 sprintf (buffer, "$$ \r\n");
2f3508ad 1081 len = strlen (buffer);
6d4f7715
ILT
1082 if (bfd_write (buffer, len, 1, abfd) != len)
1083 return false;
8f8fefcc 1084 }
6d4f7715
ILT
1085
1086 return true;
9898b929
JG
1087}
1088
9898b929 1089static boolean
9783e04a 1090internal_srec_write_object_contents (abfd, symbols)
8f8fefcc
JG
1091 bfd *abfd;
1092 int symbols;
4a81b561 1093{
9783e04a
DM
1094 tdata_type *tdata = abfd->tdata.srec_data;
1095 srec_data_list_type *list;
9898b929 1096
9783e04a 1097 if (symbols)
6d4f7715
ILT
1098 {
1099 if (! srec_write_symbols (abfd))
1100 return false;
1101 }
8f8fefcc 1102
6d4f7715
ILT
1103 if (! srec_write_header (abfd))
1104 return false;
8f8fefcc 1105
9783e04a
DM
1106 /* Now wander though all the sections provided and output them */
1107 list = tdata->head;
9898b929 1108
9783e04a 1109 while (list != (srec_data_list_type *) NULL)
9898b929 1110 {
6d4f7715
ILT
1111 if (! srec_write_section (abfd, tdata, list))
1112 return false;
9783e04a 1113 list = list->next;
9898b929 1114 }
6d4f7715 1115 return srec_write_terminator (abfd, tdata);
4a81b561
DHW
1116}
1117
8f8fefcc 1118static boolean
9783e04a 1119srec_write_object_contents (abfd)
8f8fefcc
JG
1120 bfd *abfd;
1121{
9783e04a 1122 return internal_srec_write_object_contents (abfd, 0);
8f8fefcc
JG
1123}
1124
1125static boolean
9783e04a 1126symbolsrec_write_object_contents (abfd)
8f8fefcc
JG
1127 bfd *abfd;
1128{
9783e04a 1129 return internal_srec_write_object_contents (abfd, 1);
8f8fefcc
JG
1130}
1131
9783e04a
DM
1132/*ARGSUSED*/
1133static int
57a1867e
DM
1134srec_sizeof_headers (abfd, exec)
1135 bfd *abfd;
1136 boolean exec;
39a2ce33 1137{
9783e04a 1138 return 0;
39a2ce33
SC
1139}
1140
357a1f38 1141static asymbol *
57a1867e
DM
1142srec_make_empty_symbol (abfd)
1143 bfd *abfd;
357a1f38 1144{
9783e04a
DM
1145 asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
1146 if (new)
1147 new->the_bfd = abfd;
357a1f38
SC
1148 return new;
1149}
8f8fefcc 1150
7f4c005d
KR
1151/* Return the amount of memory needed to read the symbol table. */
1152
326e32d7 1153static long
9783e04a
DM
1154srec_get_symtab_upper_bound (abfd)
1155 bfd *abfd;
8f8fefcc 1156{
7f4c005d 1157 return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *);
8f8fefcc
JG
1158}
1159
7f4c005d
KR
1160/* Return the symbol table. */
1161
326e32d7 1162static long
57a1867e
DM
1163srec_get_symtab (abfd, alocation)
1164 bfd *abfd;
1165 asymbol **alocation;
8f8fefcc 1166{
7f4c005d
KR
1167 unsigned int symcount = bfd_get_symcount (abfd);
1168 asymbol *csymbols;
1169 unsigned int i;
1170
1171 csymbols = abfd->tdata.srec_data->csymbols;
1172 if (csymbols == NULL)
9783e04a 1173 {
7f4c005d
KR
1174 asymbol *c;
1175 struct srec_symbol *s;
1176
1177 csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
1178 if (csymbols == NULL && symcount != 0)
a9713b91 1179 return false;
7f4c005d
KR
1180 abfd->tdata.srec_data->csymbols = csymbols;
1181
1182 for (s = abfd->tdata.srec_data->symbols, c = csymbols;
1183 s != NULL;
1184 s = s->next, ++c)
1185 {
1186 c->the_bfd = abfd;
1187 c->name = s->name;
1188 c->value = s->val;
1189 c->flags = BSF_GLOBAL;
1190 c->section = bfd_abs_section_ptr;
1191 c->udata.p = NULL;
1192 }
9783e04a 1193 }
7f4c005d
KR
1194
1195 for (i = 0; i < symcount; i++)
1196 *alocation++ = csymbols++;
1197 *alocation = NULL;
1198
1199 return symcount;
8f8fefcc
JG
1200}
1201
9783e04a 1202/*ARGSUSED*/
4aa65bb8 1203static void
57a1867e
DM
1204srec_get_symbol_info (ignore_abfd, symbol, ret)
1205 bfd *ignore_abfd;
1206 asymbol *symbol;
1207 symbol_info *ret;
2c3b9e47
KR
1208{
1209 bfd_symbol_info (symbol, ret);
1210}
1211
9783e04a 1212/*ARGSUSED*/
0103b447 1213static void
57a1867e
DM
1214srec_print_symbol (ignore_abfd, afile, symbol, how)
1215 bfd *ignore_abfd;
1216 PTR afile;
1217 asymbol *symbol;
1218 bfd_print_symbol_type how;
9783e04a
DM
1219{
1220 FILE *file = (FILE *) afile;
1221 switch (how)
1222 {
1223 case bfd_print_symbol_name:
1224 fprintf (file, "%s", symbol->name);
1225 break;
1226 default:
1227 bfd_print_symbol_vandf ((PTR) file, symbol);
1228 fprintf (file, " %-5s %s",
1229 symbol->section->name,
1230 symbol->name);
8f8fefcc 1231
9783e04a 1232 }
8f8fefcc
JG
1233}
1234
6812b607
ILT
1235#define srec_close_and_cleanup _bfd_generic_close_and_cleanup
1236#define srec_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
1237#define srec_new_section_hook _bfd_generic_new_section_hook
9872a49c 1238
0103b447 1239#define srec_bfd_is_local_label_name bfd_generic_is_local_label_name
6812b607
ILT
1240#define srec_get_lineno _bfd_nosymbols_get_lineno
1241#define srec_find_nearest_line _bfd_nosymbols_find_nearest_line
1242#define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
c3246d9b
ILT
1243#define srec_read_minisymbols _bfd_generic_read_minisymbols
1244#define srec_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
d0ec7a8e 1245
7f4c005d
KR
1246#define srec_get_reloc_upper_bound \
1247 ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
1248#define srec_canonicalize_reloc \
1249 ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
1250#define srec_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
1251
a9713b91
ILT
1252#define srec_get_section_contents_in_window \
1253 _bfd_generic_get_section_contents_in_window
1254
6812b607
ILT
1255#define srec_bfd_get_relocated_section_contents \
1256 bfd_generic_get_relocated_section_contents
294eaca4 1257#define srec_bfd_relax_section bfd_generic_relax_section
4c3721d5
ILT
1258#define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
1259#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
1260#define srec_bfd_final_link _bfd_generic_final_link
c3246d9b 1261#define srec_bfd_link_split_section _bfd_generic_link_split_section
3039e8ee 1262
2f3508ad 1263const bfd_target srec_vec =
4a81b561 1264{
9783e04a
DM
1265 "srec", /* name */
1266 bfd_target_srec_flavour,
0103b447
ILT
1267 BFD_ENDIAN_UNKNOWN, /* target byte order */
1268 BFD_ENDIAN_UNKNOWN, /* target headers byte order */
9783e04a
DM
1269 (HAS_RELOC | EXEC_P | /* object flags */
1270 HAS_LINENO | HAS_DEBUG |
1271 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
1272 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
1273 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1274 0, /* leading underscore */
1275 ' ', /* ar_pad_char */
1276 16, /* ar_max_namelen */
9783e04a
DM
1277 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1278 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1279 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
1280 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1281 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1282 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
9898b929
JG
1283
1284 {
9783e04a
DM
1285 _bfd_dummy_target,
1286 srec_object_p, /* bfd_check_format */
2f3508ad
ILT
1287 _bfd_dummy_target,
1288 _bfd_dummy_target,
9898b929
JG
1289 },
1290 {
9783e04a
DM
1291 bfd_false,
1292 srec_mkobject,
1293 _bfd_generic_mkarchive,
1294 bfd_false,
9898b929
JG
1295 },
1296 { /* bfd_write_contents */
9783e04a
DM
1297 bfd_false,
1298 srec_write_object_contents,
1299 _bfd_write_archive_contents,
1300 bfd_false,
9898b929 1301 },
6812b607
ILT
1302
1303 BFD_JUMP_TABLE_GENERIC (srec),
1304 BFD_JUMP_TABLE_COPY (_bfd_generic),
1305 BFD_JUMP_TABLE_CORE (_bfd_nocore),
1306 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
1307 BFD_JUMP_TABLE_SYMBOLS (srec),
7f4c005d 1308 BFD_JUMP_TABLE_RELOCS (srec),
6812b607
ILT
1309 BFD_JUMP_TABLE_WRITE (srec),
1310 BFD_JUMP_TABLE_LINK (srec),
dfc1c006 1311 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
6812b607
ILT
1312
1313 (PTR) 0
9783e04a 1314};
9898b929 1315
8f8fefcc
JG
1316
1317
2f3508ad 1318const bfd_target symbolsrec_vec =
8f8fefcc 1319{
9783e04a
DM
1320 "symbolsrec", /* name */
1321 bfd_target_srec_flavour,
0103b447
ILT
1322 BFD_ENDIAN_UNKNOWN, /* target byte order */
1323 BFD_ENDIAN_UNKNOWN, /* target headers byte order */
9783e04a
DM
1324 (HAS_RELOC | EXEC_P | /* object flags */
1325 HAS_LINENO | HAS_DEBUG |
1326 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
1327 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
1328 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1329 0, /* leading underscore */
1330 ' ', /* ar_pad_char */
1331 16, /* ar_max_namelen */
9783e04a
DM
1332 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1333 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1334 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
1335 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1336 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1337 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
8f8fefcc
JG
1338
1339 {
9783e04a
DM
1340 _bfd_dummy_target,
1341 symbolsrec_object_p, /* bfd_check_format */
2f3508ad
ILT
1342 _bfd_dummy_target,
1343 _bfd_dummy_target,
8f8fefcc
JG
1344 },
1345 {
9783e04a
DM
1346 bfd_false,
1347 srec_mkobject,
1348 _bfd_generic_mkarchive,
1349 bfd_false,
8f8fefcc
JG
1350 },
1351 { /* bfd_write_contents */
9783e04a
DM
1352 bfd_false,
1353 symbolsrec_write_object_contents,
1354 _bfd_write_archive_contents,
1355 bfd_false,
8f8fefcc 1356 },
6812b607
ILT
1357
1358 BFD_JUMP_TABLE_GENERIC (srec),
1359 BFD_JUMP_TABLE_COPY (_bfd_generic),
1360 BFD_JUMP_TABLE_CORE (_bfd_nocore),
1361 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
1362 BFD_JUMP_TABLE_SYMBOLS (srec),
7f4c005d 1363 BFD_JUMP_TABLE_RELOCS (srec),
6812b607
ILT
1364 BFD_JUMP_TABLE_WRITE (srec),
1365 BFD_JUMP_TABLE_LINK (srec),
dfc1c006 1366 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
6812b607 1367
9783e04a
DM
1368 (PTR) 0
1369};