| OLD | NEW |
| 1 /* BFD back-end for TMS320C4X coff binaries. | 1 /* BFD back-end for TMS320C4X coff binaries. |
| 2 Copyright 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2005, 2007, | 2 Copyright 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2005, 2007, |
| 3 2008 Free Software Foundation, Inc. | 3 2008, 2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz) | 5 Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz) |
| 6 | 6 |
| 7 This file is part of BFD, the Binary File Descriptor library. | 7 This file is part of BFD, the Binary File Descriptor library. |
| 8 | 8 |
| 9 This program is free software; you can redistribute it and/or modify | 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 | 10 it under the terms of the GNU General Public License as published by |
| 11 the Free Software Foundation; either version 3 of the License, or | 11 the Free Software Foundation; either version 3 of the License, or |
| 12 (at your option) any later version. | 12 (at your option) any later version. |
| 13 | 13 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 25 #include "bfd.h" | 25 #include "bfd.h" |
| 26 #include "libbfd.h" | 26 #include "libbfd.h" |
| 27 #include "bfdlink.h" | 27 #include "bfdlink.h" |
| 28 #include "coff/tic4x.h" | 28 #include "coff/tic4x.h" |
| 29 #include "coff/internal.h" | 29 #include "coff/internal.h" |
| 30 #include "libcoff.h" | 30 #include "libcoff.h" |
| 31 | 31 |
| 32 #undef F_LSYMS | 32 #undef F_LSYMS |
| 33 #define F_LSYMS F_LSYMS_TICOFF | 33 #define F_LSYMS F_LSYMS_TICOFF |
| 34 | 34 |
| 35 static bfd_boolean ticoff_bfd_is_local_label_name | 35 static reloc_howto_type * |
| 36 PARAMS ((bfd *, const char *)); | 36 coff_tic4x_rtype_to_howto (bfd *, asection *, struct internal_reloc *, |
| 37 static bfd_reloc_status_type tic4x_relocation | 37 » » » struct coff_link_hash_entry *, |
| 38 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char ** )); | 38 » » » struct internal_syment *, bfd_vma *); |
| 39 static reloc_howto_type *tic4x_coff_reloc_type_lookup | 39 static void |
| 40 PARAMS ((bfd *, bfd_reloc_code_real_type )); | 40 tic4x_reloc_processing (arelent *, struct internal_reloc *, |
| 41 static void tic4x_lookup_howto | 41 » » » asymbol **, bfd *, asection *); |
| 42 PARAMS ((arelent *, struct internal_reloc * )); | |
| 43 static reloc_howto_type *coff_tic4x_rtype_to_howto | |
| 44 PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_e
ntry *, struct internal_syment *, bfd_vma * )); | |
| 45 static void tic4x_reloc_processing | |
| 46 PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection * )
); | |
| 47 | |
| 48 | 42 |
| 49 /* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local | 43 /* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local |
| 50 labels. */ | 44 labels. */ |
| 51 static bfd_boolean | 45 static bfd_boolean |
| 52 ticoff_bfd_is_local_label_name (abfd, name) | 46 ticoff_bfd_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, |
| 53 bfd *abfd ATTRIBUTE_UNUSED; | 47 » » » » const char *name) |
| 54 const char *name; | |
| 55 { | 48 { |
| 56 if (TICOFF_LOCAL_LABEL_P(name)) | 49 if (TICOFF_LOCAL_LABEL_P(name)) |
| 57 return TRUE; | 50 return TRUE; |
| 58 return FALSE; | 51 return FALSE; |
| 59 } | 52 } |
| 60 | 53 |
| 61 #define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name | 54 #define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name |
| 62 | 55 |
| 63 #define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\ | 56 #define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\ |
| 64 tic4x_reloc_processing (RELENT,RELOC,SYMS,ABFD,SECT) | 57 tic4x_reloc_processing (RELENT,RELOC,SYMS,ABFD,SECT) |
| 65 | 58 |
| 66 /* Customize coffcode.h; the default coff_ functions are set up to use | 59 /* Customize coffcode.h; the default coff_ functions are set up to use |
| 67 COFF2; coff_bad_format_hook uses BADMAG, so set that for COFF2. | 60 COFF2; coff_bad_format_hook uses BADMAG, so set that for COFF2. |
| 68 The COFF1 and COFF0 vectors use custom _bad_format_hook procs | 61 The COFF1 and COFF0 vectors use custom _bad_format_hook procs |
| 69 instead of setting BADMAG. */ | 62 instead of setting BADMAG. */ |
| 70 #define BADMAG(x) COFF2_BADMAG(x) | 63 #define BADMAG(x) COFF2_BADMAG(x) |
| 71 | 64 |
| 72 #undef coff_rtype_to_howto | 65 #undef coff_rtype_to_howto |
| 73 #define coff_rtype_to_howto coff_tic4x_rtype_to_howto | 66 #define coff_rtype_to_howto coff_tic4x_rtype_to_howto |
| 74 | 67 |
| 75 #ifndef bfd_pe_print_pdata | 68 #ifndef bfd_pe_print_pdata |
| 76 #define bfd_pe_print_pdata NULL | 69 #define bfd_pe_print_pdata NULL |
| 77 #endif | 70 #endif |
| 78 | 71 |
| 79 #include "coffcode.h" | 72 #include "coffcode.h" |
| 80 | 73 |
| 81 static bfd_reloc_status_type | 74 static bfd_reloc_status_type |
| 82 tic4x_relocation (abfd, reloc_entry, symbol, data, input_section, | 75 tic4x_relocation (bfd *abfd ATTRIBUTE_UNUSED, |
| 83 » » output_bfd, error_message) | 76 » » arelent *reloc_entry, |
| 84 bfd *abfd ATTRIBUTE_UNUSED; | 77 » » asymbol *symbol ATTRIBUTE_UNUSED, |
| 85 arelent *reloc_entry; | 78 » » void * data ATTRIBUTE_UNUSED, |
| 86 asymbol *symbol ATTRIBUTE_UNUSED; | 79 » » asection *input_section, |
| 87 PTR data ATTRIBUTE_UNUSED; | 80 » » bfd *output_bfd, |
| 88 asection *input_section; | 81 » » char **error_message ATTRIBUTE_UNUSED) |
| 89 bfd *output_bfd; | |
| 90 char **error_message ATTRIBUTE_UNUSED; | |
| 91 { | 82 { |
| 92 if (output_bfd != (bfd *) NULL) | 83 if (output_bfd != (bfd *) NULL) |
| 93 { | 84 { |
| 94 /* This is a partial relocation, and we want to apply the | 85 /* This is a partial relocation, and we want to apply the |
| 95 relocation to the reloc entry rather than the raw data. | 86 relocation to the reloc entry rather than the raw data. |
| 96 Modify the reloc inplace to reflect what we now know. */ | 87 Modify the reloc inplace to reflect what we now know. */ |
| 97 reloc_entry->address += input_section->output_offset; | 88 reloc_entry->address += input_section->output_offset; |
| 98 return bfd_reloc_ok; | 89 return bfd_reloc_ok; |
| 99 } | 90 } |
| 100 return bfd_reloc_continue; | 91 return bfd_reloc_continue; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 121 | 112 |
| 122 #undef coff_bfd_reloc_type_lookup | 113 #undef coff_bfd_reloc_type_lookup |
| 123 #define coff_bfd_reloc_type_lookup tic4x_coff_reloc_type_lookup | 114 #define coff_bfd_reloc_type_lookup tic4x_coff_reloc_type_lookup |
| 124 #undef coff_bfd_reloc_name_lookup | 115 #undef coff_bfd_reloc_name_lookup |
| 125 #define coff_bfd_reloc_name_lookup tic4x_coff_reloc_name_lookup | 116 #define coff_bfd_reloc_name_lookup tic4x_coff_reloc_name_lookup |
| 126 | 117 |
| 127 /* For the case statement use the code values used tc_gen_reloc (defined in | 118 /* For the case statement use the code values used tc_gen_reloc (defined in |
| 128 bfd/reloc.c) to map to the howto table entries. */ | 119 bfd/reloc.c) to map to the howto table entries. */ |
| 129 | 120 |
| 130 static reloc_howto_type * | 121 static reloc_howto_type * |
| 131 tic4x_coff_reloc_type_lookup (abfd, code) | 122 tic4x_coff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
| 132 bfd *abfd ATTRIBUTE_UNUSED; | 123 » » » bfd_reloc_code_real_type code) |
| 133 bfd_reloc_code_real_type code; | |
| 134 { | 124 { |
| 135 unsigned int type; | 125 unsigned int type; |
| 136 unsigned int i; | 126 unsigned int i; |
| 137 | 127 |
| 138 switch (code) | 128 switch (code) |
| 139 { | 129 { |
| 140 case BFD_RELOC_32: type = R_RELLONG; break; | 130 case BFD_RELOC_32: type = R_RELLONG; break; |
| 141 case BFD_RELOC_24: type = R_REL24; break; | 131 case BFD_RELOC_24: type = R_REL24; break; |
| 142 case BFD_RELOC_16: type = R_RELWORD; break; | 132 case BFD_RELOC_16: type = R_RELWORD; break; |
| 143 case BFD_RELOC_24_PCREL: type = R_PCR24; break; | 133 case BFD_RELOC_24_PCREL: type = R_PCR24; break; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 169 && strcasecmp (tic4x_howto_table[i].name, r_name) == 0) | 159 && strcasecmp (tic4x_howto_table[i].name, r_name) == 0) |
| 170 return &tic4x_howto_table[i]; | 160 return &tic4x_howto_table[i]; |
| 171 | 161 |
| 172 return NULL; | 162 return NULL; |
| 173 } | 163 } |
| 174 | 164 |
| 175 /* Code to turn a r_type into a howto ptr, uses the above howto table. | 165 /* Code to turn a r_type into a howto ptr, uses the above howto table. |
| 176 Called after some initial checking by the tic4x_rtype_to_howto fn | 166 Called after some initial checking by the tic4x_rtype_to_howto fn |
| 177 below. */ | 167 below. */ |
| 178 static void | 168 static void |
| 179 tic4x_lookup_howto (internal, dst) | 169 tic4x_lookup_howto (arelent *internal, |
| 180 arelent *internal; | 170 » » struct internal_reloc *dst) |
| 181 struct internal_reloc *dst; | |
| 182 { | 171 { |
| 183 unsigned int i; | 172 unsigned int i; |
| 184 int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0; | 173 int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0; |
| 185 | 174 |
| 186 for (i = 0; i < HOWTO_SIZE; i++) | 175 for (i = 0; i < HOWTO_SIZE; i++) |
| 187 { | 176 { |
| 188 if (tic4x_howto_table[i].type == dst->r_type) | 177 if (tic4x_howto_table[i].type == dst->r_type) |
| 189 { | 178 { |
| 190 internal->howto = tic4x_howto_table + i + bank; | 179 internal->howto = tic4x_howto_table + i + bank; |
| 191 return; | 180 return; |
| 192 } | 181 } |
| 193 } | 182 } |
| 194 | 183 |
| 195 (*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"), | 184 (*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"), |
| 196 (unsigned int) dst->r_type); | 185 (unsigned int) dst->r_type); |
| 197 abort(); | 186 abort(); |
| 198 } | 187 } |
| 199 | 188 |
| 200 static reloc_howto_type * | 189 static reloc_howto_type * |
| 201 coff_tic4x_rtype_to_howto (abfd, sec, rel, h, sym, addendp) | 190 coff_tic4x_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, |
| 202 bfd *abfd ATTRIBUTE_UNUSED; | 191 » » » asection *sec, |
| 203 asection *sec; | 192 » » » struct internal_reloc *rel, |
| 204 struct internal_reloc *rel; | 193 » » » struct coff_link_hash_entry *h ATTRIBUTE_UNUSED, |
| 205 struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; | 194 » » » struct internal_syment *sym ATTRIBUTE_UNUSED, |
| 206 struct internal_syment *sym ATTRIBUTE_UNUSED; | 195 » » » bfd_vma *addendp) |
| 207 bfd_vma *addendp; | |
| 208 { | 196 { |
| 209 arelent genrel; | 197 arelent genrel; |
| 210 | 198 |
| 211 if (rel->r_symndx == -1 && addendp != NULL) | 199 if (rel->r_symndx == -1 && addendp != NULL) |
| 212 /* This is a TI "internal relocation", which means that the relocation | 200 /* This is a TI "internal relocation", which means that the relocation |
| 213 amount is the amount by which the current section is being relocated | 201 amount is the amount by which the current section is being relocated |
| 214 in the output section. */ | 202 in the output section. */ |
| 215 *addendp = (sec->output_section->vma + sec->output_offset) - sec->vma; | 203 *addendp = (sec->output_section->vma + sec->output_offset) - sec->vma; |
| 216 | 204 |
| 217 tic4x_lookup_howto (&genrel, rel); | 205 tic4x_lookup_howto (&genrel, rel); |
| 218 | 206 |
| 219 return genrel.howto; | 207 return genrel.howto; |
| 220 } | 208 } |
| 221 | 209 |
| 222 | 210 |
| 223 static void | 211 static void |
| 224 tic4x_reloc_processing (relent, reloc, symbols, abfd, section) | 212 tic4x_reloc_processing (arelent *relent, |
| 225 arelent *relent; | 213 » » » struct internal_reloc *reloc, |
| 226 struct internal_reloc *reloc; | 214 » » » asymbol **symbols, |
| 227 asymbol **symbols; | 215 » » » bfd *abfd, |
| 228 bfd *abfd; | 216 » » » asection *section) |
| 229 asection *section; | |
| 230 { | 217 { |
| 231 asymbol *ptr; | 218 asymbol *ptr; |
| 232 | 219 |
| 233 relent->address = reloc->r_vaddr; | 220 relent->address = reloc->r_vaddr; |
| 234 | 221 |
| 235 if (reloc->r_symndx != -1) | 222 if (reloc->r_symndx != -1) |
| 236 { | 223 { |
| 237 if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd)) | 224 if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd)) |
| 238 { | 225 { |
| 239 (*_bfd_error_handler) | 226 (*_bfd_error_handler) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 267 | 254 |
| 268 relent->address -= section->vma; | 255 relent->address -= section->vma; |
| 269 /* !! relent->section = (asection *) NULL; */ | 256 /* !! relent->section = (asection *) NULL; */ |
| 270 | 257 |
| 271 /* Fill in the relent->howto field from reloc->r_type. */ | 258 /* Fill in the relent->howto field from reloc->r_type. */ |
| 272 tic4x_lookup_howto (relent, reloc); | 259 tic4x_lookup_howto (relent, reloc); |
| 273 } | 260 } |
| 274 | 261 |
| 275 | 262 |
| 276 /* TI COFF v0, DOS tools (little-endian headers). */ | 263 /* TI COFF v0, DOS tools (little-endian headers). */ |
| 277 CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff0_vec, "coff0-tic4x", HAS_LOAD_PAGE, 0,
'_', NULL, (PTR)&ticoff0_swap_table); | 264 CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff0_vec, "coff0-tic4x", HAS_LOAD_PAGE, 0,
'_', NULL, & ticoff0_swap_table); |
| 278 | 265 |
| 279 /* TI COFF v0, SPARC tools (big-endian headers). */ | 266 /* TI COFF v0, SPARC tools (big-endian headers). */ |
| 280 CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff0_beh_vec, "coff0-beh-tic4x", HAS_LOAD_P
AGE, 0, '_', &tic4x_coff0_vec, (PTR)&ticoff0_swap_table); | 267 CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff0_beh_vec, "coff0-beh-tic4x", HAS_LOAD_P
AGE, 0, '_', &tic4x_coff0_vec, & ticoff0_swap_table); |
| 281 | 268 |
| 282 /* TI COFF v1, DOS tools (little-endian headers). */ | 269 /* TI COFF v1, DOS tools (little-endian headers). */ |
| 283 CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff1_vec, "coff1-tic4x", HAS_LOAD_PAGE, 0,
'_', &tic4x_coff0_beh_vec, (PTR)&ticoff1_swap_table); | 270 CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff1_vec, "coff1-tic4x", HAS_LOAD_PAGE, 0,
'_', &tic4x_coff0_beh_vec, & ticoff1_swap_table); |
| 284 | 271 |
| 285 /* TI COFF v1, SPARC tools (big-endian headers). */ | 272 /* TI COFF v1, SPARC tools (big-endian headers). */ |
| 286 CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff1_beh_vec, "coff1-beh-tic4x", HAS_LOAD_P
AGE, 0, '_', &tic4x_coff1_vec, (PTR)&ticoff1_swap_table); | 273 CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff1_beh_vec, "coff1-beh-tic4x", HAS_LOAD_P
AGE, 0, '_', &tic4x_coff1_vec, & ticoff1_swap_table); |
| 287 | 274 |
| 288 /* TI COFF v2, TI DOS tools output (little-endian headers). */ | 275 /* TI COFF v2, TI DOS tools output (little-endian headers). */ |
| 289 CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff2_vec, "coff2-tic4x", HAS_LOAD_PAGE, 0,
'_', &tic4x_coff1_beh_vec, COFF_SWAP_TABLE); | 276 CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff2_vec, "coff2-tic4x", HAS_LOAD_PAGE, 0,
'_', &tic4x_coff1_beh_vec, COFF_SWAP_TABLE); |
| 290 | 277 |
| 291 /* TI COFF v2, TI SPARC tools output (big-endian headers). */ | 278 /* TI COFF v2, TI SPARC tools output (big-endian headers). */ |
| 292 CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff2_beh_vec, "coff2-beh-tic4x", HAS_LOAD_P
AGE, 0, '_', &tic4x_coff2_vec, COFF_SWAP_TABLE); | 279 CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff2_beh_vec, "coff2-beh-tic4x", HAS_LOAD_P
AGE, 0, '_', &tic4x_coff2_vec, COFF_SWAP_TABLE); |
| OLD | NEW |