missed entry
[deliverable/binutils-gdb.git] / bfd / elf32-m68hc12.c
CommitLineData
60bcf0fa 1/* Motorola 68HC12-specific support for 32-bit ELF
07adf181
AM
2 Copyright 1999, 2000, 2002, 2003, 2004, 2005, 2006
3 Free Software Foundation, Inc.
dae78fb0 4 Contributed by Stephane Carrez (stcarrez@nerim.fr)
60bcf0fa
NC
5 (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com))
6
7This file is part of BFD, the Binary File Descriptor library.
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
3e110533 21Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
60bcf0fa
NC
22
23#include "bfd.h"
24#include "sysdep.h"
3a65329d 25#include "bfdlink.h"
60bcf0fa
NC
26#include "libbfd.h"
27#include "elf-bfd.h"
3a65329d 28#include "elf32-m68hc1x.h"
60bcf0fa 29#include "elf/m68hc11.h"
dae78fb0 30#include "opcode/m68hc11.h"
60bcf0fa 31
3a65329d 32/* Relocation functions. */
60bcf0fa 33static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
0a6a3ebe 34 (bfd *, bfd_reloc_code_real_type);
60bcf0fa 35static void m68hc11_info_to_howto_rel
0a6a3ebe 36 (bfd *, arelent *, Elf_Internal_Rela *);
60bcf0fa 37
3a65329d
SC
38/* Trampoline generation. */
39static bfd_boolean m68hc12_elf_size_one_stub
0a6a3ebe 40 (struct bfd_hash_entry *gen_entry, void *in_arg);
3a65329d 41static bfd_boolean m68hc12_elf_build_one_stub
0a6a3ebe 42 (struct bfd_hash_entry *gen_entry, void *in_arg);
3a65329d 43static struct bfd_link_hash_table* m68hc12_elf_bfd_link_hash_table_create
0a6a3ebe 44 (bfd*);
9b701e44 45
cf3d882d
AM
46static bfd_boolean m68hc12_elf_set_mach_from_flags PARAMS ((bfd *));
47
60bcf0fa 48/* Use REL instead of RELA to save space */
acf8aed4 49#define USE_REL 1
60bcf0fa 50
3a65329d 51/* The 68HC12 microcontroler has a memory bank switching system
dae78fb0
SC
52 with a 16Kb window in the 64Kb address space. The extended memory
53 is mapped in the 16Kb window (at 0x8000). The page register controls
54 which 16Kb bank is mapped. The call/rtc instructions take care of
55 bank switching in function calls/returns.
56
57 For GNU Binutils to work, we consider there is a physical memory
58 at 0..0x0ffff and a kind of virtual memory above that. Symbols
59 in virtual memory have their addresses treated in a special way
60 when disassembling and when linking.
61
62 For the linker to work properly, we must always relocate the virtual
63 memory as if it is mapped at 0x8000. When a 16-bit relocation is
64 made in the virtual memory, we check that it does not cross the
65 memory bank where it is used. This would involve a page change
66 which would be wrong. The 24-bit relocation is for that and it
67 treats the address as a physical address + page number.
68
69
70 Banked
71 Address Space
72 | | Page n
73 +---------------+ 0x1010000
74 | |
75 | jsr _foo |
76 | .. | Page 3
77 | _foo: |
78 +---------------+ 0x100C000
79 | |
80 | call _bar |
81 | .. | Page 2
82 | _bar: |
83 +---------------+ 0x1008000
84 /------>| |
85 | | call _foo | Page 1
86 | | |
87 | +---------------+ 0x1004000
88 Physical | | |
89 Address Space | | | Page 0
90 | | |
91 +-----------+ 0x00FFFF | +---------------+ 0x1000000
92 | | |
93 | call _foo | |
94 | | |
95 +-----------+ 0x00BFFF -+---/
96 | | |
97 | | |
98 | | 16K |
99 | | |
100 +-----------+ 0x008000 -+
101 | |
102 | |
103 = =
104 | |
105 | |
106 +-----------+ 0000
107
108
109 The 'call _foo' must be relocated with page 3 and 16-bit address
b34976b6 110 mapped at 0x8000.
dae78fb0 111
60bcf0fa
NC
112 The 3-bit and 16-bit PC rel relocation is only used by 68HC12. */
113static reloc_howto_type elf_m68hc11_howto_table[] = {
114 /* This reloc does nothing. */
115 HOWTO (R_M68HC11_NONE, /* type */
116 0, /* rightshift */
117 2, /* size (0 = byte, 1 = short, 2 = long) */
118 32, /* bitsize */
b34976b6 119 FALSE, /* pc_relative */
60bcf0fa 120 0, /* bitpos */
dae78fb0 121 complain_overflow_dont,/* complain_on_overflow */
60bcf0fa 122 bfd_elf_generic_reloc, /* special_function */
dae78fb0 123 "R_M68HC12_NONE", /* name */
b34976b6 124 FALSE, /* partial_inplace */
60bcf0fa
NC
125 0, /* src_mask */
126 0, /* dst_mask */
b34976b6 127 FALSE), /* pcrel_offset */
60bcf0fa
NC
128
129 /* A 8 bit absolute relocation */
130 HOWTO (R_M68HC11_8, /* type */
131 0, /* rightshift */
132 0, /* size (0 = byte, 1 = short, 2 = long) */
133 8, /* bitsize */
b34976b6 134 FALSE, /* pc_relative */
60bcf0fa
NC
135 0, /* bitpos */
136 complain_overflow_bitfield, /* complain_on_overflow */
137 bfd_elf_generic_reloc, /* special_function */
dae78fb0 138 "R_M68HC12_8", /* name */
b34976b6 139 FALSE, /* partial_inplace */
60bcf0fa
NC
140 0x00ff, /* src_mask */
141 0x00ff, /* dst_mask */
b34976b6 142 FALSE), /* pcrel_offset */
60bcf0fa
NC
143
144 /* A 8 bit absolute relocation (upper address) */
145 HOWTO (R_M68HC11_HI8, /* type */
146 8, /* rightshift */
147 0, /* size (0 = byte, 1 = short, 2 = long) */
148 8, /* bitsize */
b34976b6 149 FALSE, /* pc_relative */
60bcf0fa
NC
150 0, /* bitpos */
151 complain_overflow_bitfield, /* complain_on_overflow */
152 bfd_elf_generic_reloc, /* special_function */
dae78fb0 153 "R_M68HC12_HI8", /* name */
b34976b6 154 FALSE, /* partial_inplace */
60bcf0fa
NC
155 0x00ff, /* src_mask */
156 0x00ff, /* dst_mask */
b34976b6 157 FALSE), /* pcrel_offset */
60bcf0fa
NC
158
159 /* A 8 bit absolute relocation (upper address) */
160 HOWTO (R_M68HC11_LO8, /* type */
161 0, /* rightshift */
162 0, /* size (0 = byte, 1 = short, 2 = long) */
163 8, /* bitsize */
b34976b6 164 FALSE, /* pc_relative */
60bcf0fa
NC
165 0, /* bitpos */
166 complain_overflow_dont, /* complain_on_overflow */
167 bfd_elf_generic_reloc, /* special_function */
dae78fb0 168 "R_M68HC12_LO8", /* name */
b34976b6 169 FALSE, /* partial_inplace */
60bcf0fa
NC
170 0x00ff, /* src_mask */
171 0x00ff, /* dst_mask */
b34976b6 172 FALSE), /* pcrel_offset */
60bcf0fa
NC
173
174 /* A 8 bit PC-rel relocation */
175 HOWTO (R_M68HC11_PCREL_8, /* type */
176 0, /* rightshift */
177 0, /* size (0 = byte, 1 = short, 2 = long) */
178 8, /* bitsize */
b34976b6 179 TRUE, /* pc_relative */
60bcf0fa
NC
180 0, /* bitpos */
181 complain_overflow_bitfield, /* complain_on_overflow */
182 bfd_elf_generic_reloc, /* special_function */
dae78fb0 183 "R_M68HC12_PCREL_8", /* name */
b34976b6 184 FALSE, /* partial_inplace */
dae78fb0 185 0x00ff, /* src_mask */
60bcf0fa 186 0x00ff, /* dst_mask */
3a65329d 187 TRUE), /* pcrel_offset */
60bcf0fa
NC
188
189 /* A 16 bit absolute relocation */
190 HOWTO (R_M68HC11_16, /* type */
191 0, /* rightshift */
192 1, /* size (0 = byte, 1 = short, 2 = long) */
193 16, /* bitsize */
b34976b6 194 FALSE, /* pc_relative */
60bcf0fa
NC
195 0, /* bitpos */
196 complain_overflow_dont /*bitfield */ , /* complain_on_overflow */
3a65329d 197 bfd_elf_generic_reloc, /* special_function */
dae78fb0 198 "R_M68HC12_16", /* name */
b34976b6 199 FALSE, /* partial_inplace */
60bcf0fa
NC
200 0xffff, /* src_mask */
201 0xffff, /* dst_mask */
b34976b6 202 FALSE), /* pcrel_offset */
60bcf0fa
NC
203
204 /* A 32 bit absolute relocation. This one is never used for the
205 code relocation. It's used by gas for -gstabs generation. */
206 HOWTO (R_M68HC11_32, /* type */
207 0, /* rightshift */
208 2, /* size (0 = byte, 1 = short, 2 = long) */
209 32, /* bitsize */
b34976b6 210 FALSE, /* pc_relative */
60bcf0fa
NC
211 0, /* bitpos */
212 complain_overflow_bitfield, /* complain_on_overflow */
213 bfd_elf_generic_reloc, /* special_function */
dae78fb0 214 "R_M68HC12_32", /* name */
b34976b6 215 FALSE, /* partial_inplace */
60bcf0fa
NC
216 0xffffffff, /* src_mask */
217 0xffffffff, /* dst_mask */
b34976b6 218 FALSE), /* pcrel_offset */
60bcf0fa
NC
219
220 /* A 3 bit absolute relocation */
221 HOWTO (R_M68HC11_3B, /* type */
222 0, /* rightshift */
223 0, /* size (0 = byte, 1 = short, 2 = long) */
224 3, /* bitsize */
b34976b6 225 FALSE, /* pc_relative */
60bcf0fa
NC
226 0, /* bitpos */
227 complain_overflow_bitfield, /* complain_on_overflow */
228 bfd_elf_generic_reloc, /* special_function */
dae78fb0 229 "R_M68HC12_4B", /* name */
b34976b6 230 FALSE, /* partial_inplace */
60bcf0fa
NC
231 0x003, /* src_mask */
232 0x003, /* dst_mask */
b34976b6 233 FALSE), /* pcrel_offset */
60bcf0fa
NC
234
235 /* A 16 bit PC-rel relocation */
236 HOWTO (R_M68HC11_PCREL_16, /* type */
237 0, /* rightshift */
238 1, /* size (0 = byte, 1 = short, 2 = long) */
239 16, /* bitsize */
b34976b6 240 TRUE, /* pc_relative */
60bcf0fa
NC
241 0, /* bitpos */
242 complain_overflow_dont, /* complain_on_overflow */
243 bfd_elf_generic_reloc, /* special_function */
dae78fb0 244 "R_M68HC12_PCREL_16", /* name */
b34976b6 245 FALSE, /* partial_inplace */
dae78fb0 246 0xffff, /* src_mask */
60bcf0fa 247 0xffff, /* dst_mask */
3a65329d 248 TRUE), /* pcrel_offset */
60bcf0fa
NC
249
250 /* GNU extension to record C++ vtable hierarchy */
251 HOWTO (R_M68HC11_GNU_VTINHERIT, /* type */
252 0, /* rightshift */
253 1, /* size (0 = byte, 1 = short, 2 = long) */
254 0, /* bitsize */
b34976b6 255 FALSE, /* pc_relative */
60bcf0fa
NC
256 0, /* bitpos */
257 complain_overflow_dont, /* complain_on_overflow */
258 NULL, /* special_function */
259 "R_M68HC11_GNU_VTINHERIT", /* name */
b34976b6 260 FALSE, /* partial_inplace */
60bcf0fa
NC
261 0, /* src_mask */
262 0, /* dst_mask */
b34976b6 263 FALSE), /* pcrel_offset */
60bcf0fa
NC
264
265 /* GNU extension to record C++ vtable member usage */
266 HOWTO (R_M68HC11_GNU_VTENTRY, /* type */
267 0, /* rightshift */
268 1, /* size (0 = byte, 1 = short, 2 = long) */
269 0, /* bitsize */
b34976b6 270 FALSE, /* pc_relative */
60bcf0fa
NC
271 0, /* bitpos */
272 complain_overflow_dont, /* complain_on_overflow */
273 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
274 "R_M68HC11_GNU_VTENTRY", /* name */
b34976b6 275 FALSE, /* partial_inplace */
60bcf0fa
NC
276 0, /* src_mask */
277 0, /* dst_mask */
b34976b6 278 FALSE), /* pcrel_offset */
dae78fb0
SC
279
280 /* A 24 bit relocation */
281 HOWTO (R_M68HC11_24, /* type */
282 0, /* rightshift */
3a65329d 283 2, /* size (0 = byte, 1 = short, 2 = long) */
dae78fb0 284 24, /* bitsize */
b34976b6 285 FALSE, /* pc_relative */
dae78fb0
SC
286 0, /* bitpos */
287 complain_overflow_dont, /* complain_on_overflow */
3a65329d 288 m68hc11_elf_special_reloc, /* special_function */
dae78fb0 289 "R_M68HC12_24", /* name */
b34976b6 290 FALSE, /* partial_inplace */
3a65329d
SC
291 0xffffff, /* src_mask */
292 0xffffff, /* dst_mask */
b34976b6
AM
293 FALSE), /* pcrel_offset */
294
dae78fb0
SC
295 /* A 16-bit low relocation */
296 HOWTO (R_M68HC11_LO16, /* type */
297 0, /* rightshift */
298 1, /* size (0 = byte, 1 = short, 2 = long) */
299 16, /* bitsize */
b34976b6 300 FALSE, /* pc_relative */
dae78fb0
SC
301 0, /* bitpos */
302 complain_overflow_dont, /* complain_on_overflow */
3a65329d 303 m68hc11_elf_special_reloc,/* special_function */
dae78fb0 304 "R_M68HC12_LO16", /* name */
b34976b6 305 FALSE, /* partial_inplace */
dae78fb0
SC
306 0xffff, /* src_mask */
307 0xffff, /* dst_mask */
b34976b6 308 FALSE), /* pcrel_offset */
dae78fb0
SC
309
310 /* A page relocation */
311 HOWTO (R_M68HC11_PAGE, /* type */
312 0, /* rightshift */
313 0, /* size (0 = byte, 1 = short, 2 = long) */
314 8, /* bitsize */
b34976b6 315 FALSE, /* pc_relative */
dae78fb0
SC
316 0, /* bitpos */
317 complain_overflow_dont, /* complain_on_overflow */
3a65329d 318 m68hc11_elf_special_reloc,/* special_function */
dae78fb0 319 "R_M68HC12_PAGE", /* name */
b34976b6 320 FALSE, /* partial_inplace */
dae78fb0
SC
321 0x00ff, /* src_mask */
322 0x00ff, /* dst_mask */
b34976b6 323 FALSE), /* pcrel_offset */
dae78fb0
SC
324
325 EMPTY_HOWTO (14),
326 EMPTY_HOWTO (15),
327 EMPTY_HOWTO (16),
328 EMPTY_HOWTO (17),
329 EMPTY_HOWTO (18),
330 EMPTY_HOWTO (19),
b34976b6 331
dae78fb0
SC
332 /* Mark beginning of a jump instruction (any form). */
333 HOWTO (R_M68HC11_RL_JUMP, /* type */
334 0, /* rightshift */
335 1, /* size (0 = byte, 1 = short, 2 = long) */
336 0, /* bitsize */
b34976b6 337 FALSE, /* pc_relative */
dae78fb0
SC
338 0, /* bitpos */
339 complain_overflow_dont, /* complain_on_overflow */
340 m68hc11_elf_ignore_reloc, /* special_function */
341 "R_M68HC12_RL_JUMP", /* name */
b34976b6 342 TRUE, /* partial_inplace */
dae78fb0
SC
343 0, /* src_mask */
344 0, /* dst_mask */
b34976b6 345 TRUE), /* pcrel_offset */
dae78fb0
SC
346
347 /* Mark beginning of Gcc relaxation group instruction. */
348 HOWTO (R_M68HC11_RL_GROUP, /* type */
349 0, /* rightshift */
350 1, /* size (0 = byte, 1 = short, 2 = long) */
351 0, /* bitsize */
b34976b6 352 FALSE, /* pc_relative */
dae78fb0
SC
353 0, /* bitpos */
354 complain_overflow_dont, /* complain_on_overflow */
355 m68hc11_elf_ignore_reloc, /* special_function */
356 "R_M68HC12_RL_GROUP", /* name */
b34976b6 357 TRUE, /* partial_inplace */
dae78fb0
SC
358 0, /* src_mask */
359 0, /* dst_mask */
b34976b6 360 TRUE), /* pcrel_offset */
60bcf0fa
NC
361};
362
363/* Map BFD reloc types to M68HC11 ELF reloc types. */
364
365struct m68hc11_reloc_map
366{
367 bfd_reloc_code_real_type bfd_reloc_val;
368 unsigned char elf_reloc_val;
369};
370
371static const struct m68hc11_reloc_map m68hc11_reloc_map[] = {
372 {BFD_RELOC_NONE, R_M68HC11_NONE,},
373 {BFD_RELOC_8, R_M68HC11_8},
374 {BFD_RELOC_M68HC11_HI8, R_M68HC11_HI8},
375 {BFD_RELOC_M68HC11_LO8, R_M68HC11_LO8},
376 {BFD_RELOC_8_PCREL, R_M68HC11_PCREL_8},
377 {BFD_RELOC_16_PCREL, R_M68HC11_PCREL_16},
378 {BFD_RELOC_16, R_M68HC11_16},
379 {BFD_RELOC_32, R_M68HC11_32},
380 {BFD_RELOC_M68HC11_3B, R_M68HC11_3B},
381
60bcf0fa
NC
382 {BFD_RELOC_VTABLE_INHERIT, R_M68HC11_GNU_VTINHERIT},
383 {BFD_RELOC_VTABLE_ENTRY, R_M68HC11_GNU_VTENTRY},
dae78fb0
SC
384
385 {BFD_RELOC_M68HC11_LO16, R_M68HC11_LO16},
386 {BFD_RELOC_M68HC11_PAGE, R_M68HC11_PAGE},
387 {BFD_RELOC_M68HC11_24, R_M68HC11_24},
388
389 {BFD_RELOC_M68HC11_RL_JUMP, R_M68HC11_RL_JUMP},
390 {BFD_RELOC_M68HC11_RL_GROUP, R_M68HC11_RL_GROUP},
60bcf0fa
NC
391};
392
393static reloc_howto_type *
0a6a3ebe
SC
394bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
395 bfd_reloc_code_real_type code)
60bcf0fa
NC
396{
397 unsigned int i;
398
399 for (i = 0;
400 i < sizeof (m68hc11_reloc_map) / sizeof (struct m68hc11_reloc_map);
401 i++)
402 {
403 if (m68hc11_reloc_map[i].bfd_reloc_val == code)
404 return &elf_m68hc11_howto_table[m68hc11_reloc_map[i].elf_reloc_val];
405 }
406
407 return NULL;
408}
409
3a65329d 410/* Set the howto pointer for an M68HC11 ELF reloc. */
dae78fb0 411
3a65329d 412static void
0a6a3ebe
SC
413m68hc11_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
414 arelent *cache_ptr, Elf_Internal_Rela *dst)
dae78fb0 415{
3a65329d 416 unsigned int r_type;
dae78fb0 417
3a65329d
SC
418 r_type = ELF32_R_TYPE (dst->r_info);
419 BFD_ASSERT (r_type < (unsigned int) R_M68HC11_max);
420 cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
dae78fb0
SC
421}
422
3a65329d
SC
423\f
424/* Far trampoline generation. */
dae78fb0 425
3a65329d
SC
426/* Build a 68HC12 trampoline stub. */
427static bfd_boolean
0a6a3ebe 428m68hc12_elf_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
dae78fb0 429{
3a65329d
SC
430 struct elf32_m68hc11_stub_hash_entry *stub_entry;
431 struct bfd_link_info *info;
432 struct m68hc11_elf_link_hash_table *htab;
433 asection *stub_sec;
434 bfd *stub_bfd;
435 bfd_byte *loc;
436 bfd_vma sym_value, phys_page, phys_addr;
dae78fb0 437
3a65329d
SC
438 /* Massage our args to the form they really have. */
439 stub_entry = (struct elf32_m68hc11_stub_hash_entry *) gen_entry;
440 info = (struct bfd_link_info *) in_arg;
dae78fb0 441
3a65329d 442 htab = m68hc11_elf_hash_table (info);
dae78fb0 443
3a65329d 444 stub_sec = stub_entry->stub_sec;
dae78fb0 445
3a65329d 446 /* Make a note of the offset within the stubs for this entry. */
eea6121a
AM
447 stub_entry->stub_offset = stub_sec->size;
448 stub_sec->size += 7;
3a65329d 449 loc = stub_sec->contents + stub_entry->stub_offset;
dae78fb0 450
3a65329d 451 stub_bfd = stub_sec->owner;
dae78fb0 452
3a65329d 453 /* Create the trampoline call stub:
dae78fb0 454
3a65329d
SC
455 ldy #%addr(symbol)
456 call %page(symbol), __trampoline
dae78fb0 457
3a65329d
SC
458 */
459 sym_value = (stub_entry->target_value
460 + stub_entry->target_section->output_offset
461 + stub_entry->target_section->output_section->vma);
462 phys_addr = m68hc11_phys_addr (&htab->pinfo, sym_value);
463 phys_page = m68hc11_phys_page (&htab->pinfo, sym_value);
dae78fb0 464
3a65329d
SC
465 /* ldy #%page(sym) */
466 bfd_put_8 (stub_bfd, 0xCD, loc);
467 bfd_put_16 (stub_bfd, phys_addr, loc + 1);
468 loc += 3;
dae78fb0 469
3a65329d
SC
470 /* call %page(sym), __trampoline */
471 bfd_put_8 (stub_bfd, 0x4a, loc);
472 bfd_put_16 (stub_bfd, htab->pinfo.trampoline_addr, loc + 1);
473 bfd_put_8 (stub_bfd, phys_page, loc + 3);
b34976b6 474
3a65329d 475 return TRUE;
dae78fb0
SC
476}
477
3a65329d
SC
478/* As above, but don't actually build the stub. Just bump offset so
479 we know stub section sizes. */
60bcf0fa 480
3a65329d 481static bfd_boolean
0a6a3ebe
SC
482m68hc12_elf_size_one_stub (struct bfd_hash_entry *gen_entry,
483 void *in_arg ATTRIBUTE_UNUSED)
60bcf0fa 484{
3a65329d 485 struct elf32_m68hc11_stub_hash_entry *stub_entry;
60bcf0fa 486
3a65329d
SC
487 /* Massage our args to the form they really have. */
488 stub_entry = (struct elf32_m68hc11_stub_hash_entry *) gen_entry;
489
eea6121a 490 stub_entry->stub_sec->size += 7;
3a65329d 491 return TRUE;
60bcf0fa
NC
492}
493
3a65329d
SC
494/* Create a 68HC12 ELF linker hash table. */
495
496static struct bfd_link_hash_table *
0a6a3ebe 497m68hc12_elf_bfd_link_hash_table_create (bfd *abfd)
9b701e44 498{
3a65329d 499 struct m68hc11_elf_link_hash_table *ret;
56780f18 500
3a65329d
SC
501 ret = m68hc11_elf_hash_table_create (abfd);
502 if (ret == (struct m68hc11_elf_link_hash_table *) NULL)
503 return NULL;
9b701e44 504
3a65329d
SC
505 ret->size_one_stub = m68hc12_elf_size_one_stub;
506 ret->build_one_stub = m68hc12_elf_build_one_stub;
9b701e44 507
3a65329d
SC
508 return &ret->root.root;
509}
96405e3c 510\f
bc7c6a90 511static bfd_boolean
0a6a3ebe 512m68hc12_elf_set_mach_from_flags (bfd *abfd)
bc7c6a90
SC
513{
514 flagword flags = elf_elfheader (abfd)->e_flags;
515
516 switch (flags & EF_M68HC11_MACH_MASK)
517 {
518 case EF_M68HC12_MACH:
519 bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12, bfd_mach_m6812);
520 break;
521 case EF_M68HCS12_MACH:
522 bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12, bfd_mach_m6812s);
523 break;
524 case EF_M68HC11_GENERIC:
525 bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12,
526 bfd_mach_m6812_default);
527 break;
528 default:
529 return FALSE;
530 }
531 return TRUE;
532}
533
3f533aa9
SC
534/* Specific sections:
535 - The .page0 is a data section that is mapped in [0x0000..0x00FF].
536 Page0 accesses are faster on the M68HC12.
537 - The .vectors is the section that represents the interrupt
538 vectors. */
b35d266b 539static const struct bfd_elf_special_section elf32_m68hc12_special_sections[] =
3f533aa9 540{
0112cd26
NC
541 { STRING_COMMA_LEN (".eeprom"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
542 { STRING_COMMA_LEN (".page0"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
543 { STRING_COMMA_LEN (".softregs"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
544 { STRING_COMMA_LEN (".vectors"), 0, SHT_PROGBITS, SHF_ALLOC },
545 { NULL, 0, 0, 0, 0 }
7f4d3958 546};
3f533aa9 547\f
60bcf0fa
NC
548#define ELF_ARCH bfd_arch_m68hc12
549#define ELF_MACHINE_CODE EM_68HC12
550#define ELF_MAXPAGESIZE 0x1000
551
552#define TARGET_BIG_SYM bfd_elf32_m68hc12_vec
553#define TARGET_BIG_NAME "elf32-m68hc12"
554
555#define elf_info_to_howto 0
556#define elf_info_to_howto_rel m68hc11_info_to_howto_rel
3a65329d
SC
557#define elf_backend_check_relocs elf32_m68hc11_check_relocs
558#define elf_backend_relocate_section elf32_m68hc11_relocate_section
bc7c6a90 559#define elf_backend_object_p m68hc12_elf_set_mach_from_flags
60bcf0fa 560#define elf_backend_final_write_processing 0
3a65329d 561#define elf_backend_can_gc_sections 1
29ef7005 562#define elf_backend_special_sections elf32_m68hc12_special_sections
3a65329d
SC
563#define elf_backend_post_process_headers elf32_m68hc11_post_process_headers
564#define elf_backend_add_symbol_hook elf32_m68hc11_add_symbol_hook
565
566#define bfd_elf32_bfd_link_hash_table_create \
567 m68hc12_elf_bfd_link_hash_table_create
568#define bfd_elf32_bfd_link_hash_table_free \
569 m68hc11_elf_bfd_link_hash_table_free
96405e3c 570#define bfd_elf32_bfd_merge_private_bfd_data \
3a65329d
SC
571 _bfd_m68hc11_elf_merge_private_bfd_data
572#define bfd_elf32_bfd_set_private_flags _bfd_m68hc11_elf_set_private_flags
96405e3c 573#define bfd_elf32_bfd_print_private_bfd_data \
3a65329d 574 _bfd_m68hc11_elf_print_private_bfd_data
96405e3c 575
60bcf0fa 576#include "elf32-target.h"
This page took 0.930605 seconds and 4 git commands to generate.