OLD | NEW |
1 /* BFD back-end for Sparc COFF files. | 1 /* BFD back-end for Sparc COFF files. |
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, | 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, |
3 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc. | 3 2002, 2003, 2005, 2007, 2008, 2012 Free Software Foundation, Inc. |
4 Written by Cygnus Support. | 4 Written by Cygnus Support. |
5 | 5 |
6 This file is part of BFD, the Binary File Descriptor library. | 6 This file is part of BFD, the Binary File Descriptor library. |
7 | 7 |
8 This program is free software; you can redistribute it and/or modify | 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 | 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 | 10 the Free Software Foundation; either version 3 of the License, or |
11 (at your option) any later version. | 11 (at your option) any later version. |
12 | 12 |
13 This program is distributed in the hope that it will be useful, | 13 This program is distributed in the hope that it will be useful, |
(...skipping 13 matching lines...) Expand all Loading... |
27 #include "coff/internal.h" | 27 #include "coff/internal.h" |
28 #include "libcoff.h" | 28 #include "libcoff.h" |
29 | 29 |
30 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) | 30 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) |
31 | 31 |
32 #define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC) | 32 #define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC) |
33 | 33 |
34 /* The page size is a guess based on ELF. */ | 34 /* The page size is a guess based on ELF. */ |
35 #define COFF_PAGE_SIZE 0x10000 | 35 #define COFF_PAGE_SIZE 0x10000 |
36 | 36 |
37 | |
38 static reloc_howto_type *coff_sparc_reloc_type_lookup | |
39 PARAMS ((bfd *, bfd_reloc_code_real_type)); | |
40 static void rtype2howto PARAMS ((arelent *, struct internal_reloc *)); | |
41 | |
42 enum reloc_type | 37 enum reloc_type |
43 { | 38 { |
44 R_SPARC_NONE = 0, | 39 R_SPARC_NONE = 0, |
45 R_SPARC_8, R_SPARC_16, R_SPARC_32, | 40 R_SPARC_8, R_SPARC_16, R_SPARC_32, |
46 R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32, | 41 R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32, |
47 R_SPARC_WDISP30, R_SPARC_WDISP22, | 42 R_SPARC_WDISP30, R_SPARC_WDISP22, |
48 R_SPARC_HI22, R_SPARC_22, | 43 R_SPARC_HI22, R_SPARC_22, |
49 R_SPARC_13, R_SPARC_LO10, | 44 R_SPARC_13, R_SPARC_LO10, |
50 R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22, | 45 R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22, |
51 R_SPARC_PC10, R_SPARC_PC22, | 46 R_SPARC_PC10, R_SPARC_PC22, |
52 R_SPARC_WPLT30, | 47 R_SPARC_WPLT30, |
53 R_SPARC_COPY, | 48 R_SPARC_COPY, |
54 R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT, | 49 R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT, |
55 R_SPARC_RELATIVE, | 50 R_SPARC_RELATIVE, |
56 R_SPARC_UA32, | 51 R_SPARC_UA32, |
57 R_SPARC_max | 52 R_SPARC_max |
58 }; | 53 }; |
59 | 54 |
60 /* This is stolen pretty directly from elf.c. */ | 55 /* This is stolen pretty directly from elf.c. */ |
61 static bfd_reloc_status_type | |
62 bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, | |
63 asection *, bfd *, char **)); | |
64 | 56 |
65 static bfd_reloc_status_type | 57 static bfd_reloc_status_type |
66 bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section, | 58 bfd_coff_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED, |
67 » » » output_bfd, error_message) | 59 » » » arelent *reloc_entry, |
68 bfd *abfd ATTRIBUTE_UNUSED; | 60 » » » asymbol *symbol, |
69 arelent *reloc_entry; | 61 » » » void * data ATTRIBUTE_UNUSED, |
70 asymbol *symbol; | 62 » » » asection *input_section, |
71 PTR data ATTRIBUTE_UNUSED; | 63 » » » bfd *output_bfd, |
72 asection *input_section; | 64 » » » char **error_message ATTRIBUTE_UNUSED) |
73 bfd *output_bfd; | |
74 char **error_message ATTRIBUTE_UNUSED; | |
75 { | 65 { |
76 if (output_bfd != (bfd *) NULL | 66 if (output_bfd != (bfd *) NULL |
77 && (symbol->flags & BSF_SECTION_SYM) == 0) | 67 && (symbol->flags & BSF_SECTION_SYM) == 0) |
78 { | 68 { |
79 reloc_entry->address += input_section->output_offset; | 69 reloc_entry->address += input_section->output_offset; |
80 return bfd_reloc_ok; | 70 return bfd_reloc_ok; |
81 } | 71 } |
82 | 72 |
83 return bfd_reloc_continue; | 73 return bfd_reloc_continue; |
84 } | 74 } |
(...skipping 19 matching lines...) Expand all Loading... |
104 HOWTO(R_SPARC_PC10, 0,2,10,FALSE,0,complain_overflow_bitfield,bfd_coff_gene
ric_reloc,"R_SPARC_PC10", FALSE,0,0x000003ff,TRUE), | 94 HOWTO(R_SPARC_PC10, 0,2,10,FALSE,0,complain_overflow_bitfield,bfd_coff_gene
ric_reloc,"R_SPARC_PC10", FALSE,0,0x000003ff,TRUE), |
105 HOWTO(R_SPARC_PC22, 0,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_gene
ric_reloc,"R_SPARC_PC22", FALSE,0,0x003fffff,TRUE), | 95 HOWTO(R_SPARC_PC22, 0,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_gene
ric_reloc,"R_SPARC_PC22", FALSE,0,0x003fffff,TRUE), |
106 HOWTO(R_SPARC_WPLT30, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_WPLT30", FALSE,0,0x00000000,TRUE), | 96 HOWTO(R_SPARC_WPLT30, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_WPLT30", FALSE,0,0x00000000,TRUE), |
107 HOWTO(R_SPARC_COPY, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_COPY", FALSE,0,0x00000000,TRUE), | 97 HOWTO(R_SPARC_COPY, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_COPY", FALSE,0,0x00000000,TRUE), |
108 HOWTO(R_SPARC_GLOB_DAT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_GLOB_DAT",FALSE,0,0x00000000,TRUE), | 98 HOWTO(R_SPARC_GLOB_DAT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_GLOB_DAT",FALSE,0,0x00000000,TRUE), |
109 HOWTO(R_SPARC_JMP_SLOT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_JMP_SLOT",FALSE,0,0x00000000,TRUE), | 99 HOWTO(R_SPARC_JMP_SLOT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_JMP_SLOT",FALSE,0,0x00000000,TRUE), |
110 HOWTO(R_SPARC_RELATIVE,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_RELATIVE",FALSE,0,0x00000000,TRUE), | 100 HOWTO(R_SPARC_RELATIVE,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_RELATIVE",FALSE,0,0x00000000,TRUE), |
111 HOWTO(R_SPARC_UA32, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_UA32", FALSE,0,0x00000000,TRUE), | 101 HOWTO(R_SPARC_UA32, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_gene
ric_reloc,"R_SPARC_UA32", FALSE,0,0x00000000,TRUE), |
112 }; | 102 }; |
113 | 103 |
114 struct coff_reloc_map { | 104 struct coff_reloc_map |
| 105 { |
115 bfd_reloc_code_real_type bfd_reloc_val; | 106 bfd_reloc_code_real_type bfd_reloc_val; |
116 unsigned char coff_reloc_val; | 107 unsigned char coff_reloc_val; |
117 }; | 108 }; |
118 | 109 |
119 static const struct coff_reloc_map sparc_reloc_map[] = | 110 static const struct coff_reloc_map sparc_reloc_map[] = |
120 { | 111 { |
121 { BFD_RELOC_NONE, R_SPARC_NONE, }, | 112 { BFD_RELOC_NONE, R_SPARC_NONE, }, |
122 { BFD_RELOC_16, R_SPARC_16, }, | 113 { BFD_RELOC_16, R_SPARC_16, }, |
123 { BFD_RELOC_8, R_SPARC_8 }, | 114 { BFD_RELOC_8, R_SPARC_8 }, |
124 { BFD_RELOC_8_PCREL, R_SPARC_DISP8 }, | 115 { BFD_RELOC_8_PCREL, R_SPARC_DISP8 }, |
(...skipping 13 matching lines...) Expand all Loading... |
138 { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 }, | 129 { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 }, |
139 { BFD_RELOC_SPARC_COPY, R_SPARC_COPY }, | 130 { BFD_RELOC_SPARC_COPY, R_SPARC_COPY }, |
140 { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT }, | 131 { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT }, |
141 { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT }, | 132 { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT }, |
142 { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE }, | 133 { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE }, |
143 { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 }, | 134 { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 }, |
144 /* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */ | 135 /* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */ |
145 }; | 136 }; |
146 | 137 |
147 static reloc_howto_type * | 138 static reloc_howto_type * |
148 coff_sparc_reloc_type_lookup (abfd, code) | 139 coff_sparc_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
149 bfd *abfd ATTRIBUTE_UNUSED; | 140 » » » bfd_reloc_code_real_type code) |
150 bfd_reloc_code_real_type code; | |
151 { | 141 { |
152 unsigned int i; | 142 unsigned int i; |
153 for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++
) | 143 for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++
) |
154 { | 144 { |
155 if (sparc_reloc_map[i].bfd_reloc_val == code) | 145 if (sparc_reloc_map[i].bfd_reloc_val == code) |
156 return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val]; | 146 return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val]; |
157 } | 147 } |
158 return 0; | 148 return 0; |
159 } | 149 } |
160 #define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup | 150 #define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup |
(...skipping 10 matching lines...) Expand all Loading... |
171 i++) | 161 i++) |
172 if (coff_sparc_howto_table[i].name != NULL | 162 if (coff_sparc_howto_table[i].name != NULL |
173 && strcasecmp (coff_sparc_howto_table[i].name, r_name) == 0) | 163 && strcasecmp (coff_sparc_howto_table[i].name, r_name) == 0) |
174 return &coff_sparc_howto_table[i]; | 164 return &coff_sparc_howto_table[i]; |
175 | 165 |
176 return NULL; | 166 return NULL; |
177 } | 167 } |
178 #define coff_bfd_reloc_name_lookup coff_sparc_reloc_name_lookup | 168 #define coff_bfd_reloc_name_lookup coff_sparc_reloc_name_lookup |
179 | 169 |
180 static void | 170 static void |
181 rtype2howto (cache_ptr, dst) | 171 rtype2howto (arelent *cache_ptr, struct internal_reloc *dst) |
182 arelent *cache_ptr; | |
183 struct internal_reloc *dst; | |
184 { | 172 { |
185 BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max); | 173 BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max); |
186 cache_ptr->howto = &coff_sparc_howto_table[dst->r_type]; | 174 cache_ptr->howto = &coff_sparc_howto_table[dst->r_type]; |
187 } | 175 } |
188 | 176 |
189 #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry) | 177 #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry) |
190 | 178 |
191 #define SWAP_IN_RELOC_OFFSET H_GET_32 | 179 #define SWAP_IN_RELOC_OFFSET H_GET_32 |
192 #define SWAP_OUT_RELOC_OFFSET H_PUT_32 | 180 #define SWAP_OUT_RELOC_OFFSET H_PUT_32 |
193 #define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ | 181 #define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ |
(...skipping 18 matching lines...) Expand all Loading... |
212 | 200 |
213 #ifndef TARGET_SYM | 201 #ifndef TARGET_SYM |
214 #define TARGET_SYM sparccoff_vec | 202 #define TARGET_SYM sparccoff_vec |
215 #endif | 203 #endif |
216 | 204 |
217 #ifndef TARGET_NAME | 205 #ifndef TARGET_NAME |
218 #define TARGET_NAME "coff-sparc" | 206 #define TARGET_NAME "coff-sparc" |
219 #endif | 207 #endif |
220 | 208 |
221 CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL, COFF
_SWAP_TABLE) | 209 CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL, COFF
_SWAP_TABLE) |
OLD | NEW |