1 /* Motorola 68HC12-specific support for 32-bit ELF
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3 Contributed by Stephane Carrez (stcarrez@worldnet.fr)
4 (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com))
6 This file is part of BFD, the Binary File Descriptor library.
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
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 #include "elf/m68hc11.h"
28 static reloc_howto_type
*bfd_elf32_bfd_reloc_type_lookup
29 PARAMS ((bfd
* abfd
, bfd_reloc_code_real_type code
));
30 static void m68hc11_info_to_howto_rel
31 PARAMS ((bfd
*, arelent
*, Elf32_Internal_Rel
*));
34 /* Use REL instead of RELA to save space */
37 /* The Motorola 68HC11 microcontroler only addresses 64Kb.
38 We must handle 8 and 16-bit relocations. The 32-bit relocation
39 is defined but not used except by gas when -gstabs is used (which
41 The 3-bit and 16-bit PC rel relocation is only used by 68HC12. */
42 static reloc_howto_type elf_m68hc11_howto_table
[] = {
43 /* This reloc does nothing. */
44 HOWTO (R_M68HC11_NONE
, /* type */
46 2, /* size (0 = byte, 1 = short, 2 = long) */
48 false, /* pc_relative */
50 complain_overflow_bitfield
, /* complain_on_overflow */
51 bfd_elf_generic_reloc
, /* special_function */
52 "R_M68HC11_NONE", /* name */
53 false, /* partial_inplace */
56 false), /* pcrel_offset */
58 /* A 8 bit absolute relocation */
59 HOWTO (R_M68HC11_8
, /* type */
61 0, /* size (0 = byte, 1 = short, 2 = long) */
63 false, /* pc_relative */
65 complain_overflow_bitfield
, /* complain_on_overflow */
66 bfd_elf_generic_reloc
, /* special_function */
67 "R_M68HC11_8", /* name */
68 false, /* partial_inplace */
69 0x00ff, /* src_mask */
70 0x00ff, /* dst_mask */
71 false), /* pcrel_offset */
73 /* A 8 bit absolute relocation (upper address) */
74 HOWTO (R_M68HC11_HI8
, /* type */
76 0, /* size (0 = byte, 1 = short, 2 = long) */
78 false, /* pc_relative */
80 complain_overflow_bitfield
, /* complain_on_overflow */
81 bfd_elf_generic_reloc
, /* special_function */
82 "R_M68HC11_HI8", /* name */
83 false, /* partial_inplace */
84 0x00ff, /* src_mask */
85 0x00ff, /* dst_mask */
86 false), /* pcrel_offset */
88 /* A 8 bit absolute relocation (upper address) */
89 HOWTO (R_M68HC11_LO8
, /* type */
91 0, /* size (0 = byte, 1 = short, 2 = long) */
93 false, /* pc_relative */
95 complain_overflow_dont
, /* complain_on_overflow */
96 bfd_elf_generic_reloc
, /* special_function */
97 "R_M68HC11_LO8", /* name */
98 false, /* partial_inplace */
99 0x00ff, /* src_mask */
100 0x00ff, /* dst_mask */
101 false), /* pcrel_offset */
103 /* A 8 bit PC-rel relocation */
104 HOWTO (R_M68HC11_PCREL_8
, /* type */
106 0, /* size (0 = byte, 1 = short, 2 = long) */
108 true, /* pc_relative */
110 complain_overflow_bitfield
, /* complain_on_overflow */
111 bfd_elf_generic_reloc
, /* special_function */
112 "R_M68HC11_PCREL_8", /* name */
113 false, /* partial_inplace */
115 0x00ff, /* dst_mask */
116 false), /* pcrel_offset */
118 /* A 16 bit absolute relocation */
119 HOWTO (R_M68HC11_16
, /* type */
121 1, /* size (0 = byte, 1 = short, 2 = long) */
123 false, /* pc_relative */
125 complain_overflow_dont
/*bitfield */ , /* complain_on_overflow */
126 bfd_elf_generic_reloc
, /* special_function */
127 "R_M68HC11_16", /* name */
128 false, /* partial_inplace */
129 0xffff, /* src_mask */
130 0xffff, /* dst_mask */
131 false), /* pcrel_offset */
133 /* A 32 bit absolute relocation. This one is never used for the
134 code relocation. It's used by gas for -gstabs generation. */
135 HOWTO (R_M68HC11_32
, /* type */
137 2, /* size (0 = byte, 1 = short, 2 = long) */
139 false, /* pc_relative */
141 complain_overflow_bitfield
, /* complain_on_overflow */
142 bfd_elf_generic_reloc
, /* special_function */
143 "R_M68HC11_32", /* name */
144 false, /* partial_inplace */
145 0xffffffff, /* src_mask */
146 0xffffffff, /* dst_mask */
147 false), /* pcrel_offset */
149 /* A 3 bit absolute relocation */
150 HOWTO (R_M68HC11_3B
, /* type */
152 0, /* size (0 = byte, 1 = short, 2 = long) */
154 false, /* pc_relative */
156 complain_overflow_bitfield
, /* complain_on_overflow */
157 bfd_elf_generic_reloc
, /* special_function */
158 "R_M68HC11_4B", /* name */
159 false, /* partial_inplace */
160 0x003, /* src_mask */
161 0x003, /* dst_mask */
162 false), /* pcrel_offset */
164 /* A 16 bit PC-rel relocation */
165 HOWTO (R_M68HC11_PCREL_16
, /* type */
167 1, /* size (0 = byte, 1 = short, 2 = long) */
169 true, /* pc_relative */
171 complain_overflow_dont
, /* complain_on_overflow */
172 bfd_elf_generic_reloc
, /* special_function */
173 "R_M68HC11_PCREL_16", /* name */
174 false, /* partial_inplace */
176 0xffff, /* dst_mask */
177 false), /* pcrel_offset */
179 /* GNU extension to record C++ vtable hierarchy */
180 HOWTO (R_M68HC11_GNU_VTINHERIT
, /* type */
182 1, /* size (0 = byte, 1 = short, 2 = long) */
184 false, /* pc_relative */
186 complain_overflow_dont
, /* complain_on_overflow */
187 NULL
, /* special_function */
188 "R_M68HC11_GNU_VTINHERIT", /* name */
189 false, /* partial_inplace */
192 false), /* pcrel_offset */
194 /* GNU extension to record C++ vtable member usage */
195 HOWTO (R_M68HC11_GNU_VTENTRY
, /* type */
197 1, /* size (0 = byte, 1 = short, 2 = long) */
199 false, /* pc_relative */
201 complain_overflow_dont
, /* complain_on_overflow */
202 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
203 "R_M68HC11_GNU_VTENTRY", /* name */
204 false, /* partial_inplace */
207 false), /* pcrel_offset */
210 /* Map BFD reloc types to M68HC11 ELF reloc types. */
212 struct m68hc11_reloc_map
214 bfd_reloc_code_real_type bfd_reloc_val
;
215 unsigned char elf_reloc_val
;
218 static const struct m68hc11_reloc_map m68hc11_reloc_map
[] = {
219 {BFD_RELOC_NONE
, R_M68HC11_NONE
,},
220 {BFD_RELOC_8
, R_M68HC11_8
},
221 {BFD_RELOC_M68HC11_HI8
, R_M68HC11_HI8
},
222 {BFD_RELOC_M68HC11_LO8
, R_M68HC11_LO8
},
223 {BFD_RELOC_8_PCREL
, R_M68HC11_PCREL_8
},
224 {BFD_RELOC_16_PCREL
, R_M68HC11_PCREL_16
},
225 {BFD_RELOC_16
, R_M68HC11_16
},
226 {BFD_RELOC_32
, R_M68HC11_32
},
227 {BFD_RELOC_M68HC11_3B
, R_M68HC11_3B
},
229 /* The following relocs are defined but they probably don't work yet. */
230 {BFD_RELOC_VTABLE_INHERIT
, R_M68HC11_GNU_VTINHERIT
},
231 {BFD_RELOC_VTABLE_ENTRY
, R_M68HC11_GNU_VTENTRY
},
234 static reloc_howto_type
*
235 bfd_elf32_bfd_reloc_type_lookup (abfd
, code
)
236 bfd
*abfd ATTRIBUTE_UNUSED
;
237 bfd_reloc_code_real_type code
;
242 i
< sizeof (m68hc11_reloc_map
) / sizeof (struct m68hc11_reloc_map
);
245 if (m68hc11_reloc_map
[i
].bfd_reloc_val
== code
)
246 return &elf_m68hc11_howto_table
[m68hc11_reloc_map
[i
].elf_reloc_val
];
252 /* Set the howto pointer for an M68HC11 ELF reloc. */
255 m68hc11_info_to_howto_rel (abfd
, cache_ptr
, dst
)
256 bfd
*abfd ATTRIBUTE_UNUSED
;
258 Elf32_Internal_Rel
*dst
;
262 r_type
= ELF32_R_TYPE (dst
->r_info
);
263 BFD_ASSERT (r_type
< (unsigned int) R_M68HC11_max
);
264 cache_ptr
->howto
= &elf_m68hc11_howto_table
[r_type
];
267 /* Below is the only difference between elf32-m68hc12.c and elf32-m68hc11.c.
268 The Motorola spec says to use a different Elf machine code. */
269 #define ELF_ARCH bfd_arch_m68hc12
270 #define ELF_MACHINE_CODE EM_68HC12
271 #define ELF_MAXPAGESIZE 0x1000
273 #define TARGET_BIG_SYM bfd_elf32_m68hc12_vec
274 #define TARGET_BIG_NAME "elf32-m68hc12"
276 #define elf_info_to_howto 0
277 #define elf_info_to_howto_rel m68hc11_info_to_howto_rel
278 #define elf_backend_object_p 0
279 #define elf_backend_final_write_processing 0
281 #include "elf32-target.h"