Revert the value change of DT_ENCODING from 2003-01-17. Luckily (and
[deliverable/binutils-gdb.git] / bfd / elf32-m68hc12.c
CommitLineData
60bcf0fa 1/* Motorola 68HC12-specific support for 32-bit ELF
157090f7 2 Copyright 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007
07adf181 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
157090f7
AM
410static reloc_howto_type *
411bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
412 const char *r_name)
413{
414 unsigned int i;
415
416 for (i = 0;
417 i < (sizeof (elf_m68hc11_howto_table)
418 / sizeof (elf_m68hc11_howto_table[0]));
419 i++)
420 if (elf_m68hc11_howto_table[i].name != NULL
421 && strcasecmp (elf_m68hc11_howto_table[i].name, r_name) == 0)
422 return &elf_m68hc11_howto_table[i];
423
424 return NULL;
425}
426
3a65329d 427/* Set the howto pointer for an M68HC11 ELF reloc. */
dae78fb0 428
3a65329d 429static void
0a6a3ebe
SC
430m68hc11_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
431 arelent *cache_ptr, Elf_Internal_Rela *dst)
dae78fb0 432{
3a65329d 433 unsigned int r_type;
dae78fb0 434
3a65329d
SC
435 r_type = ELF32_R_TYPE (dst->r_info);
436 BFD_ASSERT (r_type < (unsigned int) R_M68HC11_max);
437 cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
dae78fb0
SC
438}
439
3a65329d
SC
440\f
441/* Far trampoline generation. */
dae78fb0 442
3a65329d
SC
443/* Build a 68HC12 trampoline stub. */
444static bfd_boolean
0a6a3ebe 445m68hc12_elf_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
dae78fb0 446{
3a65329d
SC
447 struct elf32_m68hc11_stub_hash_entry *stub_entry;
448 struct bfd_link_info *info;
449 struct m68hc11_elf_link_hash_table *htab;
450 asection *stub_sec;
451 bfd *stub_bfd;
452 bfd_byte *loc;
453 bfd_vma sym_value, phys_page, phys_addr;
dae78fb0 454
3a65329d
SC
455 /* Massage our args to the form they really have. */
456 stub_entry = (struct elf32_m68hc11_stub_hash_entry *) gen_entry;
457 info = (struct bfd_link_info *) in_arg;
dae78fb0 458
3a65329d 459 htab = m68hc11_elf_hash_table (info);
dae78fb0 460
3a65329d 461 stub_sec = stub_entry->stub_sec;
dae78fb0 462
3a65329d 463 /* Make a note of the offset within the stubs for this entry. */
eea6121a
AM
464 stub_entry->stub_offset = stub_sec->size;
465 stub_sec->size += 7;
3a65329d 466 loc = stub_sec->contents + stub_entry->stub_offset;
dae78fb0 467
3a65329d 468 stub_bfd = stub_sec->owner;
dae78fb0 469
3a65329d 470 /* Create the trampoline call stub:
dae78fb0 471
3a65329d
SC
472 ldy #%addr(symbol)
473 call %page(symbol), __trampoline
dae78fb0 474
3a65329d
SC
475 */
476 sym_value = (stub_entry->target_value
477 + stub_entry->target_section->output_offset
478 + stub_entry->target_section->output_section->vma);
479 phys_addr = m68hc11_phys_addr (&htab->pinfo, sym_value);
480 phys_page = m68hc11_phys_page (&htab->pinfo, sym_value);
dae78fb0 481
3a65329d
SC
482 /* ldy #%page(sym) */
483 bfd_put_8 (stub_bfd, 0xCD, loc);
484 bfd_put_16 (stub_bfd, phys_addr, loc + 1);
485 loc += 3;
dae78fb0 486
3a65329d
SC
487 /* call %page(sym), __trampoline */
488 bfd_put_8 (stub_bfd, 0x4a, loc);
489 bfd_put_16 (stub_bfd, htab->pinfo.trampoline_addr, loc + 1);
490 bfd_put_8 (stub_bfd, phys_page, loc + 3);
b34976b6 491
3a65329d 492 return TRUE;
dae78fb0
SC
493}
494
3a65329d
SC
495/* As above, but don't actually build the stub. Just bump offset so
496 we know stub section sizes. */
60bcf0fa 497
3a65329d 498static bfd_boolean
0a6a3ebe
SC
499m68hc12_elf_size_one_stub (struct bfd_hash_entry *gen_entry,
500 void *in_arg ATTRIBUTE_UNUSED)
60bcf0fa 501{
3a65329d 502 struct elf32_m68hc11_stub_hash_entry *stub_entry;
60bcf0fa 503
3a65329d
SC
504 /* Massage our args to the form they really have. */
505 stub_entry = (struct elf32_m68hc11_stub_hash_entry *) gen_entry;
506
eea6121a 507 stub_entry->stub_sec->size += 7;
3a65329d 508 return TRUE;
60bcf0fa
NC
509}
510
3a65329d
SC
511/* Create a 68HC12 ELF linker hash table. */
512
513static struct bfd_link_hash_table *
0a6a3ebe 514m68hc12_elf_bfd_link_hash_table_create (bfd *abfd)
9b701e44 515{
3a65329d 516 struct m68hc11_elf_link_hash_table *ret;
56780f18 517
3a65329d
SC
518 ret = m68hc11_elf_hash_table_create (abfd);
519 if (ret == (struct m68hc11_elf_link_hash_table *) NULL)
520 return NULL;
9b701e44 521
3a65329d
SC
522 ret->size_one_stub = m68hc12_elf_size_one_stub;
523 ret->build_one_stub = m68hc12_elf_build_one_stub;
9b701e44 524
3a65329d
SC
525 return &ret->root.root;
526}
96405e3c 527\f
bc7c6a90 528static bfd_boolean
0a6a3ebe 529m68hc12_elf_set_mach_from_flags (bfd *abfd)
bc7c6a90
SC
530{
531 flagword flags = elf_elfheader (abfd)->e_flags;
532
533 switch (flags & EF_M68HC11_MACH_MASK)
534 {
535 case EF_M68HC12_MACH:
536 bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12, bfd_mach_m6812);
537 break;
538 case EF_M68HCS12_MACH:
539 bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12, bfd_mach_m6812s);
540 break;
541 case EF_M68HC11_GENERIC:
542 bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12,
543 bfd_mach_m6812_default);
544 break;
545 default:
546 return FALSE;
547 }
548 return TRUE;
549}
550
3f533aa9
SC
551/* Specific sections:
552 - The .page0 is a data section that is mapped in [0x0000..0x00FF].
553 Page0 accesses are faster on the M68HC12.
554 - The .vectors is the section that represents the interrupt
555 vectors. */
b35d266b 556static const struct bfd_elf_special_section elf32_m68hc12_special_sections[] =
3f533aa9 557{
0112cd26
NC
558 { STRING_COMMA_LEN (".eeprom"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
559 { STRING_COMMA_LEN (".page0"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
560 { STRING_COMMA_LEN (".softregs"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
561 { STRING_COMMA_LEN (".vectors"), 0, SHT_PROGBITS, SHF_ALLOC },
562 { NULL, 0, 0, 0, 0 }
7f4d3958 563};
3f533aa9 564\f
60bcf0fa
NC
565#define ELF_ARCH bfd_arch_m68hc12
566#define ELF_MACHINE_CODE EM_68HC12
567#define ELF_MAXPAGESIZE 0x1000
568
569#define TARGET_BIG_SYM bfd_elf32_m68hc12_vec
570#define TARGET_BIG_NAME "elf32-m68hc12"
571
572#define elf_info_to_howto 0
573#define elf_info_to_howto_rel m68hc11_info_to_howto_rel
3a65329d
SC
574#define elf_backend_check_relocs elf32_m68hc11_check_relocs
575#define elf_backend_relocate_section elf32_m68hc11_relocate_section
bc7c6a90 576#define elf_backend_object_p m68hc12_elf_set_mach_from_flags
60bcf0fa 577#define elf_backend_final_write_processing 0
3a65329d 578#define elf_backend_can_gc_sections 1
29ef7005 579#define elf_backend_special_sections elf32_m68hc12_special_sections
3a65329d
SC
580#define elf_backend_post_process_headers elf32_m68hc11_post_process_headers
581#define elf_backend_add_symbol_hook elf32_m68hc11_add_symbol_hook
582
583#define bfd_elf32_bfd_link_hash_table_create \
584 m68hc12_elf_bfd_link_hash_table_create
585#define bfd_elf32_bfd_link_hash_table_free \
586 m68hc11_elf_bfd_link_hash_table_free
96405e3c 587#define bfd_elf32_bfd_merge_private_bfd_data \
3a65329d
SC
588 _bfd_m68hc11_elf_merge_private_bfd_data
589#define bfd_elf32_bfd_set_private_flags _bfd_m68hc11_elf_set_private_flags
96405e3c 590#define bfd_elf32_bfd_print_private_bfd_data \
3a65329d 591 _bfd_m68hc11_elf_print_private_bfd_data
96405e3c 592
60bcf0fa 593#include "elf32-target.h"
This page took 0.351441 seconds and 4 git commands to generate.