Commit | Line | Data |
---|---|---|
cd6213ff FF |
1 | /* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP). |
2 | Copyright 1996 Free Software Foundation, Inc. | |
3 | ||
4 | Written by Fred Fish (fnf@cygnus.com) | |
5 | ||
6 | There is nothing new under the sun. This file draws a lot on other | |
7 | coff files. | |
8 | ||
9 | This file is part of BFD, the Binary File Descriptor library. | |
10 | ||
11 | This program is free software; you can redistribute it and/or modify | |
12 | it under the terms of the GNU General Public License as published by | |
13 | the Free Software Foundation; either version 2 of the License, or | |
14 | (at your option) any later version. | |
15 | ||
16 | This program is distributed in the hope that it will be useful, | |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU General Public License | |
22 | along with this program; if not, write to the Free Software | |
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
5a608f5b FF |
24 | |
25 | #include "bfd.h" | |
26 | #include "sysdep.h" | |
27 | #include "libbfd.h" | |
28 | #include "obstack.h" | |
29 | #include "coff/tic80.h" | |
30 | #include "coff/internal.h" | |
31 | #include "libcoff.h" | |
32 | ||
4507d858 | 33 | #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) |
5a608f5b FF |
34 | |
35 | #define coff_relocate_section _bfd_coff_generic_relocate_section | |
36 | ||
4507d858 FF |
37 | static void rtype2howto PARAMS ((arelent *cache_ptr, struct internal_reloc *dst)); |
38 | ||
39 | static reloc_howto_type tic80_howto_table[] = | |
40 | { | |
41 | ||
42 | HOWTO (R_RELLONG, /* type */ | |
43 | 0, /* rightshift */ | |
44 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
45 | 32, /* bitsize */ | |
46 | false, /* pc_relative */ | |
47 | 0, /* bitpos */ | |
48 | complain_overflow_bitfield, /* complain_on_overflow */ | |
49 | NULL, /* special_function */ | |
50 | "32", /* name */ | |
51 | true, /* partial_inplace */ | |
52 | 0xffffffff, /* src_mask */ | |
53 | 0xffffffff, /* dst_mask */ | |
54 | false), /* pcrel_offset */ | |
55 | ||
56 | HOWTO (R_MPPCR, /* type */ | |
57 | 0, /* rightshift */ | |
58 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
59 | 32, /* bitsize */ | |
60 | true, /* pc_relative */ | |
61 | 0, /* bitpos */ | |
62 | complain_overflow_dont, /* complain_on_overflow */ | |
63 | NULL, /* special_function */ | |
64 | "MPPCR", /* name */ | |
65 | true, /* partial_inplace */ | |
66 | 0xffffffff, /* src_mask */ | |
67 | 0xffffffff, /* dst_mask */ | |
68 | true), /* pcrel_offset */ | |
69 | }; | |
70 | ||
71 | /* Code to turn an external r_type into a pointer to an entry in the howto_table. | |
72 | If passed an r_type we don't recognize, just set the howto field to NULL and | |
73 | the caller will print an appropriate error message. */ | |
74 | ||
75 | static void | |
76 | rtype2howto (cache_ptr, dst) | |
77 | arelent *cache_ptr; | |
78 | struct internal_reloc *dst; | |
79 | { | |
80 | switch (dst -> r_type) | |
81 | { | |
82 | default: cache_ptr -> howto = NULL; break; | |
83 | case R_RELLONG: cache_ptr -> howto = tic80_howto_table + 0; break; | |
84 | case R_MPPCR: cache_ptr -> howto = tic80_howto_table + 1; break; | |
85 | } | |
86 | } | |
87 | ||
88 | #define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst) | |
89 | #define coff_rtype_to_howto coff_tic80_rtype_to_howto | |
90 | ||
91 | static reloc_howto_type * | |
92 | coff_tic80_rtype_to_howto (abfd, sec, rel, h, sym, addendp) | |
93 | bfd *abfd; | |
94 | asection *sec; | |
95 | struct internal_reloc *rel; | |
96 | struct coff_link_hash_entry *h; | |
97 | struct internal_syment *sym; | |
98 | bfd_vma *addendp; | |
99 | { | |
100 | arelent genrel; | |
101 | ||
102 | if (rel -> r_symndx == -1 && addendp != NULL) | |
103 | { | |
104 | /* This is a TI "internal relocation", which means that the relocation | |
105 | amount is the amount by which the current section is being relocated | |
106 | in the output section. */ | |
107 | *addendp = (sec -> output_section -> vma + sec -> output_offset) - sec -> vma; | |
108 | } | |
109 | RTYPE2HOWTO (&genrel, rel); | |
110 | return genrel.howto; | |
111 | } | |
5a608f5b FF |
112 | |
113 | #ifndef BADMAG | |
114 | #define BADMAG(x) TIC80BADMAG(x) | |
115 | #endif | |
116 | ||
117 | #define TIC80 1 /* Customize coffcode.h */ | |
118 | #include "coffcode.h" | |
119 | ||
120 | const bfd_target | |
121 | #ifdef TARGET_SYM | |
122 | TARGET_SYM = | |
123 | #else | |
124 | tic80coff_vec = | |
125 | #endif | |
126 | { | |
127 | #ifdef TARGET_NAME | |
128 | TARGET_NAME, | |
129 | #else | |
130 | "coff-tic80", /* name */ | |
131 | #endif | |
132 | bfd_target_coff_flavour, | |
0716c2e9 FF |
133 | BFD_ENDIAN_LITTLE, /* data byte order is little (arch supports both) */ |
134 | BFD_ENDIAN_LITTLE, /* header byte order is little */ | |
5a608f5b FF |
135 | |
136 | (HAS_RELOC | EXEC_P | /* object flags */ | |
137 | HAS_LINENO | HAS_DEBUG | | |
138 | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), | |
139 | ||
140 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
141 | #ifdef NAMES_HAVE_UNDERSCORE | |
142 | '_', | |
143 | #else | |
144 | 0, /* leading underscore */ | |
145 | #endif | |
146 | '/', /* ar_pad_char */ | |
147 | 15, /* ar_max_namelen */ | |
4507d858 FF |
148 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, |
149 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
150 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
0716c2e9 FF |
151 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, |
152 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
153 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ | |
5a608f5b FF |
154 | |
155 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
156 | bfd_generic_archive_p, _bfd_dummy_target}, | |
157 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
158 | bfd_false}, | |
159 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
160 | _bfd_write_archive_contents, bfd_false}, | |
161 | ||
162 | BFD_JUMP_TABLE_GENERIC (coff), | |
163 | BFD_JUMP_TABLE_COPY (coff), | |
164 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
165 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
166 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
167 | BFD_JUMP_TABLE_RELOCS (coff), | |
168 | BFD_JUMP_TABLE_WRITE (coff), | |
169 | BFD_JUMP_TABLE_LINK (coff), | |
170 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
171 | ||
172 | COFF_SWAP_TABLE | |
173 | }; |