1 /* BFD back-end for s-record objects.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 Free Software Foundation, Inc.
5 Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 Ordinary S-Records cannot hold anything but addresses and
30 data, so that's all that we implement.
32 The only interesting thing is that S-Records may come out of
33 order and there is no header, so an initial scan is required
34 to discover the minimum and maximum addresses used to create
35 the vma and size of the only section we create. We
36 arbitrarily call this section ".text".
38 When bfd_get_section_contents is called the file is read
39 again, and this time the data is placed into a bfd_alloc'd
42 Any number of sections may be created for output, we save them
43 up and output them when it's time to close the bfd.
45 An s record looks like:
48 S<type><length><address><data><checksum>
53 is the number of bytes following upto the checksum. Note that
54 this is not the number of chars following, since it takes two
55 chars to represent a byte.
59 1) two byte address data record
60 2) three byte address data record
61 3) four byte address data record
62 7) four byte address termination record
63 8) three byte address termination record
64 9) two byte address termination record
67 is the start address of the data following, or in the case of
68 a termination record, the start address of the image
72 is the sum of all the raw byte data in the record, from the length
73 upwards, modulo 256 and subtracted from 255.
76 Symbol S-Record handling
79 Some ICE equipment understands an addition to the standard
80 S-Record format; symbols and their addresses can be sent
83 The format of this is:
85 (<space> <symbol> <address>)*)
88 so a short symbol table could look like:
102 We allow symbols to be anywhere in the data stream - the module names
110 #include "libiberty.h"
111 #include "safe-ctype.h"
113 static void srec_get_symbol_info
PARAMS ((bfd
*, asymbol
*, symbol_info
*));
114 static void srec_print_symbol
115 PARAMS ((bfd
*, PTR
, asymbol
*, bfd_print_symbol_type
));
116 static void srec_init
PARAMS ((void));
117 static boolean srec_mkobject
PARAMS ((bfd
*));
118 static int srec_get_byte
PARAMS ((bfd
*, boolean
*));
119 static void srec_bad_byte
PARAMS ((bfd
*, unsigned int, int, boolean
));
120 static boolean srec_scan
PARAMS ((bfd
*));
121 static const bfd_target
*srec_object_p
PARAMS ((bfd
*));
122 static const bfd_target
*symbolsrec_object_p
PARAMS ((bfd
*));
123 static boolean srec_read_section
PARAMS ((bfd
*, asection
*, bfd_byte
*));
125 static boolean srec_write_record
PARAMS ((bfd
*, unsigned int, bfd_vma
,
128 static boolean srec_write_header
PARAMS ((bfd
*));
129 static boolean srec_write_symbols
PARAMS ((bfd
*));
130 static boolean srec_new_symbol
PARAMS ((bfd
*, const char *, bfd_vma
));
131 static boolean srec_get_section_contents
132 PARAMS ((bfd
*, asection
*, PTR
, file_ptr
, bfd_size_type
));
133 static boolean srec_set_arch_mach
134 PARAMS ((bfd
*, enum bfd_architecture
, unsigned long));
135 static boolean srec_set_section_contents
136 PARAMS ((bfd
*, sec_ptr
, PTR
, file_ptr
, bfd_size_type
));
137 static boolean internal_srec_write_object_contents
PARAMS ((bfd
*, int));
138 static boolean srec_write_object_contents
PARAMS ((bfd
*));
139 static boolean symbolsrec_write_object_contents
PARAMS ((bfd
*));
140 static int srec_sizeof_headers
PARAMS ((bfd
*, boolean
));
141 static long srec_get_symtab_upper_bound
PARAMS ((bfd
*));
142 static long srec_get_symtab
PARAMS ((bfd
*, asymbol
**));
144 /* Macros for converting between hex and binary. */
146 static const char digs
[] = "0123456789ABCDEF";
148 #define NIBBLE(x) hex_value(x)
149 #define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
150 #define TOHEX(d, x, ch) \
151 d[1] = digs[(x) & 0xf]; \
152 d[0] = digs[((x)>>4)&0xf]; \
154 #define ISHEX(x) hex_p(x)
156 /* Initialize by filling in the hex conversion array. */
161 static boolean inited
= false;
170 /* The maximum number of address+data+crc bytes on a line is FF. */
171 #define MAXCHUNK 0xff
173 /* Default size for a CHUNK. */
174 #define DEFAULT_CHUNK 16
176 /* The number of data bytes we actually fit onto a line on output.
177 This variable can be modified by objcopy's --srec-len parameter.
178 For a 0x75 byte record you should set --srec-len=0x70. */
179 unsigned int Chunk
= DEFAULT_CHUNK
;
181 /* The type of srec output (free or forced to S3).
182 This variable can be modified by objcopy's --srec-forceS3
184 boolean S3Forced
= 0;
186 /* When writing an S-record file, the S-records can not be output as
187 they are seen. This structure is used to hold them in memory. */
189 struct srec_data_list_struct
191 struct srec_data_list_struct
*next
;
197 typedef struct srec_data_list_struct srec_data_list_type
;
199 /* When scanning the S-record file, a linked list of srec_symbol
200 structures is built to represent the symbol table (if there is
205 struct srec_symbol
*next
;
210 /* The S-record tdata information. */
212 typedef struct srec_data_struct
214 srec_data_list_type
*head
;
215 srec_data_list_type
*tail
;
217 struct srec_symbol
*symbols
;
218 struct srec_symbol
*symtail
;
223 static boolean srec_write_section
PARAMS ((bfd
*, tdata_type
*,
224 srec_data_list_type
*));
225 static boolean srec_write_terminator
PARAMS ((bfd
*, tdata_type
*));
227 /* Set up the S-record tdata information. */
235 if (abfd
->tdata
.srec_data
== NULL
)
237 bfd_size_type amt
= sizeof (tdata_type
);
238 tdata_type
*tdata
= (tdata_type
*) bfd_alloc (abfd
, amt
);
241 abfd
->tdata
.srec_data
= tdata
;
245 tdata
->symbols
= NULL
;
246 tdata
->symtail
= NULL
;
247 tdata
->csymbols
= NULL
;
253 /* Read a byte from an S record file. Set *ERRORPTR if an error
254 occurred. Return EOF on error or end of file. */
257 srec_get_byte (abfd
, errorptr
)
263 if (bfd_bread (&c
, (bfd_size_type
) 1, abfd
) != 1)
265 if (bfd_get_error () != bfd_error_file_truncated
)
270 return (int) (c
& 0xff);
273 /* Report a problem in an S record file. FIXME: This probably should
274 not call fprintf, but we really do need some mechanism for printing
278 srec_bad_byte (abfd
, lineno
, c
, error
)
287 bfd_set_error (bfd_error_file_truncated
);
294 sprintf (buf
, "\\%03o", (unsigned int) c
);
300 (*_bfd_error_handler
)
301 (_("%s:%d: Unexpected character `%s' in S-record file\n"),
302 bfd_archive_filename (abfd
), lineno
, buf
);
303 bfd_set_error (bfd_error_bad_value
);
307 /* Add a new symbol found in an S-record file. */
310 srec_new_symbol (abfd
, name
, val
)
315 struct srec_symbol
*n
;
316 bfd_size_type amt
= sizeof (struct srec_symbol
);
318 n
= (struct srec_symbol
*) bfd_alloc (abfd
, amt
);
325 if (abfd
->tdata
.srec_data
->symbols
== NULL
)
326 abfd
->tdata
.srec_data
->symbols
= n
;
328 abfd
->tdata
.srec_data
->symtail
->next
= n
;
329 abfd
->tdata
.srec_data
->symtail
= n
;
337 /* Read the S record file and turn it into sections. We create a new
338 section for each contiguous set of bytes. */
345 unsigned int lineno
= 1;
346 boolean error
= false;
347 bfd_byte
*buf
= NULL
;
349 asection
*sec
= NULL
;
352 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
355 while ((c
= srec_get_byte (abfd
, &error
)) != EOF
)
357 /* We only build sections from contiguous S-records, so if this
358 is not an S-record, then stop building a section. */
359 if (c
!= 'S' && c
!= '\r' && c
!= '\n')
365 srec_bad_byte (abfd
, lineno
, c
, error
);
376 /* Starting a module name, which we ignore. */
377 while ((c
= srec_get_byte (abfd
, &error
)) != '\n'
382 srec_bad_byte (abfd
, lineno
, c
, error
);
397 /* Starting a symbol definition. */
398 while ((c
= srec_get_byte (abfd
, &error
)) != EOF
399 && (c
== ' ' || c
== '\t'))
402 if (c
== '\n' || c
== '\r')
407 srec_bad_byte (abfd
, lineno
, c
, error
);
412 symbuf
= (char *) bfd_malloc (alc
+ 1);
419 while ((c
= srec_get_byte (abfd
, &error
)) != EOF
422 if ((bfd_size_type
) (p
- symbuf
) >= alc
)
427 n
= (char *) bfd_realloc (symbuf
, alc
+ 1);
430 p
= n
+ (p
- symbuf
);
439 srec_bad_byte (abfd
, lineno
, c
, error
);
444 symname
= bfd_alloc (abfd
, (bfd_size_type
) (p
- symbuf
));
447 strcpy (symname
, symbuf
);
451 while ((c
= srec_get_byte (abfd
, &error
)) != EOF
452 && (c
== ' ' || c
== '\t'))
456 srec_bad_byte (abfd
, lineno
, c
, error
);
460 /* Skip a dollar sign before the hex value. */
463 c
= srec_get_byte (abfd
, &error
);
466 srec_bad_byte (abfd
, lineno
, c
, error
);
475 symval
+= NIBBLE (c
);
476 c
= srec_get_byte (abfd
, &error
);
479 if (! srec_new_symbol (abfd
, symname
, symval
))
482 while (c
== ' ' || c
== '\t')
489 srec_bad_byte (abfd
, lineno
, c
, error
);
503 /* Starting an S-record. */
505 pos
= bfd_tell (abfd
) - 1;
507 if (bfd_bread (hdr
, (bfd_size_type
) 3, abfd
) != 3)
510 if (! ISHEX (hdr
[1]) || ! ISHEX (hdr
[2]))
512 if (! ISHEX (hdr
[1]))
516 srec_bad_byte (abfd
, lineno
, c
, error
);
520 bytes
= HEX (hdr
+ 1);
521 if (bytes
* 2 > bufsize
)
525 buf
= (bfd_byte
*) bfd_malloc ((bfd_size_type
) bytes
* 2);
531 if (bfd_bread (buf
, (bfd_size_type
) bytes
* 2, abfd
) != bytes
* 2)
534 /* Ignore the checksum byte. */
543 /* Prologue--ignore the file name, but stop building a
544 section at this point. */
549 address
= HEX (data
);
554 address
= (address
<< 8) | HEX (data
);
559 address
= (address
<< 8) | HEX (data
);
561 address
= (address
<< 8) | HEX (data
);
566 && sec
->vma
+ sec
->_raw_size
== address
)
568 /* This data goes at the end of the section we are
569 currently building. */
570 sec
->_raw_size
+= bytes
;
578 sprintf (secbuf
, ".sec%d", bfd_count_sections (abfd
) + 1);
579 amt
= strlen (secbuf
) + 1;
580 secname
= (char *) bfd_alloc (abfd
, amt
);
581 strcpy (secname
, secbuf
);
582 sec
= bfd_make_section (abfd
, secname
);
585 sec
->flags
= SEC_HAS_CONTENTS
| SEC_LOAD
| SEC_ALLOC
;
588 sec
->_raw_size
= bytes
;
595 address
= HEX (data
);
599 address
= (address
<< 8) | HEX (data
);
603 address
= (address
<< 8) | HEX (data
);
605 address
= (address
<< 8) | HEX (data
);
608 /* This is a termination record. */
609 abfd
->start_address
= address
;
637 /* Check whether an existing file is an S-record file. */
639 static const bfd_target
*
647 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
648 || bfd_bread (b
, (bfd_size_type
) 4, abfd
) != 4)
651 if (b
[0] != 'S' || !ISHEX (b
[1]) || !ISHEX (b
[2]) || !ISHEX (b
[3]))
653 bfd_set_error (bfd_error_wrong_format
);
657 if (! srec_mkobject (abfd
)
658 || ! srec_scan (abfd
))
661 if (abfd
->symcount
> 0)
662 abfd
->flags
|= HAS_SYMS
;
667 /* Check whether an existing file is an S-record file with symbols. */
669 static const bfd_target
*
670 symbolsrec_object_p (abfd
)
677 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
678 || bfd_bread (b
, (bfd_size_type
) 2, abfd
) != 2)
681 if (b
[0] != '$' || b
[1] != '$')
683 bfd_set_error (bfd_error_wrong_format
);
687 if (! srec_mkobject (abfd
)
688 || ! srec_scan (abfd
))
691 if (abfd
->symcount
> 0)
692 abfd
->flags
|= HAS_SYMS
;
697 /* Read in the contents of a section in an S-record file. */
700 srec_read_section (abfd
, section
, contents
)
706 bfd_size_type sofar
= 0;
707 boolean error
= false;
708 bfd_byte
*buf
= NULL
;
711 if (bfd_seek (abfd
, section
->filepos
, SEEK_SET
) != 0)
714 while ((c
= srec_get_byte (abfd
, &error
)) != EOF
)
721 if (c
== '\r' || c
== '\n')
724 /* This is called after srec_scan has already been called, so we
725 ought to know the exact format. */
726 BFD_ASSERT (c
== 'S');
728 if (bfd_bread (hdr
, (bfd_size_type
) 3, abfd
) != 3)
731 BFD_ASSERT (ISHEX (hdr
[1]) && ISHEX (hdr
[2]));
733 bytes
= HEX (hdr
+ 1);
735 if (bytes
* 2 > bufsize
)
739 buf
= (bfd_byte
*) bfd_malloc ((bfd_size_type
) bytes
* 2);
745 if (bfd_bread (buf
, (bfd_size_type
) bytes
* 2, abfd
) != bytes
* 2)
753 BFD_ASSERT (sofar
== section
->_raw_size
);
759 address
= HEX (data
);
764 address
= (address
<< 8) | HEX (data
);
769 address
= (address
<< 8) | HEX (data
);
771 address
= (address
<< 8) | HEX (data
);
775 if (address
!= section
->vma
+ sofar
)
777 /* We've come to the end of this section. */
778 BFD_ASSERT (sofar
== section
->_raw_size
);
784 /* Don't consider checksum. */
789 contents
[sofar
] = HEX (data
);
801 BFD_ASSERT (sofar
== section
->_raw_size
);
814 /* Get the contents of a section in an S-record file. */
817 srec_get_section_contents (abfd
, section
, location
, offset
, count
)
824 if (section
->used_by_bfd
== NULL
)
826 section
->used_by_bfd
= bfd_alloc (abfd
, section
->_raw_size
);
827 if (section
->used_by_bfd
== NULL
&& section
->_raw_size
!= 0)
830 if (! srec_read_section (abfd
, section
, section
->used_by_bfd
))
834 memcpy (location
, (bfd_byte
*) section
->used_by_bfd
+ offset
,
840 /* Set the architecture. We accept an unknown architecture here. */
843 srec_set_arch_mach (abfd
, arch
, mach
)
845 enum bfd_architecture arch
;
848 if (arch
== bfd_arch_unknown
)
850 abfd
->arch_info
= &bfd_default_arch_struct
;
853 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
856 /* We have to save up all the Srecords for a splurge before output. */
859 srec_set_section_contents (abfd
, section
, location
, offset
, bytes_to_do
)
864 bfd_size_type bytes_to_do
;
866 tdata_type
*tdata
= abfd
->tdata
.srec_data
;
867 register srec_data_list_type
*entry
;
869 entry
= ((srec_data_list_type
*)
870 bfd_alloc (abfd
, (bfd_size_type
) sizeof (srec_data_list_type
)));
875 && (section
->flags
& SEC_ALLOC
)
876 && (section
->flags
& SEC_LOAD
))
880 data
= (bfd_byte
*) bfd_alloc (abfd
, bytes_to_do
);
883 memcpy ((PTR
) data
, location
, (size_t) bytes_to_do
);
885 /* Ff S3Forced is true then always select S3 records,
886 regardless of the siez of the addresses. */
889 else if ((section
->lma
+ offset
+ bytes_to_do
- 1) <= 0xffff)
890 ; /* The default, S1, is OK. */
891 else if ((section
->lma
+ offset
+ bytes_to_do
- 1) <= 0xffffff
898 entry
->where
= section
->lma
+ offset
;
899 entry
->size
= bytes_to_do
;
901 /* Sort the records by address. Optimize for the common case of
902 adding a record to the end of the list. */
903 if (tdata
->tail
!= NULL
904 && entry
->where
>= tdata
->tail
->where
)
906 tdata
->tail
->next
= entry
;
912 register srec_data_list_type
**look
;
914 for (look
= &tdata
->head
;
915 *look
!= NULL
&& (*look
)->where
< entry
->where
;
916 look
= &(*look
)->next
)
920 if (entry
->next
== NULL
)
927 /* Write a record of type, of the supplied number of bytes. The
928 supplied bytes and length don't have a checksum. That's worked out
932 srec_write_record (abfd
, type
, address
, data
, end
)
936 const bfd_byte
*data
;
939 char buffer
[2 * MAXCHUNK
+ 6];
940 unsigned int check_sum
= 0;
941 const bfd_byte
*src
= data
;
950 dst
+= 2; /* Leave room for dst. */
956 TOHEX (dst
, (address
>> 24), check_sum
);
960 TOHEX (dst
, (address
>> 16), check_sum
);
965 TOHEX (dst
, (address
>> 8), check_sum
);
967 TOHEX (dst
, (address
), check_sum
);
972 for (src
= data
; src
< end
; src
++)
974 TOHEX (dst
, *src
, check_sum
);
978 /* Fill in the length. */
979 TOHEX (length
, (dst
- length
) / 2, check_sum
);
981 check_sum
= 255 - check_sum
;
982 TOHEX (dst
, check_sum
, check_sum
);
987 wrlen
= dst
- buffer
;
988 if (bfd_bwrite ((PTR
) buffer
, wrlen
, abfd
) != wrlen
)
994 srec_write_header (abfd
)
997 unsigned int len
= strlen (abfd
->filename
);
999 /* I'll put an arbitary 40 char limit on header size. */
1003 return srec_write_record (abfd
, 0, (bfd_vma
) 0,
1004 abfd
->filename
, abfd
->filename
+ len
);
1008 srec_write_section (abfd
, tdata
, list
)
1011 srec_data_list_type
*list
;
1013 unsigned int octets_written
= 0;
1014 bfd_byte
*location
= list
->data
;
1016 /* Validate number of data bytes to write. The srec length byte
1017 counts the address, data and crc bytes. S1 (tdata->type == 1)
1018 records have two address bytes, S2 (tdata->type == 2) records
1019 have three, and S3 (tdata->type == 3) records have four.
1020 The total length can't exceed 255, and a zero data length will
1021 spin for a long time. */
1024 else if (Chunk
> MAXCHUNK
- tdata
->type
- 2)
1025 Chunk
= MAXCHUNK
- tdata
->type
- 2;
1027 while (octets_written
< list
->size
)
1030 unsigned int octets_this_chunk
= list
->size
- octets_written
;
1032 if (octets_this_chunk
> Chunk
)
1033 octets_this_chunk
= Chunk
;
1035 address
= list
->where
+ octets_written
/ bfd_octets_per_byte (abfd
);
1037 if (! srec_write_record (abfd
,
1041 location
+ octets_this_chunk
))
1044 octets_written
+= octets_this_chunk
;
1045 location
+= octets_this_chunk
;
1052 srec_write_terminator (abfd
, tdata
)
1056 return srec_write_record (abfd
, 10 - tdata
->type
,
1057 abfd
->start_address
, NULL
, NULL
);
1061 srec_write_symbols (abfd
)
1064 /* Dump out the symbols of a bfd. */
1066 int count
= bfd_get_symcount (abfd
);
1071 asymbol
**table
= bfd_get_outsymbols (abfd
);
1072 len
= strlen (abfd
->filename
);
1073 if (bfd_bwrite ("$$ ", (bfd_size_type
) 3, abfd
) != 3
1074 || bfd_bwrite (abfd
->filename
, len
, abfd
) != len
1075 || bfd_bwrite ("\r\n", (bfd_size_type
) 2, abfd
) != 2)
1078 for (i
= 0; i
< count
; i
++)
1080 asymbol
*s
= table
[i
];
1081 if (! bfd_is_local_label (abfd
, s
)
1082 && (s
->flags
& BSF_DEBUGGING
) == 0)
1084 /* Just dump out non debug symbols. */
1087 len
= strlen (s
->name
);
1088 if (bfd_bwrite (" ", (bfd_size_type
) 2, abfd
) != 2
1089 || bfd_bwrite (s
->name
, len
, abfd
) != len
)
1092 sprintf_vma (buf
+ 1, (s
->value
1093 + s
->section
->output_section
->lma
1094 + s
->section
->output_offset
));
1096 while (p
[0] == '0' && p
[1] != 0)
1103 if (bfd_bwrite (p
, len
, abfd
) != len
)
1107 if (bfd_bwrite ("$$ \r\n", (bfd_size_type
) 5, abfd
) != 5)
1115 internal_srec_write_object_contents (abfd
, symbols
)
1119 tdata_type
*tdata
= abfd
->tdata
.srec_data
;
1120 srec_data_list_type
*list
;
1124 if (! srec_write_symbols (abfd
))
1128 if (! srec_write_header (abfd
))
1131 /* Now wander though all the sections provided and output them. */
1134 while (list
!= (srec_data_list_type
*) NULL
)
1136 if (! srec_write_section (abfd
, tdata
, list
))
1140 return srec_write_terminator (abfd
, tdata
);
1144 srec_write_object_contents (abfd
)
1147 return internal_srec_write_object_contents (abfd
, 0);
1151 symbolsrec_write_object_contents (abfd
)
1154 return internal_srec_write_object_contents (abfd
, 1);
1158 srec_sizeof_headers (abfd
, exec
)
1159 bfd
*abfd ATTRIBUTE_UNUSED
;
1160 boolean exec ATTRIBUTE_UNUSED
;
1165 /* Return the amount of memory needed to read the symbol table. */
1168 srec_get_symtab_upper_bound (abfd
)
1171 return (bfd_get_symcount (abfd
) + 1) * sizeof (asymbol
*);
1174 /* Return the symbol table. */
1177 srec_get_symtab (abfd
, alocation
)
1179 asymbol
**alocation
;
1181 bfd_size_type symcount
= bfd_get_symcount (abfd
);
1185 csymbols
= abfd
->tdata
.srec_data
->csymbols
;
1186 if (csymbols
== NULL
)
1189 struct srec_symbol
*s
;
1191 csymbols
= (asymbol
*) bfd_alloc (abfd
, symcount
* sizeof (asymbol
));
1192 if (csymbols
== NULL
&& symcount
!= 0)
1194 abfd
->tdata
.srec_data
->csymbols
= csymbols
;
1196 for (s
= abfd
->tdata
.srec_data
->symbols
, c
= csymbols
;
1203 c
->flags
= BSF_GLOBAL
;
1204 c
->section
= bfd_abs_section_ptr
;
1209 for (i
= 0; i
< symcount
; i
++)
1210 *alocation
++ = csymbols
++;
1217 srec_get_symbol_info (ignore_abfd
, symbol
, ret
)
1218 bfd
*ignore_abfd ATTRIBUTE_UNUSED
;
1222 bfd_symbol_info (symbol
, ret
);
1226 srec_print_symbol (abfd
, afile
, symbol
, how
)
1230 bfd_print_symbol_type how
;
1232 FILE *file
= (FILE *) afile
;
1235 case bfd_print_symbol_name
:
1236 fprintf (file
, "%s", symbol
->name
);
1239 bfd_print_symbol_vandf (abfd
, (PTR
) file
, symbol
);
1240 fprintf (file
, " %-5s %s",
1241 symbol
->section
->name
,
1247 #define srec_close_and_cleanup _bfd_generic_close_and_cleanup
1248 #define srec_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
1249 #define srec_new_section_hook _bfd_generic_new_section_hook
1251 #define srec_bfd_is_local_label_name bfd_generic_is_local_label_name
1252 #define srec_get_lineno _bfd_nosymbols_get_lineno
1253 #define srec_find_nearest_line _bfd_nosymbols_find_nearest_line
1254 #define srec_make_empty_symbol _bfd_generic_make_empty_symbol
1255 #define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
1256 #define srec_read_minisymbols _bfd_generic_read_minisymbols
1257 #define srec_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
1259 #define srec_get_reloc_upper_bound \
1260 ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
1261 #define srec_canonicalize_reloc \
1262 ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
1263 #define srec_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
1265 #define srec_get_section_contents_in_window \
1266 _bfd_generic_get_section_contents_in_window
1268 #define srec_bfd_get_relocated_section_contents \
1269 bfd_generic_get_relocated_section_contents
1270 #define srec_bfd_relax_section bfd_generic_relax_section
1271 #define srec_bfd_gc_sections bfd_generic_gc_sections
1272 #define srec_bfd_merge_sections bfd_generic_merge_sections
1273 #define srec_bfd_discard_group bfd_generic_discard_group
1274 #define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
1275 #define srec_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
1276 #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
1277 #define srec_bfd_link_just_syms _bfd_generic_link_just_syms
1278 #define srec_bfd_final_link _bfd_generic_final_link
1279 #define srec_bfd_link_split_section _bfd_generic_link_split_section
1281 const bfd_target srec_vec
=
1284 bfd_target_srec_flavour
,
1285 BFD_ENDIAN_UNKNOWN
, /* target byte order */
1286 BFD_ENDIAN_UNKNOWN
, /* target headers byte order */
1287 (HAS_RELOC
| EXEC_P
| /* object flags */
1288 HAS_LINENO
| HAS_DEBUG
|
1289 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
1290 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
1291 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
1292 0, /* leading underscore */
1293 ' ', /* ar_pad_char */
1294 16, /* ar_max_namelen */
1295 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1296 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1297 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
1298 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1299 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1300 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
1304 srec_object_p
, /* bfd_check_format */
1311 _bfd_generic_mkarchive
,
1314 { /* bfd_write_contents */
1316 srec_write_object_contents
,
1317 _bfd_write_archive_contents
,
1321 BFD_JUMP_TABLE_GENERIC (srec
),
1322 BFD_JUMP_TABLE_COPY (_bfd_generic
),
1323 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
1324 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive
),
1325 BFD_JUMP_TABLE_SYMBOLS (srec
),
1326 BFD_JUMP_TABLE_RELOCS (srec
),
1327 BFD_JUMP_TABLE_WRITE (srec
),
1328 BFD_JUMP_TABLE_LINK (srec
),
1329 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),
1336 const bfd_target symbolsrec_vec
=
1338 "symbolsrec", /* name */
1339 bfd_target_srec_flavour
,
1340 BFD_ENDIAN_UNKNOWN
, /* target byte order */
1341 BFD_ENDIAN_UNKNOWN
, /* target headers byte order */
1342 (HAS_RELOC
| EXEC_P
| /* object flags */
1343 HAS_LINENO
| HAS_DEBUG
|
1344 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
1345 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
1346 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
1347 0, /* leading underscore */
1348 ' ', /* ar_pad_char */
1349 16, /* ar_max_namelen */
1350 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1351 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1352 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
1353 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1354 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1355 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
1359 symbolsrec_object_p
, /* bfd_check_format */
1366 _bfd_generic_mkarchive
,
1369 { /* bfd_write_contents */
1371 symbolsrec_write_object_contents
,
1372 _bfd_write_archive_contents
,
1376 BFD_JUMP_TABLE_GENERIC (srec
),
1377 BFD_JUMP_TABLE_COPY (_bfd_generic
),
1378 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
1379 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive
),
1380 BFD_JUMP_TABLE_SYMBOLS (srec
),
1381 BFD_JUMP_TABLE_RELOCS (srec
),
1382 BFD_JUMP_TABLE_WRITE (srec
),
1383 BFD_JUMP_TABLE_LINK (srec
),
1384 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),