1 /* Motorola 68k series support for 32-bit ELF
2 Copyright 1993, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
27 static reloc_howto_type
*reloc_type_lookup
28 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
29 static void rtype_to_howto
30 PARAMS ((bfd
*, arelent
*, Elf32_Internal_Rela
*));
31 static struct bfd_hash_entry
*elf_m68k_link_hash_newfunc
32 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
33 static struct bfd_link_hash_table
*elf_m68k_link_hash_table_create
35 static boolean elf_m68k_check_relocs
36 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
37 const Elf_Internal_Rela
*));
38 static asection
*elf_m68k_gc_mark_hook
39 PARAMS ((bfd
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
40 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
41 static boolean elf_m68k_gc_sweep_hook
42 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
43 const Elf_Internal_Rela
*));
44 static boolean elf_m68k_adjust_dynamic_symbol
45 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
46 static boolean elf_m68k_adjust_dynindx
47 PARAMS ((struct elf_link_hash_entry
*, PTR
));
48 static boolean elf_m68k_size_dynamic_sections
49 PARAMS ((bfd
*, struct bfd_link_info
*));
50 static boolean elf_m68k_relocate_section
51 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
52 Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
53 static boolean elf_m68k_finish_dynamic_symbol
54 PARAMS ((bfd
*, struct bfd_link_info
*, struct elf_link_hash_entry
*,
56 static boolean elf_m68k_finish_dynamic_sections
57 PARAMS ((bfd
*, struct bfd_link_info
*));
59 static boolean elf32_m68k_set_private_flags
60 PARAMS ((bfd
*, flagword
));
61 static boolean elf32_m68k_copy_private_bfd_data
62 PARAMS ((bfd
*, bfd
*));
63 static boolean elf32_m68k_merge_private_bfd_data
64 PARAMS ((bfd
*, bfd
*));
65 static boolean elf32_m68k_print_private_bfd_data
66 PARAMS ((bfd
*, PTR
));
68 static reloc_howto_type howto_table
[] = {
69 HOWTO(R_68K_NONE
, 0, 0, 0, false,0, complain_overflow_dont
, bfd_elf_generic_reloc
, "R_68K_NONE", false, 0, 0x00000000,false),
70 HOWTO(R_68K_32
, 0, 2,32, false,0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_32", false, 0, 0xffffffff,false),
71 HOWTO(R_68K_16
, 0, 1,16, false,0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_16", false, 0, 0x0000ffff,false),
72 HOWTO(R_68K_8
, 0, 0, 8, false,0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_8", false, 0, 0x000000ff,false),
73 HOWTO(R_68K_PC32
, 0, 2,32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_PC32", false, 0, 0xffffffff,true),
74 HOWTO(R_68K_PC16
, 0, 1,16, true, 0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_PC16", false, 0, 0x0000ffff,true),
75 HOWTO(R_68K_PC8
, 0, 0, 8, true, 0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_PC8", false, 0, 0x000000ff,true),
76 HOWTO(R_68K_GOT32
, 0, 2,32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_GOT32", false, 0, 0xffffffff,true),
77 HOWTO(R_68K_GOT16
, 0, 1,16, true, 0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_GOT16", false, 0, 0x0000ffff,true),
78 HOWTO(R_68K_GOT8
, 0, 0, 8, true, 0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_GOT8", false, 0, 0x000000ff,true),
79 HOWTO(R_68K_GOT32O
, 0, 2,32, false,0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_GOT32O", false, 0, 0xffffffff,false),
80 HOWTO(R_68K_GOT16O
, 0, 1,16, false,0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_GOT16O", false, 0, 0x0000ffff,false),
81 HOWTO(R_68K_GOT8O
, 0, 0, 8, false,0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_GOT8O", false, 0, 0x000000ff,false),
82 HOWTO(R_68K_PLT32
, 0, 2,32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_PLT32", false, 0, 0xffffffff,true),
83 HOWTO(R_68K_PLT16
, 0, 1,16, true, 0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_PLT16", false, 0, 0x0000ffff,true),
84 HOWTO(R_68K_PLT8
, 0, 0, 8, true, 0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_PLT8", false, 0, 0x000000ff,true),
85 HOWTO(R_68K_PLT32O
, 0, 2,32, false,0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_68K_PLT32O", false, 0, 0xffffffff,false),
86 HOWTO(R_68K_PLT16O
, 0, 1,16, false,0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_PLT16O", false, 0, 0x0000ffff,false),
87 HOWTO(R_68K_PLT8O
, 0, 0, 8, false,0, complain_overflow_signed
, bfd_elf_generic_reloc
, "R_68K_PLT8O", false, 0, 0x000000ff,false),
88 HOWTO(R_68K_COPY
, 0, 0, 0, false,0, complain_overflow_dont
, bfd_elf_generic_reloc
, "R_68K_COPY", false, 0, 0xffffffff,false),
89 HOWTO(R_68K_GLOB_DAT
, 0, 2,32, false,0, complain_overflow_dont
, bfd_elf_generic_reloc
, "R_68K_GLOB_DAT", false, 0, 0xffffffff,false),
90 HOWTO(R_68K_JMP_SLOT
, 0, 2,32, false,0, complain_overflow_dont
, bfd_elf_generic_reloc
, "R_68K_JMP_SLOT", false, 0, 0xffffffff,false),
91 HOWTO(R_68K_RELATIVE
, 0, 2,32, false,0, complain_overflow_dont
, bfd_elf_generic_reloc
, "R_68K_RELATIVE", false, 0, 0xffffffff,false),
92 /* GNU extension to record C++ vtable hierarchy */
93 HOWTO (R_68K_GNU_VTINHERIT
, /* type */
95 2, /* size (0 = byte, 1 = short, 2 = long) */
97 false, /* pc_relative */
99 complain_overflow_dont
, /* complain_on_overflow */
100 NULL
, /* special_function */
101 "R_68K_GNU_VTINHERIT", /* name */
102 false, /* partial_inplace */
106 /* GNU extension to record C++ vtable member usage */
107 HOWTO (R_68K_GNU_VTENTRY
, /* type */
109 2, /* size (0 = byte, 1 = short, 2 = long) */
111 false, /* pc_relative */
113 complain_overflow_dont
, /* complain_on_overflow */
114 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
115 "R_68K_GNU_VTENTRY", /* name */
116 false, /* partial_inplace */
123 rtype_to_howto (abfd
, cache_ptr
, dst
)
126 Elf_Internal_Rela
*dst
;
128 BFD_ASSERT (ELF32_R_TYPE(dst
->r_info
) < (unsigned int) R_68K_max
);
129 cache_ptr
->howto
= &howto_table
[ELF32_R_TYPE(dst
->r_info
)];
132 #define elf_info_to_howto rtype_to_howto
136 bfd_reloc_code_real_type bfd_val
;
139 { BFD_RELOC_NONE
, R_68K_NONE
},
140 { BFD_RELOC_32
, R_68K_32
},
141 { BFD_RELOC_16
, R_68K_16
},
142 { BFD_RELOC_8
, R_68K_8
},
143 { BFD_RELOC_32_PCREL
, R_68K_PC32
},
144 { BFD_RELOC_16_PCREL
, R_68K_PC16
},
145 { BFD_RELOC_8_PCREL
, R_68K_PC8
},
146 { BFD_RELOC_32_GOT_PCREL
, R_68K_GOT32
},
147 { BFD_RELOC_16_GOT_PCREL
, R_68K_GOT16
},
148 { BFD_RELOC_8_GOT_PCREL
, R_68K_GOT8
},
149 { BFD_RELOC_32_GOTOFF
, R_68K_GOT32O
},
150 { BFD_RELOC_16_GOTOFF
, R_68K_GOT16O
},
151 { BFD_RELOC_8_GOTOFF
, R_68K_GOT8O
},
152 { BFD_RELOC_32_PLT_PCREL
, R_68K_PLT32
},
153 { BFD_RELOC_16_PLT_PCREL
, R_68K_PLT16
},
154 { BFD_RELOC_8_PLT_PCREL
, R_68K_PLT8
},
155 { BFD_RELOC_32_PLTOFF
, R_68K_PLT32O
},
156 { BFD_RELOC_16_PLTOFF
, R_68K_PLT16O
},
157 { BFD_RELOC_8_PLTOFF
, R_68K_PLT8O
},
158 { BFD_RELOC_NONE
, R_68K_COPY
},
159 { BFD_RELOC_68K_GLOB_DAT
, R_68K_GLOB_DAT
},
160 { BFD_RELOC_68K_JMP_SLOT
, R_68K_JMP_SLOT
},
161 { BFD_RELOC_68K_RELATIVE
, R_68K_RELATIVE
},
162 { BFD_RELOC_CTOR
, R_68K_32
},
163 { BFD_RELOC_VTABLE_INHERIT
, R_68K_GNU_VTINHERIT
},
164 { BFD_RELOC_VTABLE_ENTRY
, R_68K_GNU_VTENTRY
},
167 static reloc_howto_type
*
168 reloc_type_lookup (abfd
, code
)
170 bfd_reloc_code_real_type code
;
173 for (i
= 0; i
< sizeof (reloc_map
) / sizeof (reloc_map
[0]); i
++)
175 if (reloc_map
[i
].bfd_val
== code
)
176 return &howto_table
[reloc_map
[i
].elf_val
];
181 #define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup
182 #define ELF_ARCH bfd_arch_m68k
183 /* end code generated by elf.el */
188 /* Functions for the m68k ELF linker. */
190 /* The name of the dynamic interpreter. This is put in the .interp
193 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
195 /* The size in bytes of an entry in the procedure linkage table. */
197 #define PLT_ENTRY_SIZE 20
199 /* The first entry in a procedure linkage table looks like this. See
200 the SVR4 ABI m68k supplement to see how this works. */
202 static const bfd_byte elf_m68k_plt0_entry
[PLT_ENTRY_SIZE
] =
204 0x2f, 0x3b, 0x01, 0x70, /* move.l (%pc,addr),-(%sp) */
205 0, 0, 0, 0, /* replaced with offset to .got + 4. */
206 0x4e, 0xfb, 0x01, 0x71, /* jmp ([%pc,addr]) */
207 0, 0, 0, 0, /* replaced with offset to .got + 8. */
208 0, 0, 0, 0 /* pad out to 20 bytes. */
211 /* Subsequent entries in a procedure linkage table look like this. */
213 static const bfd_byte elf_m68k_plt_entry
[PLT_ENTRY_SIZE
] =
215 0x4e, 0xfb, 0x01, 0x71, /* jmp ([%pc,symbol@GOTPC]) */
216 0, 0, 0, 0, /* replaced with offset to symbol's .got entry. */
217 0x2f, 0x3c, /* move.l #offset,-(%sp) */
218 0, 0, 0, 0, /* replaced with offset into relocation table. */
219 0x60, 0xff, /* bra.l .plt */
220 0, 0, 0, 0 /* replaced with offset to start of .plt. */
223 #define CPU32_FLAG(abfd) (elf_elfheader (abfd)->e_flags & EF_CPU32)
225 #define PLT_CPU32_ENTRY_SIZE 24
226 /* Procedure linkage table entries for the cpu32 */
227 static const bfd_byte elf_cpu32_plt0_entry
[PLT_CPU32_ENTRY_SIZE
] =
229 0x20, 0x7b, 0x01, 0x70, /* moveal %pc@(0xc), %a0 */
230 0, 0, 0, 0, /* replaced with offset to .got + 4. */
231 0x4e, 0xd0, /* jmp %a0@ */
232 0, 0, 0, 0, /* replace with offset to .got +8. */
233 0, 0, 0, 0, /* pad out to 24 bytes. */
234 0, 0, 0, 0, /* pad out to 24 bytes. */
238 static const bfd_byte elf_cpu32_plt_entry
[PLT_CPU32_ENTRY_SIZE
] =
240 0x20, 0x7b, 0x01, 0x70, /* moveal %pc@(0xc), %a0 */
241 0, 0, 0, 0, /* replaced with offset to symbol's .got entry. */
242 0x4e, 0xd0, /* jmp %a0@ */
243 0x2f, 0x3c, /* move.l #offset,-(%sp) */
244 0, 0, 0, 0, /* replaced with offset into relocation table. */
245 0x60, 0xff, /* bra.l .plt */
246 0, 0, 0, 0, /* replaced with offset to start of .plt. */
250 /* The m68k linker needs to keep track of the number of relocs that it
251 decides to copy in check_relocs for each symbol. This is so that it
252 can discard PC relative relocs if it doesn't need them when linking
253 with -Bsymbolic. We store the information in a field extending the
254 regular ELF linker hash table. */
256 /* This structure keeps track of the number of PC relative relocs we have
257 copied for a given symbol. */
259 struct elf_m68k_pcrel_relocs_copied
262 struct elf_m68k_pcrel_relocs_copied
*next
;
263 /* A section in dynobj. */
265 /* Number of relocs copied in this section. */
269 /* m68k ELF linker hash entry. */
271 struct elf_m68k_link_hash_entry
273 struct elf_link_hash_entry root
;
275 /* Number of PC relative relocs copied for this symbol. */
276 struct elf_m68k_pcrel_relocs_copied
*pcrel_relocs_copied
;
279 /* m68k ELF linker hash table. */
281 struct elf_m68k_link_hash_table
283 struct elf_link_hash_table root
;
286 /* Declare this now that the above structures are defined. */
288 static boolean elf_m68k_discard_copies
289 PARAMS ((struct elf_m68k_link_hash_entry
*, PTR
));
291 /* Traverse an m68k ELF linker hash table. */
293 #define elf_m68k_link_hash_traverse(table, func, info) \
294 (elf_link_hash_traverse \
296 (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
299 /* Get the m68k ELF linker hash table from a link_info structure. */
301 #define elf_m68k_hash_table(p) \
302 ((struct elf_m68k_link_hash_table *) (p)->hash)
304 /* Create an entry in an m68k ELF linker hash table. */
306 static struct bfd_hash_entry
*
307 elf_m68k_link_hash_newfunc (entry
, table
, string
)
308 struct bfd_hash_entry
*entry
;
309 struct bfd_hash_table
*table
;
312 struct elf_m68k_link_hash_entry
*ret
=
313 (struct elf_m68k_link_hash_entry
*) entry
;
315 /* Allocate the structure if it has not already been allocated by a
317 if (ret
== (struct elf_m68k_link_hash_entry
*) NULL
)
318 ret
= ((struct elf_m68k_link_hash_entry
*)
319 bfd_hash_allocate (table
,
320 sizeof (struct elf_m68k_link_hash_entry
)));
321 if (ret
== (struct elf_m68k_link_hash_entry
*) NULL
)
322 return (struct bfd_hash_entry
*) ret
;
324 /* Call the allocation method of the superclass. */
325 ret
= ((struct elf_m68k_link_hash_entry
*)
326 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
328 if (ret
!= (struct elf_m68k_link_hash_entry
*) NULL
)
330 ret
->pcrel_relocs_copied
= NULL
;
333 return (struct bfd_hash_entry
*) ret
;
336 /* Create an m68k ELF linker hash table. */
338 static struct bfd_link_hash_table
*
339 elf_m68k_link_hash_table_create (abfd
)
342 struct elf_m68k_link_hash_table
*ret
;
344 ret
= ((struct elf_m68k_link_hash_table
*)
345 bfd_alloc (abfd
, sizeof (struct elf_m68k_link_hash_table
)));
346 if (ret
== (struct elf_m68k_link_hash_table
*) NULL
)
349 if (! _bfd_elf_link_hash_table_init (&ret
->root
, abfd
,
350 elf_m68k_link_hash_newfunc
))
352 bfd_release (abfd
, ret
);
356 return &ret
->root
.root
;
359 /* Keep m68k-specific flags in the ELF header */
361 elf32_m68k_set_private_flags (abfd
, flags
)
365 elf_elfheader (abfd
)->e_flags
= flags
;
366 elf_flags_init (abfd
) = true;
370 /* Copy m68k-specific data from one module to another */
372 elf32_m68k_copy_private_bfd_data (ibfd
, obfd
)
378 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
379 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
382 in_flags
= elf_elfheader (ibfd
)->e_flags
;
384 elf_elfheader (obfd
)->e_flags
= in_flags
;
385 elf_flags_init (obfd
) = true;
390 /* Copy backend specific data from one object module to another */
392 elf32_m68k_copy_private_bfd_data (ibfd
, obfd
)
399 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
400 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
403 in_flags
= elf_elfheader (ibfd
)->e_flags
;
404 out_flags
= elf_elfheader (obfd
)->e_flags
;
406 elf_elfheader (obfd
)->e_flags
= in_flags
;
407 elf_flags_init (obfd
) = true;
411 /* Merge backend specific data from an object file to the output
412 object file when linking. */
414 elf32_m68k_merge_private_bfd_data (ibfd
, obfd
)
421 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
422 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
425 in_flags
= elf_elfheader (ibfd
)->e_flags
;
426 out_flags
= elf_elfheader (obfd
)->e_flags
;
428 if (!elf_flags_init (obfd
))
430 elf_flags_init (obfd
) = true;
431 elf_elfheader (obfd
)->e_flags
= in_flags
;
437 /* Display the flags field */
439 elf32_m68k_print_private_bfd_data (abfd
, ptr
)
443 FILE *file
= (FILE *) ptr
;
445 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
447 /* Print normal ELF private data. */
448 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
450 /* Ignore init flag - it may not be set, despite the flags field containing valid data. */
452 /* xgettext:c-format */
453 fprintf (file
, _ ("private flags = %lx:"), elf_elfheader (abfd
)->e_flags
);
455 if (elf_elfheader (abfd
)->e_flags
& EF_CPU32
)
456 fprintf (file
, _ (" [cpu32]"));
462 /* Look through the relocs for a section during the first phase, and
463 allocate space in the global offset table or procedure linkage
467 elf_m68k_check_relocs (abfd
, info
, sec
, relocs
)
469 struct bfd_link_info
*info
;
471 const Elf_Internal_Rela
*relocs
;
474 Elf_Internal_Shdr
*symtab_hdr
;
475 struct elf_link_hash_entry
**sym_hashes
;
476 bfd_signed_vma
*local_got_refcounts
;
477 const Elf_Internal_Rela
*rel
;
478 const Elf_Internal_Rela
*rel_end
;
483 if (info
->relocateable
)
486 dynobj
= elf_hash_table (info
)->dynobj
;
487 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
488 sym_hashes
= elf_sym_hashes (abfd
);
489 local_got_refcounts
= elf_local_got_refcounts (abfd
);
495 rel_end
= relocs
+ sec
->reloc_count
;
496 for (rel
= relocs
; rel
< rel_end
; rel
++)
498 unsigned long r_symndx
;
499 struct elf_link_hash_entry
*h
;
501 r_symndx
= ELF32_R_SYM (rel
->r_info
);
503 if (r_symndx
< symtab_hdr
->sh_info
)
506 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
508 switch (ELF32_R_TYPE (rel
->r_info
))
514 && strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
520 /* This symbol requires a global offset table entry. */
524 /* Create the .got section. */
525 elf_hash_table (info
)->dynobj
= dynobj
= abfd
;
526 if (!_bfd_elf_create_got_section (dynobj
, info
))
532 sgot
= bfd_get_section_by_name (dynobj
, ".got");
533 BFD_ASSERT (sgot
!= NULL
);
537 && (h
!= NULL
|| info
->shared
))
539 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
542 srelgot
= bfd_make_section (dynobj
, ".rela.got");
544 || !bfd_set_section_flags (dynobj
, srelgot
,
551 || !bfd_set_section_alignment (dynobj
, srelgot
, 2))
558 if (h
->got
.refcount
== -1)
562 /* Make sure this symbol is output as a dynamic symbol. */
563 if (h
->dynindx
== -1)
565 if (!bfd_elf32_link_record_dynamic_symbol (info
, h
))
569 /* Allocate space in the .got section. */
570 sgot
->_raw_size
+= 4;
571 /* Allocate relocation space. */
572 srelgot
->_raw_size
+= sizeof (Elf32_External_Rela
);
579 /* This is a global offset table entry for a local symbol. */
580 if (local_got_refcounts
== NULL
)
584 size
= symtab_hdr
->sh_info
* sizeof (bfd_signed_vma
);
585 local_got_refcounts
= ((bfd_signed_vma
*)
586 bfd_alloc (abfd
, size
));
587 if (local_got_refcounts
== NULL
)
589 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
590 memset (local_got_refcounts
, -1, size
);
592 if (local_got_refcounts
[r_symndx
] == -1)
594 local_got_refcounts
[r_symndx
] = 1;
596 sgot
->_raw_size
+= 4;
599 /* If we are generating a shared object, we need to
600 output a R_68K_RELATIVE reloc so that the dynamic
601 linker can adjust this GOT entry. */
602 srelgot
->_raw_size
+= sizeof (Elf32_External_Rela
);
606 local_got_refcounts
[r_symndx
]++;
613 /* This symbol requires a procedure linkage table entry. We
614 actually build the entry in adjust_dynamic_symbol,
615 because this might be a case of linking PIC code which is
616 never referenced by a dynamic object, in which case we
617 don't need to generate a procedure linkage table entry
620 /* If this is a local symbol, we resolve it directly without
621 creating a procedure linkage table entry. */
625 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
626 if (h
->plt
.refcount
== -1)
635 /* This symbol requires a procedure linkage table entry. */
639 /* It does not make sense to have this relocation for a
640 local symbol. FIXME: does it? How to handle it if
641 it does make sense? */
642 bfd_set_error (bfd_error_bad_value
);
646 /* Make sure this symbol is output as a dynamic symbol. */
647 if (h
->dynindx
== -1)
649 if (!bfd_elf32_link_record_dynamic_symbol (info
, h
))
653 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
654 if (h
->plt
.refcount
== -1)
663 /* If we are creating a shared library and this is not a local
664 symbol, we need to copy the reloc into the shared library.
665 However when linking with -Bsymbolic and this is a global
666 symbol which is defined in an object we are including in the
667 link (i.e., DEF_REGULAR is set), then we can resolve the
668 reloc directly. At this point we have not seen all the input
669 files, so it is possible that DEF_REGULAR is not set now but
670 will be set later (it is never cleared). We account for that
671 possibility below by storing information in the
672 pcrel_relocs_copied field of the hash table entry. */
674 && (sec
->flags
& SEC_ALLOC
) != 0
677 || (h
->elf_link_hash_flags
678 & ELF_LINK_HASH_DEF_REGULAR
) == 0)))
682 /* Make sure a plt entry is created for this symbol if
683 it turns out to be a function defined by a dynamic
685 if (h
->plt
.refcount
== -1)
698 /* Make sure a plt entry is created for this symbol if it
699 turns out to be a function defined by a dynamic object. */
700 if (h
->plt
.refcount
== -1)
706 /* If we are creating a shared library, we need to copy the
707 reloc into the shared library. */
709 && (sec
->flags
& SEC_ALLOC
) != 0)
711 /* When creating a shared object, we must copy these
712 reloc types into the output file. We create a reloc
713 section in dynobj and make room for this reloc. */
718 name
= (bfd_elf_string_from_elf_section
720 elf_elfheader (abfd
)->e_shstrndx
,
721 elf_section_data (sec
)->rel_hdr
.sh_name
));
725 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
726 && strcmp (bfd_get_section_name (abfd
, sec
),
729 sreloc
= bfd_get_section_by_name (dynobj
, name
);
732 sreloc
= bfd_make_section (dynobj
, name
);
734 || !bfd_set_section_flags (dynobj
, sreloc
,
741 || !bfd_set_section_alignment (dynobj
, sreloc
, 2))
746 sreloc
->_raw_size
+= sizeof (Elf32_External_Rela
);
748 /* If we are linking with -Bsymbolic, we count the number of
749 PC relative relocations we have entered for this symbol,
750 so that we can discard them again if the symbol is later
751 defined by a regular object. Note that this function is
752 only called if we are using an m68kelf linker hash table,
753 which means that h is really a pointer to an
754 elf_m68k_link_hash_entry. */
755 if ((ELF32_R_TYPE (rel
->r_info
) == R_68K_PC8
756 || ELF32_R_TYPE (rel
->r_info
) == R_68K_PC16
757 || ELF32_R_TYPE (rel
->r_info
) == R_68K_PC32
)
760 struct elf_m68k_link_hash_entry
*eh
;
761 struct elf_m68k_pcrel_relocs_copied
*p
;
763 eh
= (struct elf_m68k_link_hash_entry
*) h
;
765 for (p
= eh
->pcrel_relocs_copied
; p
!= NULL
; p
= p
->next
)
766 if (p
->section
== sreloc
)
771 p
= ((struct elf_m68k_pcrel_relocs_copied
*)
772 bfd_alloc (dynobj
, sizeof *p
));
775 p
->next
= eh
->pcrel_relocs_copied
;
776 eh
->pcrel_relocs_copied
= p
;
787 /* This relocation describes the C++ object vtable hierarchy.
788 Reconstruct it for later use during GC. */
789 case R_68K_GNU_VTINHERIT
:
790 if (!_bfd_elf32_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
794 /* This relocation describes which C++ vtable entries are actually
795 used. Record for later use during GC. */
796 case R_68K_GNU_VTENTRY
:
797 if (!_bfd_elf32_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
809 /* Return the section that should be marked against GC for a given
813 elf_m68k_gc_mark_hook (abfd
, info
, rel
, h
, sym
)
815 struct bfd_link_info
*info
;
816 Elf_Internal_Rela
*rel
;
817 struct elf_link_hash_entry
*h
;
818 Elf_Internal_Sym
*sym
;
822 switch (ELF32_R_TYPE (rel
->r_info
))
824 case R_68K_GNU_VTINHERIT
:
825 case R_68K_GNU_VTENTRY
:
829 switch (h
->root
.type
)
834 case bfd_link_hash_defined
:
835 case bfd_link_hash_defweak
:
836 return h
->root
.u
.def
.section
;
838 case bfd_link_hash_common
:
839 return h
->root
.u
.c
.p
->section
;
845 if (!(elf_bad_symtab (abfd
)
846 && ELF_ST_BIND (sym
->st_info
) != STB_LOCAL
)
847 && ! ((sym
->st_shndx
<= 0 || sym
->st_shndx
>= SHN_LORESERVE
)
848 && sym
->st_shndx
!= SHN_COMMON
))
850 return bfd_section_from_elf_index (abfd
, sym
->st_shndx
);
857 /* Update the got entry reference counts for the section being removed. */
860 elf_m68k_gc_sweep_hook (abfd
, info
, sec
, relocs
)
862 struct bfd_link_info
*info
;
864 const Elf_Internal_Rela
*relocs
;
866 Elf_Internal_Shdr
*symtab_hdr
;
867 struct elf_link_hash_entry
**sym_hashes
;
868 bfd_signed_vma
*local_got_refcounts
;
869 const Elf_Internal_Rela
*rel
, *relend
;
870 unsigned long r_symndx
;
871 struct elf_link_hash_entry
*h
;
876 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
877 sym_hashes
= elf_sym_hashes (abfd
);
878 local_got_refcounts
= elf_local_got_refcounts (abfd
);
880 dynobj
= elf_hash_table (info
)->dynobj
;
883 sgot
= bfd_get_section_by_name (dynobj
, ".got");
884 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
887 relend
= relocs
+ sec
->reloc_count
;
888 for (rel
= relocs
; rel
< relend
; rel
++)
890 switch (ELF32_R_TYPE (rel
->r_info
))
898 r_symndx
= ELF32_R_SYM (rel
->r_info
);
899 if (r_symndx
>= symtab_hdr
->sh_info
)
901 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
902 if (h
->got
.refcount
> 0)
905 if (h
->got
.refcount
== 0)
907 /* We don't need the .got entry any more. */
908 sgot
->_raw_size
-= 4;
909 srelgot
->_raw_size
-= sizeof (Elf32_External_Rela
);
915 if (local_got_refcounts
[r_symndx
] > 0)
917 --local_got_refcounts
[r_symndx
];
918 if (local_got_refcounts
[r_symndx
] == 0)
920 /* We don't need the .got entry any more. */
921 sgot
->_raw_size
-= 4;
923 srelgot
->_raw_size
-= sizeof (Elf32_External_Rela
);
941 r_symndx
= ELF32_R_SYM (rel
->r_info
);
942 if (r_symndx
>= symtab_hdr
->sh_info
)
944 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
945 if (h
->plt
.refcount
> 0)
959 /* Adjust a symbol defined by a dynamic object and referenced by a
960 regular object. The current definition is in some section of the
961 dynamic object, but we're not including those sections. We have to
962 change the definition to something the rest of the link can
966 elf_m68k_adjust_dynamic_symbol (info
, h
)
967 struct bfd_link_info
*info
;
968 struct elf_link_hash_entry
*h
;
972 unsigned int power_of_two
;
974 dynobj
= elf_hash_table (info
)->dynobj
;
976 /* Make sure we know what is going on here. */
977 BFD_ASSERT (dynobj
!= NULL
978 && ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
)
979 || h
->weakdef
!= NULL
980 || ((h
->elf_link_hash_flags
981 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
982 && (h
->elf_link_hash_flags
983 & ELF_LINK_HASH_REF_REGULAR
) != 0
984 && (h
->elf_link_hash_flags
985 & ELF_LINK_HASH_DEF_REGULAR
) == 0)));
987 /* If this is a function, put it in the procedure linkage table. We
988 will fill in the contents of the procedure linkage table later,
989 when we know the address of the .got section. */
990 if (h
->type
== STT_FUNC
991 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
994 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_DYNAMIC
) == 0
995 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_REF_DYNAMIC
) == 0
996 /* We must always create the plt entry if it was referenced
997 by a PLTxxO relocation. In this case we already recorded
998 it as a dynamic symbol. */
1001 /* This case can occur if we saw a PLTxx reloc in an input
1002 file, but the symbol was never referred to by a dynamic
1003 object. In such a case, we don't actually need to build
1004 a procedure linkage table, and we can just do a PCxx
1006 BFD_ASSERT ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0);
1007 h
->plt
.offset
= (bfd_vma
) -1;
1011 /* GC may have rendered this entry unused. */
1012 if (h
->plt
.refcount
<= 0)
1014 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1015 h
->plt
.offset
= (bfd_vma
) -1;
1019 /* Make sure this symbol is output as a dynamic symbol. */
1020 if (h
->dynindx
== -1)
1022 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
1026 s
= bfd_get_section_by_name (dynobj
, ".plt");
1027 BFD_ASSERT (s
!= NULL
);
1029 /* If this is the first .plt entry, make room for the special
1031 if (s
->_raw_size
== 0)
1032 if ( CPU32_FLAG (dynobj
))
1033 s
->_raw_size
+= PLT_CPU32_ENTRY_SIZE
;
1035 s
->_raw_size
+= PLT_ENTRY_SIZE
;
1037 /* If this symbol is not defined in a regular file, and we are
1038 not generating a shared library, then set the symbol to this
1039 location in the .plt. This is required to make function
1040 pointers compare as equal between the normal executable and
1041 the shared library. */
1043 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
1045 h
->root
.u
.def
.section
= s
;
1046 h
->root
.u
.def
.value
= s
->_raw_size
;
1049 h
->plt
.offset
= s
->_raw_size
;
1051 /* Make room for this entry. */
1052 if (CPU32_FLAG (dynobj
))
1053 s
->_raw_size
+= PLT_CPU32_ENTRY_SIZE
;
1055 s
->_raw_size
+= PLT_ENTRY_SIZE
;
1057 /* We also need to make an entry in the .got.plt section, which
1058 will be placed in the .got section by the linker script. */
1060 s
= bfd_get_section_by_name (dynobj
, ".got.plt");
1061 BFD_ASSERT (s
!= NULL
);
1064 /* We also need to make an entry in the .rela.plt section. */
1066 s
= bfd_get_section_by_name (dynobj
, ".rela.plt");
1067 BFD_ASSERT (s
!= NULL
);
1068 s
->_raw_size
+= sizeof (Elf32_External_Rela
);
1073 /* Reinitialize the plt offset now that it is not used as a reference
1075 h
->plt
.offset
= (bfd_vma
) -1;
1077 /* If this is a weak symbol, and there is a real definition, the
1078 processor independent code will have arranged for us to see the
1079 real definition first, and we can just use the same value. */
1080 if (h
->weakdef
!= NULL
)
1082 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
1083 || h
->weakdef
->root
.type
== bfd_link_hash_defweak
);
1084 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
1085 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
1089 /* This is a reference to a symbol defined by a dynamic object which
1090 is not a function. */
1092 /* If we are creating a shared library, we must presume that the
1093 only references to the symbol are via the global offset table.
1094 For such cases we need not do anything here; the relocations will
1095 be handled correctly by relocate_section. */
1099 /* We must allocate the symbol in our .dynbss section, which will
1100 become part of the .bss section of the executable. There will be
1101 an entry for this symbol in the .dynsym section. The dynamic
1102 object will contain position independent code, so all references
1103 from the dynamic object to this symbol will go through the global
1104 offset table. The dynamic linker will use the .dynsym entry to
1105 determine the address it must put in the global offset table, so
1106 both the dynamic object and the regular object will refer to the
1107 same memory location for the variable. */
1109 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
1110 BFD_ASSERT (s
!= NULL
);
1112 /* We must generate a R_68K_COPY reloc to tell the dynamic linker to
1113 copy the initial value out of the dynamic object and into the
1114 runtime process image. We need to remember the offset into the
1115 .rela.bss section we are going to use. */
1116 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
1120 srel
= bfd_get_section_by_name (dynobj
, ".rela.bss");
1121 BFD_ASSERT (srel
!= NULL
);
1122 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
1123 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
1126 /* We need to figure out the alignment required for this symbol. I
1127 have no idea how ELF linkers handle this. */
1128 power_of_two
= bfd_log2 (h
->size
);
1129 if (power_of_two
> 3)
1132 /* Apply the required alignment. */
1133 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
1134 (bfd_size_type
) (1 << power_of_two
));
1135 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
1137 if (!bfd_set_section_alignment (dynobj
, s
, power_of_two
))
1141 /* Define the symbol as being at this point in the section. */
1142 h
->root
.u
.def
.section
= s
;
1143 h
->root
.u
.def
.value
= s
->_raw_size
;
1145 /* Increment the section size to make room for the symbol. */
1146 s
->_raw_size
+= h
->size
;
1151 /* Set the sizes of the dynamic sections. */
1154 elf_m68k_size_dynamic_sections (output_bfd
, info
)
1156 struct bfd_link_info
*info
;
1164 dynobj
= elf_hash_table (info
)->dynobj
;
1165 BFD_ASSERT (dynobj
!= NULL
);
1167 if (elf_hash_table (info
)->dynamic_sections_created
)
1169 /* Set the contents of the .interp section to the interpreter. */
1172 s
= bfd_get_section_by_name (dynobj
, ".interp");
1173 BFD_ASSERT (s
!= NULL
);
1174 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
1175 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
1180 /* We may have created entries in the .rela.got section.
1181 However, if we are not creating the dynamic sections, we will
1182 not actually use these entries. Reset the size of .rela.got,
1183 which will cause it to get stripped from the output file
1185 s
= bfd_get_section_by_name (dynobj
, ".rela.got");
1190 /* If this is a -Bsymbolic shared link, then we need to discard all PC
1191 relative relocs against symbols defined in a regular object. We
1192 allocated space for them in the check_relocs routine, but we will not
1193 fill them in in the relocate_section routine. */
1194 if (info
->shared
&& info
->symbolic
)
1195 elf_m68k_link_hash_traverse (elf_m68k_hash_table (info
),
1196 elf_m68k_discard_copies
,
1199 /* The check_relocs and adjust_dynamic_symbol entry points have
1200 determined the sizes of the various dynamic sections. Allocate
1205 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
1210 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
1213 /* It's OK to base decisions on the section name, because none
1214 of the dynobj section names depend upon the input files. */
1215 name
= bfd_get_section_name (dynobj
, s
);
1219 if (strcmp (name
, ".plt") == 0)
1221 if (s
->_raw_size
== 0)
1223 /* Strip this section if we don't need it; see the
1229 /* Remember whether there is a PLT. */
1233 else if (strncmp (name
, ".rela", 5) == 0)
1235 if (s
->_raw_size
== 0)
1237 /* If we don't need this section, strip it from the
1238 output file. This is mostly to handle .rela.bss and
1239 .rela.plt. We must create both sections in
1240 create_dynamic_sections, because they must be created
1241 before the linker maps input sections to output
1242 sections. The linker does that before
1243 adjust_dynamic_symbol is called, and it is that
1244 function which decides whether anything needs to go
1245 into these sections. */
1252 /* Remember whether there are any reloc sections other
1254 if (strcmp (name
, ".rela.plt") != 0)
1256 const char *outname
;
1260 /* If this relocation section applies to a read only
1261 section, then we probably need a DT_TEXTREL
1262 entry. .rela.plt is actually associated with
1263 .got.plt, which is never readonly. */
1264 outname
= bfd_get_section_name (output_bfd
,
1266 target
= bfd_get_section_by_name (output_bfd
, outname
+ 5);
1268 && (target
->flags
& SEC_READONLY
) != 0
1269 && (target
->flags
& SEC_ALLOC
) != 0)
1273 /* We use the reloc_count field as a counter if we need
1274 to copy relocs into the output file. */
1278 else if (strncmp (name
, ".got", 4) != 0)
1280 /* It's not one of our sections, so don't allocate space. */
1286 _bfd_strip_section_from_output (s
);
1290 /* Allocate memory for the section contents. */
1291 s
->contents
= (bfd_byte
*) bfd_alloc (dynobj
, s
->_raw_size
);
1292 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
1296 if (elf_hash_table (info
)->dynamic_sections_created
)
1298 /* Add some entries to the .dynamic section. We fill in the
1299 values later, in elf_m68k_finish_dynamic_sections, but we
1300 must add the entries now so that we get the correct size for
1301 the .dynamic section. The DT_DEBUG entry is filled in by the
1302 dynamic linker and used by the debugger. */
1305 if (!bfd_elf32_add_dynamic_entry (info
, DT_DEBUG
, 0))
1311 if (!bfd_elf32_add_dynamic_entry (info
, DT_PLTGOT
, 0)
1312 || !bfd_elf32_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
1313 || !bfd_elf32_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
1314 || !bfd_elf32_add_dynamic_entry (info
, DT_JMPREL
, 0))
1320 if (!bfd_elf32_add_dynamic_entry (info
, DT_RELA
, 0)
1321 || !bfd_elf32_add_dynamic_entry (info
, DT_RELASZ
, 0)
1322 || !bfd_elf32_add_dynamic_entry (info
, DT_RELAENT
,
1323 sizeof (Elf32_External_Rela
)))
1329 if (!bfd_elf32_add_dynamic_entry (info
, DT_TEXTREL
, 0))
1334 /* If we are generating a shared library, we generate a section
1335 symbol for each output section for which we might need to copy
1336 relocs. These are local symbols, which means that they must come
1337 first in the dynamic symbol table. That means we must increment
1338 the dynamic symbol index of every other dynamic symbol. */
1344 for (s
= output_bfd
->sections
; s
!= NULL
; s
= s
->next
)
1346 if ((s
->flags
& SEC_LINKER_CREATED
) != 0
1347 || (s
->flags
& SEC_ALLOC
) == 0)
1350 elf_section_data (s
)->dynindx
= c
+ 1;
1352 /* These symbols will have no names, so we don't need to
1353 fiddle with dynstr_index. */
1358 elf_link_hash_traverse (elf_hash_table (info
),
1359 elf_m68k_adjust_dynindx
,
1361 elf_hash_table (info
)->dynsymcount
+= c
;
1367 /* Increment the index of a dynamic symbol by a given amount. Called
1368 via elf_link_hash_traverse. */
1371 elf_m68k_adjust_dynindx (h
, cparg
)
1372 struct elf_link_hash_entry
*h
;
1375 int *cp
= (int *) cparg
;
1377 if (h
->dynindx
!= -1)
1382 /* This function is called via elf_m68k_link_hash_traverse if we are
1383 creating a shared object with -Bsymbolic. It discards the space
1384 allocated to copy PC relative relocs against symbols which are defined
1385 in regular objects. We allocated space for them in the check_relocs
1386 routine, but we won't fill them in in the relocate_section routine. */
1390 elf_m68k_discard_copies (h
, ignore
)
1391 struct elf_m68k_link_hash_entry
*h
;
1394 struct elf_m68k_pcrel_relocs_copied
*s
;
1396 /* We only discard relocs for symbols defined in a regular object. */
1397 if ((h
->root
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
1400 for (s
= h
->pcrel_relocs_copied
; s
!= NULL
; s
= s
->next
)
1401 s
->section
->_raw_size
-= s
->count
* sizeof (Elf32_External_Rela
);
1406 /* Relocate an M68K ELF section. */
1409 elf_m68k_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1410 contents
, relocs
, local_syms
, local_sections
)
1412 struct bfd_link_info
*info
;
1414 asection
*input_section
;
1416 Elf_Internal_Rela
*relocs
;
1417 Elf_Internal_Sym
*local_syms
;
1418 asection
**local_sections
;
1421 Elf_Internal_Shdr
*symtab_hdr
;
1422 struct elf_link_hash_entry
**sym_hashes
;
1423 bfd_vma
*local_got_offsets
;
1427 Elf_Internal_Rela
*rel
;
1428 Elf_Internal_Rela
*relend
;
1430 dynobj
= elf_hash_table (info
)->dynobj
;
1431 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1432 sym_hashes
= elf_sym_hashes (input_bfd
);
1433 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1440 relend
= relocs
+ input_section
->reloc_count
;
1441 for (; rel
< relend
; rel
++)
1444 reloc_howto_type
*howto
;
1445 unsigned long r_symndx
;
1446 struct elf_link_hash_entry
*h
;
1447 Elf_Internal_Sym
*sym
;
1450 bfd_reloc_status_type r
;
1452 r_type
= ELF32_R_TYPE (rel
->r_info
);
1453 if (r_type
< 0 || r_type
>= (int) R_68K_max
)
1455 bfd_set_error (bfd_error_bad_value
);
1458 howto
= howto_table
+ r_type
;
1460 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1462 if (info
->relocateable
)
1464 /* This is a relocateable link. We don't have to change
1465 anything, unless the reloc is against a section symbol,
1466 in which case we have to adjust according to where the
1467 section symbol winds up in the output section. */
1468 if (r_symndx
< symtab_hdr
->sh_info
)
1470 sym
= local_syms
+ r_symndx
;
1471 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1473 sec
= local_sections
[r_symndx
];
1474 rel
->r_addend
+= sec
->output_offset
+ sym
->st_value
;
1481 /* This is a final link. */
1485 if (r_symndx
< symtab_hdr
->sh_info
)
1487 sym
= local_syms
+ r_symndx
;
1488 sec
= local_sections
[r_symndx
];
1489 relocation
= (sec
->output_section
->vma
1490 + sec
->output_offset
1495 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1496 while (h
->root
.type
== bfd_link_hash_indirect
1497 || h
->root
.type
== bfd_link_hash_warning
)
1498 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1499 if (h
->root
.type
== bfd_link_hash_defined
1500 || h
->root
.type
== bfd_link_hash_defweak
)
1502 sec
= h
->root
.u
.def
.section
;
1503 if (((r_type
== R_68K_PLT8
1504 || r_type
== R_68K_PLT16
1505 || r_type
== R_68K_PLT32
1506 || r_type
== R_68K_PLT8O
1507 || r_type
== R_68K_PLT16O
1508 || r_type
== R_68K_PLT32O
)
1509 && h
->plt
.offset
!= (bfd_vma
) -1
1510 && elf_hash_table (info
)->dynamic_sections_created
)
1511 || ((r_type
== R_68K_GOT8O
1512 || r_type
== R_68K_GOT16O
1513 || r_type
== R_68K_GOT32O
1514 || ((r_type
== R_68K_GOT8
1515 || r_type
== R_68K_GOT16
1516 || r_type
== R_68K_GOT32
)
1517 && strcmp (h
->root
.root
.string
,
1518 "_GLOBAL_OFFSET_TABLE_") != 0))
1519 && elf_hash_table (info
)->dynamic_sections_created
1521 || (! info
->symbolic
&& h
->dynindx
!= -1)
1522 || (h
->elf_link_hash_flags
1523 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1525 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1526 || (h
->elf_link_hash_flags
1527 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
1528 && (input_section
->flags
& SEC_ALLOC
) != 0
1529 && (r_type
== R_68K_8
1530 || r_type
== R_68K_16
1531 || r_type
== R_68K_32
1532 || r_type
== R_68K_PC8
1533 || r_type
== R_68K_PC16
1534 || r_type
== R_68K_PC32
)))
1536 /* In these cases, we don't need the relocation
1537 value. We check specially because in some
1538 obscure cases sec->output_section will be NULL. */
1542 relocation
= (h
->root
.u
.def
.value
1543 + sec
->output_section
->vma
1544 + sec
->output_offset
);
1546 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1548 else if (info
->shared
&& !info
->symbolic
&& !info
->no_undefined
)
1552 if (!(info
->callbacks
->undefined_symbol
1553 (info
, h
->root
.root
.string
, input_bfd
,
1554 input_section
, rel
->r_offset
)))
1565 /* Relocation is to the address of the entry for this symbol
1566 in the global offset table. */
1568 && strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
1574 /* Relocation is the offset of the entry for this symbol in
1575 the global offset table. */
1582 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1583 BFD_ASSERT (sgot
!= NULL
);
1588 off
= h
->got
.offset
;
1589 BFD_ASSERT (off
!= (bfd_vma
) -1);
1591 if (!elf_hash_table (info
)->dynamic_sections_created
1593 && (info
->symbolic
|| h
->dynindx
== -1)
1594 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1596 /* This is actually a static link, or it is a
1597 -Bsymbolic link and the symbol is defined
1598 locally, or the symbol was forced to be local
1599 because of a version file.. We must initialize
1600 this entry in the global offset table. Since
1601 the offset must always be a multiple of 4, we
1602 use the least significant bit to record whether
1603 we have initialized it already.
1605 When doing a dynamic link, we create a .rela.got
1606 relocation entry to initialize the value. This
1607 is done in the finish_dynamic_symbol routine. */
1612 bfd_put_32 (output_bfd
, relocation
,
1613 sgot
->contents
+ off
);
1620 BFD_ASSERT (local_got_offsets
!= NULL
1621 && local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
1623 off
= local_got_offsets
[r_symndx
];
1625 /* The offset must always be a multiple of 4. We use
1626 the least significant bit to record whether we have
1627 already generated the necessary reloc. */
1632 bfd_put_32 (output_bfd
, relocation
, sgot
->contents
+ off
);
1637 Elf_Internal_Rela outrel
;
1639 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
1640 BFD_ASSERT (srelgot
!= NULL
);
1642 outrel
.r_offset
= (sgot
->output_section
->vma
1643 + sgot
->output_offset
1645 outrel
.r_info
= ELF32_R_INFO (0, R_68K_RELATIVE
);
1646 outrel
.r_addend
= relocation
;
1647 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
1648 (((Elf32_External_Rela
*)
1650 + srelgot
->reloc_count
));
1651 ++srelgot
->reloc_count
;
1654 local_got_offsets
[r_symndx
] |= 1;
1658 relocation
= sgot
->output_offset
+ off
;
1659 if (r_type
== R_68K_GOT8O
1660 || r_type
== R_68K_GOT16O
1661 || r_type
== R_68K_GOT32O
)
1663 /* This relocation does not use the addend. */
1667 relocation
+= sgot
->output_section
->vma
;
1674 /* Relocation is to the entry for this symbol in the
1675 procedure linkage table. */
1677 /* Resolve a PLTxx reloc against a local symbol directly,
1678 without using the procedure linkage table. */
1682 if (h
->plt
.offset
== (bfd_vma
) -1
1683 || !elf_hash_table (info
)->dynamic_sections_created
)
1685 /* We didn't make a PLT entry for this symbol. This
1686 happens when statically linking PIC code, or when
1687 using -Bsymbolic. */
1693 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1694 BFD_ASSERT (splt
!= NULL
);
1697 relocation
= (splt
->output_section
->vma
1698 + splt
->output_offset
1705 /* Relocation is the offset of the entry for this symbol in
1706 the procedure linkage table. */
1707 BFD_ASSERT (h
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1);
1711 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1712 BFD_ASSERT (splt
!= NULL
);
1715 relocation
= h
->plt
.offset
;
1717 /* This relocation does not use the addend. */
1732 && (input_section
->flags
& SEC_ALLOC
) != 0
1733 && ((r_type
!= R_68K_PC8
1734 && r_type
!= R_68K_PC16
1735 && r_type
!= R_68K_PC32
)
1737 || (h
->elf_link_hash_flags
1738 & ELF_LINK_HASH_DEF_REGULAR
) == 0)))
1740 Elf_Internal_Rela outrel
;
1741 boolean skip
, relocate
;
1743 /* When generating a shared object, these relocations
1744 are copied into the output file to be resolved at run
1751 name
= (bfd_elf_string_from_elf_section
1753 elf_elfheader (input_bfd
)->e_shstrndx
,
1754 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1758 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1759 && strcmp (bfd_get_section_name (input_bfd
,
1763 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1764 BFD_ASSERT (sreloc
!= NULL
);
1769 if (elf_section_data (input_section
)->stab_info
== NULL
)
1770 outrel
.r_offset
= rel
->r_offset
;
1775 off
= (_bfd_stab_section_offset
1776 (output_bfd
, &elf_hash_table (info
)->stab_info
,
1778 &elf_section_data (input_section
)->stab_info
,
1780 if (off
== (bfd_vma
) -1)
1782 outrel
.r_offset
= off
;
1785 outrel
.r_offset
+= (input_section
->output_section
->vma
1786 + input_section
->output_offset
);
1790 memset (&outrel
, 0, sizeof outrel
);
1793 /* h->dynindx may be -1 if the symbol was marked to
1796 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1797 || (h
->elf_link_hash_flags
1798 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1800 BFD_ASSERT (h
->dynindx
!= -1);
1802 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, r_type
);
1803 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1807 if (r_type
== R_68K_32
)
1810 outrel
.r_info
= ELF32_R_INFO (0, R_68K_RELATIVE
);
1811 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1818 sec
= local_sections
[r_symndx
];
1821 BFD_ASSERT (h
->root
.type
== bfd_link_hash_defined
1823 == bfd_link_hash_defweak
));
1824 sec
= h
->root
.u
.def
.section
;
1826 if (sec
!= NULL
&& bfd_is_abs_section (sec
))
1828 else if (sec
== NULL
|| sec
->owner
== NULL
)
1830 bfd_set_error (bfd_error_bad_value
);
1837 osec
= sec
->output_section
;
1838 indx
= elf_section_data (osec
)->dynindx
;
1839 BFD_ASSERT (indx
> 0);
1843 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
1844 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1848 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
1849 (((Elf32_External_Rela
*)
1851 + sreloc
->reloc_count
));
1852 ++sreloc
->reloc_count
;
1854 /* This reloc will be computed at runtime, so there's no
1855 need to do anything now, except for R_68K_32
1856 relocations that have been turned into
1864 case R_68K_GNU_VTINHERIT
:
1865 case R_68K_GNU_VTENTRY
:
1866 /* These are no-ops in the end. */
1873 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
1874 contents
, rel
->r_offset
,
1875 relocation
, rel
->r_addend
);
1877 if (r
!= bfd_reloc_ok
)
1882 case bfd_reloc_outofrange
:
1884 case bfd_reloc_overflow
:
1889 name
= h
->root
.root
.string
;
1892 name
= bfd_elf_string_from_elf_section (input_bfd
,
1893 symtab_hdr
->sh_link
,
1898 name
= bfd_section_name (input_bfd
, sec
);
1900 if (!(info
->callbacks
->reloc_overflow
1901 (info
, name
, howto
->name
, (bfd_vma
) 0,
1902 input_bfd
, input_section
, rel
->r_offset
)))
1913 /* Finish up dynamic symbol handling. We set the contents of various
1914 dynamic sections here. */
1917 elf_m68k_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
1919 struct bfd_link_info
*info
;
1920 struct elf_link_hash_entry
*h
;
1921 Elf_Internal_Sym
*sym
;
1924 int plt_off1
, plt_off2
, plt_off3
;
1926 dynobj
= elf_hash_table (info
)->dynobj
;
1928 if (h
->plt
.offset
!= (bfd_vma
) -1)
1935 Elf_Internal_Rela rela
;
1937 /* This symbol has an entry in the procedure linkage table. Set
1940 BFD_ASSERT (h
->dynindx
!= -1);
1942 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1943 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
1944 srela
= bfd_get_section_by_name (dynobj
, ".rela.plt");
1945 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srela
!= NULL
);
1947 /* Get the index in the procedure linkage table which
1948 corresponds to this symbol. This is the index of this symbol
1949 in all the symbols for which we are making plt entries. The
1950 first entry in the procedure linkage table is reserved. */
1951 if ( CPU32_FLAG (output_bfd
))
1952 plt_index
= h
->plt
.offset
/ PLT_CPU32_ENTRY_SIZE
- 1;
1954 plt_index
= h
->plt
.offset
/ PLT_ENTRY_SIZE
- 1;
1956 /* Get the offset into the .got table of the entry that
1957 corresponds to this function. Each .got entry is 4 bytes.
1958 The first three are reserved. */
1959 got_offset
= (plt_index
+ 3) * 4;
1961 if ( CPU32_FLAG (output_bfd
))
1963 /* Fill in the entry in the procedure linkage table. */
1964 memcpy (splt
->contents
+ h
->plt
.offset
, elf_cpu32_plt_entry
,
1965 PLT_CPU32_ENTRY_SIZE
);
1972 /* Fill in the entry in the procedure linkage table. */
1973 memcpy (splt
->contents
+ h
->plt
.offset
, elf_m68k_plt_entry
,
1980 /* The offset is relative to the first extension word. */
1981 bfd_put_32 (output_bfd
,
1982 (sgot
->output_section
->vma
1983 + sgot
->output_offset
1985 - (splt
->output_section
->vma
1986 + h
->plt
.offset
+ 2)),
1987 splt
->contents
+ h
->plt
.offset
+ plt_off1
);
1989 bfd_put_32 (output_bfd
, plt_index
* sizeof (Elf32_External_Rela
),
1990 splt
->contents
+ h
->plt
.offset
+ plt_off2
);
1991 bfd_put_32 (output_bfd
, - (h
->plt
.offset
+ plt_off3
),
1992 splt
->contents
+ h
->plt
.offset
+ plt_off3
);
1994 /* Fill in the entry in the global offset table. */
1995 bfd_put_32 (output_bfd
,
1996 (splt
->output_section
->vma
1997 + splt
->output_offset
2000 sgot
->contents
+ got_offset
);
2002 /* Fill in the entry in the .rela.plt section. */
2003 rela
.r_offset
= (sgot
->output_section
->vma
2004 + sgot
->output_offset
2006 rela
.r_info
= ELF32_R_INFO (h
->dynindx
, R_68K_JMP_SLOT
);
2008 bfd_elf32_swap_reloca_out (output_bfd
, &rela
,
2009 ((Elf32_External_Rela
*) srela
->contents
2012 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
2014 /* Mark the symbol as undefined, rather than as defined in
2015 the .plt section. Leave the value alone. */
2016 sym
->st_shndx
= SHN_UNDEF
;
2020 if (h
->got
.offset
!= (bfd_vma
) -1)
2024 Elf_Internal_Rela rela
;
2026 /* This symbol has an entry in the global offset table. Set it
2029 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2030 srela
= bfd_get_section_by_name (dynobj
, ".rela.got");
2031 BFD_ASSERT (sgot
!= NULL
&& srela
!= NULL
);
2033 rela
.r_offset
= (sgot
->output_section
->vma
2034 + sgot
->output_offset
2035 + (h
->got
.offset
&~ 1));
2037 /* If this is a -Bsymbolic link, and the symbol is defined
2038 locally, we just want to emit a RELATIVE reloc. Likewise if
2039 the symbol was forced to be local because of a version file.
2040 The entry in the global offset table will already have been
2041 initialized in the relocate_section function. */
2043 && (info
->symbolic
|| h
->dynindx
== -1)
2044 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
))
2046 rela
.r_info
= ELF32_R_INFO (0, R_68K_RELATIVE
);
2047 rela
.r_addend
= bfd_get_signed_32 (output_bfd
,
2049 + (h
->got
.offset
& ~1)));
2053 bfd_put_32 (output_bfd
, (bfd_vma
) 0,
2054 sgot
->contents
+ (h
->got
.offset
& ~1));
2055 rela
.r_info
= ELF32_R_INFO (h
->dynindx
, R_68K_GLOB_DAT
);
2059 bfd_elf32_swap_reloca_out (output_bfd
, &rela
,
2060 ((Elf32_External_Rela
*) srela
->contents
2061 + srela
->reloc_count
));
2062 ++srela
->reloc_count
;
2065 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
2068 Elf_Internal_Rela rela
;
2070 /* This symbol needs a copy reloc. Set it up. */
2072 BFD_ASSERT (h
->dynindx
!= -1
2073 && (h
->root
.type
== bfd_link_hash_defined
2074 || h
->root
.type
== bfd_link_hash_defweak
));
2076 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
2078 BFD_ASSERT (s
!= NULL
);
2080 rela
.r_offset
= (h
->root
.u
.def
.value
2081 + h
->root
.u
.def
.section
->output_section
->vma
2082 + h
->root
.u
.def
.section
->output_offset
);
2083 rela
.r_info
= ELF32_R_INFO (h
->dynindx
, R_68K_COPY
);
2085 bfd_elf32_swap_reloca_out (output_bfd
, &rela
,
2086 ((Elf32_External_Rela
*) s
->contents
2091 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
2092 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
2093 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
2094 sym
->st_shndx
= SHN_ABS
;
2099 /* Finish up the dynamic sections. */
2102 elf_m68k_finish_dynamic_sections (output_bfd
, info
)
2104 struct bfd_link_info
*info
;
2109 int plt_entry0_size
, plt_off1
, plt_off2
;
2111 dynobj
= elf_hash_table (info
)->dynobj
;
2113 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
2114 BFD_ASSERT (sgot
!= NULL
);
2115 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
2117 if (elf_hash_table (info
)->dynamic_sections_created
)
2120 Elf32_External_Dyn
*dyncon
, *dynconend
;
2122 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2123 BFD_ASSERT (splt
!= NULL
&& sdyn
!= NULL
);
2125 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
2126 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
2127 for (; dyncon
< dynconend
; dyncon
++)
2129 Elf_Internal_Dyn dyn
;
2133 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
2146 s
= bfd_get_section_by_name (output_bfd
, name
);
2147 BFD_ASSERT (s
!= NULL
);
2148 dyn
.d_un
.d_ptr
= s
->vma
;
2149 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2153 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
2154 BFD_ASSERT (s
!= NULL
);
2155 if (s
->_cooked_size
!= 0)
2156 dyn
.d_un
.d_val
= s
->_cooked_size
;
2158 dyn
.d_un
.d_val
= s
->_raw_size
;
2159 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2163 /* The procedure linkage table relocs (DT_JMPREL) should
2164 not be included in the overall relocs (DT_RELA).
2165 Therefore, we override the DT_RELASZ entry here to
2166 make it not include the JMPREL relocs. Since the
2167 linker script arranges for .rela.plt to follow all
2168 other relocation sections, we don't have to worry
2169 about changing the DT_RELA entry. */
2170 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
2173 if (s
->_cooked_size
!= 0)
2174 dyn
.d_un
.d_val
-= s
->_cooked_size
;
2176 dyn
.d_un
.d_val
-= s
->_raw_size
;
2178 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2183 /* Fill in the first entry in the procedure linkage table. */
2184 if (splt
->_raw_size
> 0)
2186 if (!CPU32_FLAG (output_bfd
))
2188 memcpy (splt
->contents
, elf_m68k_plt0_entry
, PLT_ENTRY_SIZE
);
2189 bfd_put_32 (output_bfd
,
2190 (sgot
->output_section
->vma
2191 + sgot
->output_offset
+ 4
2192 - (splt
->output_section
->vma
+ 2)),
2193 splt
->contents
+ 4);
2194 bfd_put_32 (output_bfd
,
2195 (sgot
->output_section
->vma
2196 + sgot
->output_offset
+ 8
2197 - (splt
->output_section
->vma
+ 10)),
2198 splt
->contents
+ 12);
2199 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
2204 memcpy (splt
->contents
, elf_cpu32_plt0_entry
, PLT_CPU32_ENTRY_SIZE
);
2205 bfd_put_32 (output_bfd
,
2206 (sgot
->output_section
->vma
2207 + sgot
->output_offset
+ 4
2208 - (splt
->output_section
->vma
+ 2)),
2209 splt
->contents
+ 4);
2210 bfd_put_32 (output_bfd
,
2211 (sgot
->output_section
->vma
2212 + sgot
->output_offset
+ 8
2213 - (splt
->output_section
->vma
+ 10)),
2214 splt
->contents
+ 10);
2215 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
2216 = PLT_CPU32_ENTRY_SIZE
;
2221 /* Fill in the first three entries in the global offset table. */
2222 if (sgot
->_raw_size
> 0)
2225 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
2227 bfd_put_32 (output_bfd
,
2228 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
2230 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 4);
2231 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
2234 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 4;
2240 Elf_Internal_Sym sym
;
2243 /* Set up the section symbols for the output sections. */
2245 sdynsym
= bfd_get_section_by_name (dynobj
, ".dynsym");
2246 BFD_ASSERT (sdynsym
!= NULL
);
2250 sym
.st_info
= ELF_ST_INFO (STB_LOCAL
, STT_SECTION
);
2254 for (s
= output_bfd
->sections
; s
!= NULL
; s
= s
->next
)
2258 if (elf_section_data (s
)->dynindx
== 0)
2261 sym
.st_value
= s
->vma
;
2263 indx
= elf_section_data (s
)->this_idx
;
2264 BFD_ASSERT (indx
> 0);
2265 sym
.st_shndx
= indx
;
2267 bfd_elf32_swap_symbol_out (output_bfd
, &sym
,
2268 (PTR
) (((Elf32_External_Sym
*)
2270 + elf_section_data (s
)->dynindx
));
2275 /* Set the sh_info field of the output .dynsym section to the
2276 index of the first global symbol. */
2277 elf_section_data (sdynsym
->output_section
)->this_hdr
.sh_info
= c
+ 1;
2283 #define TARGET_BIG_SYM bfd_elf32_m68k_vec
2284 #define TARGET_BIG_NAME "elf32-m68k"
2285 #define ELF_MACHINE_CODE EM_68K
2286 #define ELF_MAXPAGESIZE 0x2000
2287 #define elf_backend_create_dynamic_sections \
2288 _bfd_elf_create_dynamic_sections
2289 #define bfd_elf32_bfd_link_hash_table_create \
2290 elf_m68k_link_hash_table_create
2291 #define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link
2293 #define elf_backend_check_relocs elf_m68k_check_relocs
2294 #define elf_backend_adjust_dynamic_symbol \
2295 elf_m68k_adjust_dynamic_symbol
2296 #define elf_backend_size_dynamic_sections \
2297 elf_m68k_size_dynamic_sections
2298 #define elf_backend_relocate_section elf_m68k_relocate_section
2299 #define elf_backend_finish_dynamic_symbol \
2300 elf_m68k_finish_dynamic_symbol
2301 #define elf_backend_finish_dynamic_sections \
2302 elf_m68k_finish_dynamic_sections
2303 #define elf_backend_gc_mark_hook elf_m68k_gc_mark_hook
2304 #define elf_backend_gc_sweep_hook elf_m68k_gc_sweep_hook
2305 #define bfd_elf32_bfd_copy_private_bfd_data \
2306 elf32_m68k_copy_private_bfd_data
2307 #define bfd_elf32_bfd_merge_private_bfd_data \
2308 elf32_m68k_merge_private_bfd_data
2309 #define bfd_elf32_bfd_set_private_flags \
2310 elf32_m68k_set_private_flags
2311 #define bfd_elf32_bfd_print_private_bfd_data \
2312 elf32_m68k_print_private_bfd_data
2314 #define elf_backend_can_gc_sections 1
2315 #define elf_backend_want_got_plt 1
2316 #define elf_backend_plt_readonly 1
2317 #define elf_backend_want_plt_sym 0
2318 #define elf_backend_got_header_size 12
2320 #include "elf32-target.h"