| OLD | NEW |
| 1 /* BFD back-end for Motorola 68000 COFF binaries. | 1 /* BFD back-end for Motorola 68000 COFF binaries. |
| 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, | 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, |
| 3 2000, 2001, 2002, 2003, 2005, 2007, 2008 | 3 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2012 |
| 4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
| 5 Written by Cygnus Support. | 5 Written by Cygnus Support. |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 #ifndef COFF_PAGE_SIZE | 54 #ifndef COFF_PAGE_SIZE |
| 55 /* The page size is a guess based on ELF. */ | 55 /* The page size is a guess based on ELF. */ |
| 56 #define COFF_PAGE_SIZE 0x2000 | 56 #define COFF_PAGE_SIZE 0x2000 |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 #ifndef COFF_COMMON_ADDEND | 59 #ifndef COFF_COMMON_ADDEND |
| 60 #define RELOC_SPECIAL_FN 0 | 60 #define RELOC_SPECIAL_FN 0 |
| 61 #else | 61 #else |
| 62 static bfd_reloc_status_type m68kcoff_common_addend_special_fn | 62 static bfd_reloc_status_type m68kcoff_common_addend_special_fn |
| 63 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | 63 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
| 64 static reloc_howto_type *m68kcoff_common_addend_rtype_to_howto | 64 |
| 65 PARAMS ((bfd *, asection *, struct internal_reloc *, | |
| 66 » struct coff_link_hash_entry *, struct internal_syment *, | |
| 67 » bfd_vma *)); | |
| 68 #define RELOC_SPECIAL_FN m68kcoff_common_addend_special_fn | 65 #define RELOC_SPECIAL_FN m68kcoff_common_addend_special_fn |
| 69 #endif | 66 #endif |
| 70 | 67 |
| 71 static bfd_boolean m68k_coff_is_local_label_name | 68 static bfd_boolean m68k_coff_is_local_label_name (bfd *, const char *); |
| 72 PARAMS ((bfd *, const char *)); | |
| 73 | 69 |
| 74 /* On the delta, a symbol starting with L% is local. We won't see | 70 /* On the delta, a symbol starting with L% is local. We won't see |
| 75 such a symbol on other platforms, so it should be safe to always | 71 such a symbol on other platforms, so it should be safe to always |
| 76 consider it local here. */ | 72 consider it local here. */ |
| 77 | 73 |
| 78 static bfd_boolean | 74 static bfd_boolean |
| 79 m68k_coff_is_local_label_name (abfd, name) | 75 m68k_coff_is_local_label_name (bfd *abfd, const char *name) |
| 80 bfd *abfd; | |
| 81 const char *name; | |
| 82 { | 76 { |
| 83 if (name[0] == 'L' && name[1] == '%') | 77 if (name[0] == 'L' && name[1] == '%') |
| 84 return TRUE; | 78 return TRUE; |
| 85 | 79 |
| 86 return _bfd_coff_is_local_label_name (abfd, name); | 80 return _bfd_coff_is_local_label_name (abfd, name); |
| 87 } | 81 } |
| 88 | 82 |
| 89 #ifndef STATIC_RELOCS | 83 #ifndef STATIC_RELOCS |
| 90 /* Clean up namespace. */ | 84 /* Clean up namespace. */ |
| 91 #define m68kcoff_howto_table _bfd_m68kcoff_howto_table | 85 #define m68kcoff_howto_table _bfd_m68kcoff_howto_table |
| (...skipping 22 matching lines...) Expand all Loading... |
| 114 #endif /* not ONLY_DECLARE_RELOCS */ | 108 #endif /* not ONLY_DECLARE_RELOCS */ |
| 115 | 109 |
| 116 #ifndef BADMAG | 110 #ifndef BADMAG |
| 117 #define BADMAG(x) M68KBADMAG(x) | 111 #define BADMAG(x) M68KBADMAG(x) |
| 118 #endif | 112 #endif |
| 119 #define M68 1 /* Customize coffcode.h */ | 113 #define M68 1 /* Customize coffcode.h */ |
| 120 | 114 |
| 121 /* Turn a howto into a reloc number */ | 115 /* Turn a howto into a reloc number */ |
| 122 | 116 |
| 123 #ifdef ONLY_DECLARE_RELOCS | 117 #ifdef ONLY_DECLARE_RELOCS |
| 124 extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry)); | 118 extern void m68k_rtype2howto (arelent *internal, int relocentry); |
| 125 extern int m68k_howto2rtype PARAMS ((reloc_howto_type *)); | 119 extern int m68k_howto2rtype (reloc_howto_type *); |
| 126 extern reloc_howto_type *m68k_reloc_type_lookup | 120 extern reloc_howto_type * m68k_reloc_type_lookup |
| 127 PARAMS ((bfd *, bfd_reloc_code_real_type)); | 121 (bfd *, bfd_reloc_code_real_type); |
| 128 extern reloc_howto_type *m68k_reloc_name_lookup | 122 extern reloc_howto_type * m68k_reloc_name_lookup (bfd *, const char *); |
| 129 PARAMS ((bfd *, const char *)); | |
| 130 #else | 123 #else |
| 131 | 124 |
| 132 #ifdef STATIC_RELOCS | 125 #ifdef STATIC_RELOCS |
| 133 #define STAT_REL static | 126 #define STAT_REL static |
| 134 #else | 127 #else |
| 135 #define STAT_REL | 128 #define STAT_REL |
| 136 #endif | 129 #endif |
| 137 | 130 |
| 138 STAT_REL reloc_howto_type * m68k_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_cod
e_real_type)); | 131 STAT_REL void m68k_rtype2howto (arelent *, int); |
| 139 STAT_REL reloc_howto_type * m68k_reloc_name_lookup PARAMS ((bfd *, const char *)
); | 132 STAT_REL int m68k_howto2rtype (reloc_howto_type *); |
| 140 STAT_REL int m68k_howto2rtype PARAMS ((reloc_howto_type *)); | 133 STAT_REL reloc_howto_type * m68k_reloc_type_lookup (bfd *, bfd_reloc_code_real_t
ype); |
| 141 STAT_REL void m68k_rtype2howto PARAMS ((arelent *, int)); | 134 STAT_REL reloc_howto_type * m68k_reloc_name_lookup (bfd *, const char *); |
| 142 | |
| 143 | 135 |
| 144 STAT_REL void | 136 STAT_REL void |
| 145 m68k_rtype2howto(internal, relocentry) | 137 m68k_rtype2howto (arelent *internal, int relocentry) |
| 146 arelent *internal; | |
| 147 int relocentry; | |
| 148 { | 138 { |
| 149 switch (relocentry) | 139 switch (relocentry) |
| 150 { | 140 { |
| 151 case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break; | 141 case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break; |
| 152 case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break; | 142 case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break; |
| 153 case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break; | 143 case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break; |
| 154 case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break; | 144 case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break; |
| 155 case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break; | 145 case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break; |
| 156 case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break; | 146 case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break; |
| 157 case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break; | 147 case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break; |
| 158 } | 148 } |
| 159 } | 149 } |
| 160 | 150 |
| 161 STAT_REL int | 151 STAT_REL int |
| 162 m68k_howto2rtype (internal) | 152 m68k_howto2rtype (reloc_howto_type * internal) |
| 163 reloc_howto_type *internal; | |
| 164 { | 153 { |
| 165 if (internal->pc_relative) | 154 if (internal->pc_relative) |
| 166 { | 155 { |
| 167 switch (internal->bitsize) | 156 switch (internal->bitsize) |
| 168 { | 157 { |
| 169 case 32: return R_PCRLONG; | 158 case 32: return R_PCRLONG; |
| 170 case 16: return R_PCRWORD; | 159 case 16: return R_PCRWORD; |
| 171 case 8: return R_PCRBYTE; | 160 case 8: return R_PCRBYTE; |
| 172 } | 161 } |
| 173 } | 162 } |
| 174 else | 163 else |
| 175 { | 164 { |
| 176 switch (internal->bitsize) | 165 switch (internal->bitsize) |
| 177 { | 166 { |
| 178 case 32: return R_RELLONG; | 167 case 32: return R_RELLONG; |
| 179 case 16: return R_RELWORD; | 168 case 16: return R_RELWORD; |
| 180 case 8: return R_RELBYTE; | 169 case 8: return R_RELBYTE; |
| 181 } | 170 } |
| 182 } | 171 } |
| 183 return R_RELLONG; | 172 return R_RELLONG; |
| 184 } | 173 } |
| 185 | 174 |
| 186 STAT_REL reloc_howto_type * | 175 STAT_REL reloc_howto_type * |
| 187 m68k_reloc_type_lookup (abfd, code) | 176 m68k_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
| 188 bfd *abfd ATTRIBUTE_UNUSED; | 177 » » » bfd_reloc_code_real_type code) |
| 189 bfd_reloc_code_real_type code; | |
| 190 { | 178 { |
| 191 switch (code) | 179 switch (code) |
| 192 { | 180 { |
| 193 default: return NULL; | 181 default: return NULL; |
| 194 case BFD_RELOC_8: return m68kcoff_howto_table + 0; | 182 case BFD_RELOC_8: return m68kcoff_howto_table + 0; |
| 195 case BFD_RELOC_16: return m68kcoff_howto_table + 1; | 183 case BFD_RELOC_16: return m68kcoff_howto_table + 1; |
| 196 case BFD_RELOC_CTOR: | 184 case BFD_RELOC_CTOR: |
| 197 case BFD_RELOC_32: return m68kcoff_howto_table + 2; | 185 case BFD_RELOC_32: return m68kcoff_howto_table + 2; |
| 198 case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3; | 186 case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3; |
| 199 case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4; | 187 case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 228 external.r_type = m68k_howto2rtype (internal) | 216 external.r_type = m68k_howto2rtype (internal) |
| 229 | 217 |
| 230 #define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup | 218 #define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup |
| 231 #define coff_bfd_reloc_name_lookup m68k_reloc_name_lookup | 219 #define coff_bfd_reloc_name_lookup m68k_reloc_name_lookup |
| 232 | 220 |
| 233 #ifndef COFF_COMMON_ADDEND | 221 #ifndef COFF_COMMON_ADDEND |
| 234 #ifndef coff_rtype_to_howto | 222 #ifndef coff_rtype_to_howto |
| 235 | 223 |
| 236 #define coff_rtype_to_howto m68kcoff_rtype_to_howto | 224 #define coff_rtype_to_howto m68kcoff_rtype_to_howto |
| 237 | 225 |
| 238 static reloc_howto_type *m68kcoff_rtype_to_howto | |
| 239 PARAMS ((bfd *, asection *, struct internal_reloc *, | |
| 240 struct coff_link_hash_entry *, struct internal_syment *, | |
| 241 bfd_vma *)); | |
| 242 | |
| 243 static reloc_howto_type * | 226 static reloc_howto_type * |
| 244 m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp) | 227 m68kcoff_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, |
| 245 bfd *abfd ATTRIBUTE_UNUSED; | 228 » » » asection *sec, |
| 246 asection *sec; | 229 » » » struct internal_reloc *rel, |
| 247 struct internal_reloc *rel; | 230 » » » struct coff_link_hash_entry *h ATTRIBUTE_UNUSED, |
| 248 struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; | 231 » » » struct internal_syment *sym ATTRIBUTE_UNUSED, |
| 249 struct internal_syment *sym ATTRIBUTE_UNUSED; | 232 » » » bfd_vma *addendp) |
| 250 bfd_vma *addendp; | |
| 251 { | 233 { |
| 252 arelent relent; | 234 arelent relent; |
| 253 reloc_howto_type *howto; | 235 reloc_howto_type *howto; |
| 254 | 236 |
| 255 relent.howto = NULL; | 237 relent.howto = NULL; |
| 256 RTYPE2HOWTO (&relent, rel); | 238 RTYPE2HOWTO (&relent, rel); |
| 257 | 239 |
| 258 howto = relent.howto; | 240 howto = relent.howto; |
| 259 | 241 |
| 260 if (howto != NULL && howto->pc_relative) | 242 if (howto != NULL && howto->pc_relative) |
| 261 *addendp += sec->vma; | 243 *addendp += sec->vma; |
| 262 | 244 |
| 263 return howto; | 245 return howto; |
| 264 } | 246 } |
| 265 | 247 |
| 266 #endif /* ! defined (coff_rtype_to_howto) */ | 248 #endif /* ! defined (coff_rtype_to_howto) */ |
| 267 #endif /* ! defined (COFF_COMMON_ADDEND) */ | 249 #endif /* ! defined (COFF_COMMON_ADDEND) */ |
| 268 | 250 |
| 269 | 251 |
| 270 #ifdef COFF_COMMON_ADDEND | 252 #ifdef COFF_COMMON_ADDEND |
| 271 | 253 |
| 272 /* If COFF_COMMON_ADDEND is defined, then when using m68k COFF the | 254 /* If COFF_COMMON_ADDEND is defined, then when using m68k COFF the |
| 273 value stored in the .text section for a reference to a common | 255 value stored in the .text section for a reference to a common |
| 274 symbol is the value itself plus any desired offset. (taken from | 256 symbol is the value itself plus any desired offset. (taken from |
| 275 work done by Ian Taylor, Cygnus Support, for I386 COFF). */ | 257 work done by Ian Taylor, Cygnus Support, for I386 COFF). */ |
| 276 | 258 |
| 277 /* If we are producing relocatable output, we need to do some | 259 /* If we are producing relocatable output, we need to do some |
| 278 adjustments to the object file that are not done by the | 260 adjustments to the object file that are not done by the |
error: old chunk mismatch |
None
| OLD | NEW |