Commit | Line | Data |
---|---|---|
ae1b99e4 JL |
1 | /* Matsushita 10300 specific support for 32-bit ELF |
2 | Copyright (C) 1996 Free Software Foundation, Inc. | |
efc2b064 JL |
3 | |
4 | This file is part of BFD, the Binary File Descriptor library. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #include "bfd.h" | |
21 | #include "sysdep.h" | |
22 | #include "libbfd.h" | |
23 | #include "elf-bfd.h" | |
24 | ||
25 | static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup | |
26 | PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); | |
943686fa JL |
27 | static void mn10300_info_to_howto |
28 | PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); | |
12fdaaf8 JL |
29 | static bfd_reloc_status_type bfd_elf32_mn10300_reloc |
30 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
31 | ||
efc2b064 | 32 | |
943686fa JL |
33 | /* We have to use RELA instructions since md_apply_fix3 in the assembler |
34 | does absolutely nothing. */ | |
35 | #define USE_RELA | |
efc2b064 JL |
36 | |
37 | enum reloc_type | |
38 | { | |
ae1b99e4 | 39 | R_MN10300_NONE = 0, |
c3239e66 JL |
40 | R_MN10300_32, |
41 | R_MN10300_16, | |
42 | R_MN10300_8, | |
77bf22e6 JL |
43 | R_MN10300_PCREL32, |
44 | R_MN10300_PCREL16, | |
45 | R_MN10300_PCREL8, | |
ae1b99e4 | 46 | R_MN10300_MAX |
efc2b064 JL |
47 | }; |
48 | ||
ae1b99e4 | 49 | static reloc_howto_type elf_mn10300_howto_table[] = |
efc2b064 | 50 | { |
207e944c | 51 | /* Dummy relocation. Does nothing. */ |
ae1b99e4 | 52 | HOWTO (R_MN10300_NONE, |
efc2b064 JL |
53 | 0, |
54 | 2, | |
55 | 16, | |
56 | false, | |
57 | 0, | |
58 | complain_overflow_bitfield, | |
59 | bfd_elf_generic_reloc, | |
ae1b99e4 | 60 | "R_MN10300_NONE", |
efc2b064 JL |
61 | false, |
62 | 0, | |
63 | 0, | |
64 | false), | |
207e944c | 65 | /* Standard 32 bit reloc. */ |
c3239e66 JL |
66 | HOWTO (R_MN10300_32, |
67 | 0, | |
68 | 2, | |
69 | 32, | |
70 | false, | |
71 | 0, | |
72 | complain_overflow_bitfield, | |
73 | bfd_elf_generic_reloc, | |
74 | "R_MN10300_32", | |
d28f058e | 75 | false, |
c3239e66 JL |
76 | 0xffffffff, |
77 | 0xffffffff, | |
78 | false), | |
207e944c | 79 | /* Standard 16 bit reloc. */ |
c3239e66 JL |
80 | HOWTO (R_MN10300_16, |
81 | 0, | |
82 | 1, | |
83 | 16, | |
84 | false, | |
85 | 0, | |
86 | complain_overflow_bitfield, | |
87 | bfd_elf_generic_reloc, | |
88 | "R_MN10300_16", | |
d28f058e | 89 | false, |
c3239e66 JL |
90 | 0xffff, |
91 | 0xffff, | |
92 | false), | |
207e944c | 93 | /* Standard 8 bit reloc. */ |
c3239e66 JL |
94 | HOWTO (R_MN10300_8, |
95 | 0, | |
96 | 0, | |
97 | 8, | |
98 | false, | |
99 | 0, | |
100 | complain_overflow_bitfield, | |
101 | bfd_elf_generic_reloc, | |
102 | "R_MN10300_8", | |
d28f058e | 103 | false, |
c3239e66 JL |
104 | 0xff, |
105 | 0xff, | |
106 | false), | |
77bf22e6 JL |
107 | /* Standard 32bit pc-relative reloc. */ |
108 | HOWTO (R_MN10300_PCREL32, | |
12fdaaf8 JL |
109 | 0, |
110 | 2, | |
111 | 32, | |
112 | true, | |
113 | 0, | |
114 | complain_overflow_bitfield, | |
77bf22e6 JL |
115 | bfd_elf_generic_reloc, |
116 | "R_MN10300_PCREL32", | |
117 | false, | |
c3239e66 JL |
118 | 0xffffffff, |
119 | 0xffffffff, | |
77bf22e6 JL |
120 | true), |
121 | /* Standard 16bit pc-relative reloc. */ | |
122 | HOWTO (R_MN10300_PCREL16, | |
c3239e66 JL |
123 | 0, |
124 | 1, | |
125 | 16, | |
126 | true, | |
127 | 0, | |
128 | complain_overflow_bitfield, | |
77bf22e6 JL |
129 | bfd_elf_generic_reloc, |
130 | "R_MN10300_PCREL16", | |
131 | false, | |
c3239e66 JL |
132 | 0xffff, |
133 | 0xffff, | |
77bf22e6 JL |
134 | true), |
135 | /* Standard 8 pc-relative reloc. */ | |
136 | HOWTO (R_MN10300_PCREL8, | |
c3239e66 JL |
137 | 0, |
138 | 0, | |
139 | 8, | |
140 | true, | |
141 | 0, | |
142 | complain_overflow_bitfield, | |
77bf22e6 JL |
143 | bfd_elf_generic_reloc, |
144 | "R_MN10300_PCREL8", | |
145 | false, | |
c3239e66 JL |
146 | 0xff, |
147 | 0xff, | |
12fdaaf8 | 148 | true), |
efc2b064 JL |
149 | }; |
150 | ||
ae1b99e4 | 151 | struct mn10300_reloc_map |
efc2b064 JL |
152 | { |
153 | unsigned char bfd_reloc_val; | |
154 | unsigned char elf_reloc_val; | |
155 | }; | |
156 | ||
ae1b99e4 | 157 | static const struct mn10300_reloc_map mn10300_reloc_map[] = |
efc2b064 | 158 | { |
ae1b99e4 | 159 | { BFD_RELOC_NONE, R_MN10300_NONE, }, |
c3239e66 JL |
160 | { BFD_RELOC_32, R_MN10300_32, }, |
161 | { BFD_RELOC_16, R_MN10300_16, }, | |
162 | { BFD_RELOC_8, R_MN10300_8, }, | |
77bf22e6 JL |
163 | { BFD_RELOC_32_PCREL, R_MN10300_PCREL32, }, |
164 | { BFD_RELOC_16_PCREL, R_MN10300_PCREL16, }, | |
165 | { BFD_RELOC_8_PCREL, R_MN10300_PCREL8, }, | |
efc2b064 JL |
166 | }; |
167 | ||
168 | static reloc_howto_type * | |
169 | bfd_elf32_bfd_reloc_type_lookup (abfd, code) | |
170 | bfd *abfd; | |
171 | bfd_reloc_code_real_type code; | |
172 | { | |
173 | unsigned int i; | |
174 | ||
175 | for (i = 0; | |
ae1b99e4 | 176 | i < sizeof (mn10300_reloc_map) / sizeof (struct mn10300_reloc_map); |
efc2b064 JL |
177 | i++) |
178 | { | |
ae1b99e4 JL |
179 | if (mn10300_reloc_map[i].bfd_reloc_val == code) |
180 | return &elf_mn10300_howto_table[mn10300_reloc_map[i].elf_reloc_val]; | |
efc2b064 JL |
181 | } |
182 | ||
183 | return NULL; | |
184 | } | |
185 | ||
12fdaaf8 | 186 | /* Set the howto pointer for an MN10300 ELF reloc. */ |
efc2b064 JL |
187 | |
188 | static void | |
943686fa | 189 | mn10300_info_to_howto (abfd, cache_ptr, dst) |
efc2b064 JL |
190 | bfd *abfd; |
191 | arelent *cache_ptr; | |
943686fa | 192 | Elf32_Internal_Rela *dst; |
efc2b064 JL |
193 | { |
194 | unsigned int r_type; | |
195 | ||
196 | r_type = ELF32_R_TYPE (dst->r_info); | |
ae1b99e4 JL |
197 | BFD_ASSERT (r_type < (unsigned int) R_MN10300_MAX); |
198 | cache_ptr->howto = &elf_mn10300_howto_table[r_type]; | |
efc2b064 JL |
199 | } |
200 | ||
ae1b99e4 JL |
201 | #define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec |
202 | #define TARGET_LITTLE_NAME "elf32-mn10300" | |
203 | #define ELF_ARCH bfd_arch_mn10300 | |
204 | #define ELF_MACHINE_CODE EM_CYGNUS_MN10300 | |
efc2b064 JL |
205 | #define ELF_MAXPAGESIZE 0x1000 |
206 | ||
943686fa JL |
207 | #define elf_info_to_howto mn10300_info_to_howto |
208 | #define elf_info_to_howto_rel 0 | |
efc2b064 | 209 | |
31cffd2e JL |
210 | #define elf_symbol_leading_char '_' |
211 | ||
efc2b064 | 212 | #include "elf32-target.h" |