1 /* BFD back-end for asxxxx .rel objects.
3 Borut Razem (Free Software Foundation, Inc.)
4 Written by Borut Razem <borut.razem@gmail.com>.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
25 The object module contains the following designators:
32 H Most significant byte first
33 L Least significant byte first
46 R Relocation information
49 3.5.1 Object Module Format
53 H aa areas gg global symbols
59 G nn ii 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
62 B name base nn size nn map nn flags nn fsfx string
65 A label size ss flags ff
73 T xx xx nn nn nn nn nn ...
76 R 0 0 nn nn n1 n2 xx xx ...
79 P 0 0 nn nn n1 n2 xx xx
85 #include "libiberty.h"
86 #include "safe-ctype.h"
88 #define asxxxx_bfd_group_name bfd_generic_group_name
89 #define asxxxx_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
93 #define NELEM(x) (sizeof (x) / sizeof (x)[0])
95 /* ******************* from asld aslink.h ******************* */
97 * ASLINK - Version 3 Definitions
101 * The "A3_" area constants define values used in
102 * generating the assembler area output data.
107 * A_ A_ A_ A_ A3_ A3_ A3_
108 * +-----++-----+-----+-----+-----+-----+-----+-----+-----+
109 * |LOAD || BIT |XDATA|CODE | PAG | ABS | OVR | | |
110 * +-----++-----+-----+-----+-----+-----+-----+-----+-----+
113 #define A3_CON 000 /* concatenate */
114 #define A3_OVR 004 /* overlay */
115 #define A3_REL 000 /* relocatable */
116 #define A3_ABS 010 /* absolute */
117 #define A3_NOPAG 000 /* non-paged */
118 #define A3_PAG 020 /* paged */
121 /* Additional flags for 8051 address spaces */
122 #define A_DATA 0000 /* data space (default)*/
123 #define A_CODE 0040 /* code space */
124 #define A_XDATA 0100 /* external data space */
125 #define A_BIT 0200 /* bit addressable space */
127 /* Additional flags for hc08 */
128 #define A_NOLOAD 0400 /* nonloadable */
129 #define A_LOAD 0000 /* loadable (default) */
130 /* end sdld specific */
133 * ASLINK - Version 4 Definitions
137 * The "A4_" area constants define values used in
138 * generating the assembler area output data.
143 * +-----+-----+-----+-----+-----+-----+-----+-----+
144 * | BNK | SEG | | PAG | ABS | OVR | WL1 | WL0 |
145 * +-----+-----+-----+-----+-----+-----+-----+-----+
148 #define A4_BYTE 0x0000 /* 8 bit */
149 #define A4_WORD 0x0001 /* 16 bit */
151 #define A4_1BYTE 0x0000 /* 1 Byte Word Length */
152 #define A4_2BYTE 0x0001 /* 2 Byte Word Length */
153 #define A4_3BYTE 0x0002 /* 3 Byte Word Length */
154 #define A4_4BYTE 0x0003 /* 4 Byte Word Length */
155 #define A4_WLMSK 0x0003 /* Word Length Mask */
157 #define A4_CON 0x0400 /* Concatenating */
158 #define A4_OVR 0x0404 /* Overlaying */
159 #define A4_REL 0x0800 /* Relocatable */
160 #define A4_ABS 0x0808 /* absolute */
161 #define A4_NOPAG 0x1000 /* Non-Paged */
162 #define A4_PAG 0x1010 /* Paged */
164 #define A4_CSEG 0x4000 /* CSEG */
165 #define A4_DSEG 0x4040 /* DSEG */
166 #define A4_NOBNK 0x8000 /* Non-Banked */
167 #define A4_BNK 0x8080 /* Banked */
169 #define A4_OUT 0x0100 /* Output Code Flag */
170 /* ********************************************************** */
172 /* Macros for converting between hex and binary. */
174 #define NIBBLE(x) hex_value(x)
175 #define HEX(buffer) ((NIBBLE ((buffer)[0])<<4) + NIBBLE ((buffer)[1]))
176 #define ISHEX(x) hex_p(x)
178 /* When scanning the asxxxx .rel file, a linked list of asxxxx_symbol
179 structures is built to represent the symbol table (if there is
184 struct asxxxx_symbol
*next
;
188 struct bfd_section
*section
;
191 /* The asxxxx .rel tdata information. */
193 enum asxxxx_cpu_type_e
205 enum asxxxx_rel_version_e
224 enum asxxxx_address_size_e
231 typedef struct asxxxx_data_struct
233 struct asxxxx_symbol
*symbols
;
234 struct asxxxx_symbol
*symtail
;
238 #define CURRENT_SECT(abfd) ((abfd)->tdata.asxxxx_data->secttail)
240 unsigned int sect_id
;
241 #define NEXT_SECT_ID(abfd) (++(abfd)->tdata.asxxxx_data->sect_id)
243 enum asxxxx_cpu_type_e cpu_type
;
244 #define SET_CPU_TYPE(abfd, type) ((abfd)->tdata.asxxxx_data->cpu_type = (type))
245 #define GET_CPU_TYPE(abfd) ((abfd)->tdata.asxxxx_data->cpu_type)
247 enum asxxxx_rel_version_e rel_version
;
248 #define SET_REL_VERSION(abfd, version) ((abfd)->tdata.asxxxx_data->rel_version = (version))
249 #define GET_REL_VERSION(abfd) ((abfd)->tdata.asxxxx_data->rel_version)
251 enum asxxxx_radix_e radix
;
252 #define SET_RADIX(abfd, r) ((abfd)->tdata.asxxxx_data->radix = (r))
253 #define GET_RADIX(abfd) ((abfd)->tdata.asxxxx_data->radix)
255 enum asxxxx_endian_e endian
;
256 #define SET_ENDIAN(abfd, e) ((abfd)->tdata.asxxxx_data->endian = (e))
257 #define GET_ENDIAN(abfd) ((abfd)->tdata.asxxxx_data->endian)
259 enum asxxxx_address_size_e address_size
;
260 #define SET_ADDRESS_SIZE(abfd, as) ((abfd)->tdata.asxxxx_data->address_size = (as))
261 #define GET_ADDRESS_SIZE(abfd) ((abfd)->tdata.asxxxx_data->address_size)
265 /* Initialize by filling in the hex conversion array. */
270 static bool inited
= false;
279 /* Set up the asxxxx .rel tdata information. */
282 asxxxx_mkobject (bfd
*abfd
)
288 tdata
= (tdata_type
*) bfd_zalloc (abfd
, sizeof (tdata_type
));
292 abfd
->tdata
.asxxxx_data
= tdata
;
297 /* Read a byte from an asxxxx .rel file. Set *ERRORPTR if an error
298 occurred. Return EOF on error or end of file. */
301 asxxxx_get_byte (bfd
*abfd
, bool *errorptr
)
305 if (bfd_bread (&c
, (bfd_size_type
) 1, abfd
) != 1)
307 if (bfd_get_error () == bfd_error_invalid_operation
){
308 // FEATURE? // this error is set at EOF
309 // BUG // caller expects no error
310 } else if (bfd_get_error () == bfd_error_file_truncated
){
311 // possibly this error was set at EOF in binutils<2.38
318 return (int) (c
& 0xff);
321 /* Report a problem in an asxxxx .rel file. FIXME: This probably should
322 not call fprintf, but we really do need some mechanism for printing
326 asxxxx_bad_byte (bfd
*abfd
,
334 bfd_set_error (bfd_error_file_truncated
);
341 sprintf (buf
, "\\%03o", (unsigned int) c
);
347 (*_bfd_error_handler
)
348 (_("%pB:%d: Unexpected character `%s' in asxxxx .rel file\n"),
350 bfd_set_error (bfd_error_bad_value
);
354 /* Add a new symbol found in an asxxxx .rel file. */
357 asxxxx_new_symbol (bfd
*abfd
, const char *name
, symvalue val
, flagword flags
, struct bfd_section
*section
)
359 struct asxxxx_symbol
*n
;
361 n
= (struct asxxxx_symbol
*) bfd_alloc (abfd
, sizeof (* n
));
368 n
->section
= section
;
370 if (abfd
->tdata
.asxxxx_data
->symbols
== NULL
)
371 abfd
->tdata
.asxxxx_data
->symbols
= n
;
373 abfd
->tdata
.asxxxx_data
->symtail
->next
= n
;
374 abfd
->tdata
.asxxxx_data
->symtail
= n
;
382 /* Add a new section found in an asxxxx .rel file. */
385 asxxxx_to_asection_flags(bfd
*abfd
, unsigned int flags
, unsigned int sect_size
)
387 flagword sect_flags
= SEC_NO_FLAGS
;
390 sect_flags
|= SEC_HAS_CONTENTS
;
392 if (GET_REL_VERSION (abfd
) == REL_VER_3
)
396 * A_ A_ A_ A_ A3_ A3_ A3_
397 * +-----++-----+-----+-----+-----+-----+-----+-----+-----+
398 * |LOAD || BIT |XDATA|CODE | PAG | ABS | OVR | | |
399 * +-----++-----+-----+-----+-----+-----+-----+-----+-----+
402 if (!(flags
& A3_ABS
))
403 sect_flags
|= SEC_RELOC
;
405 switch (GET_CPU_TYPE (abfd
))
408 sect_flags
|= SEC_LOAD
;
410 sect_flags
|= (SEC_CODE
| SEC_ROM
| SEC_READONLY
);
411 if (flags
& (A_XDATA
| A_BIT
) || !(flags
& (A_CODE
| A_XDATA
| A_BIT
)))
412 sect_flags
|= SEC_DATA
;
416 sect_flags
|= SEC_CODE
;
417 sect_flags
|= (flags
& A_LOAD
) ? SEC_LOAD
: SEC_NEVER_LOAD
;
421 sect_flags
|= SEC_CODE
;
422 sect_flags
|= SEC_LOAD
;
430 * +-----+-----+-----+-----+-----+-----+-----+-----+
431 * | BNK | SEG | | PAG | ABS | OVR | WL1 | WL0 |
432 * +-----+-----+-----+-----+-----+-----+-----+-----+
435 if (!(flags
& A4_ABS
))
436 sect_flags
|= SEC_RELOC
;
438 sect_flags
|= (flags
& A4_DSEG
) ? SEC_DATA
: SEC_CODE
;
439 sect_flags
|= SEC_LOAD
;
446 asxxxx_new_section (bfd
*abfd
, const char *sect_name
, unsigned int sect_size
, unsigned int sect_flags
, unsigned int sect_addr
)
450 if ((sect
= (asection
*) bfd_zalloc (abfd
, sizeof (*sect
))) == NULL
)
453 sect
->name
= sect_name
;
454 sect
->id
= sect
->index
= NEXT_SECT_ID(abfd
);
455 sect
->flags
= asxxxx_to_asection_flags(abfd
, sect_flags
, sect_size
);
456 sect
->size
= sect
->rawsize
= sect_size
;
457 sect
->vma
= sect
->lma
= sect_addr
;
459 if (abfd
->tdata
.asxxxx_data
->sections
== NULL
)
460 abfd
->tdata
.asxxxx_data
->sections
= sect
;
463 sect
->prev
= abfd
->tdata
.asxxxx_data
->secttail
;
464 abfd
->tdata
.asxxxx_data
->secttail
->next
= sect
;
466 abfd
->tdata
.asxxxx_data
->secttail
= sect
;
471 /* Read the asxxxx .rel file and turn it into sections. We create a new
472 section for each contiguous set of bytes. */
475 asxxxx_skip_spaces (bfd
*abfd
, int *p_c
, unsigned int lineno
, bool *errorptr
)
477 if (! ISSPACE (*p_c
))
479 asxxxx_bad_byte (abfd
, *p_c
, lineno
, *errorptr
);
483 while (ISSPACE (*p_c
= asxxxx_get_byte (abfd
, errorptr
)))
490 asxxxx_skip_word (bfd
*abfd
, char *word
, int *p_c
, unsigned int lineno
, bool *errorptr
)
494 for (p
= word
; *p
!= '\0'; ++p
)
498 *p_c
= asxxxx_get_byte (abfd
, errorptr
);
502 asxxxx_bad_byte (abfd
, *p_c
, lineno
, *errorptr
);
511 asxxxx_get_word (bfd
*abfd
, char **p_word
, int *p_c
, unsigned int lineno
, bool *errorptr
)
518 symbuf
= (char *) bfd_malloc (alc
+ 1);
525 while (! ISSPACE (*p_c
= asxxxx_get_byte (abfd
, errorptr
)) && *p_c
!= EOF
)
527 if ((bfd_size_type
) (p
- symbuf
) >= alc
)
532 n
= (char *) bfd_realloc (symbuf
, alc
+ 1);
535 p
= n
+ (p
- symbuf
);
544 asxxxx_bad_byte (abfd
, *p_c
, lineno
, *errorptr
);
550 symname
= (char *) bfd_alloc (abfd
, (bfd_size_type
) (p
- symbuf
));
554 strcpy (symname
, symbuf
);
571 asxxxx_get_hex (bfd
*abfd
, unsigned int *p_val
, int *p_c
, unsigned int lineno
, bool *errorptr
)
576 *p_val
= (*p_val
<< 4) + NIBBLE (*p_c
);
577 *p_c
= asxxxx_get_byte (abfd
, errorptr
);
582 asxxxx_bad_byte (abfd
, *p_c
, lineno
, *errorptr
);
590 asxxxx_get_eol (bfd
*abfd
, int *p_c
, unsigned int *p_lineno
, bool *errorptr
)
597 else if (*p_c
!= '\r')
599 asxxxx_bad_byte (abfd
, *p_c
, *p_lineno
, *errorptr
);
607 asxxxx_skip_line (bfd
*abfd
, int *p_c
, unsigned int *p_lineno
, bool *errorptr
)
609 while ((*p_c
= asxxxx_get_byte (abfd
, errorptr
)) != EOF
&& *p_c
!= '\n' && *p_c
!= '\r')
612 return asxxxx_get_eol (abfd
, p_c
, p_lineno
, errorptr
);
616 asxxxx_set_cpu_type(bfd
*abfd
, const char *cpu_type
)
621 enum asxxxx_cpu_type_e type
;
625 { "-mmcs51", CPU_MCS51
},
626 { "-mds390", CPU_DS390
},
627 { "-mds400", CPU_DS400
},
628 { "-mhc08", CPU_HC08
},
629 { "-mz80", CPU_Z80
},
630 { "-mgbz80", CPU_GBZ80
},
631 { "-mr2K", CPU_R2K
},
635 for (i
= 0; i
< NELEM (cpus
); ++i
)
637 if (! strcmp (cpu_type
, cpus
[i
].name
))
639 SET_CPU_TYPE (abfd
, cpus
[i
].type
);
644 SET_CPU_TYPE (abfd
, CPU_UNKNOWN
);
648 asxxxx_scan (bfd
*abfd
, unsigned int *p_lineno
)
653 bfd_set_error (bfd_error_file_truncated
);
655 while ((c
= asxxxx_get_byte (abfd
, &error
)) != EOF
)
661 asxxxx_bad_byte (abfd
, c
, *p_lineno
, error
);
673 /* A CSEG size 12E2 flags 20 addr 0 */
676 unsigned int sect_size
, sect_flags
, sect_addr
;
678 /* Starting a symbol definition. */
679 c
= asxxxx_get_byte (abfd
, &error
);
681 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
684 if (! asxxxx_get_word (abfd
, §_name
, &c
, *p_lineno
, &error
))
687 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
690 if (! asxxxx_skip_word (abfd
, "size", &c
, *p_lineno
, &error
))
693 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
696 if (! asxxxx_get_hex (abfd
, §_size
, &c
, *p_lineno
, &error
))
699 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
702 if (! asxxxx_skip_word (abfd
, "flags", &c
, *p_lineno
, &error
))
705 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
708 if (! asxxxx_get_hex (abfd
, §_flags
, &c
, *p_lineno
, &error
))
711 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
714 if (! asxxxx_skip_word (abfd
, "addr", &c
, *p_lineno
, &error
))
717 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
720 if (! asxxxx_get_hex (abfd
, §_addr
, &c
, *p_lineno
, &error
))
723 if (! asxxxx_get_eol (abfd
, &c
, p_lineno
, &error
))
726 if (! asxxxx_new_section (abfd
, sect_name
, sect_size
, sect_flags
, sect_addr
))
732 * O -mds390 --model-flat24
733 * O -mds400 --model-flat24
735 * O -mmcs51 --model-huge
736 * O -mmcs51 --model-large
737 * O -mmcs51 --model-medium
738 * O -mmcs51 --model-small
739 * O -mmcs51 --model-small --xstack
744 /* check if the next character is space */
745 c
= asxxxx_get_byte (abfd
, &error
);
747 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
750 if (! asxxxx_get_word (abfd
, &cpu_type
, &c
, *p_lineno
, &error
))
753 /* eat the rest of line */
754 if (! asxxxx_skip_line (abfd
, &c
, p_lineno
, &error
))
757 asxxxx_set_cpu_type(abfd
, cpu_type
);
760 case 'G': /* V 4.XX+ */
761 case 'B': /* V 4.XX+ */
762 SET_REL_VERSION (abfd
, REL_VER_4
);
769 /* check if the next character is space */
770 c
= asxxxx_get_byte (abfd
, &error
);
772 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
775 /* eat the rest of line */
776 if (! asxxxx_skip_line (abfd
, &c
, p_lineno
, &error
))
781 /* S __ret3 Def0001 */
783 char *symname
= NULL
;
787 /* Starting a symbol definition. */
788 c
= asxxxx_get_byte (abfd
, &error
);
790 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
793 if (! asxxxx_get_word (abfd
, &symname
, &c
, *p_lineno
, &error
))
796 if (! asxxxx_skip_spaces (abfd
, &c
, *p_lineno
, &error
))
799 if (c
!= 'D' && c
!= 'R')
801 asxxxx_bad_byte (abfd
, c
, *p_lineno
, error
);
807 c
= asxxxx_get_byte (abfd
, &error
);
808 if (! asxxxx_skip_word (abfd
, "ef", &c
, *p_lineno
, &error
))
811 if (! asxxxx_get_hex(abfd
, &symval
, &c
, *p_lineno
, &error
))
814 if (! asxxxx_get_eol (abfd
, &c
, p_lineno
, &error
))
817 if (! asxxxx_new_symbol (abfd
, symname
, symval
, BSF_GLOBAL
, CURRENT_SECT(abfd
) ? CURRENT_SECT(abfd
) : (is_def
? bfd_abs_section_ptr
: bfd_und_section_ptr
)))
833 /* Check whether an existing file is an asxxxx .rel file. */
836 asxxxx_is_rel (bfd
*abfd
, unsigned int *p_lineno
)
845 switch (c
= asxxxx_get_byte (abfd
, &error
))
849 asxxxx_bad_byte (abfd
, c
, *p_lineno
, error
);
853 c
= asxxxx_get_byte (abfd
, &error
);
855 if (! asxxxx_skip_word (abfd
, "!FILE ", &c
, *p_lineno
, &error
))
859 /* eat the rest of line */
860 if (! asxxxx_skip_line (abfd
, &c
, p_lineno
, &error
))
865 SET_RADIX (abfd
, RADIX_HEX
);
868 SET_RADIX (abfd
, RADIX_DEC
);
871 SET_RADIX (abfd
, RADIX_OCT
);
873 switch (c
= asxxxx_get_byte (abfd
, &error
))
876 asxxxx_bad_byte (abfd
, c
, *p_lineno
, error
);
880 SET_ENDIAN (abfd
, ENDIAN_BIG
);
883 SET_ENDIAN (abfd
, ENDIAN_LITTLE
);
885 switch (c
= asxxxx_get_byte (abfd
, &error
))
888 asxxxx_bad_byte (abfd
, c
, *p_lineno
, error
);
895 SET_ADDRESS_SIZE (abfd
, ADDR_SIZE_2
);
899 SET_ADDRESS_SIZE (abfd
, ADDR_SIZE_2
);
902 SET_ADDRESS_SIZE (abfd
, ADDR_SIZE_3
);
905 SET_ADDRESS_SIZE (abfd
, ADDR_SIZE_4
);
907 c
= asxxxx_get_byte (abfd
, &error
);
908 if (! asxxxx_get_eol (abfd
, &c
, p_lineno
, &error
))
917 return error
? false : true;
920 static void asxxxx_cleanup(bfd
*abfd
)
922 bfd_release (abfd
, abfd
->tdata
.any
);
923 abfd
->tdata
.any
= NULL
;
927 asxxxx_object_p (bfd
*abfd
);
930 asxxxx_object_p (bfd
*abfd
)
933 unsigned int lineno
= 1;
937 if (! asxxxx_mkobject (abfd
) || ! asxxxx_is_rel (abfd
, &lineno
))
939 bfd_set_error (bfd_error_wrong_format
);
943 tdata_save
= abfd
->tdata
.any
;
944 if (! asxxxx_scan (abfd
, &lineno
))
946 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
947 bfd_release (abfd
, abfd
->tdata
.any
);
948 abfd
->tdata
.any
= tdata_save
;
952 if (abfd
->symcount
> 0)
953 abfd
->flags
|= HAS_SYMS
;
955 return asxxxx_cleanup
;
958 /* Get the contents of a section. */
961 asxxxx_get_section_contents (bfd
*abfd ATTRIBUTE_UNUSED
,
962 asection
*section ATTRIBUTE_UNUSED
,
963 void * location ATTRIBUTE_UNUSED
,
964 file_ptr offset ATTRIBUTE_UNUSED
,
965 bfd_size_type count ATTRIBUTE_UNUSED
)
970 /* Set the architecture. We accept an unknown architecture here. */
973 asxxxx_set_arch_mach (bfd
*abfd
, enum bfd_architecture arch
, unsigned long mach
)
975 if (arch
!= bfd_arch_unknown
)
976 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
978 abfd
->arch_info
= & bfd_default_arch_struct
;
982 /* Set the contents of a section. */
985 asxxxx_set_section_contents (bfd
*abfd ATTRIBUTE_UNUSED
,
986 sec_ptr section ATTRIBUTE_UNUSED
,
987 const void * location ATTRIBUTE_UNUSED
,
988 file_ptr offset ATTRIBUTE_UNUSED
,
989 bfd_size_type bytes_to_do ATTRIBUTE_UNUSED
)
995 asxxxx_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
996 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
1001 /* Return the amount of memory needed to read the symbol table. */
1004 asxxxx_get_symtab_upper_bound (bfd
*abfd
)
1006 return (bfd_get_symcount (abfd
) + 1) * sizeof (asymbol
*);
1009 /* Return the symbol table. */
1012 asxxxx_canonicalize_symtab (bfd
*abfd
, asymbol
**alocation
)
1014 bfd_size_type symcount
= bfd_get_symcount (abfd
);
1018 csymbols
= abfd
->tdata
.asxxxx_data
->csymbols
;
1019 if (csymbols
== NULL
&& symcount
!= 0)
1022 struct asxxxx_symbol
*s
;
1024 csymbols
= (asymbol
*) bfd_alloc (abfd
, symcount
* sizeof (asymbol
));
1025 if (csymbols
== NULL
)
1027 abfd
->tdata
.asxxxx_data
->csymbols
= csymbols
;
1029 for (s
= abfd
->tdata
.asxxxx_data
->symbols
, c
= csymbols
;
1036 c
->flags
= s
->flags
;
1037 c
->section
= s
->section
;
1042 for (i
= 0; i
< symcount
; i
++)
1043 *alocation
++ = csymbols
++;
1050 asxxxx_get_symbol_info (bfd
*ignore_abfd ATTRIBUTE_UNUSED
,
1054 bfd_symbol_info (symbol
, ret
);
1057 #define asxxxx_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string
1060 asxxxx_print_symbol (bfd
*abfd
,
1063 bfd_print_symbol_type how
)
1065 FILE *file
= (FILE *) afile
;
1069 case bfd_print_symbol_name
:
1070 fprintf (file
, "%s", symbol
->name
);
1073 bfd_print_symbol_vandf (abfd
, (void *) file
, symbol
);
1074 fprintf (file
, " %-5s %s",
1075 symbol
->section
->name
,
1080 static bool asxxxx_bfd_is_target_special_symbol(bfd
* a
, asymbol
* b
)
1087 #define asxxxx_find_line _bfd_nosymbols_find_line
1088 #define asxxxx_close_and_cleanup _bfd_generic_close_and_cleanup
1089 #define asxxxx_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
1090 #define asxxxx_new_section_hook _bfd_generic_new_section_hook
1091 #define asxxxx_bfd_is_local_label_name bfd_generic_is_local_label_name
1092 #define asxxxx_get_lineno _bfd_nosymbols_get_lineno
1093 #define asxxxx_find_nearest_line _bfd_nosymbols_find_nearest_line
1094 #define asxxxx_find_inliner_info _bfd_nosymbols_find_inliner_info
1095 #define asxxxx_make_empty_symbol _bfd_generic_make_empty_symbol
1096 #define asxxxx_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
1097 #define asxxxx_read_minisymbols _bfd_generic_read_minisymbols
1098 #define asxxxx_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
1099 #define asxxxx_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
1100 #define asxxxx_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
1101 #define asxxxx_bfd_relax_section bfd_generic_relax_section
1102 #define asxxxx_bfd_gc_sections bfd_generic_gc_sections
1103 #define asxxxx_bfd_lookup_section_flags bfd_generic_lookup_section_flags
1104 #define asxxxx_bfd_merge_sections bfd_generic_merge_sections
1105 #define asxxxx_bfd_is_group_section bfd_generic_is_group_section
1106 #define asxxxx_bfd_discard_group bfd_generic_discard_group
1107 #define asxxxx_section_already_linked _bfd_generic_section_already_linked
1108 #define asxxxx_bfd_define_common_symbol bfd_generic_define_common_symbol
1109 #define asxxxx_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
1110 #define asxxxx_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
1111 #define asxxxx_bfd_link_add_symbols _bfd_generic_link_add_symbols
1112 #define asxxxx_bfd_link_just_syms _bfd_generic_link_just_syms
1113 #define asxxxx_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type
1114 #define asxxxx_bfd_final_link _bfd_generic_final_link
1115 #define asxxxx_bfd_link_split_section _bfd_generic_link_split_section
1116 #define asxxxx_bfd_link_check_relocs _bfd_generic_link_check_relocs
1117 #define asxxxx_bfd_define_start_stop bfd_generic_define_start_stop
1119 const bfd_target asxxxx_vec
=
1121 "asxxxx", /* Name. */
1122 bfd_target_asxxxx_flavour
,
1123 BFD_ENDIAN_UNKNOWN
, /* Target byte order. */
1124 BFD_ENDIAN_UNKNOWN
, /* Target headers byte order. */
1125 (HAS_RELOC
| EXEC_P
| /* Object flags. */
1126 HAS_LINENO
| HAS_DEBUG
|
1127 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
1128 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
1129 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* Section flags. */
1130 0, /* Leading underscore. */
1131 '/', /* AR_pad_char. */
1132 15, /* AR_max_namelen. */
1133 1, /* match priority. */
1134 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
1135 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1136 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1137 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* Data. */
1138 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1139 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1140 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* Hdrs. */
1142 { /* Check the format of a file being read. Return a <<bfd_target *>> or zero. */
1145 asxxxx_object_p
, /* object */
1146 bfd_generic_archive_p
, /* archive */
1147 _bfd_dummy_target
, /* core */
1149 { /* Set the format of a file being written. */
1151 asxxxx_mkobject
, /* object */
1152 _bfd_generic_mkarchive
, /* archive */
1155 { /* Write cached information into a file being written, at <<bfd_close>>. */
1157 false, /* asxxxx_write_object_contents, object */
1158 _bfd_write_archive_contents
, /* archive */
1162 BFD_JUMP_TABLE_GENERIC (asxxxx
),
1163 BFD_JUMP_TABLE_COPY (_bfd_generic
),
1164 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
1165 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff
),
1166 BFD_JUMP_TABLE_SYMBOLS (asxxxx
),
1167 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs
),
1168 BFD_JUMP_TABLE_WRITE (asxxxx
),
1169 BFD_JUMP_TABLE_LINK (asxxxx
),
1170 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),