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)); | |
ae1b99e4 | 27 | static void mn10300_info_to_howto_rel |
efc2b064 JL |
28 | PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); |
29 | ||
30 | /* Try to minimize the amount of space occupied by relocation tables | |
31 | on the ROM (not that the ROM won't be swamped by other ELF overhead). */ | |
32 | #define USE_REL | |
33 | ||
34 | enum reloc_type | |
35 | { | |
ae1b99e4 | 36 | R_MN10300_NONE = 0, |
c3239e66 JL |
37 | R_MN10300_32, |
38 | R_MN10300_16, | |
39 | R_MN10300_8, | |
40 | R_MN10300_PCREL32, | |
41 | R_MN10300_PCREL16, | |
42 | R_MN10300_PCREL8, | |
ae1b99e4 | 43 | R_MN10300_MAX |
efc2b064 JL |
44 | }; |
45 | ||
ae1b99e4 | 46 | static reloc_howto_type elf_mn10300_howto_table[] = |
efc2b064 JL |
47 | { |
48 | /* */ | |
ae1b99e4 | 49 | HOWTO (R_MN10300_NONE, |
efc2b064 JL |
50 | 0, |
51 | 2, | |
52 | 16, | |
53 | false, | |
54 | 0, | |
55 | complain_overflow_bitfield, | |
56 | bfd_elf_generic_reloc, | |
ae1b99e4 | 57 | "R_MN10300_NONE", |
efc2b064 JL |
58 | false, |
59 | 0, | |
60 | 0, | |
61 | false), | |
c3239e66 JL |
62 | HOWTO (R_MN10300_32, |
63 | 0, | |
64 | 2, | |
65 | 32, | |
66 | false, | |
67 | 0, | |
68 | complain_overflow_bitfield, | |
69 | bfd_elf_generic_reloc, | |
70 | "R_MN10300_32", | |
71 | true, | |
72 | 0xffffffff, | |
73 | 0xffffffff, | |
74 | false), | |
75 | HOWTO (R_MN10300_16, | |
76 | 0, | |
77 | 1, | |
78 | 16, | |
79 | false, | |
80 | 0, | |
81 | complain_overflow_bitfield, | |
82 | bfd_elf_generic_reloc, | |
83 | "R_MN10300_16", | |
84 | true, | |
85 | 0xffff, | |
86 | 0xffff, | |
87 | false), | |
88 | HOWTO (R_MN10300_8, | |
89 | 0, | |
90 | 0, | |
91 | 8, | |
92 | false, | |
93 | 0, | |
94 | complain_overflow_bitfield, | |
95 | bfd_elf_generic_reloc, | |
96 | "R_MN10300_8", | |
97 | true, | |
98 | 0xff, | |
99 | 0xff, | |
100 | false), | |
101 | HOWTO (R_MN10300_PCREL32, | |
102 | 0, | |
103 | 2, | |
104 | 32, | |
105 | true, | |
106 | 0, | |
107 | complain_overflow_bitfield, | |
108 | bfd_elf_generic_reloc, | |
109 | "R_MN10300_PCREL32", | |
110 | true, | |
111 | 0xffffffff, | |
112 | 0xffffffff, | |
113 | false), | |
114 | HOWTO (R_MN10300_PCREL16, | |
115 | 0, | |
116 | 1, | |
117 | 16, | |
118 | true, | |
119 | 0, | |
120 | complain_overflow_bitfield, | |
121 | bfd_elf_generic_reloc, | |
122 | "R_MN10300_PCREL16", | |
123 | true, | |
124 | 0xffff, | |
125 | 0xffff, | |
126 | false), | |
127 | HOWTO (R_MN10300_PCREL8, | |
128 | 0, | |
129 | 0, | |
130 | 8, | |
131 | true, | |
132 | 0, | |
133 | complain_overflow_bitfield, | |
134 | bfd_elf_generic_reloc, | |
135 | "R_MN10300_PCREL8", | |
136 | true, | |
137 | 0xff, | |
138 | 0xff, | |
139 | false), | |
efc2b064 JL |
140 | }; |
141 | ||
ae1b99e4 | 142 | struct mn10300_reloc_map |
efc2b064 JL |
143 | { |
144 | unsigned char bfd_reloc_val; | |
145 | unsigned char elf_reloc_val; | |
146 | }; | |
147 | ||
ae1b99e4 | 148 | static const struct mn10300_reloc_map mn10300_reloc_map[] = |
efc2b064 | 149 | { |
ae1b99e4 | 150 | { BFD_RELOC_NONE, R_MN10300_NONE, }, |
c3239e66 JL |
151 | { BFD_RELOC_32, R_MN10300_32, }, |
152 | { BFD_RELOC_16, R_MN10300_16, }, | |
153 | { BFD_RELOC_8, R_MN10300_8, }, | |
154 | { BFD_RELOC_32_PCREL, R_MN10300_PCREL32, }, | |
155 | { BFD_RELOC_16_PCREL, R_MN10300_PCREL16, }, | |
156 | { BFD_RELOC_8_PCREL, R_MN10300_PCREL8, }, | |
efc2b064 JL |
157 | }; |
158 | ||
159 | static reloc_howto_type * | |
160 | bfd_elf32_bfd_reloc_type_lookup (abfd, code) | |
161 | bfd *abfd; | |
162 | bfd_reloc_code_real_type code; | |
163 | { | |
164 | unsigned int i; | |
165 | ||
166 | for (i = 0; | |
ae1b99e4 | 167 | i < sizeof (mn10300_reloc_map) / sizeof (struct mn10300_reloc_map); |
efc2b064 JL |
168 | i++) |
169 | { | |
ae1b99e4 JL |
170 | if (mn10300_reloc_map[i].bfd_reloc_val == code) |
171 | return &elf_mn10300_howto_table[mn10300_reloc_map[i].elf_reloc_val]; | |
efc2b064 JL |
172 | } |
173 | ||
174 | return NULL; | |
175 | } | |
176 | ||
177 | /* Set the howto pointer for an V850 ELF reloc. */ | |
178 | ||
179 | static void | |
ae1b99e4 | 180 | mn10300_info_to_howto_rel (abfd, cache_ptr, dst) |
efc2b064 JL |
181 | bfd *abfd; |
182 | arelent *cache_ptr; | |
183 | Elf32_Internal_Rel *dst; | |
184 | { | |
185 | unsigned int r_type; | |
186 | ||
187 | r_type = ELF32_R_TYPE (dst->r_info); | |
ae1b99e4 JL |
188 | BFD_ASSERT (r_type < (unsigned int) R_MN10300_MAX); |
189 | cache_ptr->howto = &elf_mn10300_howto_table[r_type]; | |
efc2b064 JL |
190 | } |
191 | ||
ae1b99e4 JL |
192 | #define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec |
193 | #define TARGET_LITTLE_NAME "elf32-mn10300" | |
194 | #define ELF_ARCH bfd_arch_mn10300 | |
195 | #define ELF_MACHINE_CODE EM_CYGNUS_MN10300 | |
efc2b064 JL |
196 | #define ELF_MAXPAGESIZE 0x1000 |
197 | ||
198 | #define elf_info_to_howto 0 | |
ae1b99e4 | 199 | #define elf_info_to_howto_rel mn10300_info_to_howto_rel |
efc2b064 JL |
200 | |
201 | #include "elf32-target.h" |