]>
Commit | Line | Data |
---|---|---|
ae1b99e4 | 1 | /* Matsushita 10200 specific support for 32-bit ELF |
b3ef3894 | 2 | Copyright (C) 1996, 1997 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)); | |
e14af8fc JL |
27 | static void mn10200_info_to_howto |
28 | PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); | |
efc2b064 | 29 | |
e14af8fc JL |
30 | |
31 | /* We have to use RELA instructions since md_apply_fix3 in the assembler | |
32 | does absolutely nothing. */ | |
33 | #define USE_RELA | |
efc2b064 JL |
34 | |
35 | enum reloc_type | |
36 | { | |
ae1b99e4 | 37 | R_MN10200_NONE = 0, |
e14af8fc JL |
38 | R_MN10200_32, |
39 | R_MN10200_16, | |
40 | R_MN10200_8, | |
b3ef3894 JL |
41 | R_MN10200_24, |
42 | R_MN10200_PCREL8, | |
43 | R_MN10200_PCREL24, | |
ae1b99e4 | 44 | R_MN10200_MAX |
efc2b064 JL |
45 | }; |
46 | ||
ae1b99e4 | 47 | static reloc_howto_type elf_mn10200_howto_table[] = |
efc2b064 | 48 | { |
e14af8fc | 49 | /* Dummy relocation. Does nothing. */ |
ae1b99e4 | 50 | HOWTO (R_MN10200_NONE, |
efc2b064 JL |
51 | 0, |
52 | 2, | |
53 | 16, | |
54 | false, | |
55 | 0, | |
56 | complain_overflow_bitfield, | |
57 | bfd_elf_generic_reloc, | |
ae1b99e4 | 58 | "R_MN10200_NONE", |
efc2b064 JL |
59 | false, |
60 | 0, | |
61 | 0, | |
62 | false), | |
e14af8fc JL |
63 | /* Standard 32 bit reloc. */ |
64 | HOWTO (R_MN10200_32, | |
65 | 0, | |
66 | 2, | |
67 | 32, | |
68 | false, | |
69 | 0, | |
70 | complain_overflow_bitfield, | |
71 | bfd_elf_generic_reloc, | |
72 | "R_MN10200_32", | |
73 | false, | |
74 | 0xffffffff, | |
75 | 0xffffffff, | |
76 | false), | |
77 | /* Standard 16 bit reloc. */ | |
78 | HOWTO (R_MN10200_16, | |
79 | 0, | |
80 | 1, | |
81 | 16, | |
82 | false, | |
83 | 0, | |
84 | complain_overflow_bitfield, | |
85 | bfd_elf_generic_reloc, | |
86 | "R_MN10200_16", | |
87 | false, | |
88 | 0xffff, | |
89 | 0xffff, | |
90 | false), | |
91 | /* Standard 8 bit reloc. */ | |
92 | HOWTO (R_MN10200_8, | |
93 | 0, | |
94 | 0, | |
95 | 8, | |
96 | false, | |
97 | 0, | |
98 | complain_overflow_bitfield, | |
99 | bfd_elf_generic_reloc, | |
100 | "R_MN10200_8", | |
101 | false, | |
102 | 0xff, | |
103 | 0xff, | |
104 | false), | |
b3ef3894 JL |
105 | /* Standard 24 bit reloc. */ |
106 | HOWTO (R_MN10200_24, | |
e14af8fc JL |
107 | 0, |
108 | 2, | |
b3ef3894 JL |
109 | 24, |
110 | false, | |
e14af8fc JL |
111 | 0, |
112 | complain_overflow_bitfield, | |
b3ef3894 JL |
113 | bfd_elf_generic_reloc, |
114 | "R_MN10200_24", | |
115 | false, | |
116 | 0xffffff, | |
117 | 0xffffff, | |
e14af8fc | 118 | false), |
b3ef3894 JL |
119 | /* Simple 8 pc-relative reloc. */ |
120 | HOWTO (R_MN10200_PCREL8, | |
e14af8fc JL |
121 | 0, |
122 | 0, | |
123 | 8, | |
124 | true, | |
125 | 0, | |
126 | complain_overflow_bitfield, | |
40131692 | 127 | bfd_elf_generic_reloc, |
b3ef3894 | 128 | "R_MN10200_PCREL8", |
40131692 | 129 | false, |
e14af8fc JL |
130 | 0xff, |
131 | 0xff, | |
132 | true), | |
b3ef3894 | 133 | /* Simple 32bit pc-relative reloc with a 1 byte adjustment |
e14af8fc | 134 | to get the pc-relative offset correct. */ |
b3ef3894 | 135 | HOWTO (R_MN10200_PCREL24, |
e14af8fc JL |
136 | 0, |
137 | 2, | |
b3ef3894 | 138 | 24, |
e14af8fc JL |
139 | true, |
140 | 0, | |
141 | complain_overflow_bitfield, | |
40131692 | 142 | bfd_elf_generic_reloc, |
b3ef3894 | 143 | "R_MN10200_PCREL24", |
40131692 | 144 | false, |
b3ef3894 JL |
145 | 0xffffff, |
146 | 0xffffff, | |
483e1b91 | 147 | true), |
efc2b064 JL |
148 | }; |
149 | ||
ae1b99e4 | 150 | struct mn10200_reloc_map |
efc2b064 JL |
151 | { |
152 | unsigned char bfd_reloc_val; | |
153 | unsigned char elf_reloc_val; | |
154 | }; | |
155 | ||
ae1b99e4 | 156 | static const struct mn10200_reloc_map mn10200_reloc_map[] = |
efc2b064 | 157 | { |
ae1b99e4 | 158 | { BFD_RELOC_NONE, R_MN10200_NONE, }, |
e14af8fc JL |
159 | { BFD_RELOC_32, R_MN10200_32, }, |
160 | { BFD_RELOC_16, R_MN10200_16, }, | |
161 | { BFD_RELOC_8, R_MN10200_8, }, | |
b3ef3894 JL |
162 | { BFD_RELOC_24, R_MN10200_24, }, |
163 | { BFD_RELOC_8_PCREL, R_MN10200_PCREL8, }, | |
164 | { BFD_RELOC_24_PCREL, R_MN10200_PCREL24, }, | |
efc2b064 JL |
165 | }; |
166 | ||
167 | static reloc_howto_type * | |
168 | bfd_elf32_bfd_reloc_type_lookup (abfd, code) | |
169 | bfd *abfd; | |
170 | bfd_reloc_code_real_type code; | |
171 | { | |
172 | unsigned int i; | |
173 | ||
174 | for (i = 0; | |
ae1b99e4 | 175 | i < sizeof (mn10200_reloc_map) / sizeof (struct mn10200_reloc_map); |
efc2b064 JL |
176 | i++) |
177 | { | |
ae1b99e4 JL |
178 | if (mn10200_reloc_map[i].bfd_reloc_val == code) |
179 | return &elf_mn10200_howto_table[mn10200_reloc_map[i].elf_reloc_val]; | |
efc2b064 JL |
180 | } |
181 | ||
182 | return NULL; | |
183 | } | |
184 | ||
e14af8fc | 185 | /* Set the howto pointer for an MN10200 ELF reloc. */ |
efc2b064 JL |
186 | |
187 | static void | |
e14af8fc | 188 | mn10200_info_to_howto (abfd, cache_ptr, dst) |
efc2b064 JL |
189 | bfd *abfd; |
190 | arelent *cache_ptr; | |
e14af8fc | 191 | Elf32_Internal_Rela *dst; |
efc2b064 JL |
192 | { |
193 | unsigned int r_type; | |
194 | ||
195 | r_type = ELF32_R_TYPE (dst->r_info); | |
ae1b99e4 JL |
196 | BFD_ASSERT (r_type < (unsigned int) R_MN10200_MAX); |
197 | cache_ptr->howto = &elf_mn10200_howto_table[r_type]; | |
efc2b064 JL |
198 | } |
199 | ||
ae1b99e4 JL |
200 | #define TARGET_LITTLE_SYM bfd_elf32_mn10200_vec |
201 | #define TARGET_LITTLE_NAME "elf32-mn10200" | |
202 | #define ELF_ARCH bfd_arch_mn10200 | |
203 | #define ELF_MACHINE_CODE EM_CYGNUS_MN10200 | |
efc2b064 JL |
204 | #define ELF_MAXPAGESIZE 0x1000 |
205 | ||
e14af8fc JL |
206 | #define elf_info_to_howto mn10200_info_to_howto |
207 | #define elf_info_to_howto_rel 0 | |
208 | ||
209 | #define elf_symbol_leading_char '_' | |
efc2b064 JL |
210 | |
211 | #include "elf32-target.h" |