1 |
/* OpenRISC-specific support for 32-bit ELF. |
/* OpenRISC-specific support for 32-bit ELF. |
2 |
Copyright 2001, 2002 Free Software Foundation, Inc. |
Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
3 |
Contributed by Johan Rydberg, jrydberg@opencores.org |
Contributed by Johan Rydberg, jrydberg@opencores.org |
4 |
|
|
5 |
This file is part of BFD, the Binary File Descriptor library. |
This file is part of BFD, the Binary File Descriptor library. |
30 |
static reloc_howto_type *openrisc_reloc_type_lookup |
static reloc_howto_type *openrisc_reloc_type_lookup |
31 |
PARAMS ((bfd * , bfd_reloc_code_real_type)); |
PARAMS ((bfd * , bfd_reloc_code_real_type)); |
32 |
static void openrisc_info_to_howto_rela |
static void openrisc_info_to_howto_rela |
33 |
PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); |
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); |
34 |
static boolean openrisc_elf_relocate_section |
static bfd_boolean openrisc_elf_relocate_section |
35 |
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, |
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, |
36 |
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); |
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); |
37 |
static bfd_reloc_status_type openrisc_final_link_relocate |
static bfd_reloc_status_type openrisc_final_link_relocate |
38 |
PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, |
PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, |
39 |
Elf_Internal_Rela *, bfd_vma)); |
Elf_Internal_Rela *, bfd_vma)); |
40 |
static boolean openrisc_elf_gc_sweep_hook |
static bfd_boolean openrisc_elf_gc_sweep_hook |
41 |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
42 |
const Elf_Internal_Rela *)); |
const Elf_Internal_Rela *)); |
43 |
static asection * openrisc_elf_gc_mark_hook |
static asection * openrisc_elf_gc_mark_hook |
44 |
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, |
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, |
45 |
struct elf_link_hash_entry *, Elf_Internal_Sym *)); |
struct elf_link_hash_entry *, Elf_Internal_Sym *)); |
46 |
static boolean openrisc_elf_check_relocs |
static bfd_boolean openrisc_elf_check_relocs |
47 |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
48 |
const Elf_Internal_Rela *)); |
const Elf_Internal_Rela *)); |
49 |
static boolean openrisc_elf_object_p |
static bfd_boolean openrisc_elf_object_p |
50 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
51 |
static void openrisc_elf_final_write_processing |
static void openrisc_elf_final_write_processing |
52 |
PARAMS ((bfd *, boolean)); |
PARAMS ((bfd *, bfd_boolean)); |
53 |
|
|
54 |
|
|
55 |
static reloc_howto_type openrisc_elf_howto_table[] = |
static reloc_howto_type openrisc_elf_howto_table[] = |
59 |
0, /* rightshift */ |
0, /* rightshift */ |
60 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
61 |
32, /* bitsize */ |
32, /* bitsize */ |
62 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
63 |
0, /* bitpos */ |
0, /* bitpos */ |
64 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
65 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
66 |
"R_OPENRISC_NONE", /* name */ |
"R_OPENRISC_NONE", /* name */ |
67 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
68 |
0, /* src_mask */ |
0, /* src_mask */ |
69 |
0, /* dst_mask */ |
0, /* dst_mask */ |
70 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
71 |
|
|
72 |
/* A PC relative 26 bit relocation, right shifted by 2. */ |
/* A PC relative 26 bit relocation, right shifted by 2. */ |
73 |
HOWTO (R_OPENRISC_INSN_REL_26, /* type */ |
HOWTO (R_OPENRISC_INSN_REL_26, /* type */ |
74 |
2, /* rightshift */ |
2, /* rightshift */ |
75 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
76 |
26, /* bitsize */ |
26, /* bitsize */ |
77 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
78 |
0, /* bitpos */ |
0, /* bitpos */ |
79 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
80 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
81 |
"R_OPENRISC_INSN_REL_26", /* name */ |
"R_OPENRISC_INSN_REL_26", /* name */ |
82 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
83 |
0x00000000, /* src_mask */ |
0x00000000, /* src_mask */ |
84 |
0x03ffffff, /* dst_mask */ |
0x03ffffff, /* dst_mask */ |
85 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
86 |
|
|
87 |
/* A absolute 26 bit relocation, right shifted by 2. */ |
/* A absolute 26 bit relocation, right shifted by 2. */ |
88 |
HOWTO (R_OPENRISC_INSN_ABS_26, /* type */ |
HOWTO (R_OPENRISC_INSN_ABS_26, /* type */ |
89 |
2, /* rightshift */ |
2, /* rightshift */ |
90 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
91 |
26, /* bitsize */ |
26, /* bitsize */ |
92 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
93 |
0, /* bitpos */ |
0, /* bitpos */ |
94 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
95 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
96 |
"R_OPENRISC_INSN_ABS_26", /* name */ |
"R_OPENRISC_INSN_ABS_26", /* name */ |
97 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
98 |
0x00000000, /* src_mask */ |
0x00000000, /* src_mask */ |
99 |
0x03ffffff, /* dst_mask */ |
0x03ffffff, /* dst_mask */ |
100 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
101 |
|
|
102 |
HOWTO (R_OPENRISC_LO_16_IN_INSN, /* type */ |
HOWTO (R_OPENRISC_LO_16_IN_INSN, /* type */ |
103 |
0, /* rightshift */ |
0, /* rightshift */ |
104 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
105 |
16, /* bitsize */ |
16, /* bitsize */ |
106 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
107 |
0, /* bitpos */ |
0, /* bitpos */ |
108 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
109 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
110 |
"R_OPENRISC_LO_16_IN_INSN", /* name */ |
"R_OPENRISC_LO_16_IN_INSN", /* name */ |
111 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
112 |
0, /* src_mask */ |
0, /* src_mask */ |
113 |
0x0000ffff, /* dst_mask */ |
0x0000ffff, /* dst_mask */ |
114 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
115 |
|
|
116 |
HOWTO (R_OPENRISC_HI_16_IN_INSN, /* type */ |
HOWTO (R_OPENRISC_HI_16_IN_INSN, /* type */ |
117 |
16, /* rightshift */ |
16, /* rightshift */ |
118 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
119 |
16, /* bitsize */ |
16, /* bitsize */ |
120 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
121 |
0, /* bitpos */ |
0, /* bitpos */ |
122 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
123 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
124 |
"R_OPENRISC_HI_16_IN_INSN", /* name */ |
"R_OPENRISC_HI_16_IN_INSN", /* name */ |
125 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
126 |
0, /* src_mask */ |
0, /* src_mask */ |
127 |
0x0000ffff, /* dst_mask */ |
0x0000ffff, /* dst_mask */ |
128 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
129 |
|
|
130 |
/* An 8 bit absolute relocation. */ |
/* An 8 bit absolute relocation. */ |
131 |
HOWTO (R_OPENRISC_8, /* type */ |
HOWTO (R_OPENRISC_8, /* type */ |
132 |
0, /* rightshift */ |
0, /* rightshift */ |
133 |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
134 |
8, /* bitsize */ |
8, /* bitsize */ |
135 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
136 |
0, /* bitpos */ |
0, /* bitpos */ |
137 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
138 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
139 |
"R_OPENRISC_8", /* name */ |
"R_OPENRISC_8", /* name */ |
140 |
true, /* partial_inplace */ |
TRUE, /* partial_inplace */ |
141 |
0x0000, /* src_mask */ |
0x0000, /* src_mask */ |
142 |
0x00ff, /* dst_mask */ |
0x00ff, /* dst_mask */ |
143 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
144 |
|
|
145 |
/* A 16 bit absolute relocation. */ |
/* A 16 bit absolute relocation. */ |
146 |
HOWTO (R_OPENRISC_16, /* type */ |
HOWTO (R_OPENRISC_16, /* type */ |
147 |
0, /* rightshift */ |
0, /* rightshift */ |
148 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
149 |
16, /* bitsize */ |
16, /* bitsize */ |
150 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
151 |
0, /* bitpos */ |
0, /* bitpos */ |
152 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
153 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
154 |
"R_OPENRISC_16", /* name */ |
"R_OPENRISC_16", /* name */ |
155 |
true, /* partial_inplace */ |
TRUE, /* partial_inplace */ |
156 |
0x00000000, /* src_mask */ |
0x00000000, /* src_mask */ |
157 |
0x0000ffff, /* dst_mask */ |
0x0000ffff, /* dst_mask */ |
158 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
159 |
|
|
160 |
/* A 32 bit absolute relocation. */ |
/* A 32 bit absolute relocation. */ |
161 |
HOWTO (R_OPENRISC_32, /* type */ |
HOWTO (R_OPENRISC_32, /* type */ |
162 |
0, /* rightshift */ |
0, /* rightshift */ |
163 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
164 |
32, /* bitsize */ |
32, /* bitsize */ |
165 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
166 |
0, /* bitpos */ |
0, /* bitpos */ |
167 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
168 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
169 |
"R_OPENRISC_32", /* name */ |
"R_OPENRISC_32", /* name */ |
170 |
true, /* partial_inplace */ |
TRUE, /* partial_inplace */ |
171 |
0x00000000, /* src_mask */ |
0x00000000, /* src_mask */ |
172 |
0xffffffff, /* dst_mask */ |
0xffffffff, /* dst_mask */ |
173 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
174 |
|
|
175 |
/* GNU extension to record C++ vtable hierarchy */ |
/* GNU extension to record C++ vtable hierarchy */ |
176 |
HOWTO (R_OPENRISC_GNU_VTINHERIT, /* type */ |
HOWTO (R_OPENRISC_GNU_VTINHERIT, /* type */ |
177 |
0, /* rightshift */ |
0, /* rightshift */ |
178 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
179 |
0, /* bitsize */ |
0, /* bitsize */ |
180 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
181 |
0, /* bitpos */ |
0, /* bitpos */ |
182 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
183 |
NULL, /* special_function */ |
NULL, /* special_function */ |
184 |
"R_OPENRISC_GNU_VTINHERIT", /* name */ |
"R_OPENRISC_GNU_VTINHERIT", /* name */ |
185 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
186 |
0, /* src_mask */ |
0, /* src_mask */ |
187 |
0, /* dst_mask */ |
0, /* dst_mask */ |
188 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
189 |
|
|
190 |
/* GNU extension to record C++ vtable member usage */ |
/* GNU extension to record C++ vtable member usage */ |
191 |
HOWTO (R_OPENRISC_GNU_VTENTRY, /* type */ |
HOWTO (R_OPENRISC_GNU_VTENTRY, /* type */ |
192 |
0, /* rightshift */ |
0, /* rightshift */ |
193 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
194 |
0, /* bitsize */ |
0, /* bitsize */ |
195 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
196 |
0, /* bitpos */ |
0, /* bitpos */ |
197 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
198 |
_bfd_elf_rel_vtable_reloc_fn, /* special_function */ |
_bfd_elf_rel_vtable_reloc_fn, /* special_function */ |
199 |
"R_OPENRISC_GNU_VTENTRY", /* name */ |
"R_OPENRISC_GNU_VTENTRY", /* name */ |
200 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
201 |
0, /* src_mask */ |
0, /* src_mask */ |
202 |
0, /* dst_mask */ |
0, /* dst_mask */ |
203 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
204 |
}; |
}; |
205 |
|
|
206 |
/* Map BFD reloc types to OpenRISC ELF reloc types. */ |
/* Map BFD reloc types to OpenRISC ELF reloc types. */ |
246 |
openrisc_info_to_howto_rela (abfd, cache_ptr, dst) |
openrisc_info_to_howto_rela (abfd, cache_ptr, dst) |
247 |
bfd * abfd ATTRIBUTE_UNUSED; |
bfd * abfd ATTRIBUTE_UNUSED; |
248 |
arelent * cache_ptr; |
arelent * cache_ptr; |
249 |
Elf32_Internal_Rela * dst; |
Elf_Internal_Rela * dst; |
250 |
{ |
{ |
251 |
unsigned int r_type; |
unsigned int r_type; |
252 |
|
|
289 |
} |
} |
290 |
|
|
291 |
/* Relocate an OpenRISC ELF section. |
/* Relocate an OpenRISC ELF section. |
|
There is some attempt to make this function usable for many architectures, |
|
|
both USE_REL and USE_RELA ['twould be nice if such a critter existed], |
|
|
if only to serve as a learning tool. |
|
292 |
|
|
293 |
The RELOCATE_SECTION function is called by the new ELF backend linker |
The RELOCATE_SECTION function is called by the new ELF backend linker |
294 |
to handle the relocations for a section. |
to handle the relocations for a section. |
298 |
zero. |
zero. |
299 |
|
|
300 |
This function is responsible for adjusting the section contents as |
This function is responsible for adjusting the section contents as |
301 |
necessary, and (if using Rela relocs and generating a relocateable |
necessary, and (if using Rela relocs and generating a relocatable |
302 |
output file) adjusting the reloc addend as necessary. |
output file) adjusting the reloc addend as necessary. |
303 |
|
|
304 |
This function does not have to worry about setting the reloc |
This function does not have to worry about setting the reloc |
312 |
The global hash table entry for the global symbols can be found |
The global hash table entry for the global symbols can be found |
313 |
via elf_sym_hashes (input_bfd). |
via elf_sym_hashes (input_bfd). |
314 |
|
|
315 |
When generating relocateable output, this function must handle |
When generating relocatable output, this function must handle |
316 |
STB_LOCAL/STT_SECTION symbols specially. The output symbol is |
STB_LOCAL/STT_SECTION symbols specially. The output symbol is |
317 |
going to be the section symbol corresponding to the output |
going to be the section symbol corresponding to the output |
318 |
section, which means that the addend must be adjusted |
section, which means that the addend must be adjusted |
319 |
accordingly. */ |
accordingly. */ |
320 |
|
|
321 |
static boolean |
static bfd_boolean |
322 |
openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section, |
openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section, |
323 |
contents, relocs, local_syms, local_sections) |
contents, relocs, local_syms, local_sections) |
324 |
bfd *output_bfd; |
bfd *output_bfd; |
335 |
Elf_Internal_Rela *rel; |
Elf_Internal_Rela *rel; |
336 |
Elf_Internal_Rela *relend; |
Elf_Internal_Rela *relend; |
337 |
|
|
338 |
if (info->relocateable) |
if (info->relocatable) |
339 |
return true; |
return TRUE; |
340 |
|
|
341 |
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; |
342 |
sym_hashes = elf_sym_hashes (input_bfd); |
sym_hashes = elf_sym_hashes (input_bfd); |
375 |
{ |
{ |
376 |
sym = local_syms + r_symndx; |
sym = local_syms + r_symndx; |
377 |
sec = local_sections[r_symndx]; |
sec = local_sections[r_symndx]; |
378 |
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); |
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); |
379 |
|
|
380 |
name = bfd_elf_string_from_elf_section |
name = bfd_elf_string_from_elf_section |
381 |
(input_bfd, symtab_hdr->sh_link, sym->st_name); |
(input_bfd, symtab_hdr->sh_link, sym->st_name); |
383 |
} |
} |
384 |
else |
else |
385 |
{ |
{ |
386 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
bfd_boolean unresolved_reloc, warned; |
387 |
|
|
388 |
while (h->root.type == bfd_link_hash_indirect |
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, |
389 |
|| h->root.type == bfd_link_hash_warning) |
r_symndx, symtab_hdr, sym_hashes, |
390 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
h, sec, relocation, |
391 |
|
unresolved_reloc, warned); |
|
name = h->root.root.string; |
|
|
|
|
|
if (h->root.type == bfd_link_hash_defined |
|
|
|| h->root.type == bfd_link_hash_defweak) |
|
|
{ |
|
|
sec = h->root.u.def.section; |
|
|
relocation = (h->root.u.def.value |
|
|
+ sec->output_section->vma + sec->output_offset); |
|
|
} |
|
|
else if (h->root.type == bfd_link_hash_undefweak) |
|
|
{ |
|
|
relocation = 0; |
|
|
} |
|
|
else |
|
|
{ |
|
|
if (!((*info->callbacks->undefined_symbol) |
|
|
(info, h->root.root.string, input_bfd, |
|
|
input_section, rel->r_offset, true))) |
|
|
return false; |
|
|
relocation = 0; |
|
|
} |
|
392 |
} |
} |
393 |
|
|
394 |
r = openrisc_final_link_relocate (howto, input_bfd, input_section, |
r = openrisc_final_link_relocate (howto, input_bfd, input_section, |
402 |
{ |
{ |
403 |
case bfd_reloc_overflow: |
case bfd_reloc_overflow: |
404 |
r = info->callbacks->reloc_overflow |
r = info->callbacks->reloc_overflow |
405 |
(info, name, howto->name, (bfd_vma) 0, |
(info, (h ? &h->root : NULL), name, howto->name, |
406 |
input_bfd, input_section, rel->r_offset); |
(bfd_vma) 0, input_bfd, input_section, rel->r_offset); |
407 |
break; |
break; |
408 |
|
|
409 |
case bfd_reloc_undefined: |
case bfd_reloc_undefined: |
410 |
r = info->callbacks->undefined_symbol |
r = info->callbacks->undefined_symbol |
411 |
(info, name, input_bfd, input_section, rel->r_offset, true); |
(info, name, input_bfd, input_section, rel->r_offset, TRUE); |
412 |
break; |
break; |
413 |
|
|
414 |
case bfd_reloc_outofrange: |
case bfd_reloc_outofrange: |
433 |
(info, msg, name, input_bfd, input_section, rel->r_offset); |
(info, msg, name, input_bfd, input_section, rel->r_offset); |
434 |
|
|
435 |
if (!r) |
if (!r) |
436 |
return false; |
return FALSE; |
437 |
} |
} |
438 |
} |
} |
439 |
|
|
440 |
return true; |
return TRUE; |
441 |
} |
} |
442 |
|
|
443 |
/* Return the section that should be marked against GC for a given |
/* Return the section that should be marked against GC for a given |
482 |
|
|
483 |
/* Update the got entry reference counts for the section being removed. */ |
/* Update the got entry reference counts for the section being removed. */ |
484 |
|
|
485 |
static boolean |
static bfd_boolean |
486 |
openrisc_elf_gc_sweep_hook (abfd, info, sec, relocs) |
openrisc_elf_gc_sweep_hook (abfd, info, sec, relocs) |
487 |
bfd *abfd ATTRIBUTE_UNUSED; |
bfd *abfd ATTRIBUTE_UNUSED; |
488 |
struct bfd_link_info *info ATTRIBUTE_UNUSED; |
struct bfd_link_info *info ATTRIBUTE_UNUSED; |
489 |
asection *sec ATTRIBUTE_UNUSED; |
asection *sec ATTRIBUTE_UNUSED; |
490 |
const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; |
const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; |
491 |
{ |
{ |
492 |
return true; |
return TRUE; |
493 |
} |
} |
494 |
|
|
495 |
/* Look through the relocs for a section during the first phase. |
/* Look through the relocs for a section during the first phase. |
496 |
Since we don't do .gots or .plts, we just need to consider the |
Since we don't do .gots or .plts, we just need to consider the |
497 |
virtual table relocs for gc. */ |
virtual table relocs for gc. */ |
498 |
|
|
499 |
static boolean |
static bfd_boolean |
500 |
openrisc_elf_check_relocs (abfd, info, sec, relocs) |
openrisc_elf_check_relocs (abfd, info, sec, relocs) |
501 |
bfd *abfd; |
bfd *abfd; |
502 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
508 |
const Elf_Internal_Rela *rel; |
const Elf_Internal_Rela *rel; |
509 |
const Elf_Internal_Rela *rel_end; |
const Elf_Internal_Rela *rel_end; |
510 |
|
|
511 |
if (info->relocateable) |
if (info->relocatable) |
512 |
return true; |
return TRUE; |
513 |
|
|
514 |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
515 |
sym_hashes = elf_sym_hashes (abfd); |
sym_hashes = elf_sym_hashes (abfd); |
535 |
/* This relocation describes the C++ object vtable hierarchy. |
/* This relocation describes the C++ object vtable hierarchy. |
536 |
Reconstruct it for later use during GC. */ |
Reconstruct it for later use during GC. */ |
537 |
case R_OPENRISC_GNU_VTINHERIT: |
case R_OPENRISC_GNU_VTINHERIT: |
538 |
if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
539 |
return false; |
return FALSE; |
540 |
break; |
break; |
541 |
|
|
542 |
/* This relocation describes which C++ vtable entries are actually |
/* This relocation describes which C++ vtable entries are actually |
543 |
used. Record for later use during GC. */ |
used. Record for later use during GC. */ |
544 |
case R_OPENRISC_GNU_VTENTRY: |
case R_OPENRISC_GNU_VTENTRY: |
545 |
if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) |
if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) |
546 |
return false; |
return FALSE; |
547 |
break; |
break; |
548 |
} |
} |
549 |
} |
} |
550 |
|
|
551 |
return true; |
return TRUE; |
552 |
} |
} |
553 |
|
|
554 |
/* Set the right machine number. */ |
/* Set the right machine number. */ |
555 |
|
|
556 |
static boolean |
static bfd_boolean |
557 |
openrisc_elf_object_p (abfd) |
openrisc_elf_object_p (abfd) |
558 |
bfd *abfd; |
bfd *abfd; |
559 |
{ |
{ |
563 |
(void) bfd_default_set_arch_mach (abfd, bfd_arch_openrisc, 0); |
(void) bfd_default_set_arch_mach (abfd, bfd_arch_openrisc, 0); |
564 |
break; |
break; |
565 |
} |
} |
566 |
return true; |
return TRUE; |
567 |
} |
} |
568 |
|
|
569 |
/* Store the machine number in the flags field. */ |
/* Store the machine number in the flags field. */ |
571 |
static void |
static void |
572 |
openrisc_elf_final_write_processing (abfd, linker) |
openrisc_elf_final_write_processing (abfd, linker) |
573 |
bfd *abfd; |
bfd *abfd; |
574 |
boolean linker ATTRIBUTE_UNUSED; |
bfd_boolean linker ATTRIBUTE_UNUSED; |
575 |
{ |
{ |
576 |
unsigned long val; |
unsigned long val; |
577 |
|
|