1 |
/* PowerPC64-specific support for 64-bit ELF. |
/* PowerPC64-specific support for 64-bit ELF. |
2 |
Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 |
3 |
|
Free Software Foundation, Inc. |
4 |
Written by Linus Nordberg, Swox AB <info@swox.com>, |
Written by Linus Nordberg, Swox AB <info@swox.com>, |
5 |
based on elf32-ppc.c by Ian Lance Taylor. |
based on elf32-ppc.c by Ian Lance Taylor. |
6 |
|
Largely rewritten by Alan Modra <amodra@bigpond.net.au> |
7 |
|
|
8 |
This file is part of BFD, the Binary File Descriptor library. |
This file is part of BFD, the Binary File Descriptor library. |
9 |
|
|
10 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
11 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
12 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
13 |
(at your option) any later version. |
(at your option) any later version. |
14 |
|
|
15 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
GNU General Public License for more details. |
GNU General Public License for more details. |
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
21 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
22 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
23 |
|
|
24 |
/* This file is based on the 64-bit PowerPC ELF ABI. It is also based |
/* The 64-bit PowerPC ELF ABI may be found at |
25 |
on the file elf32-ppc.c. */ |
http://www.linuxbase.org/spec/ELF/ppc64/PPC-elf64abi.txt, and |
26 |
|
http://www.linuxbase.org/spec/ELF/ppc64/spec/book1.html */ |
27 |
|
|
28 |
#include "bfd.h" |
#include "bfd.h" |
29 |
#include "sysdep.h" |
#include "sysdep.h" |
30 |
#include "bfdlink.h" |
#include "bfdlink.h" |
31 |
#include "libbfd.h" |
#include "libbfd.h" |
32 |
#include "elf-bfd.h" |
#include "elf-bfd.h" |
33 |
#include "elf/ppc.h" |
#include "elf/ppc64.h" |
34 |
#include "elf64-ppc.h" |
#include "elf64-ppc.h" |
35 |
|
|
|
#define USE_RELA /* we want RELA relocations, not REL. */ |
|
|
|
|
|
|
|
|
static void ppc_howto_init |
|
|
PARAMS ((void)); |
|
|
static reloc_howto_type *ppc64_elf_reloc_type_lookup |
|
|
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); |
|
|
static void ppc64_elf_info_to_howto |
|
|
PARAMS ((bfd *abfd, arelent *cache_ptr, Elf64_Internal_Rela *dst)); |
|
36 |
static bfd_reloc_status_type ppc64_elf_ha_reloc |
static bfd_reloc_status_type ppc64_elf_ha_reloc |
37 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
38 |
|
static bfd_reloc_status_type ppc64_elf_branch_reloc |
39 |
|
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
40 |
static bfd_reloc_status_type ppc64_elf_brtaken_reloc |
static bfd_reloc_status_type ppc64_elf_brtaken_reloc |
41 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
42 |
static bfd_reloc_status_type ppc64_elf_sectoff_reloc |
static bfd_reloc_status_type ppc64_elf_sectoff_reloc |
43 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
44 |
static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc |
static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc |
45 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
46 |
static bfd_reloc_status_type ppc64_elf_toc_reloc |
static bfd_reloc_status_type ppc64_elf_toc_reloc |
47 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
48 |
static bfd_reloc_status_type ppc64_elf_toc_ha_reloc |
static bfd_reloc_status_type ppc64_elf_toc_ha_reloc |
49 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
50 |
static bfd_reloc_status_type ppc64_elf_toc64_reloc |
static bfd_reloc_status_type ppc64_elf_toc64_reloc |
51 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
52 |
static bfd_reloc_status_type ppc64_elf_unhandled_reloc |
static bfd_reloc_status_type ppc64_elf_unhandled_reloc |
53 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
54 |
static boolean ppc64_elf_object_p |
static bfd_vma opd_entry_value |
55 |
PARAMS ((bfd *)); |
(asection *, bfd_vma, asection **, bfd_vma *); |
56 |
static boolean ppc64_elf_merge_private_bfd_data |
|
57 |
PARAMS ((bfd *, bfd *)); |
#define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec |
58 |
|
#define TARGET_LITTLE_NAME "elf64-powerpcle" |
59 |
|
#define TARGET_BIG_SYM bfd_elf64_powerpc_vec |
60 |
|
#define TARGET_BIG_NAME "elf64-powerpc" |
61 |
|
#define ELF_ARCH bfd_arch_powerpc |
62 |
|
#define ELF_MACHINE_CODE EM_PPC64 |
63 |
|
#define ELF_MAXPAGESIZE 0x10000 |
64 |
|
#define elf_info_to_howto ppc64_elf_info_to_howto |
65 |
|
|
66 |
|
#define elf_backend_want_got_sym 0 |
67 |
|
#define elf_backend_want_plt_sym 0 |
68 |
|
#define elf_backend_plt_alignment 3 |
69 |
|
#define elf_backend_plt_not_loaded 1 |
70 |
|
#define elf_backend_got_symbol_offset 0 |
71 |
|
#define elf_backend_got_header_size 8 |
72 |
|
#define elf_backend_can_gc_sections 1 |
73 |
|
#define elf_backend_can_refcount 1 |
74 |
|
#define elf_backend_rela_normal 1 |
75 |
|
|
76 |
|
#define bfd_elf64_mkobject ppc64_elf_mkobject |
77 |
|
#define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup |
78 |
|
#define bfd_elf64_bfd_merge_private_bfd_data ppc64_elf_merge_private_bfd_data |
79 |
|
#define bfd_elf64_new_section_hook ppc64_elf_new_section_hook |
80 |
|
#define bfd_elf64_bfd_link_hash_table_create ppc64_elf_link_hash_table_create |
81 |
|
#define bfd_elf64_bfd_link_hash_table_free ppc64_elf_link_hash_table_free |
82 |
|
#define bfd_elf64_get_synthetic_symtab ppc64_elf_get_synthetic_symtab |
83 |
|
|
84 |
|
#define elf_backend_object_p ppc64_elf_object_p |
85 |
|
#define elf_backend_grok_prstatus ppc64_elf_grok_prstatus |
86 |
|
#define elf_backend_grok_psinfo ppc64_elf_grok_psinfo |
87 |
|
#define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections |
88 |
|
#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol |
89 |
|
#define elf_backend_add_symbol_hook ppc64_elf_add_symbol_hook |
90 |
|
#define elf_backend_check_directives ppc64_elf_check_directives |
91 |
|
#define elf_backend_archive_symbol_lookup ppc64_elf_archive_symbol_lookup |
92 |
|
#define elf_backend_check_relocs ppc64_elf_check_relocs |
93 |
|
#define elf_backend_gc_mark_hook ppc64_elf_gc_mark_hook |
94 |
|
#define elf_backend_gc_sweep_hook ppc64_elf_gc_sweep_hook |
95 |
|
#define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol |
96 |
|
#define elf_backend_hide_symbol ppc64_elf_hide_symbol |
97 |
|
#define elf_backend_always_size_sections ppc64_elf_func_desc_adjust |
98 |
|
#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections |
99 |
|
#define elf_backend_relocate_section ppc64_elf_relocate_section |
100 |
|
#define elf_backend_finish_dynamic_symbol ppc64_elf_finish_dynamic_symbol |
101 |
|
#define elf_backend_reloc_type_class ppc64_elf_reloc_type_class |
102 |
|
#define elf_backend_finish_dynamic_sections ppc64_elf_finish_dynamic_sections |
103 |
|
#define elf_backend_link_output_symbol_hook ppc64_elf_output_symbol_hook |
104 |
|
#define elf_backend_special_sections ppc64_elf_special_sections |
105 |
|
|
106 |
/* The name of the dynamic interpreter. This is put in the .interp |
/* The name of the dynamic interpreter. This is put in the .interp |
107 |
section. */ |
section. */ |
114 |
#define PLT_INITIAL_ENTRY_SIZE PLT_ENTRY_SIZE |
#define PLT_INITIAL_ENTRY_SIZE PLT_ENTRY_SIZE |
115 |
|
|
116 |
/* TOC base pointers offset from start of TOC. */ |
/* TOC base pointers offset from start of TOC. */ |
117 |
#define TOC_BASE_OFF (0x8000) |
#define TOC_BASE_OFF 0x8000 |
118 |
|
|
119 |
/* .plt call stub instructions. */ |
/* Offset of tp and dtp pointers from start of TLS block. */ |
120 |
|
#define TP_OFFSET 0x7000 |
121 |
|
#define DTP_OFFSET 0x8000 |
122 |
|
|
123 |
|
/* .plt call stub instructions. The normal stub is like this, but |
124 |
|
sometimes the .plt entry crosses a 64k boundary and we need to |
125 |
|
insert an addis to adjust r12. */ |
126 |
|
#define PLT_CALL_STUB_SIZE (7*4) |
127 |
#define ADDIS_R12_R2 0x3d820000 /* addis %r12,%r2,xxx@ha */ |
#define ADDIS_R12_R2 0x3d820000 /* addis %r12,%r2,xxx@ha */ |
128 |
#define STD_R2_40R1 0xf8410028 /* std %r2,40(%r1) */ |
#define STD_R2_40R1 0xf8410028 /* std %r2,40(%r1) */ |
129 |
#define LD_R11_0R12 0xe96c0000 /* ld %r11,xxx+0@l(%r12) */ |
#define LD_R11_0R12 0xe96c0000 /* ld %r11,xxx+0@l(%r12) */ |
132 |
/* ld %r11,xxx+16@l(%r12) */ |
/* ld %r11,xxx+16@l(%r12) */ |
133 |
#define BCTR 0x4e800420 /* bctr */ |
#define BCTR 0x4e800420 /* bctr */ |
134 |
|
|
|
/* The normal stub is this size. */ |
|
|
#define PLT_CALL_STUB_SIZE (7*4) |
|
135 |
|
|
136 |
/* But sometimes the .plt entry crosses a 64k boundary, and we need |
#define ADDIS_R2_R2 0x3c420000 /* addis %r2,%r2,off@ha */ |
137 |
to adjust the high word with this insn. */ |
#define ADDI_R2_R2 0x38420000 /* addi %r2,%r2,off@l */ |
|
#define ADDIS_R12_R12_1 0x3d8c0001 /* addis %r12,%r12,1 */ |
|
|
|
|
|
/* The .glink fixup call stub is the same as the .plt call stub, but |
|
|
the first instruction restores r2, and the std is omitted. */ |
|
|
#define LD_R2_40R1 0xe8410028 /* ld %r2,40(%r1) */ |
|
138 |
|
|
139 |
/* Always allow this much space. */ |
#define LD_R2_40R1 0xe8410028 /* ld %r2,40(%r1) */ |
140 |
#define GLINK_CALL_STUB_SIZE (8*4) |
|
141 |
|
/* glink call stub instructions. We enter with the index in R0, and the |
142 |
|
address of glink entry in CTR. From that, we can calculate PLT0. */ |
143 |
|
#define GLINK_CALL_STUB_SIZE (16*4) |
144 |
|
#define MFCTR_R12 0x7d8902a6 /* mfctr %r12 */ |
145 |
|
#define SLDI_R11_R0_3 0x780b1f24 /* sldi %r11,%r0,3 */ |
146 |
|
#define ADDIC_R2_R0_32K 0x34408000 /* addic. %r2,%r0,-32768 */ |
147 |
|
#define SUB_R12_R12_R11 0x7d8b6050 /* sub %r12,%r12,%r11 */ |
148 |
|
#define SRADI_R2_R2_63 0x7c42fe76 /* sradi %r2,%r2,63 */ |
149 |
|
#define SLDI_R11_R0_2 0x780b1764 /* sldi %r11,%r0,2 */ |
150 |
|
#define AND_R2_R2_R11 0x7c425838 /* and %r2,%r2,%r11 */ |
151 |
|
/* sub %r12,%r12,%r11 */ |
152 |
|
#define ADD_R12_R12_R2 0x7d8c1214 /* add %r12,%r12,%r2 */ |
153 |
|
#define ADDIS_R12_R12 0x3d8c0000 /* addis %r12,%r12,xxx@ha */ |
154 |
|
/* ld %r11,xxx@l(%r12) */ |
155 |
|
#define ADDI_R12_R12 0x398c0000 /* addi %r12,%r12,xxx@l */ |
156 |
|
/* ld %r2,8(%r12) */ |
157 |
|
/* mtctr %r11 */ |
158 |
|
/* ld %r11,16(%r12) */ |
159 |
|
/* bctr */ |
160 |
|
|
161 |
/* Pad with this. */ |
/* Pad with this. */ |
162 |
#define NOP 0x60000000 |
#define NOP 0x60000000 |
174 |
#define LIS_R0_0 0x3c000000 /* lis %r0,0 */ |
#define LIS_R0_0 0x3c000000 /* lis %r0,0 */ |
175 |
#define ORI_R0_R0_0 0x60000000 /* ori %r0,%r0,0 */ |
#define ORI_R0_R0_0 0x60000000 /* ori %r0,%r0,0 */ |
176 |
|
|
177 |
/* Instructions to save and restore floating point regs. */ |
/* Instructions used by the save and restore reg functions. */ |
178 |
|
#define STD_R0_0R1 0xf8010000 /* std %r0,0(%r1) */ |
179 |
|
#define STD_R0_0R12 0xf80c0000 /* std %r0,0(%r12) */ |
180 |
|
#define LD_R0_0R1 0xe8010000 /* ld %r0,0(%r1) */ |
181 |
|
#define LD_R0_0R12 0xe80c0000 /* ld %r0,0(%r12) */ |
182 |
#define STFD_FR0_0R1 0xd8010000 /* stfd %fr0,0(%r1) */ |
#define STFD_FR0_0R1 0xd8010000 /* stfd %fr0,0(%r1) */ |
183 |
#define LFD_FR0_0R1 0xc8010000 /* lfd %fr0,0(%r1) */ |
#define LFD_FR0_0R1 0xc8010000 /* lfd %fr0,0(%r1) */ |
184 |
|
#define LI_R12_0 0x39800000 /* li %r12,0 */ |
185 |
|
#define STVX_VR0_R12_R0 0x7c0c01ce /* stvx %v0,%r12,%r0 */ |
186 |
|
#define LVX_VR0_R12_R0 0x7c0c00ce /* lvx %v0,%r12,%r0 */ |
187 |
|
#define MTLR_R0 0x7c0803a6 /* mtlr %r0 */ |
188 |
#define BLR 0x4e800020 /* blr */ |
#define BLR 0x4e800020 /* blr */ |
189 |
|
|
190 |
/* Since .opd is an array of descriptors and each entry will end up |
/* Since .opd is an array of descriptors and each entry will end up |
196 |
#endif |
#endif |
197 |
|
|
198 |
#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1) |
#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1) |
199 |
|
|
200 |
/* Relocation HOWTO's. */ |
/* Relocation HOWTO's. */ |
201 |
static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC_max]; |
static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC64_max]; |
202 |
|
|
203 |
static reloc_howto_type ppc64_elf_howto_raw[] = { |
static reloc_howto_type ppc64_elf_howto_raw[] = { |
204 |
/* This reloc does nothing. */ |
/* This reloc does nothing. */ |
205 |
HOWTO (R_PPC64_NONE, /* type */ |
HOWTO (R_PPC64_NONE, /* type */ |
206 |
0, /* rightshift */ |
0, /* rightshift */ |
207 |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
208 |
8, /* bitsize */ |
32, /* bitsize */ |
209 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
210 |
0, /* bitpos */ |
0, /* bitpos */ |
211 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
212 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
213 |
"R_PPC64_NONE", /* name */ |
"R_PPC64_NONE", /* name */ |
214 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
215 |
0xff, /* src_mask */ |
0, /* src_mask */ |
216 |
0, /* dst_mask */ |
0, /* dst_mask */ |
217 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
218 |
|
|
219 |
/* A standard 32 bit relocation. */ |
/* A standard 32 bit relocation. */ |
220 |
HOWTO (R_PPC64_ADDR32, /* type */ |
HOWTO (R_PPC64_ADDR32, /* type */ |
221 |
0, /* rightshift */ |
0, /* rightshift */ |
222 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
223 |
32, /* bitsize */ |
32, /* bitsize */ |
224 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
225 |
0, /* bitpos */ |
0, /* bitpos */ |
226 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
227 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
228 |
"R_PPC64_ADDR32", /* name */ |
"R_PPC64_ADDR32", /* name */ |
229 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
230 |
0, /* src_mask */ |
0, /* src_mask */ |
231 |
0xffffffff, /* dst_mask */ |
0xffffffff, /* dst_mask */ |
232 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
233 |
|
|
234 |
/* An absolute 26 bit branch; the lower two bits must be zero. |
/* An absolute 26 bit branch; the lower two bits must be zero. |
235 |
FIXME: we don't check that, we just clear them. */ |
FIXME: we don't check that, we just clear them. */ |
237 |
0, /* rightshift */ |
0, /* rightshift */ |
238 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
239 |
26, /* bitsize */ |
26, /* bitsize */ |
240 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
241 |
0, /* bitpos */ |
0, /* bitpos */ |
242 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
243 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
244 |
"R_PPC64_ADDR24", /* name */ |
"R_PPC64_ADDR24", /* name */ |
245 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
246 |
0xfc000003, /* src_mask */ |
0, /* src_mask */ |
247 |
0x03fffffc, /* dst_mask */ |
0x03fffffc, /* dst_mask */ |
248 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
249 |
|
|
250 |
/* A standard 16 bit relocation. */ |
/* A standard 16 bit relocation. */ |
251 |
HOWTO (R_PPC64_ADDR16, /* type */ |
HOWTO (R_PPC64_ADDR16, /* type */ |
252 |
0, /* rightshift */ |
0, /* rightshift */ |
253 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
254 |
16, /* bitsize */ |
16, /* bitsize */ |
255 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
256 |
0, /* bitpos */ |
0, /* bitpos */ |
257 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
258 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
259 |
"R_PPC64_ADDR16", /* name */ |
"R_PPC64_ADDR16", /* name */ |
260 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
261 |
0, /* src_mask */ |
0, /* src_mask */ |
262 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
263 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
264 |
|
|
265 |
/* A 16 bit relocation without overflow. */ |
/* A 16 bit relocation without overflow. */ |
266 |
HOWTO (R_PPC64_ADDR16_LO, /* type */ |
HOWTO (R_PPC64_ADDR16_LO, /* type */ |
267 |
0, /* rightshift */ |
0, /* rightshift */ |
268 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
269 |
16, /* bitsize */ |
16, /* bitsize */ |
270 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
271 |
0, /* bitpos */ |
0, /* bitpos */ |
272 |
complain_overflow_dont,/* complain_on_overflow */ |
complain_overflow_dont,/* complain_on_overflow */ |
273 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
274 |
"R_PPC64_ADDR16_LO", /* name */ |
"R_PPC64_ADDR16_LO", /* name */ |
275 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
276 |
0, /* src_mask */ |
0, /* src_mask */ |
277 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
278 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
279 |
|
|
280 |
/* Bits 16-31 of an address. */ |
/* Bits 16-31 of an address. */ |
281 |
HOWTO (R_PPC64_ADDR16_HI, /* type */ |
HOWTO (R_PPC64_ADDR16_HI, /* type */ |
282 |
16, /* rightshift */ |
16, /* rightshift */ |
283 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
284 |
16, /* bitsize */ |
16, /* bitsize */ |
285 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
286 |
0, /* bitpos */ |
0, /* bitpos */ |
287 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
288 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
289 |
"R_PPC64_ADDR16_HI", /* name */ |
"R_PPC64_ADDR16_HI", /* name */ |
290 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
291 |
0, /* src_mask */ |
0, /* src_mask */ |
292 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
293 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
294 |
|
|
295 |
/* Bits 16-31 of an address, plus 1 if the contents of the low 16 |
/* Bits 16-31 of an address, plus 1 if the contents of the low 16 |
296 |
bits, treated as a signed number, is negative. */ |
bits, treated as a signed number, is negative. */ |
298 |
16, /* rightshift */ |
16, /* rightshift */ |
299 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
300 |
16, /* bitsize */ |
16, /* bitsize */ |
301 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
302 |
0, /* bitpos */ |
0, /* bitpos */ |
303 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
304 |
ppc64_elf_ha_reloc, /* special_function */ |
ppc64_elf_ha_reloc, /* special_function */ |
305 |
"R_PPC64_ADDR16_HA", /* name */ |
"R_PPC64_ADDR16_HA", /* name */ |
306 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
307 |
0, /* src_mask */ |
0, /* src_mask */ |
308 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
309 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
310 |
|
|
311 |
/* An absolute 16 bit branch; the lower two bits must be zero. |
/* An absolute 16 bit branch; the lower two bits must be zero. |
312 |
FIXME: we don't check that, we just clear them. */ |
FIXME: we don't check that, we just clear them. */ |
314 |
0, /* rightshift */ |
0, /* rightshift */ |
315 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
316 |
16, /* bitsize */ |
16, /* bitsize */ |
317 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
318 |
0, /* bitpos */ |
0, /* bitpos */ |
319 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
320 |
bfd_elf_generic_reloc, /* special_function */ |
ppc64_elf_branch_reloc, /* special_function */ |
321 |
"R_PPC64_ADDR14", /* name */ |
"R_PPC64_ADDR14", /* name */ |
322 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
323 |
0xffff0003, /* src_mask */ |
0, /* src_mask */ |
324 |
0x0000fffc, /* dst_mask */ |
0x0000fffc, /* dst_mask */ |
325 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
326 |
|
|
327 |
/* An absolute 16 bit branch, for which bit 10 should be set to |
/* An absolute 16 bit branch, for which bit 10 should be set to |
328 |
indicate that the branch is expected to be taken. The lower two |
indicate that the branch is expected to be taken. The lower two |
331 |
0, /* rightshift */ |
0, /* rightshift */ |
332 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
333 |
16, /* bitsize */ |
16, /* bitsize */ |
334 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
335 |
0, /* bitpos */ |
0, /* bitpos */ |
336 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
337 |
ppc64_elf_brtaken_reloc, /* special_function */ |
ppc64_elf_brtaken_reloc, /* special_function */ |
338 |
"R_PPC64_ADDR14_BRTAKEN",/* name */ |
"R_PPC64_ADDR14_BRTAKEN",/* name */ |
339 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
340 |
0xffff0003, /* src_mask */ |
0, /* src_mask */ |
341 |
0x0000fffc, /* dst_mask */ |
0x0000fffc, /* dst_mask */ |
342 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
343 |
|
|
344 |
/* An absolute 16 bit branch, for which bit 10 should be set to |
/* An absolute 16 bit branch, for which bit 10 should be set to |
345 |
indicate that the branch is not expected to be taken. The lower |
indicate that the branch is not expected to be taken. The lower |
348 |
0, /* rightshift */ |
0, /* rightshift */ |
349 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
350 |
16, /* bitsize */ |
16, /* bitsize */ |
351 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
352 |
0, /* bitpos */ |
0, /* bitpos */ |
353 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
354 |
ppc64_elf_brtaken_reloc, /* special_function */ |
ppc64_elf_brtaken_reloc, /* special_function */ |
355 |
"R_PPC64_ADDR14_BRNTAKEN",/* name */ |
"R_PPC64_ADDR14_BRNTAKEN",/* name */ |
356 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
357 |
0xffff0003, /* src_mask */ |
0, /* src_mask */ |
358 |
0x0000fffc, /* dst_mask */ |
0x0000fffc, /* dst_mask */ |
359 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
360 |
|
|
361 |
/* A relative 26 bit branch; the lower two bits must be zero. */ |
/* A relative 26 bit branch; the lower two bits must be zero. */ |
362 |
HOWTO (R_PPC64_REL24, /* type */ |
HOWTO (R_PPC64_REL24, /* type */ |
363 |
0, /* rightshift */ |
0, /* rightshift */ |
364 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
365 |
26, /* bitsize */ |
26, /* bitsize */ |
366 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
367 |
0, /* bitpos */ |
0, /* bitpos */ |
368 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
369 |
bfd_elf_generic_reloc, /* special_function */ |
ppc64_elf_branch_reloc, /* special_function */ |
370 |
"R_PPC64_REL24", /* name */ |
"R_PPC64_REL24", /* name */ |
371 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
372 |
0xfc000003, /* src_mask */ |
0, /* src_mask */ |
373 |
0x03fffffc, /* dst_mask */ |
0x03fffffc, /* dst_mask */ |
374 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
375 |
|
|
376 |
/* A relative 16 bit branch; the lower two bits must be zero. */ |
/* A relative 16 bit branch; the lower two bits must be zero. */ |
377 |
HOWTO (R_PPC64_REL14, /* type */ |
HOWTO (R_PPC64_REL14, /* type */ |
378 |
0, /* rightshift */ |
0, /* rightshift */ |
379 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
380 |
16, /* bitsize */ |
16, /* bitsize */ |
381 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
382 |
0, /* bitpos */ |
0, /* bitpos */ |
383 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
384 |
bfd_elf_generic_reloc, /* special_function */ |
ppc64_elf_branch_reloc, /* special_function */ |
385 |
"R_PPC64_REL14", /* name */ |
"R_PPC64_REL14", /* name */ |
386 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
387 |
0xffff0003, /* src_mask */ |
0, /* src_mask */ |
388 |
0x0000fffc, /* dst_mask */ |
0x0000fffc, /* dst_mask */ |
389 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
390 |
|
|
391 |
/* A relative 16 bit branch. Bit 10 should be set to indicate that |
/* A relative 16 bit branch. Bit 10 should be set to indicate that |
392 |
the branch is expected to be taken. The lower two bits must be |
the branch is expected to be taken. The lower two bits must be |
395 |
0, /* rightshift */ |
0, /* rightshift */ |
396 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
397 |
16, /* bitsize */ |
16, /* bitsize */ |
398 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
399 |
0, /* bitpos */ |
0, /* bitpos */ |
400 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
401 |
ppc64_elf_brtaken_reloc, /* special_function */ |
ppc64_elf_brtaken_reloc, /* special_function */ |
402 |
"R_PPC64_REL14_BRTAKEN", /* name */ |
"R_PPC64_REL14_BRTAKEN", /* name */ |
403 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
404 |
0xffff0003, /* src_mask */ |
0, /* src_mask */ |
405 |
0x0000fffc, /* dst_mask */ |
0x0000fffc, /* dst_mask */ |
406 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
407 |
|
|
408 |
/* A relative 16 bit branch. Bit 10 should be set to indicate that |
/* A relative 16 bit branch. Bit 10 should be set to indicate that |
409 |
the branch is not expected to be taken. The lower two bits must |
the branch is not expected to be taken. The lower two bits must |
412 |
0, /* rightshift */ |
0, /* rightshift */ |
413 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
414 |
16, /* bitsize */ |
16, /* bitsize */ |
415 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
416 |
0, /* bitpos */ |
0, /* bitpos */ |
417 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
418 |
ppc64_elf_brtaken_reloc, /* special_function */ |
ppc64_elf_brtaken_reloc, /* special_function */ |
419 |
"R_PPC64_REL14_BRNTAKEN",/* name */ |
"R_PPC64_REL14_BRNTAKEN",/* name */ |
420 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
421 |
0xffff0003, /* src_mask */ |
0, /* src_mask */ |
422 |
0x0000fffc, /* dst_mask */ |
0x0000fffc, /* dst_mask */ |
423 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
424 |
|
|
425 |
/* Like R_PPC64_ADDR16, but referring to the GOT table entry for the |
/* Like R_PPC64_ADDR16, but referring to the GOT table entry for the |
426 |
symbol. */ |
symbol. */ |
428 |
0, /* rightshift */ |
0, /* rightshift */ |
429 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
430 |
16, /* bitsize */ |
16, /* bitsize */ |
431 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
432 |
0, /* bitpos */ |
0, /* bitpos */ |
433 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
434 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
435 |
"R_PPC64_GOT16", /* name */ |
"R_PPC64_GOT16", /* name */ |
436 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
437 |
0, /* src_mask */ |
0, /* src_mask */ |
438 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
439 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
440 |
|
|
441 |
/* Like R_PPC64_ADDR16_LO, but referring to the GOT table entry for |
/* Like R_PPC64_ADDR16_LO, but referring to the GOT table entry for |
442 |
the symbol. */ |
the symbol. */ |
444 |
0, /* rightshift */ |
0, /* rightshift */ |
445 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
446 |
16, /* bitsize */ |
16, /* bitsize */ |
447 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
448 |
0, /* bitpos */ |
0, /* bitpos */ |
449 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
450 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
451 |
"R_PPC64_GOT16_LO", /* name */ |
"R_PPC64_GOT16_LO", /* name */ |
452 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
453 |
0, /* src_mask */ |
0, /* src_mask */ |
454 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
455 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
456 |
|
|
457 |
/* Like R_PPC64_ADDR16_HI, but referring to the GOT table entry for |
/* Like R_PPC64_ADDR16_HI, but referring to the GOT table entry for |
458 |
the symbol. */ |
the symbol. */ |
460 |
16, /* rightshift */ |
16, /* rightshift */ |
461 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
462 |
16, /* bitsize */ |
16, /* bitsize */ |
463 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
464 |
0, /* bitpos */ |
0, /* bitpos */ |
465 |
complain_overflow_dont,/* complain_on_overflow */ |
complain_overflow_dont,/* complain_on_overflow */ |
466 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
467 |
"R_PPC64_GOT16_HI", /* name */ |
"R_PPC64_GOT16_HI", /* name */ |
468 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
469 |
0, /* src_mask */ |
0, /* src_mask */ |
470 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
471 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
472 |
|
|
473 |
/* Like R_PPC64_ADDR16_HA, but referring to the GOT table entry for |
/* Like R_PPC64_ADDR16_HA, but referring to the GOT table entry for |
474 |
the symbol. */ |
the symbol. */ |
476 |
16, /* rightshift */ |
16, /* rightshift */ |
477 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
478 |
16, /* bitsize */ |
16, /* bitsize */ |
479 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
480 |
0, /* bitpos */ |
0, /* bitpos */ |
481 |
complain_overflow_dont,/* complain_on_overflow */ |
complain_overflow_dont,/* complain_on_overflow */ |
482 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
483 |
"R_PPC64_GOT16_HA", /* name */ |
"R_PPC64_GOT16_HA", /* name */ |
484 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
485 |
0, /* src_mask */ |
0, /* src_mask */ |
486 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
487 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
488 |
|
|
489 |
/* This is used only by the dynamic linker. The symbol should exist |
/* This is used only by the dynamic linker. The symbol should exist |
490 |
both in the object being run and in some shared library. The |
both in the object being run and in some shared library. The |
495 |
0, /* rightshift */ |
0, /* rightshift */ |
496 |
0, /* this one is variable size */ |
0, /* this one is variable size */ |
497 |
0, /* bitsize */ |
0, /* bitsize */ |
498 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
499 |
0, /* bitpos */ |
0, /* bitpos */ |
500 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
501 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
502 |
"R_PPC64_COPY", /* name */ |
"R_PPC64_COPY", /* name */ |
503 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
504 |
0, /* src_mask */ |
0, /* src_mask */ |
505 |
0, /* dst_mask */ |
0, /* dst_mask */ |
506 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
507 |
|
|
508 |
/* Like R_PPC64_ADDR64, but used when setting global offset table |
/* Like R_PPC64_ADDR64, but used when setting global offset table |
509 |
entries. */ |
entries. */ |
511 |
0, /* rightshift */ |
0, /* rightshift */ |
512 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
513 |
64, /* bitsize */ |
64, /* bitsize */ |
514 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
515 |
0, /* bitpos */ |
0, /* bitpos */ |
516 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
517 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
518 |
"R_PPC64_GLOB_DAT", /* name */ |
"R_PPC64_GLOB_DAT", /* name */ |
519 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
520 |
0, /* src_mask */ |
0, /* src_mask */ |
521 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
522 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
523 |
|
|
524 |
/* Created by the link editor. Marks a procedure linkage table |
/* Created by the link editor. Marks a procedure linkage table |
525 |
entry for a symbol. */ |
entry for a symbol. */ |
527 |
0, /* rightshift */ |
0, /* rightshift */ |
528 |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
529 |
0, /* bitsize */ |
0, /* bitsize */ |
530 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
531 |
0, /* bitpos */ |
0, /* bitpos */ |
532 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
533 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
534 |
"R_PPC64_JMP_SLOT", /* name */ |
"R_PPC64_JMP_SLOT", /* name */ |
535 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
536 |
0, /* src_mask */ |
0, /* src_mask */ |
537 |
0, /* dst_mask */ |
0, /* dst_mask */ |
538 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
539 |
|
|
540 |
/* Used only by the dynamic linker. When the object is run, this |
/* Used only by the dynamic linker. When the object is run, this |
541 |
doubleword64 is set to the load address of the object, plus the |
doubleword64 is set to the load address of the object, plus the |
544 |
0, /* rightshift */ |
0, /* rightshift */ |
545 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
546 |
64, /* bitsize */ |
64, /* bitsize */ |
547 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
548 |
0, /* bitpos */ |
0, /* bitpos */ |
549 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
550 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
551 |
"R_PPC64_RELATIVE", /* name */ |
"R_PPC64_RELATIVE", /* name */ |
552 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
553 |
0, /* src_mask */ |
0, /* src_mask */ |
554 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
555 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
556 |
|
|
557 |
/* Like R_PPC64_ADDR32, but may be unaligned. */ |
/* Like R_PPC64_ADDR32, but may be unaligned. */ |
558 |
HOWTO (R_PPC64_UADDR32, /* type */ |
HOWTO (R_PPC64_UADDR32, /* type */ |
559 |
0, /* rightshift */ |
0, /* rightshift */ |
560 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
561 |
32, /* bitsize */ |
32, /* bitsize */ |
562 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
563 |
0, /* bitpos */ |
0, /* bitpos */ |
564 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
565 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
566 |
"R_PPC64_UADDR32", /* name */ |
"R_PPC64_UADDR32", /* name */ |
567 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
568 |
0, /* src_mask */ |
0, /* src_mask */ |
569 |
0xffffffff, /* dst_mask */ |
0xffffffff, /* dst_mask */ |
570 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
571 |
|
|
572 |
/* Like R_PPC64_ADDR16, but may be unaligned. */ |
/* Like R_PPC64_ADDR16, but may be unaligned. */ |
573 |
HOWTO (R_PPC64_UADDR16, /* type */ |
HOWTO (R_PPC64_UADDR16, /* type */ |
574 |
0, /* rightshift */ |
0, /* rightshift */ |
575 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
576 |
16, /* bitsize */ |
16, /* bitsize */ |
577 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
578 |
0, /* bitpos */ |
0, /* bitpos */ |
579 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
580 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
581 |
"R_PPC64_UADDR16", /* name */ |
"R_PPC64_UADDR16", /* name */ |
582 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
583 |
0, /* src_mask */ |
0, /* src_mask */ |
584 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
585 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
586 |
|
|
587 |
/* 32-bit PC relative. */ |
/* 32-bit PC relative. */ |
588 |
HOWTO (R_PPC64_REL32, /* type */ |
HOWTO (R_PPC64_REL32, /* type */ |
589 |
0, /* rightshift */ |
0, /* rightshift */ |
590 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
591 |
32, /* bitsize */ |
32, /* bitsize */ |
592 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
593 |
0, /* bitpos */ |
0, /* bitpos */ |
594 |
/* FIXME: Verify. Was complain_overflow_bitfield. */ |
/* FIXME: Verify. Was complain_overflow_bitfield. */ |
595 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
596 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
597 |
"R_PPC64_REL32", /* name */ |
"R_PPC64_REL32", /* name */ |
598 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
599 |
0, /* src_mask */ |
0, /* src_mask */ |
600 |
0xffffffff, /* dst_mask */ |
0xffffffff, /* dst_mask */ |
601 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
602 |
|
|
603 |
/* 32-bit relocation to the symbol's procedure linkage table. */ |
/* 32-bit relocation to the symbol's procedure linkage table. */ |
604 |
HOWTO (R_PPC64_PLT32, /* type */ |
HOWTO (R_PPC64_PLT32, /* type */ |
605 |
0, /* rightshift */ |
0, /* rightshift */ |
606 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
607 |
32, /* bitsize */ |
32, /* bitsize */ |
608 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
609 |
0, /* bitpos */ |
0, /* bitpos */ |
610 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
611 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
612 |
"R_PPC64_PLT32", /* name */ |
"R_PPC64_PLT32", /* name */ |
613 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
614 |
0, /* src_mask */ |
0, /* src_mask */ |
615 |
0xffffffff, /* dst_mask */ |
0xffffffff, /* dst_mask */ |
616 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
617 |
|
|
618 |
/* 32-bit PC relative relocation to the symbol's procedure linkage table. |
/* 32-bit PC relative relocation to the symbol's procedure linkage table. |
619 |
FIXME: R_PPC64_PLTREL32 not supported. */ |
FIXME: R_PPC64_PLTREL32 not supported. */ |
621 |
0, /* rightshift */ |
0, /* rightshift */ |
622 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
623 |
32, /* bitsize */ |
32, /* bitsize */ |
624 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
625 |
0, /* bitpos */ |
0, /* bitpos */ |
626 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
627 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
628 |
"R_PPC64_PLTREL32", /* name */ |
"R_PPC64_PLTREL32", /* name */ |
629 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
630 |
0, /* src_mask */ |
0, /* src_mask */ |
631 |
0xffffffff, /* dst_mask */ |
0xffffffff, /* dst_mask */ |
632 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
633 |
|
|
634 |
/* Like R_PPC64_ADDR16_LO, but referring to the PLT table entry for |
/* Like R_PPC64_ADDR16_LO, but referring to the PLT table entry for |
635 |
the symbol. */ |
the symbol. */ |
637 |
0, /* rightshift */ |
0, /* rightshift */ |
638 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
639 |
16, /* bitsize */ |
16, /* bitsize */ |
640 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
641 |
0, /* bitpos */ |
0, /* bitpos */ |
642 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
643 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
644 |
"R_PPC64_PLT16_LO", /* name */ |
"R_PPC64_PLT16_LO", /* name */ |
645 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
646 |
0, /* src_mask */ |
0, /* src_mask */ |
647 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
648 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
649 |
|
|
650 |
/* Like R_PPC64_ADDR16_HI, but referring to the PLT table entry for |
/* Like R_PPC64_ADDR16_HI, but referring to the PLT table entry for |
651 |
the symbol. */ |
the symbol. */ |
653 |
16, /* rightshift */ |
16, /* rightshift */ |
654 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
655 |
16, /* bitsize */ |
16, /* bitsize */ |
656 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
657 |
0, /* bitpos */ |
0, /* bitpos */ |
658 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
659 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
660 |
"R_PPC64_PLT16_HI", /* name */ |
"R_PPC64_PLT16_HI", /* name */ |
661 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
662 |
0, /* src_mask */ |
0, /* src_mask */ |
663 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
664 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
665 |
|
|
666 |
/* Like R_PPC64_ADDR16_HA, but referring to the PLT table entry for |
/* Like R_PPC64_ADDR16_HA, but referring to the PLT table entry for |
667 |
the symbol. */ |
the symbol. */ |
669 |
16, /* rightshift */ |
16, /* rightshift */ |
670 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
671 |
16, /* bitsize */ |
16, /* bitsize */ |
672 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
673 |
0, /* bitpos */ |
0, /* bitpos */ |
674 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
675 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
676 |
"R_PPC64_PLT16_HA", /* name */ |
"R_PPC64_PLT16_HA", /* name */ |
677 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
678 |
0, /* src_mask */ |
0, /* src_mask */ |
679 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
680 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
681 |
|
|
682 |
/* 16-bit section relative relocation. */ |
/* 16-bit section relative relocation. */ |
683 |
HOWTO (R_PPC64_SECTOFF, /* type */ |
HOWTO (R_PPC64_SECTOFF, /* type */ |
684 |
0, /* rightshift */ |
0, /* rightshift */ |
685 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
686 |
16, /* bitsize */ |
16, /* bitsize */ |
687 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
688 |
0, /* bitpos */ |
0, /* bitpos */ |
689 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
690 |
ppc64_elf_sectoff_reloc, /* special_function */ |
ppc64_elf_sectoff_reloc, /* special_function */ |
691 |
"R_PPC64_SECTOFF", /* name */ |
"R_PPC64_SECTOFF", /* name */ |
692 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
693 |
0, /* src_mask */ |
0, /* src_mask */ |
694 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
695 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
696 |
|
|
697 |
/* Like R_PPC64_SECTOFF, but no overflow warning. */ |
/* Like R_PPC64_SECTOFF, but no overflow warning. */ |
698 |
HOWTO (R_PPC64_SECTOFF_LO, /* type */ |
HOWTO (R_PPC64_SECTOFF_LO, /* type */ |
699 |
0, /* rightshift */ |
0, /* rightshift */ |
700 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
701 |
16, /* bitsize */ |
16, /* bitsize */ |
702 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
703 |
0, /* bitpos */ |
0, /* bitpos */ |
704 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
705 |
ppc64_elf_sectoff_reloc, /* special_function */ |
ppc64_elf_sectoff_reloc, /* special_function */ |
706 |
"R_PPC64_SECTOFF_LO", /* name */ |
"R_PPC64_SECTOFF_LO", /* name */ |
707 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
708 |
0, /* src_mask */ |
0, /* src_mask */ |
709 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
710 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
711 |
|
|
712 |
/* 16-bit upper half section relative relocation. */ |
/* 16-bit upper half section relative relocation. */ |
713 |
HOWTO (R_PPC64_SECTOFF_HI, /* type */ |
HOWTO (R_PPC64_SECTOFF_HI, /* type */ |
714 |
16, /* rightshift */ |
16, /* rightshift */ |
715 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
716 |
16, /* bitsize */ |
16, /* bitsize */ |
717 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
718 |
0, /* bitpos */ |
0, /* bitpos */ |
719 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
720 |
ppc64_elf_sectoff_reloc, /* special_function */ |
ppc64_elf_sectoff_reloc, /* special_function */ |
721 |
"R_PPC64_SECTOFF_HI", /* name */ |
"R_PPC64_SECTOFF_HI", /* name */ |
722 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
723 |
0, /* src_mask */ |
0, /* src_mask */ |
724 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
725 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
726 |
|
|
727 |
/* 16-bit upper half adjusted section relative relocation. */ |
/* 16-bit upper half adjusted section relative relocation. */ |
728 |
HOWTO (R_PPC64_SECTOFF_HA, /* type */ |
HOWTO (R_PPC64_SECTOFF_HA, /* type */ |
729 |
16, /* rightshift */ |
16, /* rightshift */ |
730 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
731 |
16, /* bitsize */ |
16, /* bitsize */ |
732 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
733 |
0, /* bitpos */ |
0, /* bitpos */ |
734 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
735 |
ppc64_elf_sectoff_ha_reloc, /* special_function */ |
ppc64_elf_sectoff_ha_reloc, /* special_function */ |
736 |
"R_PPC64_SECTOFF_HA", /* name */ |
"R_PPC64_SECTOFF_HA", /* name */ |
737 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
738 |
0, /* src_mask */ |
0, /* src_mask */ |
739 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
740 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
741 |
|
|
742 |
/* Like R_PPC64_REL24 without touching the two least significant |
/* Like R_PPC64_REL24 without touching the two least significant bits. */ |
743 |
bits. Should have been named R_PPC64_REL30! */ |
HOWTO (R_PPC64_REL30, /* type */ |
|
HOWTO (R_PPC64_ADDR30, /* type */ |
|
744 |
2, /* rightshift */ |
2, /* rightshift */ |
745 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
746 |
30, /* bitsize */ |
30, /* bitsize */ |
747 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
748 |
0, /* bitpos */ |
0, /* bitpos */ |
749 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
750 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
751 |
"R_PPC64_ADDR30", /* name */ |
"R_PPC64_REL30", /* name */ |
752 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
753 |
0x00000003, /* src_mask */ |
0, /* src_mask */ |
754 |
0xfffffffc, /* dst_mask */ |
0xfffffffc, /* dst_mask */ |
755 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
756 |
|
|
757 |
/* Relocs in the 64-bit PowerPC ELF ABI, not in the 32-bit ABI. */ |
/* Relocs in the 64-bit PowerPC ELF ABI, not in the 32-bit ABI. */ |
758 |
|
|
761 |
0, /* rightshift */ |
0, /* rightshift */ |
762 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
763 |
64, /* bitsize */ |
64, /* bitsize */ |
764 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
765 |
0, /* bitpos */ |
0, /* bitpos */ |
766 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
767 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
768 |
"R_PPC64_ADDR64", /* name */ |
"R_PPC64_ADDR64", /* name */ |
769 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
770 |
0, /* src_mask */ |
0, /* src_mask */ |
771 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
772 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
773 |
|
|
774 |
/* The bits 32-47 of an address. */ |
/* The bits 32-47 of an address. */ |
775 |
HOWTO (R_PPC64_ADDR16_HIGHER, /* type */ |
HOWTO (R_PPC64_ADDR16_HIGHER, /* type */ |
776 |
32, /* rightshift */ |
32, /* rightshift */ |
777 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
778 |
16, /* bitsize */ |
16, /* bitsize */ |
779 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
780 |
0, /* bitpos */ |
0, /* bitpos */ |
781 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
782 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
783 |
"R_PPC64_ADDR16_HIGHER", /* name */ |
"R_PPC64_ADDR16_HIGHER", /* name */ |
784 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
785 |
0, /* src_mask */ |
0, /* src_mask */ |
786 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
787 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
788 |
|
|
789 |
/* The bits 32-47 of an address, plus 1 if the contents of the low |
/* The bits 32-47 of an address, plus 1 if the contents of the low |
790 |
16 bits, treated as a signed number, is negative. */ |
16 bits, treated as a signed number, is negative. */ |
792 |
32, /* rightshift */ |
32, /* rightshift */ |
793 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
794 |
16, /* bitsize */ |
16, /* bitsize */ |
795 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
796 |
0, /* bitpos */ |
0, /* bitpos */ |
797 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
798 |
ppc64_elf_ha_reloc, /* special_function */ |
ppc64_elf_ha_reloc, /* special_function */ |
799 |
"R_PPC64_ADDR16_HIGHERA", /* name */ |
"R_PPC64_ADDR16_HIGHERA", /* name */ |
800 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
801 |
0, /* src_mask */ |
0, /* src_mask */ |
802 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
803 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
804 |
|
|
805 |
/* The bits 48-63 of an address. */ |
/* The bits 48-63 of an address. */ |
806 |
HOWTO (R_PPC64_ADDR16_HIGHEST,/* type */ |
HOWTO (R_PPC64_ADDR16_HIGHEST,/* type */ |
807 |
48, /* rightshift */ |
48, /* rightshift */ |
808 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
809 |
16, /* bitsize */ |
16, /* bitsize */ |
810 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
811 |
0, /* bitpos */ |
0, /* bitpos */ |
812 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
813 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
814 |
"R_PPC64_ADDR16_HIGHEST", /* name */ |
"R_PPC64_ADDR16_HIGHEST", /* name */ |
815 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
816 |
0, /* src_mask */ |
0, /* src_mask */ |
817 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
818 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
819 |
|
|
820 |
/* The bits 48-63 of an address, plus 1 if the contents of the low |
/* The bits 48-63 of an address, plus 1 if the contents of the low |
821 |
16 bits, treated as a signed number, is negative. */ |
16 bits, treated as a signed number, is negative. */ |
823 |
48, /* rightshift */ |
48, /* rightshift */ |
824 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
825 |
16, /* bitsize */ |
16, /* bitsize */ |
826 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
827 |
0, /* bitpos */ |
0, /* bitpos */ |
828 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
829 |
ppc64_elf_ha_reloc, /* special_function */ |
ppc64_elf_ha_reloc, /* special_function */ |
830 |
"R_PPC64_ADDR16_HIGHESTA", /* name */ |
"R_PPC64_ADDR16_HIGHESTA", /* name */ |
831 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
832 |
0, /* src_mask */ |
0, /* src_mask */ |
833 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
834 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
835 |
|
|
836 |
/* Like ADDR64, but may be unaligned. */ |
/* Like ADDR64, but may be unaligned. */ |
837 |
HOWTO (R_PPC64_UADDR64, /* type */ |
HOWTO (R_PPC64_UADDR64, /* type */ |
838 |
0, /* rightshift */ |
0, /* rightshift */ |
839 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
840 |
64, /* bitsize */ |
64, /* bitsize */ |
841 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
842 |
0, /* bitpos */ |
0, /* bitpos */ |
843 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
844 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
845 |
"R_PPC64_UADDR64", /* name */ |
"R_PPC64_UADDR64", /* name */ |
846 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
847 |
0, /* src_mask */ |
0, /* src_mask */ |
848 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
849 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
850 |
|
|
851 |
/* 64-bit relative relocation. */ |
/* 64-bit relative relocation. */ |
852 |
HOWTO (R_PPC64_REL64, /* type */ |
HOWTO (R_PPC64_REL64, /* type */ |
853 |
0, /* rightshift */ |
0, /* rightshift */ |
854 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
855 |
64, /* bitsize */ |
64, /* bitsize */ |
856 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
857 |
0, /* bitpos */ |
0, /* bitpos */ |
858 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
859 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
860 |
"R_PPC64_REL64", /* name */ |
"R_PPC64_REL64", /* name */ |
861 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
862 |
0, /* src_mask */ |
0, /* src_mask */ |
863 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
864 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
865 |
|
|
866 |
/* 64-bit relocation to the symbol's procedure linkage table. */ |
/* 64-bit relocation to the symbol's procedure linkage table. */ |
867 |
HOWTO (R_PPC64_PLT64, /* type */ |
HOWTO (R_PPC64_PLT64, /* type */ |
868 |
0, /* rightshift */ |
0, /* rightshift */ |
869 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
870 |
64, /* bitsize */ |
64, /* bitsize */ |
871 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
872 |
0, /* bitpos */ |
0, /* bitpos */ |
873 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
874 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
875 |
"R_PPC64_PLT64", /* name */ |
"R_PPC64_PLT64", /* name */ |
876 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
877 |
0, /* src_mask */ |
0, /* src_mask */ |
878 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
879 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
880 |
|
|
881 |
/* 64-bit PC relative relocation to the symbol's procedure linkage |
/* 64-bit PC relative relocation to the symbol's procedure linkage |
882 |
table. */ |
table. */ |
885 |
0, /* rightshift */ |
0, /* rightshift */ |
886 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
887 |
64, /* bitsize */ |
64, /* bitsize */ |
888 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
889 |
0, /* bitpos */ |
0, /* bitpos */ |
890 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
891 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
892 |
"R_PPC64_PLTREL64", /* name */ |
"R_PPC64_PLTREL64", /* name */ |
893 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
894 |
0, /* src_mask */ |
0, /* src_mask */ |
895 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
896 |
true), /* pcrel_offset */ |
TRUE), /* pcrel_offset */ |
897 |
|
|
898 |
/* 16 bit TOC-relative relocation. */ |
/* 16 bit TOC-relative relocation. */ |
899 |
|
|
902 |
0, /* rightshift */ |
0, /* rightshift */ |
903 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
904 |
16, /* bitsize */ |
16, /* bitsize */ |
905 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
906 |
0, /* bitpos */ |
0, /* bitpos */ |
907 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
908 |
ppc64_elf_toc_reloc, /* special_function */ |
ppc64_elf_toc_reloc, /* special_function */ |
909 |
"R_PPC64_TOC16", /* name */ |
"R_PPC64_TOC16", /* name */ |
910 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
911 |
0, /* src_mask */ |
0, /* src_mask */ |
912 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
913 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
914 |
|
|
915 |
/* 16 bit TOC-relative relocation without overflow. */ |
/* 16 bit TOC-relative relocation without overflow. */ |
916 |
|
|
919 |
0, /* rightshift */ |
0, /* rightshift */ |
920 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
921 |
16, /* bitsize */ |
16, /* bitsize */ |
922 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
923 |
0, /* bitpos */ |
0, /* bitpos */ |
924 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
925 |
ppc64_elf_toc_reloc, /* special_function */ |
ppc64_elf_toc_reloc, /* special_function */ |
926 |
"R_PPC64_TOC16_LO", /* name */ |
"R_PPC64_TOC16_LO", /* name */ |
927 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
928 |
0, /* src_mask */ |
0, /* src_mask */ |
929 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
930 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
931 |
|
|
932 |
/* 16 bit TOC-relative relocation, high 16 bits. */ |
/* 16 bit TOC-relative relocation, high 16 bits. */ |
933 |
|
|
936 |
16, /* rightshift */ |
16, /* rightshift */ |
937 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
938 |
16, /* bitsize */ |
16, /* bitsize */ |
939 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
940 |
0, /* bitpos */ |
0, /* bitpos */ |
941 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
942 |
ppc64_elf_toc_reloc, /* special_function */ |
ppc64_elf_toc_reloc, /* special_function */ |
943 |
"R_PPC64_TOC16_HI", /* name */ |
"R_PPC64_TOC16_HI", /* name */ |
944 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
945 |
0, /* src_mask */ |
0, /* src_mask */ |
946 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
947 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
948 |
|
|
949 |
/* 16 bit TOC-relative relocation, high 16 bits, plus 1 if the |
/* 16 bit TOC-relative relocation, high 16 bits, plus 1 if the |
950 |
contents of the low 16 bits, treated as a signed number, is |
contents of the low 16 bits, treated as a signed number, is |
955 |
16, /* rightshift */ |
16, /* rightshift */ |
956 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
957 |
16, /* bitsize */ |
16, /* bitsize */ |
958 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
959 |
0, /* bitpos */ |
0, /* bitpos */ |
960 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
961 |
ppc64_elf_toc_ha_reloc, /* special_function */ |
ppc64_elf_toc_ha_reloc, /* special_function */ |
962 |
"R_PPC64_TOC16_HA", /* name */ |
"R_PPC64_TOC16_HA", /* name */ |
963 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
964 |
0, /* src_mask */ |
0, /* src_mask */ |
965 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
966 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
967 |
|
|
968 |
/* 64-bit relocation; insert value of TOC base (.TOC.). */ |
/* 64-bit relocation; insert value of TOC base (.TOC.). */ |
969 |
|
|
972 |
0, /* rightshift */ |
0, /* rightshift */ |
973 |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ |
974 |
64, /* bitsize */ |
64, /* bitsize */ |
975 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
976 |
0, /* bitpos */ |
0, /* bitpos */ |
977 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
978 |
ppc64_elf_toc64_reloc, /* special_function */ |
ppc64_elf_toc64_reloc, /* special_function */ |
979 |
"R_PPC64_TOC", /* name */ |
"R_PPC64_TOC", /* name */ |
980 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
981 |
0, /* src_mask */ |
0, /* src_mask */ |
982 |
ONES (64), /* dst_mask */ |
ONES (64), /* dst_mask */ |
983 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
984 |
|
|
985 |
/* Like R_PPC64_GOT16, but also informs the link editor that the |
/* Like R_PPC64_GOT16, but also informs the link editor that the |
986 |
value to relocate may (!) refer to a PLT entry which the link |
value to relocate may (!) refer to a PLT entry which the link |
995 |
0, /* rightshift */ |
0, /* rightshift */ |
996 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
997 |
16, /* bitsize */ |
16, /* bitsize */ |
998 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
999 |
0, /* bitpos */ |
0, /* bitpos */ |
1000 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
1001 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1002 |
"R_PPC64_PLTGOT16", /* name */ |
"R_PPC64_PLTGOT16", /* name */ |
1003 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1004 |
0, /* src_mask */ |
0, /* src_mask */ |
1005 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
1006 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1007 |
|
|
1008 |
/* Like R_PPC64_PLTGOT16, but without overflow. */ |
/* Like R_PPC64_PLTGOT16, but without overflow. */ |
1009 |
/* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ |
/* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ |
1011 |
0, /* rightshift */ |
0, /* rightshift */ |
1012 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1013 |
16, /* bitsize */ |
16, /* bitsize */ |
1014 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1015 |
0, /* bitpos */ |
0, /* bitpos */ |
1016 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1017 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1018 |
"R_PPC64_PLTGOT16_LO", /* name */ |
"R_PPC64_PLTGOT16_LO", /* name */ |
1019 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1020 |
0, /* src_mask */ |
0, /* src_mask */ |
1021 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
1022 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1023 |
|
|
1024 |
/* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address. */ |
/* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address. */ |
1025 |
/* FIXME: R_PPC64_PLTGOT16_HI not implemented. */ |
/* FIXME: R_PPC64_PLTGOT16_HI not implemented. */ |
1027 |
16, /* rightshift */ |
16, /* rightshift */ |
1028 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1029 |
16, /* bitsize */ |
16, /* bitsize */ |
1030 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1031 |
0, /* bitpos */ |
0, /* bitpos */ |
1032 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1033 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1034 |
"R_PPC64_PLTGOT16_HI", /* name */ |
"R_PPC64_PLTGOT16_HI", /* name */ |
1035 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1036 |
0, /* src_mask */ |
0, /* src_mask */ |
1037 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
1038 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1039 |
|
|
1040 |
/* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address, plus |
/* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address, plus |
1041 |
1 if the contents of the low 16 bits, treated as a signed number, |
1 if the contents of the low 16 bits, treated as a signed number, |
1045 |
16, /* rightshift */ |
16, /* rightshift */ |
1046 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1047 |
16, /* bitsize */ |
16, /* bitsize */ |
1048 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1049 |
0, /* bitpos */ |
0, /* bitpos */ |
1050 |
complain_overflow_dont,/* complain_on_overflow */ |
complain_overflow_dont,/* complain_on_overflow */ |
1051 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1052 |
"R_PPC64_PLTGOT16_HA", /* name */ |
"R_PPC64_PLTGOT16_HA", /* name */ |
1053 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1054 |
0, /* src_mask */ |
0, /* src_mask */ |
1055 |
0xffff, /* dst_mask */ |
0xffff, /* dst_mask */ |
1056 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1057 |
|
|
1058 |
/* Like R_PPC64_ADDR16, but for instructions with a DS field. */ |
/* Like R_PPC64_ADDR16, but for instructions with a DS field. */ |
1059 |
HOWTO (R_PPC64_ADDR16_DS, /* type */ |
HOWTO (R_PPC64_ADDR16_DS, /* type */ |
1060 |
0, /* rightshift */ |
0, /* rightshift */ |
1061 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1062 |
16, /* bitsize */ |
16, /* bitsize */ |
1063 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1064 |
0, /* bitpos */ |
0, /* bitpos */ |
1065 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
1066 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
1067 |
"R_PPC64_ADDR16_DS", /* name */ |
"R_PPC64_ADDR16_DS", /* name */ |
1068 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1069 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1070 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1071 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1072 |
|
|
1073 |
/* Like R_PPC64_ADDR16_LO, but for instructions with a DS field. */ |
/* Like R_PPC64_ADDR16_LO, but for instructions with a DS field. */ |
1074 |
HOWTO (R_PPC64_ADDR16_LO_DS, /* type */ |
HOWTO (R_PPC64_ADDR16_LO_DS, /* type */ |
1075 |
0, /* rightshift */ |
0, /* rightshift */ |
1076 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1077 |
16, /* bitsize */ |
16, /* bitsize */ |
1078 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1079 |
0, /* bitpos */ |
0, /* bitpos */ |
1080 |
complain_overflow_dont,/* complain_on_overflow */ |
complain_overflow_dont,/* complain_on_overflow */ |
1081 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
1082 |
"R_PPC64_ADDR16_LO_DS",/* name */ |
"R_PPC64_ADDR16_LO_DS",/* name */ |
1083 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1084 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1085 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1086 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1087 |
|
|
1088 |
/* Like R_PPC64_GOT16, but for instructions with a DS field. */ |
/* Like R_PPC64_GOT16, but for instructions with a DS field. */ |
1089 |
HOWTO (R_PPC64_GOT16_DS, /* type */ |
HOWTO (R_PPC64_GOT16_DS, /* type */ |
1090 |
0, /* rightshift */ |
0, /* rightshift */ |
1091 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1092 |
16, /* bitsize */ |
16, /* bitsize */ |
1093 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1094 |
0, /* bitpos */ |
0, /* bitpos */ |
1095 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
1096 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1097 |
"R_PPC64_GOT16_DS", /* name */ |
"R_PPC64_GOT16_DS", /* name */ |
1098 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1099 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1100 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1101 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1102 |
|
|
1103 |
/* Like R_PPC64_GOT16_LO, but for instructions with a DS field. */ |
/* Like R_PPC64_GOT16_LO, but for instructions with a DS field. */ |
1104 |
HOWTO (R_PPC64_GOT16_LO_DS, /* type */ |
HOWTO (R_PPC64_GOT16_LO_DS, /* type */ |
1105 |
0, /* rightshift */ |
0, /* rightshift */ |
1106 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1107 |
16, /* bitsize */ |
16, /* bitsize */ |
1108 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1109 |
0, /* bitpos */ |
0, /* bitpos */ |
1110 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1111 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1112 |
"R_PPC64_GOT16_LO_DS", /* name */ |
"R_PPC64_GOT16_LO_DS", /* name */ |
1113 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1114 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1115 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1116 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1117 |
|
|
1118 |
/* Like R_PPC64_PLT16_LO, but for instructions with a DS field. */ |
/* Like R_PPC64_PLT16_LO, but for instructions with a DS field. */ |
1119 |
HOWTO (R_PPC64_PLT16_LO_DS, /* type */ |
HOWTO (R_PPC64_PLT16_LO_DS, /* type */ |
1120 |
0, /* rightshift */ |
0, /* rightshift */ |
1121 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1122 |
16, /* bitsize */ |
16, /* bitsize */ |
1123 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1124 |
0, /* bitpos */ |
0, /* bitpos */ |
1125 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1126 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1127 |
"R_PPC64_PLT16_LO_DS", /* name */ |
"R_PPC64_PLT16_LO_DS", /* name */ |
1128 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1129 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1130 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1131 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1132 |
|
|
1133 |
/* Like R_PPC64_SECTOFF, but for instructions with a DS field. */ |
/* Like R_PPC64_SECTOFF, but for instructions with a DS field. */ |
1134 |
HOWTO (R_PPC64_SECTOFF_DS, /* type */ |
HOWTO (R_PPC64_SECTOFF_DS, /* type */ |
1135 |
0, /* rightshift */ |
0, /* rightshift */ |
1136 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1137 |
16, /* bitsize */ |
16, /* bitsize */ |
1138 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1139 |
0, /* bitpos */ |
0, /* bitpos */ |
1140 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
1141 |
ppc64_elf_sectoff_reloc, /* special_function */ |
ppc64_elf_sectoff_reloc, /* special_function */ |
1142 |
"R_PPC64_SECTOFF_DS", /* name */ |
"R_PPC64_SECTOFF_DS", /* name */ |
1143 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1144 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1145 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1146 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1147 |
|
|
1148 |
/* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */ |
/* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */ |
1149 |
HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */ |
HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */ |
1150 |
0, /* rightshift */ |
0, /* rightshift */ |
1151 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1152 |
16, /* bitsize */ |
16, /* bitsize */ |
1153 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1154 |
0, /* bitpos */ |
0, /* bitpos */ |
1155 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1156 |
ppc64_elf_sectoff_reloc, /* special_function */ |
ppc64_elf_sectoff_reloc, /* special_function */ |
1157 |
"R_PPC64_SECTOFF_LO_DS",/* name */ |
"R_PPC64_SECTOFF_LO_DS",/* name */ |
1158 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1159 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1160 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1161 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1162 |
|
|
1163 |
/* Like R_PPC64_TOC16, but for instructions with a DS field. */ |
/* Like R_PPC64_TOC16, but for instructions with a DS field. */ |
1164 |
HOWTO (R_PPC64_TOC16_DS, /* type */ |
HOWTO (R_PPC64_TOC16_DS, /* type */ |
1165 |
0, /* rightshift */ |
0, /* rightshift */ |
1166 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1167 |
16, /* bitsize */ |
16, /* bitsize */ |
1168 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1169 |
0, /* bitpos */ |
0, /* bitpos */ |
1170 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
1171 |
ppc64_elf_toc_reloc, /* special_function */ |
ppc64_elf_toc_reloc, /* special_function */ |
1172 |
"R_PPC64_TOC16_DS", /* name */ |
"R_PPC64_TOC16_DS", /* name */ |
1173 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1174 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1175 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1176 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1177 |
|
|
1178 |
/* Like R_PPC64_TOC16_LO, but for instructions with a DS field. */ |
/* Like R_PPC64_TOC16_LO, but for instructions with a DS field. */ |
1179 |
HOWTO (R_PPC64_TOC16_LO_DS, /* type */ |
HOWTO (R_PPC64_TOC16_LO_DS, /* type */ |
1180 |
0, /* rightshift */ |
0, /* rightshift */ |
1181 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1182 |
16, /* bitsize */ |
16, /* bitsize */ |
1183 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1184 |
0, /* bitpos */ |
0, /* bitpos */ |
1185 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1186 |
ppc64_elf_toc_reloc, /* special_function */ |
ppc64_elf_toc_reloc, /* special_function */ |
1187 |
"R_PPC64_TOC16_LO_DS", /* name */ |
"R_PPC64_TOC16_LO_DS", /* name */ |
1188 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1189 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1190 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1191 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1192 |
|
|
1193 |
/* Like R_PPC64_PLTGOT16, but for instructions with a DS field. */ |
/* Like R_PPC64_PLTGOT16, but for instructions with a DS field. */ |
1194 |
/* FIXME: R_PPC64_PLTGOT16_DS not implemented. */ |
/* FIXME: R_PPC64_PLTGOT16_DS not implemented. */ |
1196 |
0, /* rightshift */ |
0, /* rightshift */ |
1197 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1198 |
16, /* bitsize */ |
16, /* bitsize */ |
1199 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1200 |
0, /* bitpos */ |
0, /* bitpos */ |
1201 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
1202 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1203 |
"R_PPC64_PLTGOT16_DS", /* name */ |
"R_PPC64_PLTGOT16_DS", /* name */ |
1204 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1205 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1206 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1207 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1208 |
|
|
1209 |
/* Like R_PPC64_PLTGOT16_LO, but for instructions with a DS field. */ |
/* Like R_PPC64_PLTGOT16_LO, but for instructions with a DS field. */ |
1210 |
/* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ |
/* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ |
1212 |
0, /* rightshift */ |
0, /* rightshift */ |
1213 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1214 |
16, /* bitsize */ |
16, /* bitsize */ |
1215 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1216 |
0, /* bitpos */ |
0, /* bitpos */ |
1217 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1218 |
ppc64_elf_unhandled_reloc, /* special_function */ |
ppc64_elf_unhandled_reloc, /* special_function */ |
1219 |
"R_PPC64_PLTGOT16_LO_DS",/* name */ |
"R_PPC64_PLTGOT16_LO_DS",/* name */ |
1220 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1221 |
0x0003, /* src_mask */ |
0, /* src_mask */ |
1222 |
0xfffc, /* dst_mask */ |
0xfffc, /* dst_mask */ |
1223 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1224 |
|
|
1225 |
|
/* Marker reloc for TLS. */ |
1226 |
|
HOWTO (R_PPC64_TLS, |
1227 |
|
0, /* rightshift */ |
1228 |
|
2, /* size (0 = byte, 1 = short, 2 = long) */ |
1229 |
|
32, /* bitsize */ |
1230 |
|
FALSE, /* pc_relative */ |
1231 |
|
0, /* bitpos */ |
1232 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1233 |
|
bfd_elf_generic_reloc, /* special_function */ |
1234 |
|
"R_PPC64_TLS", /* name */ |
1235 |
|
FALSE, /* partial_inplace */ |
1236 |
|
0, /* src_mask */ |
1237 |
|
0, /* dst_mask */ |
1238 |
|
FALSE), /* pcrel_offset */ |
1239 |
|
|
1240 |
|
/* Computes the load module index of the load module that contains the |
1241 |
|
definition of its TLS sym. */ |
1242 |
|
HOWTO (R_PPC64_DTPMOD64, |
1243 |
|
0, /* rightshift */ |
1244 |
|
4, /* size (0 = byte, 1 = short, 2 = long) */ |
1245 |
|
64, /* bitsize */ |
1246 |
|
FALSE, /* pc_relative */ |
1247 |
|
0, /* bitpos */ |
1248 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1249 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1250 |
|
"R_PPC64_DTPMOD64", /* name */ |
1251 |
|
FALSE, /* partial_inplace */ |
1252 |
|
0, /* src_mask */ |
1253 |
|
ONES (64), /* dst_mask */ |
1254 |
|
FALSE), /* pcrel_offset */ |
1255 |
|
|
1256 |
|
/* Computes a dtv-relative displacement, the difference between the value |
1257 |
|
of sym+add and the base address of the thread-local storage block that |
1258 |
|
contains the definition of sym, minus 0x8000. */ |
1259 |
|
HOWTO (R_PPC64_DTPREL64, |
1260 |
|
0, /* rightshift */ |
1261 |
|
4, /* size (0 = byte, 1 = short, 2 = long) */ |
1262 |
|
64, /* bitsize */ |
1263 |
|
FALSE, /* pc_relative */ |
1264 |
|
0, /* bitpos */ |
1265 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1266 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1267 |
|
"R_PPC64_DTPREL64", /* name */ |
1268 |
|
FALSE, /* partial_inplace */ |
1269 |
|
0, /* src_mask */ |
1270 |
|
ONES (64), /* dst_mask */ |
1271 |
|
FALSE), /* pcrel_offset */ |
1272 |
|
|
1273 |
|
/* A 16 bit dtprel reloc. */ |
1274 |
|
HOWTO (R_PPC64_DTPREL16, |
1275 |
|
0, /* rightshift */ |
1276 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1277 |
|
16, /* bitsize */ |
1278 |
|
FALSE, /* pc_relative */ |
1279 |
|
0, /* bitpos */ |
1280 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1281 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1282 |
|
"R_PPC64_DTPREL16", /* name */ |
1283 |
|
FALSE, /* partial_inplace */ |
1284 |
|
0, /* src_mask */ |
1285 |
|
0xffff, /* dst_mask */ |
1286 |
|
FALSE), /* pcrel_offset */ |
1287 |
|
|
1288 |
|
/* Like DTPREL16, but no overflow. */ |
1289 |
|
HOWTO (R_PPC64_DTPREL16_LO, |
1290 |
|
0, /* rightshift */ |
1291 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1292 |
|
16, /* bitsize */ |
1293 |
|
FALSE, /* pc_relative */ |
1294 |
|
0, /* bitpos */ |
1295 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1296 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1297 |
|
"R_PPC64_DTPREL16_LO", /* name */ |
1298 |
|
FALSE, /* partial_inplace */ |
1299 |
|
0, /* src_mask */ |
1300 |
|
0xffff, /* dst_mask */ |
1301 |
|
FALSE), /* pcrel_offset */ |
1302 |
|
|
1303 |
|
/* Like DTPREL16_LO, but next higher group of 16 bits. */ |
1304 |
|
HOWTO (R_PPC64_DTPREL16_HI, |
1305 |
|
16, /* rightshift */ |
1306 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1307 |
|
16, /* bitsize */ |
1308 |
|
FALSE, /* pc_relative */ |
1309 |
|
0, /* bitpos */ |
1310 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1311 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1312 |
|
"R_PPC64_DTPREL16_HI", /* name */ |
1313 |
|
FALSE, /* partial_inplace */ |
1314 |
|
0, /* src_mask */ |
1315 |
|
0xffff, /* dst_mask */ |
1316 |
|
FALSE), /* pcrel_offset */ |
1317 |
|
|
1318 |
|
/* Like DTPREL16_HI, but adjust for low 16 bits. */ |
1319 |
|
HOWTO (R_PPC64_DTPREL16_HA, |
1320 |
|
16, /* rightshift */ |
1321 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1322 |
|
16, /* bitsize */ |
1323 |
|
FALSE, /* pc_relative */ |
1324 |
|
0, /* bitpos */ |
1325 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1326 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1327 |
|
"R_PPC64_DTPREL16_HA", /* name */ |
1328 |
|
FALSE, /* partial_inplace */ |
1329 |
|
0, /* src_mask */ |
1330 |
|
0xffff, /* dst_mask */ |
1331 |
|
FALSE), /* pcrel_offset */ |
1332 |
|
|
1333 |
|
/* Like DTPREL16_HI, but next higher group of 16 bits. */ |
1334 |
|
HOWTO (R_PPC64_DTPREL16_HIGHER, |
1335 |
|
32, /* rightshift */ |
1336 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1337 |
|
16, /* bitsize */ |
1338 |
|
FALSE, /* pc_relative */ |
1339 |
|
0, /* bitpos */ |
1340 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1341 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1342 |
|
"R_PPC64_DTPREL16_HIGHER", /* name */ |
1343 |
|
FALSE, /* partial_inplace */ |
1344 |
|
0, /* src_mask */ |
1345 |
|
0xffff, /* dst_mask */ |
1346 |
|
FALSE), /* pcrel_offset */ |
1347 |
|
|
1348 |
|
/* Like DTPREL16_HIGHER, but adjust for low 16 bits. */ |
1349 |
|
HOWTO (R_PPC64_DTPREL16_HIGHERA, |
1350 |
|
32, /* rightshift */ |
1351 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1352 |
|
16, /* bitsize */ |
1353 |
|
FALSE, /* pc_relative */ |
1354 |
|
0, /* bitpos */ |
1355 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1356 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1357 |
|
"R_PPC64_DTPREL16_HIGHERA", /* name */ |
1358 |
|
FALSE, /* partial_inplace */ |
1359 |
|
0, /* src_mask */ |
1360 |
|
0xffff, /* dst_mask */ |
1361 |
|
FALSE), /* pcrel_offset */ |
1362 |
|
|
1363 |
|
/* Like DTPREL16_HIGHER, but next higher group of 16 bits. */ |
1364 |
|
HOWTO (R_PPC64_DTPREL16_HIGHEST, |
1365 |
|
48, /* rightshift */ |
1366 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1367 |
|
16, /* bitsize */ |
1368 |
|
FALSE, /* pc_relative */ |
1369 |
|
0, /* bitpos */ |
1370 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1371 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1372 |
|
"R_PPC64_DTPREL16_HIGHEST", /* name */ |
1373 |
|
FALSE, /* partial_inplace */ |
1374 |
|
0, /* src_mask */ |
1375 |
|
0xffff, /* dst_mask */ |
1376 |
|
FALSE), /* pcrel_offset */ |
1377 |
|
|
1378 |
|
/* Like DTPREL16_HIGHEST, but adjust for low 16 bits. */ |
1379 |
|
HOWTO (R_PPC64_DTPREL16_HIGHESTA, |
1380 |
|
48, /* rightshift */ |
1381 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1382 |
|
16, /* bitsize */ |
1383 |
|
FALSE, /* pc_relative */ |
1384 |
|
0, /* bitpos */ |
1385 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1386 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1387 |
|
"R_PPC64_DTPREL16_HIGHESTA", /* name */ |
1388 |
|
FALSE, /* partial_inplace */ |
1389 |
|
0, /* src_mask */ |
1390 |
|
0xffff, /* dst_mask */ |
1391 |
|
FALSE), /* pcrel_offset */ |
1392 |
|
|
1393 |
|
/* Like DTPREL16, but for insns with a DS field. */ |
1394 |
|
HOWTO (R_PPC64_DTPREL16_DS, |
1395 |
|
0, /* rightshift */ |
1396 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1397 |
|
16, /* bitsize */ |
1398 |
|
FALSE, /* pc_relative */ |
1399 |
|
0, /* bitpos */ |
1400 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1401 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1402 |
|
"R_PPC64_DTPREL16_DS", /* name */ |
1403 |
|
FALSE, /* partial_inplace */ |
1404 |
|
0, /* src_mask */ |
1405 |
|
0xfffc, /* dst_mask */ |
1406 |
|
FALSE), /* pcrel_offset */ |
1407 |
|
|
1408 |
|
/* Like DTPREL16_DS, but no overflow. */ |
1409 |
|
HOWTO (R_PPC64_DTPREL16_LO_DS, |
1410 |
|
0, /* rightshift */ |
1411 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1412 |
|
16, /* bitsize */ |
1413 |
|
FALSE, /* pc_relative */ |
1414 |
|
0, /* bitpos */ |
1415 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1416 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1417 |
|
"R_PPC64_DTPREL16_LO_DS", /* name */ |
1418 |
|
FALSE, /* partial_inplace */ |
1419 |
|
0, /* src_mask */ |
1420 |
|
0xfffc, /* dst_mask */ |
1421 |
|
FALSE), /* pcrel_offset */ |
1422 |
|
|
1423 |
|
/* Computes a tp-relative displacement, the difference between the value of |
1424 |
|
sym+add and the value of the thread pointer (r13). */ |
1425 |
|
HOWTO (R_PPC64_TPREL64, |
1426 |
|
0, /* rightshift */ |
1427 |
|
4, /* size (0 = byte, 1 = short, 2 = long) */ |
1428 |
|
64, /* bitsize */ |
1429 |
|
FALSE, /* pc_relative */ |
1430 |
|
0, /* bitpos */ |
1431 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1432 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1433 |
|
"R_PPC64_TPREL64", /* name */ |
1434 |
|
FALSE, /* partial_inplace */ |
1435 |
|
0, /* src_mask */ |
1436 |
|
ONES (64), /* dst_mask */ |
1437 |
|
FALSE), /* pcrel_offset */ |
1438 |
|
|
1439 |
|
/* A 16 bit tprel reloc. */ |
1440 |
|
HOWTO (R_PPC64_TPREL16, |
1441 |
|
0, /* rightshift */ |
1442 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1443 |
|
16, /* bitsize */ |
1444 |
|
FALSE, /* pc_relative */ |
1445 |
|
0, /* bitpos */ |
1446 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1447 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1448 |
|
"R_PPC64_TPREL16", /* name */ |
1449 |
|
FALSE, /* partial_inplace */ |
1450 |
|
0, /* src_mask */ |
1451 |
|
0xffff, /* dst_mask */ |
1452 |
|
FALSE), /* pcrel_offset */ |
1453 |
|
|
1454 |
|
/* Like TPREL16, but no overflow. */ |
1455 |
|
HOWTO (R_PPC64_TPREL16_LO, |
1456 |
|
0, /* rightshift */ |
1457 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1458 |
|
16, /* bitsize */ |
1459 |
|
FALSE, /* pc_relative */ |
1460 |
|
0, /* bitpos */ |
1461 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1462 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1463 |
|
"R_PPC64_TPREL16_LO", /* name */ |
1464 |
|
FALSE, /* partial_inplace */ |
1465 |
|
0, /* src_mask */ |
1466 |
|
0xffff, /* dst_mask */ |
1467 |
|
FALSE), /* pcrel_offset */ |
1468 |
|
|
1469 |
|
/* Like TPREL16_LO, but next higher group of 16 bits. */ |
1470 |
|
HOWTO (R_PPC64_TPREL16_HI, |
1471 |
|
16, /* rightshift */ |
1472 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1473 |
|
16, /* bitsize */ |
1474 |
|
FALSE, /* pc_relative */ |
1475 |
|
0, /* bitpos */ |
1476 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1477 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1478 |
|
"R_PPC64_TPREL16_HI", /* name */ |
1479 |
|
FALSE, /* partial_inplace */ |
1480 |
|
0, /* src_mask */ |
1481 |
|
0xffff, /* dst_mask */ |
1482 |
|
FALSE), /* pcrel_offset */ |
1483 |
|
|
1484 |
|
/* Like TPREL16_HI, but adjust for low 16 bits. */ |
1485 |
|
HOWTO (R_PPC64_TPREL16_HA, |
1486 |
|
16, /* rightshift */ |
1487 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1488 |
|
16, /* bitsize */ |
1489 |
|
FALSE, /* pc_relative */ |
1490 |
|
0, /* bitpos */ |
1491 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1492 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1493 |
|
"R_PPC64_TPREL16_HA", /* name */ |
1494 |
|
FALSE, /* partial_inplace */ |
1495 |
|
0, /* src_mask */ |
1496 |
|
0xffff, /* dst_mask */ |
1497 |
|
FALSE), /* pcrel_offset */ |
1498 |
|
|
1499 |
|
/* Like TPREL16_HI, but next higher group of 16 bits. */ |
1500 |
|
HOWTO (R_PPC64_TPREL16_HIGHER, |
1501 |
|
32, /* rightshift */ |
1502 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1503 |
|
16, /* bitsize */ |
1504 |
|
FALSE, /* pc_relative */ |
1505 |
|
0, /* bitpos */ |
1506 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1507 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1508 |
|
"R_PPC64_TPREL16_HIGHER", /* name */ |
1509 |
|
FALSE, /* partial_inplace */ |
1510 |
|
0, /* src_mask */ |
1511 |
|
0xffff, /* dst_mask */ |
1512 |
|
FALSE), /* pcrel_offset */ |
1513 |
|
|
1514 |
|
/* Like TPREL16_HIGHER, but adjust for low 16 bits. */ |
1515 |
|
HOWTO (R_PPC64_TPREL16_HIGHERA, |
1516 |
|
32, /* rightshift */ |
1517 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1518 |
|
16, /* bitsize */ |
1519 |
|
FALSE, /* pc_relative */ |
1520 |
|
0, /* bitpos */ |
1521 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1522 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1523 |
|
"R_PPC64_TPREL16_HIGHERA", /* name */ |
1524 |
|
FALSE, /* partial_inplace */ |
1525 |
|
0, /* src_mask */ |
1526 |
|
0xffff, /* dst_mask */ |
1527 |
|
FALSE), /* pcrel_offset */ |
1528 |
|
|
1529 |
|
/* Like TPREL16_HIGHER, but next higher group of 16 bits. */ |
1530 |
|
HOWTO (R_PPC64_TPREL16_HIGHEST, |
1531 |
|
48, /* rightshift */ |
1532 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1533 |
|
16, /* bitsize */ |
1534 |
|
FALSE, /* pc_relative */ |
1535 |
|
0, /* bitpos */ |
1536 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1537 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1538 |
|
"R_PPC64_TPREL16_HIGHEST", /* name */ |
1539 |
|
FALSE, /* partial_inplace */ |
1540 |
|
0, /* src_mask */ |
1541 |
|
0xffff, /* dst_mask */ |
1542 |
|
FALSE), /* pcrel_offset */ |
1543 |
|
|
1544 |
|
/* Like TPREL16_HIGHEST, but adjust for low 16 bits. */ |
1545 |
|
HOWTO (R_PPC64_TPREL16_HIGHESTA, |
1546 |
|
48, /* rightshift */ |
1547 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1548 |
|
16, /* bitsize */ |
1549 |
|
FALSE, /* pc_relative */ |
1550 |
|
0, /* bitpos */ |
1551 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1552 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1553 |
|
"R_PPC64_TPREL16_HIGHESTA", /* name */ |
1554 |
|
FALSE, /* partial_inplace */ |
1555 |
|
0, /* src_mask */ |
1556 |
|
0xffff, /* dst_mask */ |
1557 |
|
FALSE), /* pcrel_offset */ |
1558 |
|
|
1559 |
|
/* Like TPREL16, but for insns with a DS field. */ |
1560 |
|
HOWTO (R_PPC64_TPREL16_DS, |
1561 |
|
0, /* rightshift */ |
1562 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1563 |
|
16, /* bitsize */ |
1564 |
|
FALSE, /* pc_relative */ |
1565 |
|
0, /* bitpos */ |
1566 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1567 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1568 |
|
"R_PPC64_TPREL16_DS", /* name */ |
1569 |
|
FALSE, /* partial_inplace */ |
1570 |
|
0, /* src_mask */ |
1571 |
|
0xfffc, /* dst_mask */ |
1572 |
|
FALSE), /* pcrel_offset */ |
1573 |
|
|
1574 |
|
/* Like TPREL16_DS, but no overflow. */ |
1575 |
|
HOWTO (R_PPC64_TPREL16_LO_DS, |
1576 |
|
0, /* rightshift */ |
1577 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1578 |
|
16, /* bitsize */ |
1579 |
|
FALSE, /* pc_relative */ |
1580 |
|
0, /* bitpos */ |
1581 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1582 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1583 |
|
"R_PPC64_TPREL16_LO_DS", /* name */ |
1584 |
|
FALSE, /* partial_inplace */ |
1585 |
|
0, /* src_mask */ |
1586 |
|
0xfffc, /* dst_mask */ |
1587 |
|
FALSE), /* pcrel_offset */ |
1588 |
|
|
1589 |
|
/* Allocates two contiguous entries in the GOT to hold a tls_index structure, |
1590 |
|
with values (sym+add)@dtpmod and (sym+add)@dtprel, and computes the offset |
1591 |
|
to the first entry relative to the TOC base (r2). */ |
1592 |
|
HOWTO (R_PPC64_GOT_TLSGD16, |
1593 |
|
0, /* rightshift */ |
1594 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1595 |
|
16, /* bitsize */ |
1596 |
|
FALSE, /* pc_relative */ |
1597 |
|
0, /* bitpos */ |
1598 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1599 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1600 |
|
"R_PPC64_GOT_TLSGD16", /* name */ |
1601 |
|
FALSE, /* partial_inplace */ |
1602 |
|
0, /* src_mask */ |
1603 |
|
0xffff, /* dst_mask */ |
1604 |
|
FALSE), /* pcrel_offset */ |
1605 |
|
|
1606 |
|
/* Like GOT_TLSGD16, but no overflow. */ |
1607 |
|
HOWTO (R_PPC64_GOT_TLSGD16_LO, |
1608 |
|
0, /* rightshift */ |
1609 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1610 |
|
16, /* bitsize */ |
1611 |
|
FALSE, /* pc_relative */ |
1612 |
|
0, /* bitpos */ |
1613 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1614 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1615 |
|
"R_PPC64_GOT_TLSGD16_LO", /* name */ |
1616 |
|
FALSE, /* partial_inplace */ |
1617 |
|
0, /* src_mask */ |
1618 |
|
0xffff, /* dst_mask */ |
1619 |
|
FALSE), /* pcrel_offset */ |
1620 |
|
|
1621 |
|
/* Like GOT_TLSGD16_LO, but next higher group of 16 bits. */ |
1622 |
|
HOWTO (R_PPC64_GOT_TLSGD16_HI, |
1623 |
|
16, /* rightshift */ |
1624 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1625 |
|
16, /* bitsize */ |
1626 |
|
FALSE, /* pc_relative */ |
1627 |
|
0, /* bitpos */ |
1628 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1629 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1630 |
|
"R_PPC64_GOT_TLSGD16_HI", /* name */ |
1631 |
|
FALSE, /* partial_inplace */ |
1632 |
|
0, /* src_mask */ |
1633 |
|
0xffff, /* dst_mask */ |
1634 |
|
FALSE), /* pcrel_offset */ |
1635 |
|
|
1636 |
|
/* Like GOT_TLSGD16_HI, but adjust for low 16 bits. */ |
1637 |
|
HOWTO (R_PPC64_GOT_TLSGD16_HA, |
1638 |
|
16, /* rightshift */ |
1639 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1640 |
|
16, /* bitsize */ |
1641 |
|
FALSE, /* pc_relative */ |
1642 |
|
0, /* bitpos */ |
1643 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1644 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1645 |
|
"R_PPC64_GOT_TLSGD16_HA", /* name */ |
1646 |
|
FALSE, /* partial_inplace */ |
1647 |
|
0, /* src_mask */ |
1648 |
|
0xffff, /* dst_mask */ |
1649 |
|
FALSE), /* pcrel_offset */ |
1650 |
|
|
1651 |
|
/* Allocates two contiguous entries in the GOT to hold a tls_index structure, |
1652 |
|
with values (sym+add)@dtpmod and zero, and computes the offset to the |
1653 |
|
first entry relative to the TOC base (r2). */ |
1654 |
|
HOWTO (R_PPC64_GOT_TLSLD16, |
1655 |
|
0, /* rightshift */ |
1656 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1657 |
|
16, /* bitsize */ |
1658 |
|
FALSE, /* pc_relative */ |
1659 |
|
0, /* bitpos */ |
1660 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1661 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1662 |
|
"R_PPC64_GOT_TLSLD16", /* name */ |
1663 |
|
FALSE, /* partial_inplace */ |
1664 |
|
0, /* src_mask */ |
1665 |
|
0xffff, /* dst_mask */ |
1666 |
|
FALSE), /* pcrel_offset */ |
1667 |
|
|
1668 |
|
/* Like GOT_TLSLD16, but no overflow. */ |
1669 |
|
HOWTO (R_PPC64_GOT_TLSLD16_LO, |
1670 |
|
0, /* rightshift */ |
1671 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1672 |
|
16, /* bitsize */ |
1673 |
|
FALSE, /* pc_relative */ |
1674 |
|
0, /* bitpos */ |
1675 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1676 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1677 |
|
"R_PPC64_GOT_TLSLD16_LO", /* name */ |
1678 |
|
FALSE, /* partial_inplace */ |
1679 |
|
0, /* src_mask */ |
1680 |
|
0xffff, /* dst_mask */ |
1681 |
|
FALSE), /* pcrel_offset */ |
1682 |
|
|
1683 |
|
/* Like GOT_TLSLD16_LO, but next higher group of 16 bits. */ |
1684 |
|
HOWTO (R_PPC64_GOT_TLSLD16_HI, |
1685 |
|
16, /* rightshift */ |
1686 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1687 |
|
16, /* bitsize */ |
1688 |
|
FALSE, /* pc_relative */ |
1689 |
|
0, /* bitpos */ |
1690 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1691 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1692 |
|
"R_PPC64_GOT_TLSLD16_HI", /* name */ |
1693 |
|
FALSE, /* partial_inplace */ |
1694 |
|
0, /* src_mask */ |
1695 |
|
0xffff, /* dst_mask */ |
1696 |
|
FALSE), /* pcrel_offset */ |
1697 |
|
|
1698 |
|
/* Like GOT_TLSLD16_HI, but adjust for low 16 bits. */ |
1699 |
|
HOWTO (R_PPC64_GOT_TLSLD16_HA, |
1700 |
|
16, /* rightshift */ |
1701 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1702 |
|
16, /* bitsize */ |
1703 |
|
FALSE, /* pc_relative */ |
1704 |
|
0, /* bitpos */ |
1705 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1706 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1707 |
|
"R_PPC64_GOT_TLSLD16_HA", /* name */ |
1708 |
|
FALSE, /* partial_inplace */ |
1709 |
|
0, /* src_mask */ |
1710 |
|
0xffff, /* dst_mask */ |
1711 |
|
FALSE), /* pcrel_offset */ |
1712 |
|
|
1713 |
|
/* Allocates an entry in the GOT with value (sym+add)@dtprel, and computes |
1714 |
|
the offset to the entry relative to the TOC base (r2). */ |
1715 |
|
HOWTO (R_PPC64_GOT_DTPREL16_DS, |
1716 |
|
0, /* rightshift */ |
1717 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1718 |
|
16, /* bitsize */ |
1719 |
|
FALSE, /* pc_relative */ |
1720 |
|
0, /* bitpos */ |
1721 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1722 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1723 |
|
"R_PPC64_GOT_DTPREL16_DS", /* name */ |
1724 |
|
FALSE, /* partial_inplace */ |
1725 |
|
0, /* src_mask */ |
1726 |
|
0xfffc, /* dst_mask */ |
1727 |
|
FALSE), /* pcrel_offset */ |
1728 |
|
|
1729 |
|
/* Like GOT_DTPREL16_DS, but no overflow. */ |
1730 |
|
HOWTO (R_PPC64_GOT_DTPREL16_LO_DS, |
1731 |
|
0, /* rightshift */ |
1732 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1733 |
|
16, /* bitsize */ |
1734 |
|
FALSE, /* pc_relative */ |
1735 |
|
0, /* bitpos */ |
1736 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1737 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1738 |
|
"R_PPC64_GOT_DTPREL16_LO_DS", /* name */ |
1739 |
|
FALSE, /* partial_inplace */ |
1740 |
|
0, /* src_mask */ |
1741 |
|
0xfffc, /* dst_mask */ |
1742 |
|
FALSE), /* pcrel_offset */ |
1743 |
|
|
1744 |
|
/* Like GOT_DTPREL16_LO_DS, but next higher group of 16 bits. */ |
1745 |
|
HOWTO (R_PPC64_GOT_DTPREL16_HI, |
1746 |
|
16, /* rightshift */ |
1747 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1748 |
|
16, /* bitsize */ |
1749 |
|
FALSE, /* pc_relative */ |
1750 |
|
0, /* bitpos */ |
1751 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1752 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1753 |
|
"R_PPC64_GOT_DTPREL16_HI", /* name */ |
1754 |
|
FALSE, /* partial_inplace */ |
1755 |
|
0, /* src_mask */ |
1756 |
|
0xffff, /* dst_mask */ |
1757 |
|
FALSE), /* pcrel_offset */ |
1758 |
|
|
1759 |
|
/* Like GOT_DTPREL16_HI, but adjust for low 16 bits. */ |
1760 |
|
HOWTO (R_PPC64_GOT_DTPREL16_HA, |
1761 |
|
16, /* rightshift */ |
1762 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1763 |
|
16, /* bitsize */ |
1764 |
|
FALSE, /* pc_relative */ |
1765 |
|
0, /* bitpos */ |
1766 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1767 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1768 |
|
"R_PPC64_GOT_DTPREL16_HA", /* name */ |
1769 |
|
FALSE, /* partial_inplace */ |
1770 |
|
0, /* src_mask */ |
1771 |
|
0xffff, /* dst_mask */ |
1772 |
|
FALSE), /* pcrel_offset */ |
1773 |
|
|
1774 |
|
/* Allocates an entry in the GOT with value (sym+add)@tprel, and computes the |
1775 |
|
offset to the entry relative to the TOC base (r2). */ |
1776 |
|
HOWTO (R_PPC64_GOT_TPREL16_DS, |
1777 |
|
0, /* rightshift */ |
1778 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1779 |
|
16, /* bitsize */ |
1780 |
|
FALSE, /* pc_relative */ |
1781 |
|
0, /* bitpos */ |
1782 |
|
complain_overflow_signed, /* complain_on_overflow */ |
1783 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1784 |
|
"R_PPC64_GOT_TPREL16_DS", /* name */ |
1785 |
|
FALSE, /* partial_inplace */ |
1786 |
|
0, /* src_mask */ |
1787 |
|
0xfffc, /* dst_mask */ |
1788 |
|
FALSE), /* pcrel_offset */ |
1789 |
|
|
1790 |
|
/* Like GOT_TPREL16_DS, but no overflow. */ |
1791 |
|
HOWTO (R_PPC64_GOT_TPREL16_LO_DS, |
1792 |
|
0, /* rightshift */ |
1793 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1794 |
|
16, /* bitsize */ |
1795 |
|
FALSE, /* pc_relative */ |
1796 |
|
0, /* bitpos */ |
1797 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1798 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1799 |
|
"R_PPC64_GOT_TPREL16_LO_DS", /* name */ |
1800 |
|
FALSE, /* partial_inplace */ |
1801 |
|
0, /* src_mask */ |
1802 |
|
0xfffc, /* dst_mask */ |
1803 |
|
FALSE), /* pcrel_offset */ |
1804 |
|
|
1805 |
|
/* Like GOT_TPREL16_LO_DS, but next higher group of 16 bits. */ |
1806 |
|
HOWTO (R_PPC64_GOT_TPREL16_HI, |
1807 |
|
16, /* rightshift */ |
1808 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1809 |
|
16, /* bitsize */ |
1810 |
|
FALSE, /* pc_relative */ |
1811 |
|
0, /* bitpos */ |
1812 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1813 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1814 |
|
"R_PPC64_GOT_TPREL16_HI", /* name */ |
1815 |
|
FALSE, /* partial_inplace */ |
1816 |
|
0, /* src_mask */ |
1817 |
|
0xffff, /* dst_mask */ |
1818 |
|
FALSE), /* pcrel_offset */ |
1819 |
|
|
1820 |
|
/* Like GOT_TPREL16_HI, but adjust for low 16 bits. */ |
1821 |
|
HOWTO (R_PPC64_GOT_TPREL16_HA, |
1822 |
|
16, /* rightshift */ |
1823 |
|
1, /* size (0 = byte, 1 = short, 2 = long) */ |
1824 |
|
16, /* bitsize */ |
1825 |
|
FALSE, /* pc_relative */ |
1826 |
|
0, /* bitpos */ |
1827 |
|
complain_overflow_dont, /* complain_on_overflow */ |
1828 |
|
ppc64_elf_unhandled_reloc, /* special_function */ |
1829 |
|
"R_PPC64_GOT_TPREL16_HA", /* name */ |
1830 |
|
FALSE, /* partial_inplace */ |
1831 |
|
0, /* src_mask */ |
1832 |
|
0xffff, /* dst_mask */ |
1833 |
|
FALSE), /* pcrel_offset */ |
1834 |
|
|
1835 |
/* GNU extension to record C++ vtable hierarchy. */ |
/* GNU extension to record C++ vtable hierarchy. */ |
1836 |
HOWTO (R_PPC64_GNU_VTINHERIT, /* type */ |
HOWTO (R_PPC64_GNU_VTINHERIT, /* type */ |
1837 |
0, /* rightshift */ |
0, /* rightshift */ |
1838 |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
1839 |
0, /* bitsize */ |
0, /* bitsize */ |
1840 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1841 |
0, /* bitpos */ |
0, /* bitpos */ |
1842 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1843 |
NULL, /* special_function */ |
NULL, /* special_function */ |
1844 |
"R_PPC64_GNU_VTINHERIT", /* name */ |
"R_PPC64_GNU_VTINHERIT", /* name */ |
1845 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1846 |
0, /* src_mask */ |
0, /* src_mask */ |
1847 |
0, /* dst_mask */ |
0, /* dst_mask */ |
1848 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1849 |
|
|
1850 |
/* GNU extension to record C++ vtable member usage. */ |
/* GNU extension to record C++ vtable member usage. */ |
1851 |
HOWTO (R_PPC64_GNU_VTENTRY, /* type */ |
HOWTO (R_PPC64_GNU_VTENTRY, /* type */ |
1852 |
0, /* rightshift */ |
0, /* rightshift */ |
1853 |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
1854 |
0, /* bitsize */ |
0, /* bitsize */ |
1855 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
1856 |
0, /* bitpos */ |
0, /* bitpos */ |
1857 |
complain_overflow_dont, /* complain_on_overflow */ |
complain_overflow_dont, /* complain_on_overflow */ |
1858 |
NULL, /* special_function */ |
NULL, /* special_function */ |
1859 |
"R_PPC64_GNU_VTENTRY", /* name */ |
"R_PPC64_GNU_VTENTRY", /* name */ |
1860 |
false, /* partial_inplace */ |
FALSE, /* partial_inplace */ |
1861 |
0, /* src_mask */ |
0, /* src_mask */ |
1862 |
0, /* dst_mask */ |
0, /* dst_mask */ |
1863 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
1864 |
}; |
}; |
1865 |
|
|
1866 |
|
|
1868 |
be done. */ |
be done. */ |
1869 |
|
|
1870 |
static void |
static void |
1871 |
ppc_howto_init () |
ppc_howto_init (void) |
1872 |
{ |
{ |
1873 |
unsigned int i, type; |
unsigned int i, type; |
1874 |
|
|
1884 |
} |
} |
1885 |
|
|
1886 |
static reloc_howto_type * |
static reloc_howto_type * |
1887 |
ppc64_elf_reloc_type_lookup (abfd, code) |
ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
1888 |
bfd *abfd ATTRIBUTE_UNUSED; |
bfd_reloc_code_real_type code) |
|
bfd_reloc_code_real_type code; |
|
1889 |
{ |
{ |
1890 |
enum elf_ppc_reloc_type ppc_reloc = R_PPC_NONE; |
enum elf_ppc64_reloc_type r = R_PPC64_NONE; |
1891 |
|
|
1892 |
if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) |
if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) |
1893 |
/* Initialize howto table if needed. */ |
/* Initialize howto table if needed. */ |
1894 |
ppc_howto_init (); |
ppc_howto_init (); |
1895 |
|
|
1896 |
switch ((int) code) |
switch (code) |
1897 |
{ |
{ |
1898 |
default: |
default: |
1899 |
return (reloc_howto_type *) NULL; |
return NULL; |
1900 |
|
|
1901 |
case BFD_RELOC_NONE: ppc_reloc = R_PPC64_NONE; |
case BFD_RELOC_NONE: r = R_PPC64_NONE; |
1902 |
|
break; |
1903 |
|
case BFD_RELOC_32: r = R_PPC64_ADDR32; |
1904 |
|
break; |
1905 |
|
case BFD_RELOC_PPC_BA26: r = R_PPC64_ADDR24; |
1906 |
|
break; |
1907 |
|
case BFD_RELOC_16: r = R_PPC64_ADDR16; |
1908 |
|
break; |
1909 |
|
case BFD_RELOC_LO16: r = R_PPC64_ADDR16_LO; |
1910 |
|
break; |
1911 |
|
case BFD_RELOC_HI16: r = R_PPC64_ADDR16_HI; |
1912 |
|
break; |
1913 |
|
case BFD_RELOC_HI16_S: r = R_PPC64_ADDR16_HA; |
1914 |
|
break; |
1915 |
|
case BFD_RELOC_PPC_BA16: r = R_PPC64_ADDR14; |
1916 |
|
break; |
1917 |
|
case BFD_RELOC_PPC_BA16_BRTAKEN: r = R_PPC64_ADDR14_BRTAKEN; |
1918 |
|
break; |
1919 |
|
case BFD_RELOC_PPC_BA16_BRNTAKEN: r = R_PPC64_ADDR14_BRNTAKEN; |
1920 |
|
break; |
1921 |
|
case BFD_RELOC_PPC_B26: r = R_PPC64_REL24; |
1922 |
|
break; |
1923 |
|
case BFD_RELOC_PPC_B16: r = R_PPC64_REL14; |
1924 |
|
break; |
1925 |
|
case BFD_RELOC_PPC_B16_BRTAKEN: r = R_PPC64_REL14_BRTAKEN; |
1926 |
|
break; |
1927 |
|
case BFD_RELOC_PPC_B16_BRNTAKEN: r = R_PPC64_REL14_BRNTAKEN; |
1928 |
|
break; |
1929 |
|
case BFD_RELOC_16_GOTOFF: r = R_PPC64_GOT16; |
1930 |
|
break; |
1931 |
|
case BFD_RELOC_LO16_GOTOFF: r = R_PPC64_GOT16_LO; |
1932 |
|
break; |
1933 |
|
case BFD_RELOC_HI16_GOTOFF: r = R_PPC64_GOT16_HI; |
1934 |
|
break; |
1935 |
|
case BFD_RELOC_HI16_S_GOTOFF: r = R_PPC64_GOT16_HA; |
1936 |
|
break; |
1937 |
|
case BFD_RELOC_PPC_COPY: r = R_PPC64_COPY; |
1938 |
|
break; |
1939 |
|
case BFD_RELOC_PPC_GLOB_DAT: r = R_PPC64_GLOB_DAT; |
1940 |
|
break; |
1941 |
|
case BFD_RELOC_32_PCREL: r = R_PPC64_REL32; |
1942 |
|
break; |
1943 |
|
case BFD_RELOC_32_PLTOFF: r = R_PPC64_PLT32; |
1944 |
break; |
break; |
1945 |
case BFD_RELOC_32: ppc_reloc = R_PPC64_ADDR32; |
case BFD_RELOC_32_PLT_PCREL: r = R_PPC64_PLTREL32; |
1946 |
break; |
break; |
1947 |
case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC64_ADDR24; |
case BFD_RELOC_LO16_PLTOFF: r = R_PPC64_PLT16_LO; |
1948 |
break; |
break; |
1949 |
case BFD_RELOC_16: ppc_reloc = R_PPC64_ADDR16; |
case BFD_RELOC_HI16_PLTOFF: r = R_PPC64_PLT16_HI; |
1950 |
break; |
break; |
1951 |
case BFD_RELOC_LO16: ppc_reloc = R_PPC64_ADDR16_LO; |
case BFD_RELOC_HI16_S_PLTOFF: r = R_PPC64_PLT16_HA; |
1952 |
break; |
break; |
1953 |
case BFD_RELOC_HI16: ppc_reloc = R_PPC64_ADDR16_HI; |
case BFD_RELOC_16_BASEREL: r = R_PPC64_SECTOFF; |
1954 |
break; |
break; |
1955 |
case BFD_RELOC_HI16_S: ppc_reloc = R_PPC64_ADDR16_HA; |
case BFD_RELOC_LO16_BASEREL: r = R_PPC64_SECTOFF_LO; |
1956 |
break; |
break; |
1957 |
case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC64_ADDR14; |
case BFD_RELOC_HI16_BASEREL: r = R_PPC64_SECTOFF_HI; |
1958 |
break; |
break; |
1959 |
case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC64_ADDR14_BRTAKEN; |
case BFD_RELOC_HI16_S_BASEREL: r = R_PPC64_SECTOFF_HA; |
1960 |
break; |
break; |
1961 |
case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC64_ADDR14_BRNTAKEN; |
case BFD_RELOC_CTOR: r = R_PPC64_ADDR64; |
1962 |
break; |
break; |
1963 |
case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC64_REL24; |
case BFD_RELOC_64: r = R_PPC64_ADDR64; |
1964 |
break; |
break; |
1965 |
case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC64_REL14; |
case BFD_RELOC_PPC64_HIGHER: r = R_PPC64_ADDR16_HIGHER; |
1966 |
break; |
break; |
1967 |
case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC64_REL14_BRTAKEN; |
case BFD_RELOC_PPC64_HIGHER_S: r = R_PPC64_ADDR16_HIGHERA; |
1968 |
break; |
break; |
1969 |
case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC64_REL14_BRNTAKEN; |
case BFD_RELOC_PPC64_HIGHEST: r = R_PPC64_ADDR16_HIGHEST; |
1970 |
break; |
break; |
1971 |
case BFD_RELOC_16_GOTOFF: ppc_reloc = R_PPC64_GOT16; |
case BFD_RELOC_PPC64_HIGHEST_S: r = R_PPC64_ADDR16_HIGHESTA; |
1972 |
break; |
break; |
1973 |
case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC64_GOT16_LO; |
case BFD_RELOC_64_PCREL: r = R_PPC64_REL64; |
1974 |
break; |
break; |
1975 |
case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC64_GOT16_HI; |
case BFD_RELOC_64_PLTOFF: r = R_PPC64_PLT64; |
1976 |
break; |
break; |
1977 |
case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC64_GOT16_HA; |
case BFD_RELOC_64_PLT_PCREL: r = R_PPC64_PLTREL64; |
1978 |
break; |
break; |
1979 |
case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC64_COPY; |
case BFD_RELOC_PPC_TOC16: r = R_PPC64_TOC16; |
1980 |
break; |
break; |
1981 |
case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC64_GLOB_DAT; |
case BFD_RELOC_PPC64_TOC16_LO: r = R_PPC64_TOC16_LO; |
1982 |
break; |
break; |
1983 |
case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC64_REL32; |
case BFD_RELOC_PPC64_TOC16_HI: r = R_PPC64_TOC16_HI; |
1984 |
break; |
break; |
1985 |
case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC64_PLT32; |
case BFD_RELOC_PPC64_TOC16_HA: r = R_PPC64_TOC16_HA; |
1986 |
break; |
break; |
1987 |
case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC64_PLTREL32; |
case BFD_RELOC_PPC64_TOC: r = R_PPC64_TOC; |
1988 |
break; |
break; |
1989 |
case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC64_PLT16_LO; |
case BFD_RELOC_PPC64_PLTGOT16: r = R_PPC64_PLTGOT16; |
1990 |
break; |
break; |
1991 |
case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC64_PLT16_HI; |
case BFD_RELOC_PPC64_PLTGOT16_LO: r = R_PPC64_PLTGOT16_LO; |
1992 |
break; |
break; |
1993 |
case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC64_PLT16_HA; |
case BFD_RELOC_PPC64_PLTGOT16_HI: r = R_PPC64_PLTGOT16_HI; |
1994 |
break; |
break; |
1995 |
case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC64_SECTOFF; |
case BFD_RELOC_PPC64_PLTGOT16_HA: r = R_PPC64_PLTGOT16_HA; |
1996 |
break; |
break; |
1997 |
case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC64_SECTOFF_LO; |
case BFD_RELOC_PPC64_ADDR16_DS: r = R_PPC64_ADDR16_DS; |
1998 |
break; |
break; |
1999 |
case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC64_SECTOFF_HI; |
case BFD_RELOC_PPC64_ADDR16_LO_DS: r = R_PPC64_ADDR16_LO_DS; |
2000 |
break; |
break; |
2001 |
case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC64_SECTOFF_HA; |
case BFD_RELOC_PPC64_GOT16_DS: r = R_PPC64_GOT16_DS; |
2002 |
break; |
break; |
2003 |
case BFD_RELOC_CTOR: ppc_reloc = R_PPC64_ADDR64; |
case BFD_RELOC_PPC64_GOT16_LO_DS: r = R_PPC64_GOT16_LO_DS; |
2004 |
break; |
break; |
2005 |
case BFD_RELOC_64: ppc_reloc = R_PPC64_ADDR64; |
case BFD_RELOC_PPC64_PLT16_LO_DS: r = R_PPC64_PLT16_LO_DS; |
2006 |
break; |
break; |
2007 |
case BFD_RELOC_PPC64_HIGHER: ppc_reloc = R_PPC64_ADDR16_HIGHER; |
case BFD_RELOC_PPC64_SECTOFF_DS: r = R_PPC64_SECTOFF_DS; |
2008 |
break; |
break; |
2009 |
case BFD_RELOC_PPC64_HIGHER_S: ppc_reloc = R_PPC64_ADDR16_HIGHERA; |
case BFD_RELOC_PPC64_SECTOFF_LO_DS: r = R_PPC64_SECTOFF_LO_DS; |
2010 |
break; |
break; |
2011 |
case BFD_RELOC_PPC64_HIGHEST: ppc_reloc = R_PPC64_ADDR16_HIGHEST; |
case BFD_RELOC_PPC64_TOC16_DS: r = R_PPC64_TOC16_DS; |
2012 |
break; |
break; |
2013 |
case BFD_RELOC_PPC64_HIGHEST_S: ppc_reloc = R_PPC64_ADDR16_HIGHESTA; |
case BFD_RELOC_PPC64_TOC16_LO_DS: r = R_PPC64_TOC16_LO_DS; |
2014 |
break; |
break; |
2015 |
case BFD_RELOC_64_PCREL: ppc_reloc = R_PPC64_REL64; |
case BFD_RELOC_PPC64_PLTGOT16_DS: r = R_PPC64_PLTGOT16_DS; |
2016 |
break; |
break; |
2017 |
case BFD_RELOC_64_PLTOFF: ppc_reloc = R_PPC64_PLT64; |
case BFD_RELOC_PPC64_PLTGOT16_LO_DS: r = R_PPC64_PLTGOT16_LO_DS; |
2018 |
break; |
break; |
2019 |
case BFD_RELOC_64_PLT_PCREL: ppc_reloc = R_PPC64_PLTREL64; |
case BFD_RELOC_PPC_TLS: r = R_PPC64_TLS; |
2020 |
break; |
break; |
2021 |
case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC64_TOC16; |
case BFD_RELOC_PPC_DTPMOD: r = R_PPC64_DTPMOD64; |
2022 |
break; |
break; |
2023 |
case BFD_RELOC_PPC64_TOC16_LO: ppc_reloc = R_PPC64_TOC16_LO; |
case BFD_RELOC_PPC_TPREL16: r = R_PPC64_TPREL16; |
2024 |
break; |
break; |
2025 |
case BFD_RELOC_PPC64_TOC16_HI: ppc_reloc = R_PPC64_TOC16_HI; |
case BFD_RELOC_PPC_TPREL16_LO: r = R_PPC64_TPREL16_LO; |
2026 |
break; |
break; |
2027 |
case BFD_RELOC_PPC64_TOC16_HA: ppc_reloc = R_PPC64_TOC16_HA; |
case BFD_RELOC_PPC_TPREL16_HI: r = R_PPC64_TPREL16_HI; |
2028 |
break; |
break; |
2029 |
case BFD_RELOC_PPC64_TOC: ppc_reloc = R_PPC64_TOC; |
case BFD_RELOC_PPC_TPREL16_HA: r = R_PPC64_TPREL16_HA; |
2030 |
break; |
break; |
2031 |
case BFD_RELOC_PPC64_PLTGOT16: ppc_reloc = R_PPC64_PLTGOT16; |
case BFD_RELOC_PPC_TPREL: r = R_PPC64_TPREL64; |
2032 |
break; |
break; |
2033 |
case BFD_RELOC_PPC64_PLTGOT16_LO: ppc_reloc = R_PPC64_PLTGOT16_LO; |
case BFD_RELOC_PPC_DTPREL16: r = R_PPC64_DTPREL16; |
2034 |
break; |
break; |
2035 |
case BFD_RELOC_PPC64_PLTGOT16_HI: ppc_reloc = R_PPC64_PLTGOT16_HI; |
case BFD_RELOC_PPC_DTPREL16_LO: r = R_PPC64_DTPREL16_LO; |
2036 |
break; |
break; |
2037 |
case BFD_RELOC_PPC64_PLTGOT16_HA: ppc_reloc = R_PPC64_PLTGOT16_HA; |
case BFD_RELOC_PPC_DTPREL16_HI: r = R_PPC64_DTPREL16_HI; |
2038 |
break; |
break; |
2039 |
case BFD_RELOC_PPC64_ADDR16_DS: ppc_reloc = R_PPC64_ADDR16_DS; |
case BFD_RELOC_PPC_DTPREL16_HA: r = R_PPC64_DTPREL16_HA; |
2040 |
break; |
break; |
2041 |
case BFD_RELOC_PPC64_ADDR16_LO_DS: ppc_reloc = R_PPC64_ADDR16_LO_DS; |
case BFD_RELOC_PPC_DTPREL: r = R_PPC64_DTPREL64; |
2042 |
break; |
break; |
2043 |
case BFD_RELOC_PPC64_GOT16_DS: ppc_reloc = R_PPC64_GOT16_DS; |
case BFD_RELOC_PPC_GOT_TLSGD16: r = R_PPC64_GOT_TLSGD16; |
2044 |
break; |
break; |
2045 |
case BFD_RELOC_PPC64_GOT16_LO_DS: ppc_reloc = R_PPC64_GOT16_LO_DS; |
case BFD_RELOC_PPC_GOT_TLSGD16_LO: r = R_PPC64_GOT_TLSGD16_LO; |
2046 |
break; |
break; |
2047 |
case BFD_RELOC_PPC64_PLT16_LO_DS: ppc_reloc = R_PPC64_PLT16_LO_DS; |
case BFD_RELOC_PPC_GOT_TLSGD16_HI: r = R_PPC64_GOT_TLSGD16_HI; |
2048 |
break; |
break; |
2049 |
case BFD_RELOC_PPC64_SECTOFF_DS: ppc_reloc = R_PPC64_SECTOFF_DS; |
case BFD_RELOC_PPC_GOT_TLSGD16_HA: r = R_PPC64_GOT_TLSGD16_HA; |
2050 |
break; |
break; |
2051 |
case BFD_RELOC_PPC64_SECTOFF_LO_DS: ppc_reloc = R_PPC64_SECTOFF_LO_DS; |
case BFD_RELOC_PPC_GOT_TLSLD16: r = R_PPC64_GOT_TLSLD16; |
2052 |
break; |
break; |
2053 |
case BFD_RELOC_PPC64_TOC16_DS: ppc_reloc = R_PPC64_TOC16_DS; |
case BFD_RELOC_PPC_GOT_TLSLD16_LO: r = R_PPC64_GOT_TLSLD16_LO; |
2054 |
break; |
break; |
2055 |
case BFD_RELOC_PPC64_TOC16_LO_DS: ppc_reloc = R_PPC64_TOC16_LO_DS; |
case BFD_RELOC_PPC_GOT_TLSLD16_HI: r = R_PPC64_GOT_TLSLD16_HI; |
2056 |
break; |
break; |
2057 |
case BFD_RELOC_PPC64_PLTGOT16_DS: ppc_reloc = R_PPC64_PLTGOT16_DS; |
case BFD_RELOC_PPC_GOT_TLSLD16_HA: r = R_PPC64_GOT_TLSLD16_HA; |
2058 |
break; |
break; |
2059 |
case BFD_RELOC_PPC64_PLTGOT16_LO_DS: ppc_reloc = R_PPC64_PLTGOT16_LO_DS; |
case BFD_RELOC_PPC_GOT_TPREL16: r = R_PPC64_GOT_TPREL16_DS; |
2060 |
break; |
break; |
2061 |
case BFD_RELOC_VTABLE_INHERIT: ppc_reloc = R_PPC64_GNU_VTINHERIT; |
case BFD_RELOC_PPC_GOT_TPREL16_LO: r = R_PPC64_GOT_TPREL16_LO_DS; |
2062 |
break; |
break; |
2063 |
case BFD_RELOC_VTABLE_ENTRY: ppc_reloc = R_PPC64_GNU_VTENTRY; |
case BFD_RELOC_PPC_GOT_TPREL16_HI: r = R_PPC64_GOT_TPREL16_HI; |
2064 |
|
break; |
2065 |
|
case BFD_RELOC_PPC_GOT_TPREL16_HA: r = R_PPC64_GOT_TPREL16_HA; |
2066 |
|
break; |
2067 |
|
case BFD_RELOC_PPC_GOT_DTPREL16: r = R_PPC64_GOT_DTPREL16_DS; |
2068 |
|
break; |
2069 |
|
case BFD_RELOC_PPC_GOT_DTPREL16_LO: r = R_PPC64_GOT_DTPREL16_LO_DS; |
2070 |
|
break; |
2071 |
|
case BFD_RELOC_PPC_GOT_DTPREL16_HI: r = R_PPC64_GOT_DTPREL16_HI; |
2072 |
|
break; |
2073 |
|
case BFD_RELOC_PPC_GOT_DTPREL16_HA: r = R_PPC64_GOT_DTPREL16_HA; |
2074 |
|
break; |
2075 |
|
case BFD_RELOC_PPC64_TPREL16_DS: r = R_PPC64_TPREL16_DS; |
2076 |
|
break; |
2077 |
|
case BFD_RELOC_PPC64_TPREL16_LO_DS: r = R_PPC64_TPREL16_LO_DS; |
2078 |
|
break; |
2079 |
|
case BFD_RELOC_PPC64_TPREL16_HIGHER: r = R_PPC64_TPREL16_HIGHER; |
2080 |
|
break; |
2081 |
|
case BFD_RELOC_PPC64_TPREL16_HIGHERA: r = R_PPC64_TPREL16_HIGHERA; |
2082 |
|
break; |
2083 |
|
case BFD_RELOC_PPC64_TPREL16_HIGHEST: r = R_PPC64_TPREL16_HIGHEST; |
2084 |
|
break; |
2085 |
|
case BFD_RELOC_PPC64_TPREL16_HIGHESTA: r = R_PPC64_TPREL16_HIGHESTA; |
2086 |
|
break; |
2087 |
|
case BFD_RELOC_PPC64_DTPREL16_DS: r = R_PPC64_DTPREL16_DS; |
2088 |
|
break; |
2089 |
|
case BFD_RELOC_PPC64_DTPREL16_LO_DS: r = R_PPC64_DTPREL16_LO_DS; |
2090 |
|
break; |
2091 |
|
case BFD_RELOC_PPC64_DTPREL16_HIGHER: r = R_PPC64_DTPREL16_HIGHER; |
2092 |
|
break; |
2093 |
|
case BFD_RELOC_PPC64_DTPREL16_HIGHERA: r = R_PPC64_DTPREL16_HIGHERA; |
2094 |
|
break; |
2095 |
|
case BFD_RELOC_PPC64_DTPREL16_HIGHEST: r = R_PPC64_DTPREL16_HIGHEST; |
2096 |
|
break; |
2097 |
|
case BFD_RELOC_PPC64_DTPREL16_HIGHESTA: r = R_PPC64_DTPREL16_HIGHESTA; |
2098 |
|
break; |
2099 |
|
case BFD_RELOC_VTABLE_INHERIT: r = R_PPC64_GNU_VTINHERIT; |
2100 |
|
break; |
2101 |
|
case BFD_RELOC_VTABLE_ENTRY: r = R_PPC64_GNU_VTENTRY; |
2102 |
break; |
break; |
2103 |
} |
} |
2104 |
|
|
2105 |
return ppc64_elf_howto_table[(int) ppc_reloc]; |
return ppc64_elf_howto_table[r]; |
2106 |
}; |
}; |
2107 |
|
|
2108 |
/* Set the howto pointer for a PowerPC ELF reloc. */ |
/* Set the howto pointer for a PowerPC ELF reloc. */ |
2109 |
|
|
2110 |
static void |
static void |
2111 |
ppc64_elf_info_to_howto (abfd, cache_ptr, dst) |
ppc64_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, |
2112 |
bfd *abfd ATTRIBUTE_UNUSED; |
Elf_Internal_Rela *dst) |
|
arelent *cache_ptr; |
|
|
Elf64_Internal_Rela *dst; |
|
2113 |
{ |
{ |
2114 |
unsigned int type; |
unsigned int type; |
2115 |
|
|
2123 |
cache_ptr->howto = ppc64_elf_howto_table[type]; |
cache_ptr->howto = ppc64_elf_howto_table[type]; |
2124 |
} |
} |
2125 |
|
|
2126 |
/* Handle the R_PPC_ADDR16_HA and similar relocs. */ |
/* Handle the R_PPC64_ADDR16_HA and similar relocs. */ |
2127 |
|
|
2128 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2129 |
ppc64_elf_ha_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2130 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2131 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
|
arelent *reloc_entry; |
|
|
asymbol *symbol; |
|
|
PTR data; |
|
|
asection *input_section; |
|
|
bfd *output_bfd; |
|
|
char **error_message; |
|
2132 |
{ |
{ |
2133 |
/* If this is a relocatable link (output_bfd test tells us), just |
/* If this is a relocatable link (output_bfd test tells us), just |
2134 |
call the generic function. Any adjustment will be done at final |
call the generic function. Any adjustment will be done at final |
2145 |
} |
} |
2146 |
|
|
2147 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2148 |
ppc64_elf_brtaken_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_branch_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2149 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2150 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
2151 |
arelent *reloc_entry; |
{ |
2152 |
asymbol *symbol; |
if (output_bfd != NULL) |
2153 |
PTR data; |
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, |
2154 |
asection *input_section; |
input_section, output_bfd, error_message); |
2155 |
bfd *output_bfd; |
|
2156 |
char **error_message; |
if (strcmp (symbol->section->name, ".opd") == 0 |
2157 |
|
&& (symbol->section->owner->flags & DYNAMIC) == 0) |
2158 |
|
{ |
2159 |
|
bfd_vma dest = opd_entry_value (symbol->section, |
2160 |
|
symbol->value + reloc_entry->addend, |
2161 |
|
NULL, NULL); |
2162 |
|
if (dest != (bfd_vma) -1) |
2163 |
|
reloc_entry->addend = dest - (symbol->value |
2164 |
|
+ symbol->section->output_section->vma |
2165 |
|
+ symbol->section->output_offset); |
2166 |
|
} |
2167 |
|
return bfd_reloc_continue; |
2168 |
|
} |
2169 |
|
|
2170 |
|
static bfd_reloc_status_type |
2171 |
|
ppc64_elf_brtaken_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2172 |
|
void *data, asection *input_section, |
2173 |
|
bfd *output_bfd, char **error_message) |
2174 |
{ |
{ |
2175 |
long insn; |
long insn; |
2176 |
enum elf_ppc_reloc_type r_type; |
enum elf_ppc64_reloc_type r_type; |
2177 |
bfd_size_type octets; |
bfd_size_type octets; |
2178 |
/* Disabled until we sort out how ld should choose 'y' vs 'at'. */ |
/* Disabled until we sort out how ld should choose 'y' vs 'at'. */ |
2179 |
boolean is_power4 = false; |
bfd_boolean is_power4 = FALSE; |
2180 |
|
|
2181 |
/* If this is a relocatable link (output_bfd test tells us), just |
/* If this is a relocatable link (output_bfd test tells us), just |
2182 |
call the generic function. Any adjustment will be done at final |
call the generic function. Any adjustment will be done at final |
2188 |
octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
2189 |
insn = bfd_get_32 (abfd, (bfd_byte *) data + octets); |
insn = bfd_get_32 (abfd, (bfd_byte *) data + octets); |
2190 |
insn &= ~(0x01 << 21); |
insn &= ~(0x01 << 21); |
2191 |
r_type = (enum elf_ppc_reloc_type) reloc_entry->howto->type; |
r_type = reloc_entry->howto->type; |
2192 |
if (r_type == R_PPC64_ADDR14_BRTAKEN |
if (r_type == R_PPC64_ADDR14_BRTAKEN |
2193 |
|| r_type == R_PPC64_REL14_BRTAKEN) |
|| r_type == R_PPC64_REL14_BRTAKEN) |
2194 |
insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ |
insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ |
2203 |
else if ((insn & (0x14 << 21)) == (0x10 << 21)) |
else if ((insn & (0x14 << 21)) == (0x10 << 21)) |
2204 |
insn |= 0x08 << 21; |
insn |= 0x08 << 21; |
2205 |
else |
else |
2206 |
return bfd_reloc_continue; |
goto out; |
2207 |
} |
} |
2208 |
else |
else |
2209 |
{ |
{ |
2224 |
if ((bfd_signed_vma) (target - from) < 0) |
if ((bfd_signed_vma) (target - from) < 0) |
2225 |
insn ^= 0x01 << 21; |
insn ^= 0x01 << 21; |
2226 |
} |
} |
2227 |
bfd_put_32 (abfd, (bfd_vma) insn, (bfd_byte *) data + octets); |
bfd_put_32 (abfd, insn, (bfd_byte *) data + octets); |
2228 |
return bfd_reloc_continue; |
out: |
2229 |
|
return ppc64_elf_branch_reloc (abfd, reloc_entry, symbol, data, |
2230 |
|
input_section, output_bfd, error_message); |
2231 |
} |
} |
2232 |
|
|
2233 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2234 |
ppc64_elf_sectoff_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_sectoff_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2235 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2236 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
|
arelent *reloc_entry; |
|
|
asymbol *symbol; |
|
|
PTR data; |
|
|
asection *input_section; |
|
|
bfd *output_bfd; |
|
|
char **error_message; |
|
2237 |
{ |
{ |
2238 |
/* If this is a relocatable link (output_bfd test tells us), just |
/* If this is a relocatable link (output_bfd test tells us), just |
2239 |
call the generic function. Any adjustment will be done at final |
call the generic function. Any adjustment will be done at final |
2248 |
} |
} |
2249 |
|
|
2250 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2251 |
ppc64_elf_sectoff_ha_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_sectoff_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2252 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2253 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
|
arelent *reloc_entry; |
|
|
asymbol *symbol; |
|
|
PTR data; |
|
|
asection *input_section; |
|
|
bfd *output_bfd; |
|
|
char **error_message; |
|
2254 |
{ |
{ |
2255 |
/* If this is a relocatable link (output_bfd test tells us), just |
/* If this is a relocatable link (output_bfd test tells us), just |
2256 |
call the generic function. Any adjustment will be done at final |
call the generic function. Any adjustment will be done at final |
2268 |
} |
} |
2269 |
|
|
2270 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2271 |
ppc64_elf_toc_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_toc_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2272 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2273 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
|
arelent *reloc_entry; |
|
|
asymbol *symbol; |
|
|
PTR data; |
|
|
asection *input_section; |
|
|
bfd *output_bfd; |
|
|
char **error_message; |
|
2274 |
{ |
{ |
2275 |
bfd_vma TOCstart; |
bfd_vma TOCstart; |
2276 |
|
|
2291 |
} |
} |
2292 |
|
|
2293 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2294 |
ppc64_elf_toc_ha_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_toc_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2295 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2296 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
|
arelent *reloc_entry; |
|
|
asymbol *symbol; |
|
|
PTR data; |
|
|
asection *input_section; |
|
|
bfd *output_bfd; |
|
|
char **error_message; |
|
2297 |
{ |
{ |
2298 |
bfd_vma TOCstart; |
bfd_vma TOCstart; |
2299 |
|
|
2317 |
} |
} |
2318 |
|
|
2319 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2320 |
ppc64_elf_toc64_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_toc64_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2321 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2322 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
|
arelent *reloc_entry; |
|
|
asymbol *symbol; |
|
|
PTR data; |
|
|
asection *input_section; |
|
|
bfd *output_bfd; |
|
|
char **error_message; |
|
2323 |
{ |
{ |
2324 |
bfd_vma TOCstart; |
bfd_vma TOCstart; |
2325 |
bfd_size_type octets; |
bfd_size_type octets; |
2341 |
} |
} |
2342 |
|
|
2343 |
static bfd_reloc_status_type |
static bfd_reloc_status_type |
2344 |
ppc64_elf_unhandled_reloc (abfd, reloc_entry, symbol, data, |
ppc64_elf_unhandled_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
2345 |
input_section, output_bfd, error_message) |
void *data, asection *input_section, |
2346 |
bfd *abfd; |
bfd *output_bfd, char **error_message) |
|
arelent *reloc_entry; |
|
|
asymbol *symbol; |
|
|
PTR data; |
|
|
asection *input_section; |
|
|
bfd *output_bfd; |
|
|
char **error_message; |
|
2347 |
{ |
{ |
2348 |
/* If this is a relocatable link (output_bfd test tells us), just |
/* If this is a relocatable link (output_bfd test tells us), just |
2349 |
call the generic function. Any adjustment will be done at final |
call the generic function. Any adjustment will be done at final |
2362 |
return bfd_reloc_dangerous; |
return bfd_reloc_dangerous; |
2363 |
} |
} |
2364 |
|
|
2365 |
|
struct ppc64_elf_obj_tdata |
2366 |
|
{ |
2367 |
|
struct elf_obj_tdata elf; |
2368 |
|
|
2369 |
|
/* Shortcuts to dynamic linker sections. */ |
2370 |
|
asection *got; |
2371 |
|
asection *relgot; |
2372 |
|
|
2373 |
|
union { |
2374 |
|
/* Used during garbage collection. We attach global symbols defined |
2375 |
|
on removed .opd entries to this section so that the sym is removed. */ |
2376 |
|
asection *deleted_section; |
2377 |
|
|
2378 |
|
/* Used when adding symbols. */ |
2379 |
|
bfd_boolean has_dotsym; |
2380 |
|
} u; |
2381 |
|
|
2382 |
|
/* TLS local dynamic got entry handling. Suppose for multiple GOT |
2383 |
|
sections means we potentially need one of these for each input bfd. */ |
2384 |
|
union { |
2385 |
|
bfd_signed_vma refcount; |
2386 |
|
bfd_vma offset; |
2387 |
|
} tlsld_got; |
2388 |
|
|
2389 |
|
/* A copy of relocs before they are modified for --emit-relocs. */ |
2390 |
|
Elf_Internal_Rela *opd_relocs; |
2391 |
|
}; |
2392 |
|
|
2393 |
|
#define ppc64_elf_tdata(bfd) \ |
2394 |
|
((struct ppc64_elf_obj_tdata *) (bfd)->tdata.any) |
2395 |
|
|
2396 |
|
#define ppc64_tlsld_got(bfd) \ |
2397 |
|
(&ppc64_elf_tdata (bfd)->tlsld_got) |
2398 |
|
|
2399 |
|
/* Override the generic function because we store some extras. */ |
2400 |
|
|
2401 |
|
static bfd_boolean |
2402 |
|
ppc64_elf_mkobject (bfd *abfd) |
2403 |
|
{ |
2404 |
|
bfd_size_type amt = sizeof (struct ppc64_elf_obj_tdata); |
2405 |
|
abfd->tdata.any = bfd_zalloc (abfd, amt); |
2406 |
|
if (abfd->tdata.any == NULL) |
2407 |
|
return FALSE; |
2408 |
|
return TRUE; |
2409 |
|
} |
2410 |
|
|
2411 |
|
/* Return 1 if target is one of ours. */ |
2412 |
|
|
2413 |
|
static bfd_boolean |
2414 |
|
is_ppc64_elf_target (const struct bfd_target *targ) |
2415 |
|
{ |
2416 |
|
extern const bfd_target bfd_elf64_powerpc_vec; |
2417 |
|
extern const bfd_target bfd_elf64_powerpcle_vec; |
2418 |
|
|
2419 |
|
return targ == &bfd_elf64_powerpc_vec || targ == &bfd_elf64_powerpcle_vec; |
2420 |
|
} |
2421 |
|
|
2422 |
/* Fix bad default arch selected for a 64 bit input bfd when the |
/* Fix bad default arch selected for a 64 bit input bfd when the |
2423 |
default is 32 bit. */ |
default is 32 bit. */ |
2424 |
|
|
2425 |
static boolean |
static bfd_boolean |
2426 |
ppc64_elf_object_p (abfd) |
ppc64_elf_object_p (bfd *abfd) |
|
bfd *abfd; |
|
2427 |
{ |
{ |
2428 |
if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 32) |
if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 32) |
2429 |
{ |
{ |
2436 |
BFD_ASSERT (abfd->arch_info->bits_per_word == 64); |
BFD_ASSERT (abfd->arch_info->bits_per_word == 64); |
2437 |
} |
} |
2438 |
} |
} |
2439 |
return true; |
return TRUE; |
2440 |
|
} |
2441 |
|
|
2442 |
|
/* Support for core dump NOTE sections. */ |
2443 |
|
|
2444 |
|
static bfd_boolean |
2445 |
|
ppc64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) |
2446 |
|
{ |
2447 |
|
size_t offset, size; |
2448 |
|
|
2449 |
|
if (note->descsz != 504) |
2450 |
|
return FALSE; |
2451 |
|
|
2452 |
|
/* pr_cursig */ |
2453 |
|
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); |
2454 |
|
|
2455 |
|
/* pr_pid */ |
2456 |
|
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32); |
2457 |
|
|
2458 |
|
/* pr_reg */ |
2459 |
|
offset = 112; |
2460 |
|
size = 384; |
2461 |
|
|
2462 |
|
/* Make a ".reg/999" section. */ |
2463 |
|
return _bfd_elfcore_make_pseudosection (abfd, ".reg", |
2464 |
|
size, note->descpos + offset); |
2465 |
|
} |
2466 |
|
|
2467 |
|
static bfd_boolean |
2468 |
|
ppc64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) |
2469 |
|
{ |
2470 |
|
if (note->descsz != 136) |
2471 |
|
return FALSE; |
2472 |
|
|
2473 |
|
elf_tdata (abfd)->core_program |
2474 |
|
= _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); |
2475 |
|
elf_tdata (abfd)->core_command |
2476 |
|
= _bfd_elfcore_strndup (abfd, note->descdata + 56, 80); |
2477 |
|
|
2478 |
|
return TRUE; |
2479 |
} |
} |
2480 |
|
|
2481 |
/* Merge backend specific data from an object file to the output |
/* Merge backend specific data from an object file to the output |
2482 |
object file when linking. */ |
object file when linking. */ |
2483 |
|
|
2484 |
static boolean |
static bfd_boolean |
2485 |
ppc64_elf_merge_private_bfd_data (ibfd, obfd) |
ppc64_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) |
|
bfd *ibfd; |
|
|
bfd *obfd; |
|
2486 |
{ |
{ |
2487 |
/* Check if we have the same endianess. */ |
/* Check if we have the same endianess. */ |
2488 |
if (ibfd->xvec->byteorder != obfd->xvec->byteorder |
if (ibfd->xvec->byteorder != obfd->xvec->byteorder |
2489 |
|
&& ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN |
2490 |
&& obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) |
&& obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) |
2491 |
{ |
{ |
2492 |
const char *msg; |
const char *msg; |
2493 |
|
|
2494 |
if (bfd_big_endian (ibfd)) |
if (bfd_big_endian (ibfd)) |
2495 |
msg = _("%s: compiled for a big endian system and target is little endian"); |
msg = _("%B: compiled for a big endian system " |
2496 |
|
"and target is little endian"); |
2497 |
else |
else |
2498 |
msg = _("%s: compiled for a little endian system and target is big endian"); |
msg = _("%B: compiled for a little endian system " |
2499 |
|
"and target is big endian"); |
2500 |
|
|
2501 |
(*_bfd_error_handler) (msg, bfd_archive_filename (ibfd)); |
(*_bfd_error_handler) (msg, ibfd); |
2502 |
|
|
2503 |
bfd_set_error (bfd_error_wrong_format); |
bfd_set_error (bfd_error_wrong_format); |
2504 |
return false; |
return FALSE; |
2505 |
|
} |
2506 |
|
|
2507 |
|
return TRUE; |
2508 |
|
} |
2509 |
|
|
2510 |
|
/* Add extra PPC sections. */ |
2511 |
|
|
2512 |
|
static struct bfd_elf_special_section const ppc64_elf_special_sections[]= |
2513 |
|
{ |
2514 |
|
{ ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, |
2515 |
|
{ ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, |
2516 |
|
{ ".plt", 4, 0, SHT_NOBITS, 0 }, |
2517 |
|
{ ".toc", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, |
2518 |
|
{ ".toc1", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, |
2519 |
|
{ ".tocbss", 7, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, |
2520 |
|
{ NULL, 0, 0, 0, 0 } |
2521 |
|
}; |
2522 |
|
|
2523 |
|
struct _ppc64_elf_section_data |
2524 |
|
{ |
2525 |
|
struct bfd_elf_section_data elf; |
2526 |
|
|
2527 |
|
/* An array with one entry for each opd function descriptor. */ |
2528 |
|
union |
2529 |
|
{ |
2530 |
|
/* Points to the function code section for local opd entries. */ |
2531 |
|
asection **func_sec; |
2532 |
|
/* After editing .opd, adjust references to opd local syms. */ |
2533 |
|
long *adjust; |
2534 |
|
} opd; |
2535 |
|
|
2536 |
|
/* An array for toc sections, indexed by offset/8. |
2537 |
|
Specifies the relocation symbol index used at a given toc offset. */ |
2538 |
|
unsigned *t_symndx; |
2539 |
|
}; |
2540 |
|
|
2541 |
|
#define ppc64_elf_section_data(sec) \ |
2542 |
|
((struct _ppc64_elf_section_data *) elf_section_data (sec)) |
2543 |
|
|
2544 |
|
static bfd_boolean |
2545 |
|
ppc64_elf_new_section_hook (bfd *abfd, asection *sec) |
2546 |
|
{ |
2547 |
|
struct _ppc64_elf_section_data *sdata; |
2548 |
|
bfd_size_type amt = sizeof (*sdata); |
2549 |
|
|
2550 |
|
sdata = bfd_zalloc (abfd, amt); |
2551 |
|
if (sdata == NULL) |
2552 |
|
return FALSE; |
2553 |
|
sec->used_by_bfd = sdata; |
2554 |
|
|
2555 |
|
return _bfd_elf_new_section_hook (abfd, sec); |
2556 |
|
} |
2557 |
|
|
2558 |
|
static void * |
2559 |
|
get_opd_info (asection * sec) |
2560 |
|
{ |
2561 |
|
if (sec != NULL |
2562 |
|
&& ppc64_elf_section_data (sec) != NULL |
2563 |
|
&& ppc64_elf_section_data (sec)->opd.adjust != NULL) |
2564 |
|
return ppc64_elf_section_data (sec)->opd.adjust; |
2565 |
|
return NULL; |
2566 |
|
} |
2567 |
|
|
2568 |
|
/* Parameters for the qsort hook. */ |
2569 |
|
static asection *synthetic_opd; |
2570 |
|
static bfd_boolean synthetic_relocatable; |
2571 |
|
|
2572 |
|
/* qsort comparison function for ppc64_elf_get_synthetic_symtab. */ |
2573 |
|
|
2574 |
|
static int |
2575 |
|
compare_symbols (const void *ap, const void *bp) |
2576 |
|
{ |
2577 |
|
const asymbol *a = * (const asymbol **) ap; |
2578 |
|
const asymbol *b = * (const asymbol **) bp; |
2579 |
|
|
2580 |
|
/* Section symbols first. */ |
2581 |
|
if ((a->flags & BSF_SECTION_SYM) && !(b->flags & BSF_SECTION_SYM)) |
2582 |
|
return -1; |
2583 |
|
if (!(a->flags & BSF_SECTION_SYM) && (b->flags & BSF_SECTION_SYM)) |
2584 |
|
return 1; |
2585 |
|
|
2586 |
|
/* then .opd symbols. */ |
2587 |
|
if (a->section == synthetic_opd && b->section != synthetic_opd) |
2588 |
|
return -1; |
2589 |
|
if (a->section != synthetic_opd && b->section == synthetic_opd) |
2590 |
|
return 1; |
2591 |
|
|
2592 |
|
/* then other code symbols. */ |
2593 |
|
if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) |
2594 |
|
== (SEC_CODE | SEC_ALLOC) |
2595 |
|
&& (b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) |
2596 |
|
!= (SEC_CODE | SEC_ALLOC)) |
2597 |
|
return -1; |
2598 |
|
|
2599 |
|
if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) |
2600 |
|
!= (SEC_CODE | SEC_ALLOC) |
2601 |
|
&& (b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) |
2602 |
|
== (SEC_CODE | SEC_ALLOC)) |
2603 |
|
return 1; |
2604 |
|
|
2605 |
|
if (synthetic_relocatable) |
2606 |
|
{ |
2607 |
|
if (a->section->id < b->section->id) |
2608 |
|
return -1; |
2609 |
|
|
2610 |
|
if (a->section->id > b->section->id) |
2611 |
|
return 1; |
2612 |
|
} |
2613 |
|
|
2614 |
|
if (a->value + a->section->vma < b->value + b->section->vma) |
2615 |
|
return -1; |
2616 |
|
|
2617 |
|
if (a->value + a->section->vma > b->value + b->section->vma) |
2618 |
|
return 1; |
2619 |
|
|
2620 |
|
return 0; |
2621 |
|
} |
2622 |
|
|
2623 |
|
/* Search SYMS for a symbol of the given VALUE. */ |
2624 |
|
|
2625 |
|
static asymbol * |
2626 |
|
sym_exists_at (asymbol **syms, long lo, long hi, int id, bfd_vma value) |
2627 |
|
{ |
2628 |
|
long mid; |
2629 |
|
|
2630 |
|
if (id == -1) |
2631 |
|
{ |
2632 |
|
while (lo < hi) |
2633 |
|
{ |
2634 |
|
mid = (lo + hi) >> 1; |
2635 |
|
if (syms[mid]->value + syms[mid]->section->vma < value) |
2636 |
|
lo = mid + 1; |
2637 |
|
else if (syms[mid]->value + syms[mid]->section->vma > value) |
2638 |
|
hi = mid; |
2639 |
|
else |
2640 |
|
return syms[mid]; |
2641 |
|
} |
2642 |
|
} |
2643 |
|
else |
2644 |
|
{ |
2645 |
|
while (lo < hi) |
2646 |
|
{ |
2647 |
|
mid = (lo + hi) >> 1; |
2648 |
|
if (syms[mid]->section->id < id) |
2649 |
|
lo = mid + 1; |
2650 |
|
else if (syms[mid]->section->id > id) |
2651 |
|
hi = mid; |
2652 |
|
else if (syms[mid]->value < value) |
2653 |
|
lo = mid + 1; |
2654 |
|
else if (syms[mid]->value > value) |
2655 |
|
hi = mid; |
2656 |
|
else |
2657 |
|
return syms[mid]; |
2658 |
|
} |
2659 |
|
} |
2660 |
|
return NULL; |
2661 |
|
} |
2662 |
|
|
2663 |
|
/* Create synthetic symbols, effectively restoring "dot-symbol" function |
2664 |
|
entry syms. */ |
2665 |
|
|
2666 |
|
static long |
2667 |
|
ppc64_elf_get_synthetic_symtab (bfd *abfd, |
2668 |
|
long static_count, asymbol **static_syms, |
2669 |
|
long dyn_count, asymbol **dyn_syms, |
2670 |
|
asymbol **ret) |
2671 |
|
{ |
2672 |
|
asymbol *s; |
2673 |
|
long i; |
2674 |
|
long count; |
2675 |
|
char *names; |
2676 |
|
long symcount, codesecsym, codesecsymend, secsymend, opdsymend; |
2677 |
|
asection *opd; |
2678 |
|
bfd_boolean relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0; |
2679 |
|
asymbol **syms; |
2680 |
|
|
2681 |
|
*ret = NULL; |
2682 |
|
|
2683 |
|
opd = bfd_get_section_by_name (abfd, ".opd"); |
2684 |
|
if (opd == NULL) |
2685 |
|
return 0; |
2686 |
|
|
2687 |
|
symcount = static_count; |
2688 |
|
if (!relocatable) |
2689 |
|
symcount += dyn_count; |
2690 |
|
if (symcount == 0) |
2691 |
|
return 0; |
2692 |
|
|
2693 |
|
syms = bfd_malloc ((symcount + 1) * sizeof (*syms)); |
2694 |
|
if (syms == NULL) |
2695 |
|
return -1; |
2696 |
|
|
2697 |
|
if (!relocatable && static_count != 0 && dyn_count != 0) |
2698 |
|
{ |
2699 |
|
/* Use both symbol tables. */ |
2700 |
|
memcpy (syms, static_syms, static_count * sizeof (*syms)); |
2701 |
|
memcpy (syms + static_count, dyn_syms, (dyn_count + 1) * sizeof (*syms)); |
2702 |
|
} |
2703 |
|
else if (!relocatable && static_count == 0) |
2704 |
|
memcpy (syms, dyn_syms, (symcount + 1) * sizeof (*syms)); |
2705 |
|
else |
2706 |
|
memcpy (syms, static_syms, (symcount + 1) * sizeof (*syms)); |
2707 |
|
|
2708 |
|
synthetic_opd = opd; |
2709 |
|
synthetic_relocatable = relocatable; |
2710 |
|
qsort (syms, symcount, sizeof (*syms), compare_symbols); |
2711 |
|
|
2712 |
|
if (!relocatable && symcount > 1) |
2713 |
|
{ |
2714 |
|
long j; |
2715 |
|
/* Trim duplicate syms, since we may have merged the normal and |
2716 |
|
dynamic symbols. Actually, we only care about syms that have |
2717 |
|
different values, so trim any with the same value. */ |
2718 |
|
for (i = 1, j = 1; i < symcount; ++i) |
2719 |
|
if (syms[i - 1]->value + syms[i - 1]->section->vma |
2720 |
|
!= syms[i]->value + syms[i]->section->vma) |
2721 |
|
syms[j++] = syms[i]; |
2722 |
|
symcount = j; |
2723 |
|
} |
2724 |
|
|
2725 |
|
i = 0; |
2726 |
|
if (syms[i]->section == opd) |
2727 |
|
++i; |
2728 |
|
codesecsym = i; |
2729 |
|
|
2730 |
|
for (; i < symcount; ++i) |
2731 |
|
if (((syms[i]->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) |
2732 |
|
!= (SEC_CODE | SEC_ALLOC)) |
2733 |
|
|| (syms[i]->flags & BSF_SECTION_SYM) == 0) |
2734 |
|
break; |
2735 |
|
codesecsymend = i; |
2736 |
|
|
2737 |
|
for (; i < symcount; ++i) |
2738 |
|
if ((syms[i]->flags & BSF_SECTION_SYM) == 0) |
2739 |
|
break; |
2740 |
|
secsymend = i; |
2741 |
|
|
2742 |
|
for (; i < symcount; ++i) |
2743 |
|
if (syms[i]->section != opd) |
2744 |
|
break; |
2745 |
|
opdsymend = i; |
2746 |
|
|
2747 |
|
for (; i < symcount; ++i) |
2748 |
|
if ((syms[i]->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) |
2749 |
|
!= (SEC_CODE | SEC_ALLOC)) |
2750 |
|
break; |
2751 |
|
symcount = i; |
2752 |
|
|
2753 |
|
count = 0; |
2754 |
|
if (opdsymend == secsymend) |
2755 |
|
goto done; |
2756 |
|
|
2757 |
|
if (relocatable) |
2758 |
|
{ |
2759 |
|
bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean); |
2760 |
|
arelent *r; |
2761 |
|
size_t size; |
2762 |
|
long relcount; |
2763 |
|
|
2764 |
|
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; |
2765 |
|
relcount = (opd->flags & SEC_RELOC) ? opd->reloc_count : 0; |
2766 |
|
if (relcount == 0) |
2767 |
|
goto done; |
2768 |
|
|
2769 |
|
if (!(*slurp_relocs) (abfd, opd, static_syms, FALSE)) |
2770 |
|
{ |
2771 |
|
count = -1; |
2772 |
|
goto done; |
2773 |
|
} |
2774 |
|
|
2775 |
|
size = 0; |
2776 |
|
for (i = secsymend, r = opd->relocation; i < opdsymend; ++i) |
2777 |
|
{ |
2778 |
|
asymbol *sym; |
2779 |
|
|
2780 |
|
while (r < opd->relocation + relcount |
2781 |
|
&& r->address < syms[i]->value + opd->vma) |
2782 |
|
++r; |
2783 |
|
|
2784 |
|
if (r == opd->relocation + relcount) |
2785 |
|
break; |
2786 |
|
|
2787 |
|
if (r->address != syms[i]->value + opd->vma) |
2788 |
|
continue; |
2789 |
|
|
2790 |
|
if (r->howto->type != R_PPC64_ADDR64) |
2791 |
|
continue; |
2792 |
|
|
2793 |
|
sym = *r->sym_ptr_ptr; |
2794 |
|
if (!sym_exists_at (syms, opdsymend, symcount, |
2795 |
|
sym->section->id, sym->value + r->addend)) |
2796 |
|
{ |
2797 |
|
++count; |
2798 |
|
size += sizeof (asymbol); |
2799 |
|
size += strlen (syms[i]->name) + 2; |
2800 |
|
} |
2801 |
|
} |
2802 |
|
|
2803 |
|
s = *ret = bfd_malloc (size); |
2804 |
|
if (s == NULL) |
2805 |
|
{ |
2806 |
|
count = -1; |
2807 |
|
goto done; |
2808 |
|
} |
2809 |
|
|
2810 |
|
names = (char *) (s + count); |
2811 |
|
|
2812 |
|
for (i = secsymend, r = opd->relocation; i < opdsymend; ++i) |
2813 |
|
{ |
2814 |
|
asymbol *sym; |
2815 |
|
|
2816 |
|
while (r < opd->relocation + relcount |
2817 |
|
&& r->address < syms[i]->value + opd->vma) |
2818 |
|
++r; |
2819 |
|
|
2820 |
|
if (r == opd->relocation + relcount) |
2821 |
|
break; |
2822 |
|
|
2823 |
|
if (r->address != syms[i]->value + opd->vma) |
2824 |
|
continue; |
2825 |
|
|
2826 |
|
if (r->howto->type != R_PPC64_ADDR64) |
2827 |
|
continue; |
2828 |
|
|
2829 |
|
sym = *r->sym_ptr_ptr; |
2830 |
|
if (!sym_exists_at (syms, opdsymend, symcount, |
2831 |
|
sym->section->id, sym->value + r->addend)) |
2832 |
|
{ |
2833 |
|
size_t len; |
2834 |
|
|
2835 |
|
*s = *syms[i]; |
2836 |
|
s->section = sym->section; |
2837 |
|
s->value = sym->value + r->addend; |
2838 |
|
s->name = names; |
2839 |
|
*names++ = '.'; |
2840 |
|
len = strlen (syms[i]->name); |
2841 |
|
memcpy (names, syms[i]->name, len + 1); |
2842 |
|
names += len + 1; |
2843 |
|
s++; |
2844 |
|
} |
2845 |
|
} |
2846 |
|
} |
2847 |
|
else |
2848 |
|
{ |
2849 |
|
bfd_byte *contents; |
2850 |
|
size_t size; |
2851 |
|
|
2852 |
|
if (!bfd_malloc_and_get_section (abfd, opd, &contents)) |
2853 |
|
{ |
2854 |
|
if (contents) |
2855 |
|
{ |
2856 |
|
free_contents_and_exit: |
2857 |
|
free (contents); |
2858 |
|
} |
2859 |
|
count = -1; |
2860 |
|
goto done; |
2861 |
|
} |
2862 |
|
|
2863 |
|
size = 0; |
2864 |
|
for (i = secsymend; i < opdsymend; ++i) |
2865 |
|
{ |
2866 |
|
bfd_vma ent; |
2867 |
|
|
2868 |
|
ent = bfd_get_64 (abfd, contents + syms[i]->value); |
2869 |
|
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent)) |
2870 |
|
{ |
2871 |
|
++count; |
2872 |
|
size += sizeof (asymbol); |
2873 |
|
size += strlen (syms[i]->name) + 2; |
2874 |
|
} |
2875 |
|
} |
2876 |
|
|
2877 |
|
s = *ret = bfd_malloc (size); |
2878 |
|
if (s == NULL) |
2879 |
|
goto free_contents_and_exit; |
2880 |
|
|
2881 |
|
names = (char *) (s + count); |
2882 |
|
|
2883 |
|
for (i = secsymend; i < opdsymend; ++i) |
2884 |
|
{ |
2885 |
|
bfd_vma ent; |
2886 |
|
|
2887 |
|
ent = bfd_get_64 (abfd, contents + syms[i]->value); |
2888 |
|
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent)) |
2889 |
|
{ |
2890 |
|
long lo, hi; |
2891 |
|
size_t len; |
2892 |
|
asection *sec = abfd->sections; |
2893 |
|
|
2894 |
|
*s = *syms[i]; |
2895 |
|
lo = codesecsym; |
2896 |
|
hi = codesecsymend; |
2897 |
|
while (lo < hi) |
2898 |
|
{ |
2899 |
|
long mid = (lo + hi) >> 1; |
2900 |
|
if (syms[mid]->section->vma < ent) |
2901 |
|
lo = mid + 1; |
2902 |
|
else if (syms[mid]->section->vma > ent) |
2903 |
|
hi = mid; |
2904 |
|
else |
2905 |
|
{ |
2906 |
|
sec = syms[mid]->section; |
2907 |
|
break; |
2908 |
|
} |
2909 |
|
} |
2910 |
|
|
2911 |
|
if (lo >= hi && lo > codesecsym) |
2912 |
|
sec = syms[lo - 1]->section; |
2913 |
|
|
2914 |
|
for (; sec != NULL; sec = sec->next) |
2915 |
|
{ |
2916 |
|
if (sec->vma > ent) |
2917 |
|
break; |
2918 |
|
if ((sec->flags & SEC_ALLOC) == 0 |
2919 |
|
|| (sec->flags & SEC_LOAD) == 0) |
2920 |
|
break; |
2921 |
|
if ((sec->flags & SEC_CODE) != 0) |
2922 |
|
s->section = sec; |
2923 |
|
} |
2924 |
|
s->value = ent - s->section->vma; |
2925 |
|
s->name = names; |
2926 |
|
*names++ = '.'; |
2927 |
|
len = strlen (syms[i]->name); |
2928 |
|
memcpy (names, syms[i]->name, len + 1); |
2929 |
|
names += len + 1; |
2930 |
|
s++; |
2931 |
|
} |
2932 |
|
} |
2933 |
|
free (contents); |
2934 |
} |
} |
2935 |
|
|
2936 |
return true; |
done: |
2937 |
|
free (syms); |
2938 |
|
return count; |
2939 |
} |
} |
2940 |
|
|
2941 |
/* The following functions are specific to the ELF linker, while |
/* The following functions are specific to the ELF linker, while |
2978 |
. |
. |
2979 |
. .foo_stub: |
. .foo_stub: |
2980 |
. addis 12,2,Lfoo@toc@ha # in practice, the call stub |
. addis 12,2,Lfoo@toc@ha # in practice, the call stub |
2981 |
. addi 12,12,Lfoo@toc@l # is slightly optimised, but |
. addi 12,12,Lfoo@toc@l # is slightly optimized, but |
2982 |
. std 2,40(1) # this is the general idea |
. std 2,40(1) # this is the general idea |
2983 |
. ld 11,0(12) |
. ld 11,0(12) |
2984 |
. ld 2,8(12) |
. ld 2,8(12) |
3004 |
creating a shared library containing foo, we need to have both symbols |
creating a shared library containing foo, we need to have both symbols |
3005 |
dynamic so that references to .foo are satisfied during the early |
dynamic so that references to .foo are satisfied during the early |
3006 |
stages of linking. Otherwise the linker might decide to pull in a |
stages of linking. Otherwise the linker might decide to pull in a |
3007 |
definition from some other object, eg. a static library. */ |
definition from some other object, eg. a static library. |
3008 |
|
|
3009 |
|
Update: As of August 2004, we support a new convention. Function |
3010 |
|
calls may use the function descriptor symbol, ie. "bl foo". This |
3011 |
|
behaves exactly as "bl .foo". */ |
3012 |
|
|
3013 |
/* The linker needs to keep track of the number of relocs that it |
/* The linker needs to keep track of the number of relocs that it |
3014 |
decides to copy as dynamic relocs in check_relocs for each symbol. |
decides to copy as dynamic relocs in check_relocs for each symbol. |
3030 |
bfd_size_type pc_count; |
bfd_size_type pc_count; |
3031 |
}; |
}; |
3032 |
|
|
3033 |
|
/* Track GOT entries needed for a given symbol. We might need more |
3034 |
|
than one got entry per symbol. */ |
3035 |
|
struct got_entry |
3036 |
|
{ |
3037 |
|
struct got_entry *next; |
3038 |
|
|
3039 |
|
/* The symbol addend that we'll be placing in the GOT. */ |
3040 |
|
bfd_vma addend; |
3041 |
|
|
3042 |
|
/* Unlike other ELF targets, we use separate GOT entries for the same |
3043 |
|
symbol referenced from different input files. This is to support |
3044 |
|
automatic multiple TOC/GOT sections, where the TOC base can vary |
3045 |
|
from one input file to another. |
3046 |
|
|
3047 |
|
Point to the BFD owning this GOT entry. */ |
3048 |
|
bfd *owner; |
3049 |
|
|
3050 |
|
/* Zero for non-tls entries, or TLS_TLS and one of TLS_GD, TLS_LD, |
3051 |
|
TLS_TPREL or TLS_DTPREL for tls entries. */ |
3052 |
|
char tls_type; |
3053 |
|
|
3054 |
|
/* Reference count until size_dynamic_sections, GOT offset thereafter. */ |
3055 |
|
union |
3056 |
|
{ |
3057 |
|
bfd_signed_vma refcount; |
3058 |
|
bfd_vma offset; |
3059 |
|
} got; |
3060 |
|
}; |
3061 |
|
|
3062 |
|
/* The same for PLT. */ |
3063 |
|
struct plt_entry |
3064 |
|
{ |
3065 |
|
struct plt_entry *next; |
3066 |
|
|
3067 |
|
bfd_vma addend; |
3068 |
|
|
3069 |
|
union |
3070 |
|
{ |
3071 |
|
bfd_signed_vma refcount; |
3072 |
|
bfd_vma offset; |
3073 |
|
} plt; |
3074 |
|
}; |
3075 |
|
|
3076 |
/* Of those relocs that might be copied as dynamic relocs, this macro |
/* Of those relocs that might be copied as dynamic relocs, this macro |
3077 |
selects between relative and absolute types. */ |
selects those that must be copied when linking a shared library, |
3078 |
|
even when the symbol is local. */ |
3079 |
|
|
3080 |
#define IS_ABSOLUTE_RELOC(RTYPE) \ |
#define MUST_BE_DYN_RELOC(RTYPE) \ |
3081 |
((RTYPE) != R_PPC64_REL32 \ |
((RTYPE) != R_PPC64_REL32 \ |
3082 |
&& (RTYPE) != R_PPC64_REL64 \ |
&& (RTYPE) != R_PPC64_REL64 \ |
3083 |
&& (RTYPE) != R_PPC64_ADDR30) |
&& (RTYPE) != R_PPC64_REL30) |
3084 |
|
|
3085 |
|
/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid |
3086 |
|
copying dynamic variables from a shared lib into an app's dynbss |
3087 |
|
section, and instead use a dynamic relocation to point into the |
3088 |
|
shared lib. With code that gcc generates, it's vital that this be |
3089 |
|
enabled; In the PowerPC64 ABI, the address of a function is actually |
3090 |
|
the address of a function descriptor, which resides in the .opd |
3091 |
|
section. gcc uses the descriptor directly rather than going via the |
3092 |
|
GOT as some other ABI's do, which means that initialized function |
3093 |
|
pointers must reference the descriptor. Thus, a function pointer |
3094 |
|
initialized to the address of a function in a shared library will |
3095 |
|
either require a copy reloc, or a dynamic reloc. Using a copy reloc |
3096 |
|
redefines the function descriptor symbol to point to the copy. This |
3097 |
|
presents a problem as a plt entry for that function is also |
3098 |
|
initialized from the function descriptor symbol and the copy reloc |
3099 |
|
may not be initialized first. */ |
3100 |
|
#define ELIMINATE_COPY_RELOCS 1 |
3101 |
|
|
3102 |
/* Section name for stubs is the associated section name plus this |
/* Section name for stubs is the associated section name plus this |
3103 |
string. */ |
string. */ |
3112 |
ppc_stub_plt_branch: |
ppc_stub_plt_branch: |
3113 |
Similar to the above, but a 24 bit branch in the stub section won't |
Similar to the above, but a 24 bit branch in the stub section won't |
3114 |
reach its destination. |
reach its destination. |
3115 |
. addis %r12,%r2,xxx@ha |
. addis %r12,%r2,xxx@toc@ha |
3116 |
. ld %r11,xxx@l(%r12) |
. ld %r11,xxx@toc@l(%r12) |
3117 |
. mtctr %r11 |
. mtctr %r11 |
3118 |
. bctr |
. bctr |
3119 |
|
|
3120 |
ppc_stub_plt_call: |
ppc_stub_plt_call: |
3121 |
Used to call a function in a shared library. |
Used to call a function in a shared library. If it so happens that |
3122 |
. addis %r12,%r2,xxx@ha |
the plt entry referenced crosses a 64k boundary, then an extra |
3123 |
|
"addis %r12,%r12,1" will be inserted before the load at xxx+8 or |
3124 |
|
xxx+16 as appropriate. |
3125 |
|
. addis %r12,%r2,xxx@toc@ha |
3126 |
. std %r2,40(%r1) |
. std %r2,40(%r1) |
3127 |
. ld %r11,xxx+0@l(%r12) |
. ld %r11,xxx+0@toc@l(%r12) |
3128 |
. ld %r2,xxx+8@l(%r12) |
. ld %r2,xxx+8@toc@l(%r12) |
3129 |
|
. mtctr %r11 |
3130 |
|
. ld %r11,xxx+16@toc@l(%r12) |
3131 |
|
. bctr |
3132 |
|
|
3133 |
|
ppc_stub_long_branch and ppc_stub_plt_branch may also have additional |
3134 |
|
code to adjust the value and save r2 to support multiple toc sections. |
3135 |
|
A ppc_stub_long_branch with an r2 offset looks like: |
3136 |
|
. std %r2,40(%r1) |
3137 |
|
. addis %r2,%r2,off@ha |
3138 |
|
. addi %r2,%r2,off@l |
3139 |
|
. b dest |
3140 |
|
|
3141 |
|
A ppc_stub_plt_branch with an r2 offset looks like: |
3142 |
|
. std %r2,40(%r1) |
3143 |
|
. addis %r12,%r2,xxx@toc@ha |
3144 |
|
. ld %r11,xxx@toc@l(%r12) |
3145 |
|
. addis %r2,%r2,off@ha |
3146 |
|
. addi %r2,%r2,off@l |
3147 |
. mtctr %r11 |
. mtctr %r11 |
|
. ld %r11,xxx+16@l(%r12) |
|
3148 |
. bctr |
. bctr |
3149 |
*/ |
*/ |
3150 |
|
|
3151 |
enum ppc_stub_type { |
enum ppc_stub_type { |
3152 |
ppc_stub_none, |
ppc_stub_none, |
3153 |
ppc_stub_long_branch, |
ppc_stub_long_branch, |
3154 |
|
ppc_stub_long_branch_r2off, |
3155 |
ppc_stub_plt_branch, |
ppc_stub_plt_branch, |
3156 |
|
ppc_stub_plt_branch_r2off, |
3157 |
ppc_stub_plt_call |
ppc_stub_plt_call |
3158 |
}; |
}; |
3159 |
|
|
3162 |
/* Base hash table entry structure. */ |
/* Base hash table entry structure. */ |
3163 |
struct bfd_hash_entry root; |
struct bfd_hash_entry root; |
3164 |
|
|
3165 |
|
enum ppc_stub_type stub_type; |
3166 |
|
|
3167 |
/* The stub section. */ |
/* The stub section. */ |
3168 |
asection *stub_sec; |
asection *stub_sec; |
3169 |
|
|
3175 |
bfd_vma target_value; |
bfd_vma target_value; |
3176 |
asection *target_section; |
asection *target_section; |
3177 |
|
|
|
enum ppc_stub_type stub_type; |
|
|
|
|
3178 |
/* The symbol table entry, if any, that this was derived from. */ |
/* The symbol table entry, if any, that this was derived from. */ |
3179 |
struct ppc_link_hash_entry *h; |
struct ppc_link_hash_entry *h; |
3180 |
|
|
3181 |
|
/* And the reloc addend that this was derived from. */ |
3182 |
|
bfd_vma addend; |
3183 |
|
|
3184 |
/* Where this stub is being called from, or, in the case of combined |
/* Where this stub is being called from, or, in the case of combined |
3185 |
stub sections, the first input section in the group. */ |
stub sections, the first input section in the group. */ |
3186 |
asection *id_sec; |
asection *id_sec; |
3210 |
struct ppc_dyn_relocs *dyn_relocs; |
struct ppc_dyn_relocs *dyn_relocs; |
3211 |
|
|
3212 |
/* Link between function code and descriptor symbols. */ |
/* Link between function code and descriptor symbols. */ |
3213 |
struct elf_link_hash_entry *oh; |
struct ppc_link_hash_entry *oh; |
3214 |
|
|
3215 |
/* Flag function code and descriptor symbols. */ |
/* Flag function code and descriptor symbols. */ |
3216 |
unsigned int is_func:1; |
unsigned int is_func:1; |
3217 |
unsigned int is_func_descriptor:1; |
unsigned int is_func_descriptor:1; |
3218 |
unsigned int is_entry:1; |
unsigned int fake:1; |
3219 |
|
|
3220 |
|
/* Whether global opd/toc sym has been adjusted or not. |
3221 |
|
After ppc64_elf_edit_opd/ppc64_elf_edit_toc has run, this flag |
3222 |
|
should be set for all globals defined in any opd/toc section. */ |
3223 |
|
unsigned int adjust_done:1; |
3224 |
|
|
3225 |
|
/* Set if we twiddled this symbol to weak at some stage. */ |
3226 |
|
unsigned int was_undefined:1; |
3227 |
|
|
3228 |
|
/* Contexts in which symbol is used in the GOT (or TOC). |
3229 |
|
TLS_GD .. TLS_EXPLICIT bits are or'd into the mask as the |
3230 |
|
corresponding relocs are encountered during check_relocs. |
3231 |
|
tls_optimize clears TLS_GD .. TLS_TPREL when optimizing to |
3232 |
|
indicate the corresponding GOT entry type is not needed. |
3233 |
|
tls_optimize may also set TLS_TPRELGD when a GD reloc turns into |
3234 |
|
a TPREL one. We use a separate flag rather than setting TPREL |
3235 |
|
just for convenience in distinguishing the two cases. */ |
3236 |
|
#define TLS_GD 1 /* GD reloc. */ |
3237 |
|
#define TLS_LD 2 /* LD reloc. */ |
3238 |
|
#define TLS_TPREL 4 /* TPREL reloc, => IE. */ |
3239 |
|
#define TLS_DTPREL 8 /* DTPREL reloc, => LD. */ |
3240 |
|
#define TLS_TLS 16 /* Any TLS reloc. */ |
3241 |
|
#define TLS_EXPLICIT 32 /* Marks TOC section TLS relocs. */ |
3242 |
|
#define TLS_TPRELGD 64 /* TPREL reloc resulting from GD->IE. */ |
3243 |
|
char tls_mask; |
3244 |
}; |
}; |
3245 |
|
|
3246 |
/* ppc64 ELF linker hash table. */ |
/* ppc64 ELF linker hash table. */ |
3259 |
bfd *stub_bfd; |
bfd *stub_bfd; |
3260 |
|
|
3261 |
/* Linker call-backs. */ |
/* Linker call-backs. */ |
3262 |
asection * (*add_stub_section) PARAMS ((const char *, asection *)); |
asection * (*add_stub_section) (const char *, asection *); |
3263 |
void (*layout_sections_again) PARAMS ((void)); |
void (*layout_sections_again) (void); |
3264 |
|
|
3265 |
/* Array to keep track of which stub sections have been created, and |
/* Array to keep track of which stub sections have been created, and |
3266 |
information on stub grouping. */ |
information on stub grouping. */ |
3269 |
asection *link_sec; |
asection *link_sec; |
3270 |
/* The stub section. */ |
/* The stub section. */ |
3271 |
asection *stub_sec; |
asection *stub_sec; |
3272 |
|
/* Along with elf_gp, specifies the TOC pointer used in this group. */ |
3273 |
|
bfd_vma toc_off; |
3274 |
} *stub_group; |
} *stub_group; |
3275 |
|
|
3276 |
/* Assorted information used by ppc64_elf_size_stubs. */ |
/* Temp used when calculating TOC pointers. */ |
3277 |
|
bfd_vma toc_curr; |
3278 |
|
|
3279 |
|
/* Highest input section id. */ |
3280 |
|
int top_id; |
3281 |
|
|
3282 |
|
/* Highest output section index. */ |
3283 |
int top_index; |
int top_index; |
3284 |
|
|
3285 |
|
/* List of input sections for each output section. */ |
3286 |
asection **input_list; |
asection **input_list; |
3287 |
|
|
3288 |
/* Short-cuts to get to dynamic linker sections. */ |
/* Short-cuts to get to dynamic linker sections. */ |
3289 |
asection *sgot; |
asection *got; |
3290 |
asection *srelgot; |
asection *plt; |
3291 |
asection *splt; |
asection *relplt; |
3292 |
asection *srelplt; |
asection *dynbss; |
3293 |
asection *sdynbss; |
asection *relbss; |
3294 |
asection *srelbss; |
asection *glink; |
|
asection *sglink; |
|
3295 |
asection *sfpr; |
asection *sfpr; |
3296 |
asection *sbrlt; |
asection *brlt; |
3297 |
asection *srelbrlt; |
asection *relbrlt; |
3298 |
|
|
3299 |
|
/* Shortcut to .__tls_get_addr and __tls_get_addr. */ |
3300 |
|
struct ppc_link_hash_entry *tls_get_addr; |
3301 |
|
struct ppc_link_hash_entry *tls_get_addr_fd; |
3302 |
|
|
3303 |
|
/* Statistics. */ |
3304 |
|
unsigned long stub_count[ppc_stub_plt_call]; |
3305 |
|
|
3306 |
|
/* Number of stubs against global syms. */ |
3307 |
|
unsigned long stub_globals; |
3308 |
|
|
3309 |
|
/* Set if we should emit symbols for stubs. */ |
3310 |
|
unsigned int emit_stub_syms:1; |
3311 |
|
|
3312 |
|
/* Support for multiple toc sections. */ |
3313 |
|
unsigned int no_multi_toc:1; |
3314 |
|
unsigned int multi_toc_needed:1; |
3315 |
|
|
3316 |
/* Set on error. */ |
/* Set on error. */ |
3317 |
unsigned int stub_error; |
unsigned int stub_error:1; |
3318 |
|
|
3319 |
/* Flag set when small branches are detected. Used to |
/* Flag set when small branches are detected. Used to |
3320 |
select suitable defaults for the stub group size. */ |
select suitable defaults for the stub group size. */ |
3321 |
unsigned int has_14bit_branch; |
unsigned int has_14bit_branch:1; |
3322 |
|
|
3323 |
/* Set if we detect a reference undefined weak symbol. */ |
/* Temp used by ppc64_elf_check_directives. */ |
3324 |
unsigned int have_undefweak; |
unsigned int twiddled_syms:1; |
3325 |
|
|
3326 |
/* Incremented every time we size stubs. */ |
/* Incremented every time we size stubs. */ |
3327 |
unsigned int stub_iteration; |
unsigned int stub_iteration; |
3330 |
struct sym_sec_cache sym_sec; |
struct sym_sec_cache sym_sec; |
3331 |
}; |
}; |
3332 |
|
|
3333 |
static struct bfd_hash_entry *stub_hash_newfunc |
/* Rename some of the generic section flags to better document how they |
3334 |
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); |
are used here. */ |
3335 |
static struct bfd_hash_entry *branch_hash_newfunc |
#define has_toc_reloc has_gp_reloc |
3336 |
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); |
#define makes_toc_func_call need_finalize_relax |
3337 |
static struct bfd_hash_entry *link_hash_newfunc |
#define call_check_in_progress reloc_done |
|
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); |
|
|
static struct bfd_link_hash_table *ppc64_elf_link_hash_table_create |
|
|
PARAMS ((bfd *)); |
|
|
static void ppc64_elf_link_hash_table_free |
|
|
PARAMS ((struct bfd_link_hash_table *)); |
|
|
static char *ppc_stub_name |
|
|
PARAMS ((const asection *, const asection *, |
|
|
const struct ppc_link_hash_entry *, const Elf_Internal_Rela *)); |
|
|
static struct ppc_stub_hash_entry *ppc_get_stub_entry |
|
|
PARAMS ((const asection *, const asection *, struct elf_link_hash_entry *, |
|
|
const Elf_Internal_Rela *, struct ppc_link_hash_table *)); |
|
|
static struct ppc_stub_hash_entry *ppc_add_stub |
|
|
PARAMS ((const char *, asection *, struct ppc_link_hash_table *)); |
|
|
static boolean create_linkage_sections |
|
|
PARAMS ((bfd *, struct bfd_link_info *)); |
|
|
static boolean create_got_section |
|
|
PARAMS ((bfd *, struct bfd_link_info *)); |
|
|
static boolean ppc64_elf_create_dynamic_sections |
|
|
PARAMS ((bfd *, struct bfd_link_info *)); |
|
|
static void ppc64_elf_copy_indirect_symbol |
|
|
PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); |
|
|
static boolean ppc64_elf_check_relocs |
|
|
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
|
|
const Elf_Internal_Rela *)); |
|
|
static asection * ppc64_elf_gc_mark_hook |
|
|
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, |
|
|
struct elf_link_hash_entry *, Elf_Internal_Sym *)); |
|
|
static boolean ppc64_elf_gc_sweep_hook |
|
|
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
|
|
const Elf_Internal_Rela *)); |
|
|
static boolean func_desc_adjust |
|
|
PARAMS ((struct elf_link_hash_entry *, PTR)); |
|
|
static boolean ppc64_elf_func_desc_adjust |
|
|
PARAMS ((bfd *, struct bfd_link_info *)); |
|
|
static boolean ppc64_elf_adjust_dynamic_symbol |
|
|
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); |
|
|
static void ppc64_elf_hide_symbol |
|
|
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean)); |
|
|
static boolean edit_opd |
|
|
PARAMS ((bfd *, struct bfd_link_info *)); |
|
|
static boolean allocate_dynrelocs |
|
|
PARAMS ((struct elf_link_hash_entry *, PTR)); |
|
|
static boolean readonly_dynrelocs |
|
|
PARAMS ((struct elf_link_hash_entry *, PTR)); |
|
|
static enum elf_reloc_type_class ppc64_elf_reloc_type_class |
|
|
PARAMS ((const Elf_Internal_Rela *)); |
|
|
static boolean ppc64_elf_size_dynamic_sections |
|
|
PARAMS ((bfd *, struct bfd_link_info *)); |
|
|
static INLINE enum ppc_stub_type ppc_type_of_stub |
|
|
PARAMS ((asection *, const Elf_Internal_Rela *, |
|
|
struct ppc_link_hash_entry **, bfd_vma)); |
|
|
static bfd_byte *build_plt_stub |
|
|
PARAMS ((bfd *, bfd_byte *, int, int)); |
|
|
static boolean ppc_build_one_stub |
|
|
PARAMS ((struct bfd_hash_entry *, PTR)); |
|
|
static boolean ppc_size_one_stub |
|
|
PARAMS ((struct bfd_hash_entry *, PTR)); |
|
|
static void group_sections |
|
|
PARAMS ((struct ppc_link_hash_table *, bfd_size_type, boolean)); |
|
|
static boolean ppc64_elf_relocate_section |
|
|
PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *, |
|
|
Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, |
|
|
asection **)); |
|
|
static boolean ppc64_elf_finish_dynamic_symbol |
|
|
PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, |
|
|
Elf_Internal_Sym *)); |
|
|
static boolean ppc64_elf_finish_dynamic_sections |
|
|
PARAMS ((bfd *, struct bfd_link_info *)); |
|
3338 |
|
|
3339 |
/* Get the ppc64 ELF linker hash table from a link_info structure. */ |
/* Get the ppc64 ELF linker hash table from a link_info structure. */ |
3340 |
|
|
3352 |
/* Create an entry in the stub hash table. */ |
/* Create an entry in the stub hash table. */ |
3353 |
|
|
3354 |
static struct bfd_hash_entry * |
static struct bfd_hash_entry * |
3355 |
stub_hash_newfunc (entry, table, string) |
stub_hash_newfunc (struct bfd_hash_entry *entry, |
3356 |
struct bfd_hash_entry *entry; |
struct bfd_hash_table *table, |
3357 |
struct bfd_hash_table *table; |
const char *string) |
|
const char *string; |
|
3358 |
{ |
{ |
3359 |
/* Allocate the structure if it has not already been allocated by a |
/* Allocate the structure if it has not already been allocated by a |
3360 |
subclass. */ |
subclass. */ |
3373 |
|
|
3374 |
/* Initialize the local fields. */ |
/* Initialize the local fields. */ |
3375 |
eh = (struct ppc_stub_hash_entry *) entry; |
eh = (struct ppc_stub_hash_entry *) entry; |
3376 |
|
eh->stub_type = ppc_stub_none; |
3377 |
eh->stub_sec = NULL; |
eh->stub_sec = NULL; |
3378 |
eh->stub_offset = 0; |
eh->stub_offset = 0; |
3379 |
eh->target_value = 0; |
eh->target_value = 0; |
3380 |
eh->target_section = NULL; |
eh->target_section = NULL; |
|
eh->stub_type = ppc_stub_none; |
|
3381 |
eh->h = NULL; |
eh->h = NULL; |
3382 |
eh->id_sec = NULL; |
eh->id_sec = NULL; |
3383 |
} |
} |
3388 |
/* Create an entry in the branch hash table. */ |
/* Create an entry in the branch hash table. */ |
3389 |
|
|
3390 |
static struct bfd_hash_entry * |
static struct bfd_hash_entry * |
3391 |
branch_hash_newfunc (entry, table, string) |
branch_hash_newfunc (struct bfd_hash_entry *entry, |
3392 |
struct bfd_hash_entry *entry; |
struct bfd_hash_table *table, |
3393 |
struct bfd_hash_table *table; |
const char *string) |
|
const char *string; |
|
3394 |
{ |
{ |
3395 |
/* Allocate the structure if it has not already been allocated by a |
/* Allocate the structure if it has not already been allocated by a |
3396 |
subclass. */ |
subclass. */ |
3419 |
/* Create an entry in a ppc64 ELF linker hash table. */ |
/* Create an entry in a ppc64 ELF linker hash table. */ |
3420 |
|
|
3421 |
static struct bfd_hash_entry * |
static struct bfd_hash_entry * |
3422 |
link_hash_newfunc (entry, table, string) |
link_hash_newfunc (struct bfd_hash_entry *entry, |
3423 |
struct bfd_hash_entry *entry; |
struct bfd_hash_table *table, |
3424 |
struct bfd_hash_table *table; |
const char *string) |
|
const char *string; |
|
3425 |
{ |
{ |
3426 |
/* Allocate the structure if it has not already been allocated by a |
/* Allocate the structure if it has not already been allocated by a |
3427 |
subclass. */ |
subclass. */ |
3438 |
{ |
{ |
3439 |
struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) entry; |
struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) entry; |
3440 |
|
|
3441 |
eh->stub_cache = NULL; |
memset (&eh->stub_cache, 0, |
3442 |
eh->dyn_relocs = NULL; |
(sizeof (struct ppc_link_hash_entry) |
3443 |
eh->oh = NULL; |
- offsetof (struct ppc_link_hash_entry, stub_cache))); |
|
eh->is_func = 0; |
|
|
eh->is_func_descriptor = 0; |
|
|
eh->is_entry = 0; |
|
3444 |
} |
} |
3445 |
|
|
3446 |
return entry; |
return entry; |
3449 |
/* Create a ppc64 ELF linker hash table. */ |
/* Create a ppc64 ELF linker hash table. */ |
3450 |
|
|
3451 |
static struct bfd_link_hash_table * |
static struct bfd_link_hash_table * |
3452 |
ppc64_elf_link_hash_table_create (abfd) |
ppc64_elf_link_hash_table_create (bfd *abfd) |
|
bfd *abfd; |
|
3453 |
{ |
{ |
3454 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
3455 |
bfd_size_type amt = sizeof (struct ppc_link_hash_table); |
bfd_size_type amt = sizeof (struct ppc_link_hash_table); |
3456 |
|
|
3457 |
htab = (struct ppc_link_hash_table *) bfd_malloc (amt); |
htab = bfd_zmalloc (amt); |
3458 |
if (htab == NULL) |
if (htab == NULL) |
3459 |
return NULL; |
return NULL; |
3460 |
|
|
3472 |
if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc)) |
if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc)) |
3473 |
return NULL; |
return NULL; |
3474 |
|
|
3475 |
htab->stub_bfd = NULL; |
/* Initializing two fields of the union is just cosmetic. We really |
3476 |
htab->add_stub_section = NULL; |
only care about glist, but when compiled on a 32-bit host the |
3477 |
htab->layout_sections_again = NULL; |
bfd_vma fields are larger. Setting the bfd_vma to zero makes |
3478 |
htab->stub_group = NULL; |
debugger inspection of these fields look nicer. */ |
3479 |
htab->sgot = NULL; |
htab->elf.init_refcount.refcount = 0; |
3480 |
htab->srelgot = NULL; |
htab->elf.init_refcount.glist = NULL; |
3481 |
htab->splt = NULL; |
htab->elf.init_offset.offset = 0; |
3482 |
htab->srelplt = NULL; |
htab->elf.init_offset.glist = NULL; |
|
htab->sdynbss = NULL; |
|
|
htab->srelbss = NULL; |
|
|
htab->sglink = NULL; |
|
|
htab->sfpr = NULL; |
|
|
htab->sbrlt = NULL; |
|
|
htab->srelbrlt = NULL; |
|
|
htab->stub_error = 0; |
|
|
htab->has_14bit_branch = 0; |
|
|
htab->have_undefweak = 0; |
|
|
htab->stub_iteration = 0; |
|
|
htab->sym_sec.abfd = NULL; |
|
3483 |
|
|
3484 |
return &htab->elf.root; |
return &htab->elf.root; |
3485 |
} |
} |
3487 |
/* Free the derived linker hash table. */ |
/* Free the derived linker hash table. */ |
3488 |
|
|
3489 |
static void |
static void |
3490 |
ppc64_elf_link_hash_table_free (hash) |
ppc64_elf_link_hash_table_free (struct bfd_link_hash_table *hash) |
|
struct bfd_link_hash_table *hash; |
|
3491 |
{ |
{ |
3492 |
struct ppc_link_hash_table *ret = (struct ppc_link_hash_table *) hash; |
struct ppc_link_hash_table *ret = (struct ppc_link_hash_table *) hash; |
3493 |
|
|
3496 |
_bfd_generic_link_hash_table_free (hash); |
_bfd_generic_link_hash_table_free (hash); |
3497 |
} |
} |
3498 |
|
|
3499 |
|
/* Satisfy the ELF linker by filling in some fields in our fake bfd. */ |
3500 |
|
|
3501 |
|
void |
3502 |
|
ppc64_elf_init_stub_bfd (bfd *abfd, struct bfd_link_info *info) |
3503 |
|
{ |
3504 |
|
struct ppc_link_hash_table *htab; |
3505 |
|
|
3506 |
|
elf_elfheader (abfd)->e_ident[EI_CLASS] = ELFCLASS64; |
3507 |
|
|
3508 |
|
/* Always hook our dynamic sections into the first bfd, which is the |
3509 |
|
linker created stub bfd. This ensures that the GOT header is at |
3510 |
|
the start of the output TOC section. */ |
3511 |
|
htab = ppc_hash_table (info); |
3512 |
|
htab->stub_bfd = abfd; |
3513 |
|
htab->elf.dynobj = abfd; |
3514 |
|
} |
3515 |
|
|
3516 |
/* Build a name for an entry in the stub hash table. */ |
/* Build a name for an entry in the stub hash table. */ |
3517 |
|
|
3518 |
static char * |
static char * |
3519 |
ppc_stub_name (input_section, sym_sec, h, rel) |
ppc_stub_name (const asection *input_section, |
3520 |
const asection *input_section; |
const asection *sym_sec, |
3521 |
const asection *sym_sec; |
const struct ppc_link_hash_entry *h, |
3522 |
const struct ppc_link_hash_entry *h; |
const Elf_Internal_Rela *rel) |
|
const Elf_Internal_Rela *rel; |
|
3523 |
{ |
{ |
3524 |
char *stub_name; |
char *stub_name; |
3525 |
bfd_size_type len; |
bfd_size_type len; |
3533 |
{ |
{ |
3534 |
len = 8 + 1 + strlen (h->elf.root.root.string) + 1 + 8 + 1; |
len = 8 + 1 + strlen (h->elf.root.root.string) + 1 + 8 + 1; |
3535 |
stub_name = bfd_malloc (len); |
stub_name = bfd_malloc (len); |
3536 |
if (stub_name != NULL) |
if (stub_name == NULL) |
3537 |
{ |
return stub_name; |
3538 |
sprintf (stub_name, "%08x_%s+%x", |
|
3539 |
input_section->id & 0xffffffff, |
sprintf (stub_name, "%08x.%s+%x", |
3540 |
h->elf.root.root.string, |
input_section->id & 0xffffffff, |
3541 |
(int) rel->r_addend & 0xffffffff); |
h->elf.root.root.string, |
3542 |
} |
(int) rel->r_addend & 0xffffffff); |
3543 |
} |
} |
3544 |
else |
else |
3545 |
{ |
{ |
3546 |
len = 8 + 1 + 8 + 1 + 8 + 1 + 16 + 1; |
len = 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1; |
3547 |
stub_name = bfd_malloc (len); |
stub_name = bfd_malloc (len); |
3548 |
if (stub_name != NULL) |
if (stub_name == NULL) |
3549 |
{ |
return stub_name; |
3550 |
sprintf (stub_name, "%08x_%x:%x+%x", |
|
3551 |
input_section->id & 0xffffffff, |
sprintf (stub_name, "%08x.%x:%x+%x", |
3552 |
sym_sec->id & 0xffffffff, |
input_section->id & 0xffffffff, |
3553 |
(int) ELF64_R_SYM (rel->r_info) & 0xffffffff, |
sym_sec->id & 0xffffffff, |
3554 |
(int) rel->r_addend & 0xffffffff); |
(int) ELF64_R_SYM (rel->r_info) & 0xffffffff, |
3555 |
} |
(int) rel->r_addend & 0xffffffff); |
3556 |
} |
} |
3557 |
|
if (stub_name[len - 2] == '+' && stub_name[len - 1] == '0') |
3558 |
|
stub_name[len - 2] = 0; |
3559 |
return stub_name; |
return stub_name; |
3560 |
} |
} |
3561 |
|
|
3563 |
creating the stub name takes a bit of time. */ |
creating the stub name takes a bit of time. */ |
3564 |
|
|
3565 |
static struct ppc_stub_hash_entry * |
static struct ppc_stub_hash_entry * |
3566 |
ppc_get_stub_entry (input_section, sym_sec, hash, rel, htab) |
ppc_get_stub_entry (const asection *input_section, |
3567 |
const asection *input_section; |
const asection *sym_sec, |
3568 |
const asection *sym_sec; |
struct ppc_link_hash_entry *h, |
3569 |
struct elf_link_hash_entry *hash; |
const Elf_Internal_Rela *rel, |
3570 |
const Elf_Internal_Rela *rel; |
struct ppc_link_hash_table *htab) |
|
struct ppc_link_hash_table *htab; |
|
3571 |
{ |
{ |
3572 |
struct ppc_stub_hash_entry *stub_entry; |
struct ppc_stub_hash_entry *stub_entry; |
|
struct ppc_link_hash_entry *h = (struct ppc_link_hash_entry *) hash; |
|
3573 |
const asection *id_sec; |
const asection *id_sec; |
3574 |
|
|
3575 |
/* If this input section is part of a group of sections sharing one |
/* If this input section is part of a group of sections sharing one |
3594 |
return NULL; |
return NULL; |
3595 |
|
|
3596 |
stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, |
stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, |
3597 |
stub_name, false, false); |
stub_name, FALSE, FALSE); |
3598 |
if (h != NULL) |
if (h != NULL) |
3599 |
h->stub_cache = stub_entry; |
h->stub_cache = stub_entry; |
3600 |
|
|
3608 |
stub entry are initialised. */ |
stub entry are initialised. */ |
3609 |
|
|
3610 |
static struct ppc_stub_hash_entry * |
static struct ppc_stub_hash_entry * |
3611 |
ppc_add_stub (stub_name, section, htab) |
ppc_add_stub (const char *stub_name, |
3612 |
const char *stub_name; |
asection *section, |
3613 |
asection *section; |
struct ppc_link_hash_table *htab) |
|
struct ppc_link_hash_table *htab; |
|
3614 |
{ |
{ |
3615 |
asection *link_sec; |
asection *link_sec; |
3616 |
asection *stub_sec; |
asection *stub_sec; |
3645 |
|
|
3646 |
/* Enter this entry into the linker stub hash table. */ |
/* Enter this entry into the linker stub hash table. */ |
3647 |
stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, stub_name, |
stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, stub_name, |
3648 |
true, false); |
TRUE, FALSE); |
3649 |
if (stub_entry == NULL) |
if (stub_entry == NULL) |
3650 |
{ |
{ |
3651 |
(*_bfd_error_handler) (_("%s: cannot create stub entry %s"), |
(*_bfd_error_handler) (_("%B: cannot create stub entry %s"), |
3652 |
bfd_archive_filename (section->owner), |
section->owner, stub_name); |
|
stub_name); |
|
3653 |
return NULL; |
return NULL; |
3654 |
} |
} |
3655 |
|
|
3661 |
|
|
3662 |
/* Create sections for linker generated code. */ |
/* Create sections for linker generated code. */ |
3663 |
|
|
3664 |
static boolean |
static bfd_boolean |
3665 |
create_linkage_sections (dynobj, info) |
create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) |
|
bfd *dynobj; |
|
|
struct bfd_link_info *info; |
|
3666 |
{ |
{ |
3667 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
3668 |
flagword flags; |
flagword flags; |
3676 |
if (htab->sfpr == NULL |
if (htab->sfpr == NULL |
3677 |
|| ! bfd_set_section_flags (dynobj, htab->sfpr, flags) |
|| ! bfd_set_section_flags (dynobj, htab->sfpr, flags) |
3678 |
|| ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) |
|| ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) |
3679 |
return false; |
return FALSE; |
3680 |
|
|
3681 |
/* Create .glink for lazy dynamic linking support. */ |
/* Create .glink for lazy dynamic linking support. */ |
3682 |
htab->sglink = bfd_make_section_anyway (dynobj, ".glink"); |
htab->glink = bfd_make_section_anyway (dynobj, ".glink"); |
3683 |
if (htab->sglink == NULL |
if (htab->glink == NULL |
3684 |
|| ! bfd_set_section_flags (dynobj, htab->sglink, flags) |
|| ! bfd_set_section_flags (dynobj, htab->glink, flags) |
3685 |
|| ! bfd_set_section_alignment (dynobj, htab->sglink, 2)) |
|| ! bfd_set_section_alignment (dynobj, htab->glink, 2)) |
3686 |
return false; |
return FALSE; |
3687 |
|
|
3688 |
/* Create .branch_lt for plt_branch stubs. */ |
/* Create .branch_lt for plt_branch stubs. */ |
3689 |
flags = (SEC_ALLOC | SEC_LOAD |
flags = (SEC_ALLOC | SEC_LOAD |
3690 |
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); |
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); |
3691 |
htab->sbrlt = bfd_make_section_anyway (dynobj, ".branch_lt"); |
htab->brlt = bfd_make_section_anyway (dynobj, ".branch_lt"); |
3692 |
if (htab->sbrlt == NULL |
if (htab->brlt == NULL |
3693 |
|| ! bfd_set_section_flags (dynobj, htab->sbrlt, flags) |
|| ! bfd_set_section_flags (dynobj, htab->brlt, flags) |
3694 |
|| ! bfd_set_section_alignment (dynobj, htab->sbrlt, 3)) |
|| ! bfd_set_section_alignment (dynobj, htab->brlt, 3)) |
3695 |
return false; |
return FALSE; |
3696 |
|
|
3697 |
if (info->shared) |
if (info->shared || info->emitrelocations) |
3698 |
{ |
{ |
3699 |
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY |
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY |
3700 |
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); |
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); |
3701 |
htab->srelbrlt = bfd_make_section_anyway (dynobj, ".rela.branch_lt"); |
htab->relbrlt = bfd_make_section_anyway (dynobj, ".rela.branch_lt"); |
3702 |
if (!htab->srelbrlt |
if (!htab->relbrlt |
3703 |
|| ! bfd_set_section_flags (dynobj, htab->srelbrlt, flags) |
|| ! bfd_set_section_flags (dynobj, htab->relbrlt, flags) |
3704 |
|| ! bfd_set_section_alignment (dynobj, htab->srelbrlt, 3)) |
|| ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) |
3705 |
return false; |
return FALSE; |
3706 |
} |
} |
3707 |
return true; |
return TRUE; |
3708 |
} |
} |
3709 |
|
|
3710 |
/* Create .got and .rela.got sections in DYNOBJ, and set up |
/* Create .got and .rela.got sections in ABFD, and .got in dynobj if |
3711 |
shortcuts to them in our hash table. */ |
not already done. */ |
3712 |
|
|
3713 |
static boolean |
static bfd_boolean |
3714 |
create_got_section (dynobj, info) |
create_got_section (bfd *abfd, struct bfd_link_info *info) |
|
bfd *dynobj; |
|
|
struct bfd_link_info *info; |
|
3715 |
{ |
{ |
3716 |
struct ppc_link_hash_table *htab; |
asection *got, *relgot; |
3717 |
|
flagword flags; |
3718 |
|
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
3719 |
|
|
3720 |
if (! _bfd_elf_create_got_section (dynobj, info)) |
if (!htab->got) |
3721 |
return false; |
{ |
3722 |
|
if (! _bfd_elf_create_got_section (htab->elf.dynobj, info)) |
3723 |
|
return FALSE; |
3724 |
|
|
3725 |
htab = ppc_hash_table (info); |
htab->got = bfd_get_section_by_name (htab->elf.dynobj, ".got"); |
3726 |
htab->sgot = bfd_get_section_by_name (dynobj, ".got"); |
if (!htab->got) |
3727 |
if (!htab->sgot) |
abort (); |
3728 |
abort (); |
} |
3729 |
|
|
3730 |
|
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY |
3731 |
|
| SEC_LINKER_CREATED); |
3732 |
|
|
3733 |
htab->srelgot = bfd_make_section (dynobj, ".rela.got"); |
got = bfd_make_section (abfd, ".got"); |
3734 |
if (!htab->srelgot |
if (!got |
3735 |
|| ! bfd_set_section_flags (dynobj, htab->srelgot, |
|| !bfd_set_section_flags (abfd, got, flags) |
3736 |
(SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS |
|| !bfd_set_section_alignment (abfd, got, 3)) |
3737 |
| SEC_IN_MEMORY | SEC_LINKER_CREATED |
return FALSE; |
3738 |
| SEC_READONLY)) |
|
3739 |
|| ! bfd_set_section_alignment (dynobj, htab->srelgot, 3)) |
relgot = bfd_make_section (abfd, ".rela.got"); |
3740 |
return false; |
if (!relgot |
3741 |
return true; |
|| ! bfd_set_section_flags (abfd, relgot, flags | SEC_READONLY) |
3742 |
|
|| ! bfd_set_section_alignment (abfd, relgot, 3)) |
3743 |
|
return FALSE; |
3744 |
|
|
3745 |
|
ppc64_elf_tdata (abfd)->got = got; |
3746 |
|
ppc64_elf_tdata (abfd)->relgot = relgot; |
3747 |
|
return TRUE; |
3748 |
} |
} |
3749 |
|
|
3750 |
/* Create the dynamic sections, and set up shortcuts. */ |
/* Create the dynamic sections, and set up shortcuts. */ |
3751 |
|
|
3752 |
static boolean |
static bfd_boolean |
3753 |
ppc64_elf_create_dynamic_sections (dynobj, info) |
ppc64_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) |
|
bfd *dynobj; |
|
|
struct bfd_link_info *info; |
|
3754 |
{ |
{ |
3755 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
3756 |
|
|
|
htab = ppc_hash_table (info); |
|
|
if (!htab->sgot && !create_got_section (dynobj, info)) |
|
|
return false; |
|
|
|
|
3757 |
if (!_bfd_elf_create_dynamic_sections (dynobj, info)) |
if (!_bfd_elf_create_dynamic_sections (dynobj, info)) |
3758 |
return false; |
return FALSE; |
3759 |
|
|
3760 |
htab->splt = bfd_get_section_by_name (dynobj, ".plt"); |
htab = ppc_hash_table (info); |
3761 |
htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt"); |
if (!htab->got) |
3762 |
htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); |
htab->got = bfd_get_section_by_name (dynobj, ".got"); |
3763 |
|
htab->plt = bfd_get_section_by_name (dynobj, ".plt"); |
3764 |
|
htab->relplt = bfd_get_section_by_name (dynobj, ".rela.plt"); |
3765 |
|
htab->dynbss = bfd_get_section_by_name (dynobj, ".dynbss"); |
3766 |
if (!info->shared) |
if (!info->shared) |
3767 |
htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); |
htab->relbss = bfd_get_section_by_name (dynobj, ".rela.bss"); |
3768 |
|
|
3769 |
if (!htab->splt || !htab->srelplt || !htab->sdynbss |
if (!htab->got || !htab->plt || !htab->relplt || !htab->dynbss |
3770 |
|| (!info->shared && !htab->srelbss)) |
|| (!info->shared && !htab->relbss)) |
3771 |
abort (); |
abort (); |
3772 |
|
|
3773 |
return true; |
return TRUE; |
3774 |
|
} |
3775 |
|
|
3776 |
|
/* Merge PLT info on FROM with that on TO. */ |
3777 |
|
|
3778 |
|
static void |
3779 |
|
move_plt_plist (struct ppc_link_hash_entry *from, |
3780 |
|
struct ppc_link_hash_entry *to) |
3781 |
|
{ |
3782 |
|
if (from->elf.plt.plist != NULL) |
3783 |
|
{ |
3784 |
|
if (to->elf.plt.plist != NULL) |
3785 |
|
{ |
3786 |
|
struct plt_entry **entp; |
3787 |
|
struct plt_entry *ent; |
3788 |
|
|
3789 |
|
for (entp = &from->elf.plt.plist; (ent = *entp) != NULL; ) |
3790 |
|
{ |
3791 |
|
struct plt_entry *dent; |
3792 |
|
|
3793 |
|
for (dent = to->elf.plt.plist; dent != NULL; dent = dent->next) |
3794 |
|
if (dent->addend == ent->addend) |
3795 |
|
{ |
3796 |
|
dent->plt.refcount += ent->plt.refcount; |
3797 |
|
*entp = ent->next; |
3798 |
|
break; |
3799 |
|
} |
3800 |
|
if (dent == NULL) |
3801 |
|
entp = &ent->next; |
3802 |
|
} |
3803 |
|
*entp = to->elf.plt.plist; |
3804 |
|
} |
3805 |
|
|
3806 |
|
to->elf.plt.plist = from->elf.plt.plist; |
3807 |
|
from->elf.plt.plist = NULL; |
3808 |
|
} |
3809 |
} |
} |
3810 |
|
|
3811 |
/* Copy the extra info we tack onto an elf_link_hash_entry. */ |
/* Copy the extra info we tack onto an elf_link_hash_entry. */ |
3812 |
|
|
3813 |
static void |
static void |
3814 |
ppc64_elf_copy_indirect_symbol (dir, ind) |
ppc64_elf_copy_indirect_symbol |
3815 |
struct elf_link_hash_entry *dir, *ind; |
(const struct elf_backend_data *bed ATTRIBUTE_UNUSED, |
3816 |
|
struct elf_link_hash_entry *dir, |
3817 |
|
struct elf_link_hash_entry *ind) |
3818 |
{ |
{ |
3819 |
struct ppc_link_hash_entry *edir, *eind; |
struct ppc_link_hash_entry *edir, *eind; |
3820 |
|
|
3821 |
edir = (struct ppc_link_hash_entry *) dir; |
edir = (struct ppc_link_hash_entry *) dir; |
3822 |
eind = (struct ppc_link_hash_entry *) ind; |
eind = (struct ppc_link_hash_entry *) ind; |
3823 |
|
|
3824 |
|
/* Copy over any dynamic relocs we may have on the indirect sym. */ |
3825 |
if (eind->dyn_relocs != NULL) |
if (eind->dyn_relocs != NULL) |
3826 |
{ |
{ |
3827 |
if (edir->dyn_relocs != NULL) |
if (edir->dyn_relocs != NULL) |
3829 |
struct ppc_dyn_relocs **pp; |
struct ppc_dyn_relocs **pp; |
3830 |
struct ppc_dyn_relocs *p; |
struct ppc_dyn_relocs *p; |
3831 |
|
|
3832 |
if (ind->root.type == bfd_link_hash_indirect) |
if (eind->elf.root.type == bfd_link_hash_indirect) |
3833 |
abort (); |
abort (); |
3834 |
|
|
3835 |
/* Add reloc counts against the weak sym to the strong sym |
/* Add reloc counts against the weak sym to the strong sym |
3858 |
|
|
3859 |
edir->is_func |= eind->is_func; |
edir->is_func |= eind->is_func; |
3860 |
edir->is_func_descriptor |= eind->is_func_descriptor; |
edir->is_func_descriptor |= eind->is_func_descriptor; |
3861 |
edir->is_entry |= eind->is_entry; |
edir->tls_mask |= eind->tls_mask; |
3862 |
|
|
3863 |
|
/* If called to transfer flags for a weakdef during processing |
3864 |
|
of elf_adjust_dynamic_symbol, don't copy NON_GOT_REF. |
3865 |
|
We clear it ourselves for ELIMINATE_COPY_RELOCS. */ |
3866 |
|
if (!(ELIMINATE_COPY_RELOCS |
3867 |
|
&& eind->elf.root.type != bfd_link_hash_indirect |
3868 |
|
&& edir->elf.dynamic_adjusted)) |
3869 |
|
edir->elf.non_got_ref |= eind->elf.non_got_ref; |
3870 |
|
|
3871 |
|
edir->elf.ref_dynamic |= eind->elf.ref_dynamic; |
3872 |
|
edir->elf.ref_regular |= eind->elf.ref_regular; |
3873 |
|
edir->elf.ref_regular_nonweak |= eind->elf.ref_regular_nonweak; |
3874 |
|
edir->elf.needs_plt |= eind->elf.needs_plt; |
3875 |
|
|
3876 |
|
/* If we were called to copy over info for a weak sym, that's all. */ |
3877 |
|
if (eind->elf.root.type != bfd_link_hash_indirect) |
3878 |
|
return; |
3879 |
|
|
3880 |
|
/* Copy over got entries that we may have already seen to the |
3881 |
|
symbol which just became indirect. */ |
3882 |
|
if (eind->elf.got.glist != NULL) |
3883 |
|
{ |
3884 |
|
if (edir->elf.got.glist != NULL) |
3885 |
|
{ |
3886 |
|
struct got_entry **entp; |
3887 |
|
struct got_entry *ent; |
3888 |
|
|
3889 |
|
for (entp = &eind->elf.got.glist; (ent = *entp) != NULL; ) |
3890 |
|
{ |
3891 |
|
struct got_entry *dent; |
3892 |
|
|
3893 |
|
for (dent = edir->elf.got.glist; dent != NULL; dent = dent->next) |
3894 |
|
if (dent->addend == ent->addend |
3895 |
|
&& dent->owner == ent->owner |
3896 |
|
&& dent->tls_type == ent->tls_type) |
3897 |
|
{ |
3898 |
|
dent->got.refcount += ent->got.refcount; |
3899 |
|
*entp = ent->next; |
3900 |
|
break; |
3901 |
|
} |
3902 |
|
if (dent == NULL) |
3903 |
|
entp = &ent->next; |
3904 |
|
} |
3905 |
|
*entp = edir->elf.got.glist; |
3906 |
|
} |
3907 |
|
|
3908 |
|
edir->elf.got.glist = eind->elf.got.glist; |
3909 |
|
eind->elf.got.glist = NULL; |
3910 |
|
} |
3911 |
|
|
3912 |
|
/* And plt entries. */ |
3913 |
|
move_plt_plist (eind, edir); |
3914 |
|
|
3915 |
|
if (edir->elf.dynindx == -1) |
3916 |
|
{ |
3917 |
|
edir->elf.dynindx = eind->elf.dynindx; |
3918 |
|
edir->elf.dynstr_index = eind->elf.dynstr_index; |
3919 |
|
eind->elf.dynindx = -1; |
3920 |
|
eind->elf.dynstr_index = 0; |
3921 |
|
} |
3922 |
|
else |
3923 |
|
BFD_ASSERT (eind->elf.dynindx == -1); |
3924 |
|
} |
3925 |
|
|
3926 |
|
/* Find the function descriptor hash entry from the given function code |
3927 |
|
hash entry FH. Link the entries via their OH fields. */ |
3928 |
|
|
3929 |
_bfd_elf_link_hash_copy_indirect (dir, ind); |
static struct ppc_link_hash_entry * |
3930 |
|
get_fdh (struct ppc_link_hash_entry *fh, struct ppc_link_hash_table *htab) |
3931 |
|
{ |
3932 |
|
struct ppc_link_hash_entry *fdh = fh->oh; |
3933 |
|
|
3934 |
|
if (fdh == NULL) |
3935 |
|
{ |
3936 |
|
const char *fd_name = fh->elf.root.root.string + 1; |
3937 |
|
|
3938 |
|
fdh = (struct ppc_link_hash_entry *) |
3939 |
|
elf_link_hash_lookup (&htab->elf, fd_name, FALSE, FALSE, FALSE); |
3940 |
|
if (fdh != NULL) |
3941 |
|
{ |
3942 |
|
fdh->is_func_descriptor = 1; |
3943 |
|
fdh->oh = fh; |
3944 |
|
fh->is_func = 1; |
3945 |
|
fh->oh = fdh; |
3946 |
|
} |
3947 |
|
} |
3948 |
|
|
3949 |
|
return fdh; |
3950 |
} |
} |
3951 |
|
|
3952 |
/* Set a flag, used by ppc64_elf_gc_mark_hook, on the entry symbol and |
/* Make a fake function descriptor sym for the code sym FH. */ |
|
symbols undefined on the command-line. */ |
|
3953 |
|
|
3954 |
boolean |
static struct ppc_link_hash_entry * |
3955 |
ppc64_elf_mark_entry_syms (info) |
make_fdh (struct bfd_link_info *info, |
3956 |
struct bfd_link_info *info; |
struct ppc_link_hash_entry *fh) |
3957 |
{ |
{ |
3958 |
|
bfd *abfd; |
3959 |
|
asymbol *newsym; |
3960 |
|
struct bfd_link_hash_entry *bh; |
3961 |
|
struct ppc_link_hash_entry *fdh; |
3962 |
|
|
3963 |
|
abfd = fh->elf.root.u.undef.abfd; |
3964 |
|
newsym = bfd_make_empty_symbol (abfd); |
3965 |
|
newsym->name = fh->elf.root.root.string + 1; |
3966 |
|
newsym->section = bfd_und_section_ptr; |
3967 |
|
newsym->value = 0; |
3968 |
|
newsym->flags = BSF_WEAK; |
3969 |
|
|
3970 |
|
bh = NULL; |
3971 |
|
if (!_bfd_generic_link_add_one_symbol (info, abfd, newsym->name, |
3972 |
|
newsym->flags, newsym->section, |
3973 |
|
newsym->value, NULL, FALSE, FALSE, |
3974 |
|
&bh)) |
3975 |
|
return NULL; |
3976 |
|
|
3977 |
|
fdh = (struct ppc_link_hash_entry *) bh; |
3978 |
|
fdh->elf.non_elf = 0; |
3979 |
|
fdh->fake = 1; |
3980 |
|
fdh->is_func_descriptor = 1; |
3981 |
|
fdh->oh = fh; |
3982 |
|
fh->is_func = 1; |
3983 |
|
fh->oh = fdh; |
3984 |
|
return fdh; |
3985 |
|
} |
3986 |
|
|
3987 |
|
/* Hacks to support old ABI code. |
3988 |
|
When making function calls, old ABI code references function entry |
3989 |
|
points (dot symbols), while new ABI code references the function |
3990 |
|
descriptor symbol. We need to make any combination of reference and |
3991 |
|
definition work together, without breaking archive linking. |
3992 |
|
|
3993 |
|
For a defined function "foo" and an undefined call to "bar": |
3994 |
|
An old object defines "foo" and ".foo", references ".bar" (possibly |
3995 |
|
"bar" too). |
3996 |
|
A new object defines "foo" and references "bar". |
3997 |
|
|
3998 |
|
A new object thus has no problem with its undefined symbols being |
3999 |
|
satisfied by definitions in an old object. On the other hand, the |
4000 |
|
old object won't have ".bar" satisfied by a new object. */ |
4001 |
|
|
4002 |
|
/* Fix function descriptor symbols defined in .opd sections to be |
4003 |
|
function type. */ |
4004 |
|
|
4005 |
|
static bfd_boolean |
4006 |
|
ppc64_elf_add_symbol_hook (bfd *ibfd, |
4007 |
|
struct bfd_link_info *info ATTRIBUTE_UNUSED, |
4008 |
|
Elf_Internal_Sym *isym, |
4009 |
|
const char **name, |
4010 |
|
flagword *flags ATTRIBUTE_UNUSED, |
4011 |
|
asection **sec, |
4012 |
|
bfd_vma *value ATTRIBUTE_UNUSED) |
4013 |
|
{ |
4014 |
|
if (*sec != NULL |
4015 |
|
&& strcmp (bfd_get_section_name (ibfd, *sec), ".opd") == 0) |
4016 |
|
isym->st_info = ELF_ST_INFO (ELF_ST_BIND (isym->st_info), STT_FUNC); |
4017 |
|
|
4018 |
|
if ((*name)[0] == '.' |
4019 |
|
&& ELF_ST_BIND (isym->st_info) == STB_GLOBAL |
4020 |
|
&& ELF_ST_TYPE (isym->st_info) < STT_SECTION |
4021 |
|
&& is_ppc64_elf_target (ibfd->xvec)) |
4022 |
|
ppc64_elf_tdata (ibfd)->u.has_dotsym = 1; |
4023 |
|
|
4024 |
|
return TRUE; |
4025 |
|
} |
4026 |
|
|
4027 |
|
/* This function makes an old ABI object reference to ".bar" cause the |
4028 |
|
inclusion of a new ABI object archive that defines "bar". |
4029 |
|
NAME is a symbol defined in an archive. Return a symbol in the hash |
4030 |
|
table that might be satisfied by the archive symbols. */ |
4031 |
|
|
4032 |
|
static struct elf_link_hash_entry * |
4033 |
|
ppc64_elf_archive_symbol_lookup (bfd *abfd, |
4034 |
|
struct bfd_link_info *info, |
4035 |
|
const char *name) |
4036 |
|
{ |
4037 |
|
struct elf_link_hash_entry *h; |
4038 |
|
char *dot_name; |
4039 |
|
size_t len; |
4040 |
|
|
4041 |
|
h = _bfd_elf_archive_symbol_lookup (abfd, info, name); |
4042 |
|
if (h != NULL |
4043 |
|
/* Don't return this sym if it is a fake function descriptor |
4044 |
|
created by add_symbol_adjust. */ |
4045 |
|
&& !(h->root.type == bfd_link_hash_undefweak |
4046 |
|
&& ((struct ppc_link_hash_entry *) h)->fake)) |
4047 |
|
return h; |
4048 |
|
|
4049 |
|
if (name[0] == '.') |
4050 |
|
return h; |
4051 |
|
|
4052 |
|
len = strlen (name); |
4053 |
|
dot_name = bfd_alloc (abfd, len + 2); |
4054 |
|
if (dot_name == NULL) |
4055 |
|
return (struct elf_link_hash_entry *) 0 - 1; |
4056 |
|
dot_name[0] = '.'; |
4057 |
|
memcpy (dot_name + 1, name, len + 1); |
4058 |
|
h = _bfd_elf_archive_symbol_lookup (abfd, info, dot_name); |
4059 |
|
bfd_release (abfd, dot_name); |
4060 |
|
return h; |
4061 |
|
} |
4062 |
|
|
4063 |
|
/* This function satisfies all old ABI object references to ".bar" if a |
4064 |
|
new ABI object defines "bar". Well, at least, undefined dot symbols |
4065 |
|
are made weak. This stops later archive searches from including an |
4066 |
|
object if we already have a function descriptor definition. It also |
4067 |
|
prevents the linker complaining about undefined symbols. |
4068 |
|
We also check and correct mismatched symbol visibility here. The |
4069 |
|
most restrictive visibility of the function descriptor and the |
4070 |
|
function entry symbol is used. */ |
4071 |
|
|
4072 |
|
struct add_symbol_adjust_data |
4073 |
|
{ |
4074 |
|
struct bfd_link_info *info; |
4075 |
|
bfd_boolean ok; |
4076 |
|
}; |
4077 |
|
|
4078 |
|
static bfd_boolean |
4079 |
|
add_symbol_adjust (struct elf_link_hash_entry *h, void *inf) |
4080 |
|
{ |
4081 |
|
struct add_symbol_adjust_data *data; |
4082 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
4083 |
struct bfd_sym_chain *sym; |
struct ppc_link_hash_entry *eh; |
4084 |
|
struct ppc_link_hash_entry *fdh; |
4085 |
|
|
4086 |
|
if (h->root.type == bfd_link_hash_indirect) |
4087 |
|
return TRUE; |
4088 |
|
|
4089 |
|
if (h->root.type == bfd_link_hash_warning) |
4090 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
4091 |
|
|
4092 |
|
if (h->root.root.string[0] != '.') |
4093 |
|
return TRUE; |
4094 |
|
|
4095 |
|
data = inf; |
4096 |
|
htab = ppc_hash_table (data->info); |
4097 |
|
eh = (struct ppc_link_hash_entry *) h; |
4098 |
|
fdh = get_fdh (eh, htab); |
4099 |
|
if (fdh == NULL |
4100 |
|
&& !data->info->relocatable |
4101 |
|
&& (eh->elf.root.type == bfd_link_hash_undefined |
4102 |
|
|| eh->elf.root.type == bfd_link_hash_undefweak) |
4103 |
|
&& eh->elf.ref_regular) |
4104 |
|
{ |
4105 |
|
/* Make an undefweak function descriptor sym, which is enough to |
4106 |
|
pull in an --as-needed shared lib, but won't cause link |
4107 |
|
errors. Archives are handled elsewhere. */ |
4108 |
|
fdh = make_fdh (data->info, eh); |
4109 |
|
if (fdh == NULL) |
4110 |
|
data->ok = FALSE; |
4111 |
|
else |
4112 |
|
fdh->elf.ref_regular = 1; |
4113 |
|
} |
4114 |
|
else if (fdh != NULL) |
4115 |
|
{ |
4116 |
|
unsigned entry_vis = ELF_ST_VISIBILITY (eh->elf.other) - 1; |
4117 |
|
unsigned descr_vis = ELF_ST_VISIBILITY (fdh->elf.other) - 1; |
4118 |
|
if (entry_vis < descr_vis) |
4119 |
|
fdh->elf.other += entry_vis - descr_vis; |
4120 |
|
else if (entry_vis > descr_vis) |
4121 |
|
eh->elf.other += descr_vis - entry_vis; |
4122 |
|
|
4123 |
|
if ((fdh->elf.root.type == bfd_link_hash_defined |
4124 |
|
|| fdh->elf.root.type == bfd_link_hash_defweak) |
4125 |
|
&& eh->elf.root.type == bfd_link_hash_undefined) |
4126 |
|
{ |
4127 |
|
eh->elf.root.type = bfd_link_hash_undefweak; |
4128 |
|
eh->was_undefined = 1; |
4129 |
|
htab->twiddled_syms = 1; |
4130 |
|
} |
4131 |
|
} |
4132 |
|
|
4133 |
|
return TRUE; |
4134 |
|
} |
4135 |
|
|
4136 |
|
static bfd_boolean |
4137 |
|
ppc64_elf_check_directives (bfd *abfd, struct bfd_link_info *info) |
4138 |
|
{ |
4139 |
|
struct ppc_link_hash_table *htab; |
4140 |
|
struct add_symbol_adjust_data data; |
4141 |
|
|
4142 |
|
if (!is_ppc64_elf_target (abfd->xvec)) |
4143 |
|
return TRUE; |
4144 |
|
|
4145 |
|
if (!ppc64_elf_tdata (abfd)->u.has_dotsym) |
4146 |
|
return TRUE; |
4147 |
|
ppc64_elf_tdata (abfd)->u.deleted_section = NULL; |
4148 |
|
|
4149 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
4150 |
for (sym = info->gc_sym_list; sym; sym = sym->next) |
if (!is_ppc64_elf_target (htab->elf.root.creator)) |
4151 |
|
return TRUE; |
4152 |
|
|
4153 |
|
data.info = info; |
4154 |
|
data.ok = TRUE; |
4155 |
|
elf_link_hash_traverse (&htab->elf, add_symbol_adjust, &data); |
4156 |
|
|
4157 |
|
/* We need to fix the undefs list for any syms we have twiddled to |
4158 |
|
undef_weak. */ |
4159 |
|
if (htab->twiddled_syms) |
4160 |
{ |
{ |
4161 |
struct elf_link_hash_entry *h; |
bfd_link_repair_undef_list (&htab->elf.root); |
4162 |
|
htab->twiddled_syms = 0; |
4163 |
|
} |
4164 |
|
return data.ok; |
4165 |
|
} |
4166 |
|
|
4167 |
h = elf_link_hash_lookup (&htab->elf, sym->name, false, false, false); |
static bfd_boolean |
4168 |
if (h != NULL) |
update_local_sym_info (bfd *abfd, Elf_Internal_Shdr *symtab_hdr, |
4169 |
((struct ppc_link_hash_entry *) h)->is_entry = 1; |
unsigned long r_symndx, bfd_vma r_addend, int tls_type) |
4170 |
|
{ |
4171 |
|
struct got_entry **local_got_ents = elf_local_got_ents (abfd); |
4172 |
|
char *local_got_tls_masks; |
4173 |
|
|
4174 |
|
if (local_got_ents == NULL) |
4175 |
|
{ |
4176 |
|
bfd_size_type size = symtab_hdr->sh_info; |
4177 |
|
|
4178 |
|
size *= sizeof (*local_got_ents) + sizeof (*local_got_tls_masks); |
4179 |
|
local_got_ents = bfd_zalloc (abfd, size); |
4180 |
|
if (local_got_ents == NULL) |
4181 |
|
return FALSE; |
4182 |
|
elf_local_got_ents (abfd) = local_got_ents; |
4183 |
} |
} |
4184 |
return true; |
|
4185 |
|
if ((tls_type & TLS_EXPLICIT) == 0) |
4186 |
|
{ |
4187 |
|
struct got_entry *ent; |
4188 |
|
|
4189 |
|
for (ent = local_got_ents[r_symndx]; ent != NULL; ent = ent->next) |
4190 |
|
if (ent->addend == r_addend |
4191 |
|
&& ent->owner == abfd |
4192 |
|
&& ent->tls_type == tls_type) |
4193 |
|
break; |
4194 |
|
if (ent == NULL) |
4195 |
|
{ |
4196 |
|
bfd_size_type amt = sizeof (*ent); |
4197 |
|
ent = bfd_alloc (abfd, amt); |
4198 |
|
if (ent == NULL) |
4199 |
|
return FALSE; |
4200 |
|
ent->next = local_got_ents[r_symndx]; |
4201 |
|
ent->addend = r_addend; |
4202 |
|
ent->owner = abfd; |
4203 |
|
ent->tls_type = tls_type; |
4204 |
|
ent->got.refcount = 0; |
4205 |
|
local_got_ents[r_symndx] = ent; |
4206 |
|
} |
4207 |
|
ent->got.refcount += 1; |
4208 |
|
} |
4209 |
|
|
4210 |
|
local_got_tls_masks = (char *) (local_got_ents + symtab_hdr->sh_info); |
4211 |
|
local_got_tls_masks[r_symndx] |= tls_type; |
4212 |
|
return TRUE; |
4213 |
|
} |
4214 |
|
|
4215 |
|
static bfd_boolean |
4216 |
|
update_plt_info (bfd *abfd, struct ppc_link_hash_entry *eh, bfd_vma addend) |
4217 |
|
{ |
4218 |
|
struct plt_entry *ent; |
4219 |
|
|
4220 |
|
for (ent = eh->elf.plt.plist; ent != NULL; ent = ent->next) |
4221 |
|
if (ent->addend == addend) |
4222 |
|
break; |
4223 |
|
if (ent == NULL) |
4224 |
|
{ |
4225 |
|
bfd_size_type amt = sizeof (*ent); |
4226 |
|
ent = bfd_alloc (abfd, amt); |
4227 |
|
if (ent == NULL) |
4228 |
|
return FALSE; |
4229 |
|
ent->next = eh->elf.plt.plist; |
4230 |
|
ent->addend = addend; |
4231 |
|
ent->plt.refcount = 0; |
4232 |
|
eh->elf.plt.plist = ent; |
4233 |
|
} |
4234 |
|
ent->plt.refcount += 1; |
4235 |
|
eh->elf.needs_plt = 1; |
4236 |
|
if (eh->elf.root.root.string[0] == '.' |
4237 |
|
&& eh->elf.root.root.string[1] != '\0') |
4238 |
|
eh->is_func = 1; |
4239 |
|
return TRUE; |
4240 |
} |
} |
4241 |
|
|
4242 |
/* Look through the relocs for a section during the first phase, and |
/* Look through the relocs for a section during the first phase, and |
4243 |
calculate needed space in the global offset table, procedure |
calculate needed space in the global offset table, procedure |
4244 |
linkage table, and dynamic reloc sections. */ |
linkage table, and dynamic reloc sections. */ |
4245 |
|
|
4246 |
static boolean |
static bfd_boolean |
4247 |
ppc64_elf_check_relocs (abfd, info, sec, relocs) |
ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, |
4248 |
bfd *abfd; |
asection *sec, const Elf_Internal_Rela *relocs) |
|
struct bfd_link_info *info; |
|
|
asection *sec; |
|
|
const Elf_Internal_Rela *relocs; |
|
4249 |
{ |
{ |
4250 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
4251 |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_hdr; |
4255 |
asection *sreloc; |
asection *sreloc; |
4256 |
asection **opd_sym_map; |
asection **opd_sym_map; |
4257 |
|
|
4258 |
if (info->relocateable) |
if (info->relocatable) |
4259 |
return true; |
return TRUE; |
4260 |
|
|
4261 |
|
/* Don't do anything special with non-loaded, non-alloced sections. |
4262 |
|
In particular, any relocs in such sections should not affect GOT |
4263 |
|
and PLT reference counting (ie. we don't allow them to create GOT |
4264 |
|
or PLT entries), there's no possibility or desire to optimize TLS |
4265 |
|
relocs, and there's not much point in propagating relocs to shared |
4266 |
|
libs that the dynamic linker won't relocate. */ |
4267 |
|
if ((sec->flags & SEC_ALLOC) == 0) |
4268 |
|
return TRUE; |
4269 |
|
|
4270 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
4271 |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
4294 |
}; |
}; |
4295 |
bfd_size_type amt; |
bfd_size_type amt; |
4296 |
|
|
4297 |
amt = sec->_raw_size * sizeof (union opd_info) / 24; |
amt = sec->size * sizeof (union opd_info) / 8; |
4298 |
opd_sym_map = (asection **) bfd_zalloc (abfd, amt); |
opd_sym_map = bfd_zalloc (abfd, amt); |
4299 |
if (opd_sym_map == NULL) |
if (opd_sym_map == NULL) |
4300 |
return false; |
return FALSE; |
4301 |
elf_section_data (sec)->tdata = opd_sym_map; |
ppc64_elf_section_data (sec)->opd.func_sec = opd_sym_map; |
4302 |
} |
} |
4303 |
|
|
|
if (htab->elf.dynobj == NULL) |
|
|
htab->elf.dynobj = abfd; |
|
4304 |
if (htab->sfpr == NULL |
if (htab->sfpr == NULL |
4305 |
&& !create_linkage_sections (htab->elf.dynobj, info)) |
&& !create_linkage_sections (htab->elf.dynobj, info)) |
4306 |
return false; |
return FALSE; |
4307 |
|
|
4308 |
rel_end = relocs + sec->reloc_count; |
rel_end = relocs + sec->reloc_count; |
4309 |
for (rel = relocs; rel < rel_end; rel++) |
for (rel = relocs; rel < rel_end; rel++) |
4310 |
{ |
{ |
4311 |
unsigned long r_symndx; |
unsigned long r_symndx; |
4312 |
struct elf_link_hash_entry *h; |
struct elf_link_hash_entry *h; |
4313 |
enum elf_ppc_reloc_type r_type; |
enum elf_ppc64_reloc_type r_type; |
4314 |
|
int tls_type = 0; |
4315 |
|
|
4316 |
r_symndx = ELF64_R_SYM (rel->r_info); |
r_symndx = ELF64_R_SYM (rel->r_info); |
4317 |
if (r_symndx < symtab_hdr->sh_info) |
if (r_symndx < symtab_hdr->sh_info) |
4319 |
else |
else |
4320 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
4321 |
|
|
4322 |
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); |
r_type = ELF64_R_TYPE (rel->r_info); |
4323 |
switch (r_type) |
switch (r_type) |
4324 |
{ |
{ |
4325 |
/* GOT16 relocations */ |
case R_PPC64_GOT_TLSLD16: |
4326 |
|
case R_PPC64_GOT_TLSLD16_LO: |
4327 |
|
case R_PPC64_GOT_TLSLD16_HI: |
4328 |
|
case R_PPC64_GOT_TLSLD16_HA: |
4329 |
|
ppc64_tlsld_got (abfd)->refcount += 1; |
4330 |
|
tls_type = TLS_TLS | TLS_LD; |
4331 |
|
goto dogottls; |
4332 |
|
|
4333 |
|
case R_PPC64_GOT_TLSGD16: |
4334 |
|
case R_PPC64_GOT_TLSGD16_LO: |
4335 |
|
case R_PPC64_GOT_TLSGD16_HI: |
4336 |
|
case R_PPC64_GOT_TLSGD16_HA: |
4337 |
|
tls_type = TLS_TLS | TLS_GD; |
4338 |
|
goto dogottls; |
4339 |
|
|
4340 |
|
case R_PPC64_GOT_TPREL16_DS: |
4341 |
|
case R_PPC64_GOT_TPREL16_LO_DS: |
4342 |
|
case R_PPC64_GOT_TPREL16_HI: |
4343 |
|
case R_PPC64_GOT_TPREL16_HA: |
4344 |
|
if (info->shared) |
4345 |
|
info->flags |= DF_STATIC_TLS; |
4346 |
|
tls_type = TLS_TLS | TLS_TPREL; |
4347 |
|
goto dogottls; |
4348 |
|
|
4349 |
|
case R_PPC64_GOT_DTPREL16_DS: |
4350 |
|
case R_PPC64_GOT_DTPREL16_LO_DS: |
4351 |
|
case R_PPC64_GOT_DTPREL16_HI: |
4352 |
|
case R_PPC64_GOT_DTPREL16_HA: |
4353 |
|
tls_type = TLS_TLS | TLS_DTPREL; |
4354 |
|
dogottls: |
4355 |
|
sec->has_tls_reloc = 1; |
4356 |
|
/* Fall thru */ |
4357 |
|
|
4358 |
case R_PPC64_GOT16: |
case R_PPC64_GOT16: |
4359 |
case R_PPC64_GOT16_DS: |
case R_PPC64_GOT16_DS: |
4360 |
case R_PPC64_GOT16_HA: |
case R_PPC64_GOT16_HA: |
4361 |
case R_PPC64_GOT16_HI: |
case R_PPC64_GOT16_HI: |
4362 |
case R_PPC64_GOT16_LO: |
case R_PPC64_GOT16_LO: |
4363 |
case R_PPC64_GOT16_LO_DS: |
case R_PPC64_GOT16_LO_DS: |
|
|
|
4364 |
/* This symbol requires a global offset table entry. */ |
/* This symbol requires a global offset table entry. */ |
4365 |
if (htab->sgot == NULL |
sec->has_toc_reloc = 1; |
4366 |
&& !create_got_section (htab->elf.dynobj, info)) |
if (ppc64_elf_tdata (abfd)->got == NULL |
4367 |
return false; |
&& !create_got_section (abfd, info)) |
4368 |
|
return FALSE; |
4369 |
|
|
4370 |
if (h != NULL) |
if (h != NULL) |
4371 |
{ |
{ |
4372 |
h->got.refcount += 1; |
struct ppc_link_hash_entry *eh; |
4373 |
} |
struct got_entry *ent; |
|
else |
|
|
{ |
|
|
bfd_signed_vma *local_got_refcounts; |
|
4374 |
|
|
4375 |
/* This is a global offset table entry for a local symbol. */ |
eh = (struct ppc_link_hash_entry *) h; |
4376 |
local_got_refcounts = elf_local_got_refcounts (abfd); |
for (ent = eh->elf.got.glist; ent != NULL; ent = ent->next) |
4377 |
if (local_got_refcounts == NULL) |
if (ent->addend == rel->r_addend |
4378 |
{ |
&& ent->owner == abfd |
4379 |
bfd_size_type size; |
&& ent->tls_type == tls_type) |
4380 |
|
break; |
4381 |
size = symtab_hdr->sh_info; |
if (ent == NULL) |
4382 |
size *= sizeof (bfd_signed_vma); |
{ |
4383 |
local_got_refcounts = ((bfd_signed_vma *) |
bfd_size_type amt = sizeof (*ent); |
4384 |
bfd_zalloc (abfd, size)); |
ent = bfd_alloc (abfd, amt); |
4385 |
if (local_got_refcounts == NULL) |
if (ent == NULL) |
4386 |
return false; |
return FALSE; |
4387 |
elf_local_got_refcounts (abfd) = local_got_refcounts; |
ent->next = eh->elf.got.glist; |
4388 |
|
ent->addend = rel->r_addend; |
4389 |
|
ent->owner = abfd; |
4390 |
|
ent->tls_type = tls_type; |
4391 |
|
ent->got.refcount = 0; |
4392 |
|
eh->elf.got.glist = ent; |
4393 |
} |
} |
4394 |
local_got_refcounts[r_symndx] += 1; |
ent->got.refcount += 1; |
4395 |
|
eh->tls_mask |= tls_type; |
4396 |
} |
} |
4397 |
|
else |
4398 |
|
/* This is a global offset table entry for a local symbol. */ |
4399 |
|
if (!update_local_sym_info (abfd, symtab_hdr, r_symndx, |
4400 |
|
rel->r_addend, tls_type)) |
4401 |
|
return FALSE; |
4402 |
break; |
break; |
4403 |
|
|
4404 |
case R_PPC64_PLT16_HA: |
case R_PPC64_PLT16_HA: |
4416 |
/* It does not make sense to have a procedure linkage |
/* It does not make sense to have a procedure linkage |
4417 |
table entry for a local symbol. */ |
table entry for a local symbol. */ |
4418 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
4419 |
return false; |
return FALSE; |
4420 |
} |
} |
4421 |
|
else |
4422 |
h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; |
if (!update_plt_info (abfd, (struct ppc_link_hash_entry *) h, |
4423 |
h->plt.refcount += 1; |
rel->r_addend)) |
4424 |
((struct ppc_link_hash_entry *) h)->is_func = 1; |
return FALSE; |
4425 |
break; |
break; |
4426 |
|
|
4427 |
/* The following relocations don't need to propagate the |
/* The following relocations don't need to propagate the |
4433 |
case R_PPC64_SECTOFF_HA: |
case R_PPC64_SECTOFF_HA: |
4434 |
case R_PPC64_SECTOFF_DS: |
case R_PPC64_SECTOFF_DS: |
4435 |
case R_PPC64_SECTOFF_LO_DS: |
case R_PPC64_SECTOFF_LO_DS: |
4436 |
|
case R_PPC64_DTPREL16: |
4437 |
|
case R_PPC64_DTPREL16_LO: |
4438 |
|
case R_PPC64_DTPREL16_HI: |
4439 |
|
case R_PPC64_DTPREL16_HA: |
4440 |
|
case R_PPC64_DTPREL16_DS: |
4441 |
|
case R_PPC64_DTPREL16_LO_DS: |
4442 |
|
case R_PPC64_DTPREL16_HIGHER: |
4443 |
|
case R_PPC64_DTPREL16_HIGHERA: |
4444 |
|
case R_PPC64_DTPREL16_HIGHEST: |
4445 |
|
case R_PPC64_DTPREL16_HIGHESTA: |
4446 |
|
break; |
4447 |
|
|
4448 |
|
/* Nor do these. */ |
4449 |
case R_PPC64_TOC16: |
case R_PPC64_TOC16: |
4450 |
case R_PPC64_TOC16_LO: |
case R_PPC64_TOC16_LO: |
4451 |
case R_PPC64_TOC16_HI: |
case R_PPC64_TOC16_HI: |
4452 |
case R_PPC64_TOC16_HA: |
case R_PPC64_TOC16_HA: |
4453 |
case R_PPC64_TOC16_DS: |
case R_PPC64_TOC16_DS: |
4454 |
case R_PPC64_TOC16_LO_DS: |
case R_PPC64_TOC16_LO_DS: |
4455 |
|
sec->has_toc_reloc = 1; |
4456 |
break; |
break; |
4457 |
|
|
4458 |
/* This relocation describes the C++ object vtable hierarchy. |
/* This relocation describes the C++ object vtable hierarchy. |
4459 |
Reconstruct it for later use during GC. */ |
Reconstruct it for later use during GC. */ |
4460 |
case R_PPC64_GNU_VTINHERIT: |
case R_PPC64_GNU_VTINHERIT: |
4461 |
if (!_bfd_elf64_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
4462 |
return false; |
return FALSE; |
4463 |
break; |
break; |
4464 |
|
|
4465 |
/* This relocation describes which C++ vtable entries are actually |
/* This relocation describes which C++ vtable entries are actually |
4466 |
used. Record for later use during GC. */ |
used. Record for later use during GC. */ |
4467 |
case R_PPC64_GNU_VTENTRY: |
case R_PPC64_GNU_VTENTRY: |
4468 |
if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_addend)) |
if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) |
4469 |
return false; |
return FALSE; |
4470 |
break; |
break; |
4471 |
|
|
4472 |
case R_PPC64_REL14: |
case R_PPC64_REL14: |
4476 |
/* Fall through. */ |
/* Fall through. */ |
4477 |
|
|
4478 |
case R_PPC64_REL24: |
case R_PPC64_REL24: |
4479 |
if (h != NULL |
if (h != NULL) |
|
&& h->root.root.string[0] == '.' |
|
|
&& h->root.root.string[1] != 0) |
|
4480 |
{ |
{ |
4481 |
/* We may need a .plt entry if the function this reloc |
/* We may need a .plt entry if the function this reloc |
4482 |
refers to is in a shared lib. */ |
refers to is in a shared lib. */ |
4483 |
h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; |
if (!update_plt_info (abfd, (struct ppc_link_hash_entry *) h, |
4484 |
h->plt.refcount += 1; |
rel->r_addend)) |
4485 |
((struct ppc_link_hash_entry *) h)->is_func = 1; |
return FALSE; |
4486 |
|
if (h == &htab->tls_get_addr->elf |
4487 |
|
|| h == &htab->tls_get_addr_fd->elf) |
4488 |
|
sec->has_tls_reloc = 1; |
4489 |
|
else if (htab->tls_get_addr == NULL |
4490 |
|
&& !strncmp (h->root.root.string, ".__tls_get_addr", 15) |
4491 |
|
&& (h->root.root.string[15] == 0 |
4492 |
|
|| h->root.root.string[15] == '@')) |
4493 |
|
{ |
4494 |
|
htab->tls_get_addr = (struct ppc_link_hash_entry *) h; |
4495 |
|
sec->has_tls_reloc = 1; |
4496 |
|
} |
4497 |
|
else if (htab->tls_get_addr_fd == NULL |
4498 |
|
&& !strncmp (h->root.root.string, "__tls_get_addr", 14) |
4499 |
|
&& (h->root.root.string[14] == 0 |
4500 |
|
|| h->root.root.string[14] == '@')) |
4501 |
|
{ |
4502 |
|
htab->tls_get_addr_fd = (struct ppc_link_hash_entry *) h; |
4503 |
|
sec->has_tls_reloc = 1; |
4504 |
|
} |
4505 |
} |
} |
4506 |
break; |
break; |
4507 |
|
|
4508 |
case R_PPC64_ADDR64: |
case R_PPC64_TPREL64: |
4509 |
if (opd_sym_map != NULL |
tls_type = TLS_EXPLICIT | TLS_TLS | TLS_TPREL; |
4510 |
&& h != NULL |
if (info->shared) |
4511 |
&& h->root.root.string[0] == '.' |
info->flags |= DF_STATIC_TLS; |
4512 |
&& h->root.root.string[1] != 0) |
goto dotlstoc; |
4513 |
{ |
|
4514 |
struct elf_link_hash_entry *fdh; |
case R_PPC64_DTPMOD64: |
4515 |
|
if (rel + 1 < rel_end |
4516 |
fdh = elf_link_hash_lookup (&htab->elf, h->root.root.string + 1, |
&& rel[1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_DTPREL64) |
4517 |
false, false, false); |
&& rel[1].r_offset == rel->r_offset + 8) |
4518 |
if (fdh != NULL) |
tls_type = TLS_EXPLICIT | TLS_TLS | TLS_GD; |
4519 |
{ |
else |
4520 |
((struct ppc_link_hash_entry *) fdh)->is_func_descriptor = 1; |
tls_type = TLS_EXPLICIT | TLS_TLS | TLS_LD; |
4521 |
((struct ppc_link_hash_entry *) fdh)->oh = h; |
goto dotlstoc; |
4522 |
((struct ppc_link_hash_entry *) h)->is_func = 1; |
|
4523 |
((struct ppc_link_hash_entry *) h)->oh = fdh; |
case R_PPC64_DTPREL64: |
4524 |
} |
tls_type = TLS_EXPLICIT | TLS_TLS | TLS_DTPREL; |
4525 |
|
if (rel != relocs |
4526 |
|
&& rel[-1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_DTPMOD64) |
4527 |
|
&& rel[-1].r_offset == rel->r_offset - 8) |
4528 |
|
/* This is the second reloc of a dtpmod, dtprel pair. |
4529 |
|
Don't mark with TLS_DTPREL. */ |
4530 |
|
goto dodyn; |
4531 |
|
|
4532 |
|
dotlstoc: |
4533 |
|
sec->has_tls_reloc = 1; |
4534 |
|
if (h != NULL) |
4535 |
|
{ |
4536 |
|
struct ppc_link_hash_entry *eh; |
4537 |
|
eh = (struct ppc_link_hash_entry *) h; |
4538 |
|
eh->tls_mask |= tls_type; |
4539 |
} |
} |
4540 |
|
else |
4541 |
|
if (!update_local_sym_info (abfd, symtab_hdr, r_symndx, |
4542 |
|
rel->r_addend, tls_type)) |
4543 |
|
return FALSE; |
4544 |
|
|
4545 |
|
if (ppc64_elf_section_data (sec)->t_symndx == NULL) |
4546 |
|
{ |
4547 |
|
/* One extra to simplify get_tls_mask. */ |
4548 |
|
bfd_size_type amt = sec->size * sizeof (unsigned) / 8 + 1; |
4549 |
|
ppc64_elf_section_data (sec)->t_symndx = bfd_zalloc (abfd, amt); |
4550 |
|
if (ppc64_elf_section_data (sec)->t_symndx == NULL) |
4551 |
|
return FALSE; |
4552 |
|
} |
4553 |
|
BFD_ASSERT (rel->r_offset % 8 == 0); |
4554 |
|
ppc64_elf_section_data (sec)->t_symndx[rel->r_offset / 8] = r_symndx; |
4555 |
|
|
4556 |
|
/* Mark the second slot of a GD or LD entry. |
4557 |
|
-1 to indicate GD and -2 to indicate LD. */ |
4558 |
|
if (tls_type == (TLS_EXPLICIT | TLS_TLS | TLS_GD)) |
4559 |
|
ppc64_elf_section_data (sec)->t_symndx[rel->r_offset / 8 + 1] = -1; |
4560 |
|
else if (tls_type == (TLS_EXPLICIT | TLS_TLS | TLS_LD)) |
4561 |
|
ppc64_elf_section_data (sec)->t_symndx[rel->r_offset / 8 + 1] = -2; |
4562 |
|
goto dodyn; |
4563 |
|
|
4564 |
|
case R_PPC64_TPREL16: |
4565 |
|
case R_PPC64_TPREL16_LO: |
4566 |
|
case R_PPC64_TPREL16_HI: |
4567 |
|
case R_PPC64_TPREL16_HA: |
4568 |
|
case R_PPC64_TPREL16_DS: |
4569 |
|
case R_PPC64_TPREL16_LO_DS: |
4570 |
|
case R_PPC64_TPREL16_HIGHER: |
4571 |
|
case R_PPC64_TPREL16_HIGHERA: |
4572 |
|
case R_PPC64_TPREL16_HIGHEST: |
4573 |
|
case R_PPC64_TPREL16_HIGHESTA: |
4574 |
|
if (info->shared) |
4575 |
|
{ |
4576 |
|
info->flags |= DF_STATIC_TLS; |
4577 |
|
goto dodyn; |
4578 |
|
} |
4579 |
|
break; |
4580 |
|
|
4581 |
|
case R_PPC64_ADDR64: |
4582 |
if (opd_sym_map != NULL |
if (opd_sym_map != NULL |
|
&& h == NULL |
|
4583 |
&& rel + 1 < rel_end |
&& rel + 1 < rel_end |
4584 |
&& ((enum elf_ppc_reloc_type) ELF64_R_TYPE ((rel + 1)->r_info) |
&& ELF64_R_TYPE ((rel + 1)->r_info) == R_PPC64_TOC) |
|
== R_PPC64_TOC)) |
|
4585 |
{ |
{ |
4586 |
asection *s; |
if (h != NULL) |
4587 |
|
{ |
4588 |
|
if (h->root.root.string[0] == '.' |
4589 |
|
&& h->root.root.string[1] != 0 |
4590 |
|
&& get_fdh ((struct ppc_link_hash_entry *) h, htab)) |
4591 |
|
; |
4592 |
|
else |
4593 |
|
((struct ppc_link_hash_entry *) h)->is_func = 1; |
4594 |
|
} |
4595 |
|
else |
4596 |
|
{ |
4597 |
|
asection *s; |
4598 |
|
|
4599 |
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, sec, |
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, sec, |
4600 |
r_symndx); |
r_symndx); |
4601 |
if (s == NULL) |
if (s == NULL) |
4602 |
return false; |
return FALSE; |
4603 |
else if (s != sec) |
else if (s != sec) |
4604 |
opd_sym_map[rel->r_offset / 24] = s; |
opd_sym_map[rel->r_offset / 8] = s; |
4605 |
|
} |
4606 |
} |
} |
4607 |
/* Fall through. */ |
/* Fall through. */ |
4608 |
|
|
4609 |
case R_PPC64_REL64: |
case R_PPC64_REL30: |
4610 |
case R_PPC64_REL32: |
case R_PPC64_REL32: |
4611 |
|
case R_PPC64_REL64: |
4612 |
case R_PPC64_ADDR14: |
case R_PPC64_ADDR14: |
4613 |
case R_PPC64_ADDR14_BRNTAKEN: |
case R_PPC64_ADDR14_BRNTAKEN: |
4614 |
case R_PPC64_ADDR14_BRTAKEN: |
case R_PPC64_ADDR14_BRTAKEN: |
4623 |
case R_PPC64_ADDR16_LO: |
case R_PPC64_ADDR16_LO: |
4624 |
case R_PPC64_ADDR16_LO_DS: |
case R_PPC64_ADDR16_LO_DS: |
4625 |
case R_PPC64_ADDR24: |
case R_PPC64_ADDR24: |
|
case R_PPC64_ADDR30: |
|
4626 |
case R_PPC64_ADDR32: |
case R_PPC64_ADDR32: |
4627 |
case R_PPC64_UADDR16: |
case R_PPC64_UADDR16: |
4628 |
case R_PPC64_UADDR32: |
case R_PPC64_UADDR32: |
4629 |
case R_PPC64_UADDR64: |
case R_PPC64_UADDR64: |
4630 |
case R_PPC64_TOC: |
case R_PPC64_TOC: |
4631 |
|
if (h != NULL && !info->shared) |
4632 |
|
/* We may need a copy reloc. */ |
4633 |
|
h->non_got_ref = 1; |
4634 |
|
|
4635 |
/* Don't propagate .opd relocs. */ |
/* Don't propagate .opd relocs. */ |
4636 |
if (NO_OPD_RELOCS && opd_sym_map != NULL) |
if (NO_OPD_RELOCS && opd_sym_map != NULL) |
4637 |
break; |
break; |
4648 |
later (it is never cleared). In case of a weak definition, |
later (it is never cleared). In case of a weak definition, |
4649 |
DEF_REGULAR may be cleared later by a strong definition in |
DEF_REGULAR may be cleared later by a strong definition in |
4650 |
a shared library. We account for that possibility below by |
a shared library. We account for that possibility below by |
4651 |
storing information in the relocs_copied field of the hash |
storing information in the dyn_relocs field of the hash |
4652 |
table entry. A similar situation occurs when creating |
table entry. A similar situation occurs when creating |
4653 |
shared libraries and symbol visibility changes render the |
shared libraries and symbol visibility changes render the |
4654 |
symbol local. |
symbol local. |
4657 |
may need to keep relocations for symbols satisfied by a |
may need to keep relocations for symbols satisfied by a |
4658 |
dynamic library if we manage to avoid copy relocs for the |
dynamic library if we manage to avoid copy relocs for the |
4659 |
symbol. */ |
symbol. */ |
4660 |
|
dodyn: |
4661 |
if ((info->shared |
if ((info->shared |
4662 |
&& (sec->flags & SEC_ALLOC) != 0 |
&& (MUST_BE_DYN_RELOC (r_type) |
|
&& (IS_ABSOLUTE_RELOC (r_type) |
|
4663 |
|| (h != NULL |
|| (h != NULL |
4664 |
&& (! info->symbolic |
&& (! info->symbolic |
4665 |
|| h->root.type == bfd_link_hash_defweak |
|| h->root.type == bfd_link_hash_defweak |
4666 |
|| (h->elf_link_hash_flags |
|| !h->def_regular)))) |
4667 |
& ELF_LINK_HASH_DEF_REGULAR) == 0)))) |
|| (ELIMINATE_COPY_RELOCS |
4668 |
|| (!info->shared |
&& !info->shared |
|
&& (sec->flags & SEC_ALLOC) != 0 |
|
4669 |
&& h != NULL |
&& h != NULL |
4670 |
&& (h->root.type == bfd_link_hash_defweak |
&& (h->root.type == bfd_link_hash_defweak |
4671 |
|| (h->elf_link_hash_flags |
|| !h->def_regular))) |
|
& ELF_LINK_HASH_DEF_REGULAR) == 0))) |
|
4672 |
{ |
{ |
4673 |
struct ppc_dyn_relocs *p; |
struct ppc_dyn_relocs *p; |
4674 |
struct ppc_dyn_relocs **head; |
struct ppc_dyn_relocs **head; |
4686 |
elf_elfheader (abfd)->e_shstrndx, |
elf_elfheader (abfd)->e_shstrndx, |
4687 |
elf_section_data (sec)->rel_hdr.sh_name)); |
elf_section_data (sec)->rel_hdr.sh_name)); |
4688 |
if (name == NULL) |
if (name == NULL) |
4689 |
return false; |
return FALSE; |
4690 |
|
|
4691 |
if (strncmp (name, ".rela", 5) != 0 |
if (strncmp (name, ".rela", 5) != 0 |
4692 |
|| strcmp (bfd_get_section_name (abfd, sec), |
|| strcmp (bfd_get_section_name (abfd, sec), |
4693 |
name + 5) != 0) |
name + 5) != 0) |
4694 |
{ |
{ |
4695 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
4696 |
(_("%s: bad relocation section name `%s\'"), |
(_("%B: bad relocation section name `%s\'"), |
4697 |
bfd_archive_filename (abfd), name); |
abfd, name); |
4698 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
4699 |
} |
} |
4700 |
|
|
4706 |
|
|
4707 |
sreloc = bfd_make_section (dynobj, name); |
sreloc = bfd_make_section (dynobj, name); |
4708 |
flags = (SEC_HAS_CONTENTS | SEC_READONLY |
flags = (SEC_HAS_CONTENTS | SEC_READONLY |
4709 |
| SEC_IN_MEMORY | SEC_LINKER_CREATED); |
| SEC_IN_MEMORY | SEC_LINKER_CREATED |
4710 |
if ((sec->flags & SEC_ALLOC) != 0) |
| SEC_ALLOC | SEC_LOAD); |
|
flags |= SEC_ALLOC | SEC_LOAD; |
|
4711 |
if (sreloc == NULL |
if (sreloc == NULL |
4712 |
|| ! bfd_set_section_flags (dynobj, sreloc, flags) |
|| ! bfd_set_section_flags (dynobj, sreloc, flags) |
4713 |
|| ! bfd_set_section_alignment (dynobj, sreloc, 3)) |
|| ! bfd_set_section_alignment (dynobj, sreloc, 3)) |
4714 |
return false; |
return FALSE; |
4715 |
} |
} |
4716 |
elf_section_data (sec)->sreloc = sreloc; |
elf_section_data (sec)->sreloc = sreloc; |
4717 |
} |
} |
4732 |
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, |
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, |
4733 |
sec, r_symndx); |
sec, r_symndx); |
4734 |
if (s == NULL) |
if (s == NULL) |
4735 |
return false; |
return FALSE; |
4736 |
|
|
4737 |
head = ((struct ppc_dyn_relocs **) |
head = ((struct ppc_dyn_relocs **) |
4738 |
&elf_section_data (s)->local_dynrel); |
&elf_section_data (s)->local_dynrel); |
4741 |
p = *head; |
p = *head; |
4742 |
if (p == NULL || p->sec != sec) |
if (p == NULL || p->sec != sec) |
4743 |
{ |
{ |
4744 |
p = ((struct ppc_dyn_relocs *) |
p = bfd_alloc (htab->elf.dynobj, sizeof *p); |
|
bfd_alloc (htab->elf.dynobj, |
|
|
(bfd_size_type) sizeof *p)); |
|
4745 |
if (p == NULL) |
if (p == NULL) |
4746 |
return false; |
return FALSE; |
4747 |
p->next = *head; |
p->next = *head; |
4748 |
*head = p; |
*head = p; |
4749 |
p->sec = sec; |
p->sec = sec; |
4752 |
} |
} |
4753 |
|
|
4754 |
p->count += 1; |
p->count += 1; |
4755 |
if (!IS_ABSOLUTE_RELOC (r_type)) |
if (!MUST_BE_DYN_RELOC (r_type)) |
4756 |
p->pc_count += 1; |
p->pc_count += 1; |
4757 |
} |
} |
4758 |
break; |
break; |
4762 |
} |
} |
4763 |
} |
} |
4764 |
|
|
4765 |
return true; |
return TRUE; |
4766 |
|
} |
4767 |
|
|
4768 |
|
/* OFFSET in OPD_SEC specifies a function descriptor. Return the address |
4769 |
|
of the code entry point, and its section. */ |
4770 |
|
|
4771 |
|
static bfd_vma |
4772 |
|
opd_entry_value (asection *opd_sec, |
4773 |
|
bfd_vma offset, |
4774 |
|
asection **code_sec, |
4775 |
|
bfd_vma *code_off) |
4776 |
|
{ |
4777 |
|
bfd *opd_bfd = opd_sec->owner; |
4778 |
|
Elf_Internal_Rela *relocs; |
4779 |
|
Elf_Internal_Rela *lo, *hi, *look; |
4780 |
|
bfd_vma val; |
4781 |
|
|
4782 |
|
/* No relocs implies we are linking a --just-symbols object. */ |
4783 |
|
if (opd_sec->reloc_count == 0) |
4784 |
|
{ |
4785 |
|
bfd_vma val; |
4786 |
|
|
4787 |
|
if (!bfd_get_section_contents (opd_bfd, opd_sec, &val, offset, 8)) |
4788 |
|
return (bfd_vma) -1; |
4789 |
|
|
4790 |
|
if (code_sec != NULL) |
4791 |
|
{ |
4792 |
|
asection *sec, *likely = NULL; |
4793 |
|
for (sec = opd_bfd->sections; sec != NULL; sec = sec->next) |
4794 |
|
if (sec->vma <= val |
4795 |
|
&& (sec->flags & SEC_LOAD) != 0 |
4796 |
|
&& (sec->flags & SEC_ALLOC) != 0) |
4797 |
|
likely = sec; |
4798 |
|
if (likely != NULL) |
4799 |
|
{ |
4800 |
|
*code_sec = likely; |
4801 |
|
if (code_off != NULL) |
4802 |
|
*code_off = val - likely->vma; |
4803 |
|
} |
4804 |
|
} |
4805 |
|
return val; |
4806 |
|
} |
4807 |
|
|
4808 |
|
relocs = ppc64_elf_tdata (opd_bfd)->opd_relocs; |
4809 |
|
if (relocs == NULL) |
4810 |
|
relocs = _bfd_elf_link_read_relocs (opd_bfd, opd_sec, NULL, NULL, TRUE); |
4811 |
|
|
4812 |
|
/* Go find the opd reloc at the sym address. */ |
4813 |
|
lo = relocs; |
4814 |
|
BFD_ASSERT (lo != NULL); |
4815 |
|
hi = lo + opd_sec->reloc_count - 1; /* ignore last reloc */ |
4816 |
|
val = (bfd_vma) -1; |
4817 |
|
while (lo < hi) |
4818 |
|
{ |
4819 |
|
look = lo + (hi - lo) / 2; |
4820 |
|
if (look->r_offset < offset) |
4821 |
|
lo = look + 1; |
4822 |
|
else if (look->r_offset > offset) |
4823 |
|
hi = look; |
4824 |
|
else |
4825 |
|
{ |
4826 |
|
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (opd_bfd)->symtab_hdr; |
4827 |
|
if (ELF64_R_TYPE (look->r_info) == R_PPC64_ADDR64 |
4828 |
|
&& ELF64_R_TYPE ((look + 1)->r_info) == R_PPC64_TOC) |
4829 |
|
{ |
4830 |
|
unsigned long symndx = ELF64_R_SYM (look->r_info); |
4831 |
|
asection *sec; |
4832 |
|
|
4833 |
|
if (symndx < symtab_hdr->sh_info) |
4834 |
|
{ |
4835 |
|
Elf_Internal_Sym *sym; |
4836 |
|
|
4837 |
|
sym = (Elf_Internal_Sym *) symtab_hdr->contents; |
4838 |
|
if (sym == NULL) |
4839 |
|
{ |
4840 |
|
sym = bfd_elf_get_elf_syms (opd_bfd, symtab_hdr, |
4841 |
|
symtab_hdr->sh_info, |
4842 |
|
0, NULL, NULL, NULL); |
4843 |
|
if (sym == NULL) |
4844 |
|
break; |
4845 |
|
symtab_hdr->contents = (bfd_byte *) sym; |
4846 |
|
} |
4847 |
|
|
4848 |
|
sym += symndx; |
4849 |
|
val = sym->st_value; |
4850 |
|
sec = NULL; |
4851 |
|
if ((sym->st_shndx != SHN_UNDEF |
4852 |
|
&& sym->st_shndx < SHN_LORESERVE) |
4853 |
|
|| sym->st_shndx > SHN_HIRESERVE) |
4854 |
|
sec = bfd_section_from_elf_index (opd_bfd, sym->st_shndx); |
4855 |
|
BFD_ASSERT ((sec->flags & SEC_MERGE) == 0); |
4856 |
|
} |
4857 |
|
else |
4858 |
|
{ |
4859 |
|
struct elf_link_hash_entry **sym_hashes; |
4860 |
|
struct elf_link_hash_entry *rh; |
4861 |
|
|
4862 |
|
sym_hashes = elf_sym_hashes (opd_bfd); |
4863 |
|
rh = sym_hashes[symndx - symtab_hdr->sh_info]; |
4864 |
|
while (rh->root.type == bfd_link_hash_indirect |
4865 |
|
|| rh->root.type == bfd_link_hash_warning) |
4866 |
|
rh = ((struct elf_link_hash_entry *) rh->root.u.i.link); |
4867 |
|
BFD_ASSERT (rh->root.type == bfd_link_hash_defined |
4868 |
|
|| rh->root.type == bfd_link_hash_defweak); |
4869 |
|
val = rh->root.u.def.value; |
4870 |
|
sec = rh->root.u.def.section; |
4871 |
|
} |
4872 |
|
val += look->r_addend; |
4873 |
|
if (code_off != NULL) |
4874 |
|
*code_off = val; |
4875 |
|
if (code_sec != NULL) |
4876 |
|
*code_sec = sec; |
4877 |
|
if (sec != NULL && sec->output_section != NULL) |
4878 |
|
val += sec->output_section->vma + sec->output_offset; |
4879 |
|
} |
4880 |
|
break; |
4881 |
|
} |
4882 |
|
} |
4883 |
|
|
4884 |
|
return val; |
4885 |
} |
} |
4886 |
|
|
4887 |
/* Return the section that should be marked against GC for a given |
/* Return the section that should be marked against GC for a given |
4888 |
relocation. */ |
relocation. */ |
4889 |
|
|
4890 |
static asection * |
static asection * |
4891 |
ppc64_elf_gc_mark_hook (sec, info, rel, h, sym) |
ppc64_elf_gc_mark_hook (asection *sec, |
4892 |
asection *sec; |
struct bfd_link_info *info, |
4893 |
struct bfd_link_info *info ATTRIBUTE_UNUSED; |
Elf_Internal_Rela *rel, |
4894 |
Elf_Internal_Rela *rel; |
struct elf_link_hash_entry *h, |
4895 |
struct elf_link_hash_entry *h; |
Elf_Internal_Sym *sym) |
|
Elf_Internal_Sym *sym; |
|
4896 |
{ |
{ |
4897 |
asection *rsec = NULL; |
asection *rsec; |
4898 |
|
|
4899 |
|
/* First mark all our entry sym sections. */ |
4900 |
|
if (info->gc_sym_list != NULL) |
4901 |
|
{ |
4902 |
|
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
4903 |
|
struct bfd_sym_chain *sym = info->gc_sym_list; |
4904 |
|
|
4905 |
|
info->gc_sym_list = NULL; |
4906 |
|
do |
4907 |
|
{ |
4908 |
|
struct ppc_link_hash_entry *eh; |
4909 |
|
|
4910 |
|
eh = (struct ppc_link_hash_entry *) |
4911 |
|
elf_link_hash_lookup (&htab->elf, sym->name, FALSE, FALSE, FALSE); |
4912 |
|
if (eh == NULL) |
4913 |
|
continue; |
4914 |
|
if (eh->elf.root.type != bfd_link_hash_defined |
4915 |
|
&& eh->elf.root.type != bfd_link_hash_defweak) |
4916 |
|
continue; |
4917 |
|
|
4918 |
|
if (eh->is_func_descriptor |
4919 |
|
&& (eh->oh->elf.root.type == bfd_link_hash_defined |
4920 |
|
|| eh->oh->elf.root.type == bfd_link_hash_defweak)) |
4921 |
|
rsec = eh->oh->elf.root.u.def.section; |
4922 |
|
else if (get_opd_info (eh->elf.root.u.def.section) != NULL |
4923 |
|
&& opd_entry_value (eh->elf.root.u.def.section, |
4924 |
|
eh->elf.root.u.def.value, |
4925 |
|
&rsec, NULL) != (bfd_vma) -1) |
4926 |
|
; |
4927 |
|
else |
4928 |
|
continue; |
4929 |
|
|
4930 |
|
if (!rsec->gc_mark) |
4931 |
|
_bfd_elf_gc_mark (info, rsec, ppc64_elf_gc_mark_hook); |
4932 |
|
|
4933 |
|
rsec = eh->elf.root.u.def.section; |
4934 |
|
if (!rsec->gc_mark) |
4935 |
|
_bfd_elf_gc_mark (info, rsec, ppc64_elf_gc_mark_hook); |
4936 |
|
|
4937 |
|
sym = sym->next; |
4938 |
|
} |
4939 |
|
while (sym != NULL); |
4940 |
|
} |
4941 |
|
|
4942 |
|
/* Syms return NULL if we're marking .opd, so we avoid marking all |
4943 |
|
function sections, as all functions are referenced in .opd. */ |
4944 |
|
rsec = NULL; |
4945 |
|
if (get_opd_info (sec) != NULL) |
4946 |
|
return rsec; |
4947 |
|
|
4948 |
if (h != NULL) |
if (h != NULL) |
4949 |
{ |
{ |
4950 |
enum elf_ppc_reloc_type r_type; |
enum elf_ppc64_reloc_type r_type; |
4951 |
struct ppc_link_hash_entry *fdh; |
struct ppc_link_hash_entry *eh; |
4952 |
|
|
4953 |
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); |
r_type = ELF64_R_TYPE (rel->r_info); |
4954 |
switch (r_type) |
switch (r_type) |
4955 |
{ |
{ |
4956 |
case R_PPC64_GNU_VTINHERIT: |
case R_PPC64_GNU_VTINHERIT: |
4962 |
{ |
{ |
4963 |
case bfd_link_hash_defined: |
case bfd_link_hash_defined: |
4964 |
case bfd_link_hash_defweak: |
case bfd_link_hash_defweak: |
4965 |
fdh = (struct ppc_link_hash_entry *) h; |
eh = (struct ppc_link_hash_entry *) h; |
4966 |
|
if (eh->oh != NULL |
4967 |
|
&& eh->oh->is_func_descriptor |
4968 |
|
&& (eh->oh->elf.root.type == bfd_link_hash_defined |
4969 |
|
|| eh->oh->elf.root.type == bfd_link_hash_defweak)) |
4970 |
|
eh = eh->oh; |
4971 |
|
|
4972 |
/* Function descriptor syms cause the associated |
/* Function descriptor syms cause the associated |
4973 |
function code sym section to be marked. */ |
function code sym section to be marked. */ |
4974 |
if (fdh->is_func_descriptor) |
if (eh->is_func_descriptor |
4975 |
rsec = fdh->oh->root.u.def.section; |
&& (eh->oh->elf.root.type == bfd_link_hash_defined |
4976 |
|
|| eh->oh->elf.root.type == bfd_link_hash_defweak)) |
4977 |
|
{ |
4978 |
|
/* They also mark their opd section. */ |
4979 |
|
if (!eh->elf.root.u.def.section->gc_mark) |
4980 |
|
_bfd_elf_gc_mark (info, eh->elf.root.u.def.section, |
4981 |
|
ppc64_elf_gc_mark_hook); |
4982 |
|
|
4983 |
/* Function entry syms return NULL if they are in .opd |
rsec = eh->oh->elf.root.u.def.section; |
4984 |
and are not ._start (or others undefined on the ld |
} |
4985 |
command line). Thus we avoid marking all function |
else if (get_opd_info (eh->elf.root.u.def.section) != NULL |
4986 |
sections, as all functions are referenced in .opd. */ |
&& opd_entry_value (eh->elf.root.u.def.section, |
4987 |
else if ((fdh->oh != NULL |
eh->elf.root.u.def.value, |
4988 |
&& ((struct ppc_link_hash_entry *) fdh->oh)->is_entry) |
&rsec, NULL) != (bfd_vma) -1) |
4989 |
|| elf_section_data (sec)->tdata == NULL) |
{ |
4990 |
|
if (!eh->elf.root.u.def.section->gc_mark) |
4991 |
|
_bfd_elf_gc_mark (info, eh->elf.root.u.def.section, |
4992 |
|
ppc64_elf_gc_mark_hook); |
4993 |
|
} |
4994 |
|
else |
4995 |
rsec = h->root.u.def.section; |
rsec = h->root.u.def.section; |
4996 |
break; |
break; |
4997 |
|
|
5009 |
asection **opd_sym_section; |
asection **opd_sym_section; |
5010 |
|
|
5011 |
rsec = bfd_section_from_elf_index (sec->owner, sym->st_shndx); |
rsec = bfd_section_from_elf_index (sec->owner, sym->st_shndx); |
5012 |
opd_sym_section = (asection **) elf_section_data (rsec)->tdata; |
opd_sym_section = get_opd_info (rsec); |
5013 |
if (opd_sym_section != NULL) |
if (opd_sym_section != NULL) |
5014 |
rsec = opd_sym_section[sym->st_value / 24]; |
{ |
5015 |
else if (elf_section_data (sec)->tdata != NULL) |
if (!rsec->gc_mark) |
5016 |
rsec = NULL; |
_bfd_elf_gc_mark (info, rsec, ppc64_elf_gc_mark_hook); |
5017 |
|
|
5018 |
|
rsec = opd_sym_section[(sym->st_value + rel->r_addend) / 8]; |
5019 |
|
} |
5020 |
} |
} |
5021 |
|
|
5022 |
return rsec; |
return rsec; |
5025 |
/* Update the .got, .plt. and dynamic reloc reference counts for the |
/* Update the .got, .plt. and dynamic reloc reference counts for the |
5026 |
section being removed. */ |
section being removed. */ |
5027 |
|
|
5028 |
static boolean |
static bfd_boolean |
5029 |
ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs) |
ppc64_elf_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, |
5030 |
bfd *abfd; |
asection *sec, const Elf_Internal_Rela *relocs) |
|
struct bfd_link_info *info ATTRIBUTE_UNUSED; |
|
|
asection *sec; |
|
|
const Elf_Internal_Rela *relocs; |
|
5031 |
{ |
{ |
5032 |
|
struct ppc_link_hash_table *htab; |
5033 |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_hdr; |
5034 |
struct elf_link_hash_entry **sym_hashes; |
struct elf_link_hash_entry **sym_hashes; |
5035 |
bfd_signed_vma *local_got_refcounts; |
struct got_entry **local_got_ents; |
5036 |
const Elf_Internal_Rela *rel, *relend; |
const Elf_Internal_Rela *rel, *relend; |
5037 |
|
|
5038 |
|
if ((sec->flags & SEC_ALLOC) == 0) |
5039 |
|
return TRUE; |
5040 |
|
|
5041 |
elf_section_data (sec)->local_dynrel = NULL; |
elf_section_data (sec)->local_dynrel = NULL; |
5042 |
|
|
5043 |
|
htab = ppc_hash_table (info); |
5044 |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
5045 |
sym_hashes = elf_sym_hashes (abfd); |
sym_hashes = elf_sym_hashes (abfd); |
5046 |
local_got_refcounts = elf_local_got_refcounts (abfd); |
local_got_ents = elf_local_got_ents (abfd); |
5047 |
|
|
5048 |
relend = relocs + sec->reloc_count; |
relend = relocs + sec->reloc_count; |
5049 |
for (rel = relocs; rel < relend; rel++) |
for (rel = relocs; rel < relend; rel++) |
5050 |
{ |
{ |
5051 |
unsigned long r_symndx; |
unsigned long r_symndx; |
5052 |
enum elf_ppc_reloc_type r_type; |
enum elf_ppc64_reloc_type r_type; |
5053 |
struct elf_link_hash_entry *h; |
struct elf_link_hash_entry *h = NULL; |
5054 |
|
char tls_type = 0; |
5055 |
|
|
5056 |
r_symndx = ELF64_R_SYM (rel->r_info); |
r_symndx = ELF64_R_SYM (rel->r_info); |
5057 |
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); |
r_type = ELF64_R_TYPE (rel->r_info); |
5058 |
|
if (r_symndx >= symtab_hdr->sh_info) |
5059 |
|
{ |
5060 |
|
struct ppc_link_hash_entry *eh; |
5061 |
|
struct ppc_dyn_relocs **pp; |
5062 |
|
struct ppc_dyn_relocs *p; |
5063 |
|
|
5064 |
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
5065 |
|
while (h->root.type == bfd_link_hash_indirect |
5066 |
|
|| h->root.type == bfd_link_hash_warning) |
5067 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
5068 |
|
eh = (struct ppc_link_hash_entry *) h; |
5069 |
|
|
5070 |
|
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) |
5071 |
|
if (p->sec == sec) |
5072 |
|
{ |
5073 |
|
/* Everything must go for SEC. */ |
5074 |
|
*pp = p->next; |
5075 |
|
break; |
5076 |
|
} |
5077 |
|
} |
5078 |
|
|
5079 |
switch (r_type) |
switch (r_type) |
5080 |
{ |
{ |
5081 |
|
case R_PPC64_GOT_TLSLD16: |
5082 |
|
case R_PPC64_GOT_TLSLD16_LO: |
5083 |
|
case R_PPC64_GOT_TLSLD16_HI: |
5084 |
|
case R_PPC64_GOT_TLSLD16_HA: |
5085 |
|
ppc64_tlsld_got (abfd)->refcount -= 1; |
5086 |
|
tls_type = TLS_TLS | TLS_LD; |
5087 |
|
goto dogot; |
5088 |
|
|
5089 |
|
case R_PPC64_GOT_TLSGD16: |
5090 |
|
case R_PPC64_GOT_TLSGD16_LO: |
5091 |
|
case R_PPC64_GOT_TLSGD16_HI: |
5092 |
|
case R_PPC64_GOT_TLSGD16_HA: |
5093 |
|
tls_type = TLS_TLS | TLS_GD; |
5094 |
|
goto dogot; |
5095 |
|
|
5096 |
|
case R_PPC64_GOT_TPREL16_DS: |
5097 |
|
case R_PPC64_GOT_TPREL16_LO_DS: |
5098 |
|
case R_PPC64_GOT_TPREL16_HI: |
5099 |
|
case R_PPC64_GOT_TPREL16_HA: |
5100 |
|
tls_type = TLS_TLS | TLS_TPREL; |
5101 |
|
goto dogot; |
5102 |
|
|
5103 |
|
case R_PPC64_GOT_DTPREL16_DS: |
5104 |
|
case R_PPC64_GOT_DTPREL16_LO_DS: |
5105 |
|
case R_PPC64_GOT_DTPREL16_HI: |
5106 |
|
case R_PPC64_GOT_DTPREL16_HA: |
5107 |
|
tls_type = TLS_TLS | TLS_DTPREL; |
5108 |
|
goto dogot; |
5109 |
|
|
5110 |
case R_PPC64_GOT16: |
case R_PPC64_GOT16: |
5111 |
case R_PPC64_GOT16_DS: |
case R_PPC64_GOT16_DS: |
5112 |
case R_PPC64_GOT16_HA: |
case R_PPC64_GOT16_HA: |
5113 |
case R_PPC64_GOT16_HI: |
case R_PPC64_GOT16_HI: |
5114 |
case R_PPC64_GOT16_LO: |
case R_PPC64_GOT16_LO: |
5115 |
case R_PPC64_GOT16_LO_DS: |
case R_PPC64_GOT16_LO_DS: |
5116 |
if (r_symndx >= symtab_hdr->sh_info) |
dogot: |
5117 |
{ |
{ |
5118 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
struct got_entry *ent; |
5119 |
if (h->got.refcount > 0) |
|
5120 |
h->got.refcount--; |
if (h != NULL) |
5121 |
} |
ent = h->got.glist; |
5122 |
else |
else |
5123 |
{ |
ent = local_got_ents[r_symndx]; |
5124 |
if (local_got_refcounts[r_symndx] > 0) |
|
5125 |
local_got_refcounts[r_symndx]--; |
for (; ent != NULL; ent = ent->next) |
5126 |
} |
if (ent->addend == rel->r_addend |
5127 |
|
&& ent->owner == abfd |
5128 |
|
&& ent->tls_type == tls_type) |
5129 |
|
break; |
5130 |
|
if (ent == NULL) |
5131 |
|
abort (); |
5132 |
|
if (ent->got.refcount > 0) |
5133 |
|
ent->got.refcount -= 1; |
5134 |
|
} |
5135 |
break; |
break; |
5136 |
|
|
5137 |
case R_PPC64_PLT16_HA: |
case R_PPC64_PLT16_HA: |
5139 |
case R_PPC64_PLT16_LO: |
case R_PPC64_PLT16_LO: |
5140 |
case R_PPC64_PLT32: |
case R_PPC64_PLT32: |
5141 |
case R_PPC64_PLT64: |
case R_PPC64_PLT64: |
|
if (r_symndx >= symtab_hdr->sh_info) |
|
|
{ |
|
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
|
|
if (h->plt.refcount > 0) |
|
|
h->plt.refcount--; |
|
|
} |
|
|
break; |
|
|
|
|
5142 |
case R_PPC64_REL14: |
case R_PPC64_REL14: |
5143 |
case R_PPC64_REL14_BRNTAKEN: |
case R_PPC64_REL14_BRNTAKEN: |
5144 |
case R_PPC64_REL14_BRTAKEN: |
case R_PPC64_REL14_BRTAKEN: |
5145 |
case R_PPC64_REL24: |
case R_PPC64_REL24: |
5146 |
if (r_symndx >= symtab_hdr->sh_info) |
if (h != NULL) |
5147 |
{ |
{ |
5148 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
struct plt_entry *ent; |
5149 |
if (h->plt.refcount > 0) |
|
5150 |
h->plt.refcount--; |
for (ent = h->plt.plist; ent != NULL; ent = ent->next) |
5151 |
|
if (ent->addend == rel->r_addend) |
5152 |
|
break; |
5153 |
|
if (ent == NULL) |
5154 |
|
abort (); |
5155 |
|
if (ent->plt.refcount > 0) |
5156 |
|
ent->plt.refcount -= 1; |
5157 |
} |
} |
5158 |
break; |
break; |
5159 |
|
|
5160 |
case R_PPC64_REL32: |
default: |
5161 |
case R_PPC64_REL64: |
break; |
5162 |
if (r_symndx >= symtab_hdr->sh_info) |
} |
5163 |
{ |
} |
5164 |
struct ppc_link_hash_entry *eh; |
return TRUE; |
5165 |
struct ppc_dyn_relocs **pp; |
} |
|
struct ppc_dyn_relocs *p; |
|
5166 |
|
|
5167 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
/* The maximum size of .sfpr. */ |
5168 |
eh = (struct ppc_link_hash_entry *) h; |
#define SFPR_MAX (218*4) |
5169 |
|
|
5170 |
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) |
struct sfpr_def_parms |
5171 |
if (p->sec == sec) |
{ |
5172 |
{ |
const char name[12]; |
5173 |
p->pc_count -= 1; |
unsigned char lo, hi; |
5174 |
p->count -= 1; |
bfd_byte * (*write_ent) (bfd *, bfd_byte *, int); |
5175 |
if (p->count == 0) |
bfd_byte * (*write_tail) (bfd *, bfd_byte *, int); |
5176 |
*pp = p->next; |
}; |
|
break; |
|
|
} |
|
|
} |
|
|
break; |
|
5177 |
|
|
5178 |
case R_PPC64_ADDR14: |
/* Auto-generate _save*, _rest* functions in .sfpr. */ |
|
case R_PPC64_ADDR14_BRNTAKEN: |
|
|
case R_PPC64_ADDR14_BRTAKEN: |
|
|
case R_PPC64_ADDR16: |
|
|
case R_PPC64_ADDR16_DS: |
|
|
case R_PPC64_ADDR16_HA: |
|
|
case R_PPC64_ADDR16_HI: |
|
|
case R_PPC64_ADDR16_HIGHER: |
|
|
case R_PPC64_ADDR16_HIGHERA: |
|
|
case R_PPC64_ADDR16_HIGHEST: |
|
|
case R_PPC64_ADDR16_HIGHESTA: |
|
|
case R_PPC64_ADDR16_LO: |
|
|
case R_PPC64_ADDR16_LO_DS: |
|
|
case R_PPC64_ADDR24: |
|
|
case R_PPC64_ADDR30: |
|
|
case R_PPC64_ADDR32: |
|
|
case R_PPC64_ADDR64: |
|
|
case R_PPC64_UADDR16: |
|
|
case R_PPC64_UADDR32: |
|
|
case R_PPC64_UADDR64: |
|
|
case R_PPC64_TOC: |
|
|
if (r_symndx >= symtab_hdr->sh_info) |
|
|
{ |
|
|
struct ppc_link_hash_entry *eh; |
|
|
struct ppc_dyn_relocs **pp; |
|
|
struct ppc_dyn_relocs *p; |
|
5179 |
|
|
5180 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
static unsigned int |
5181 |
eh = (struct ppc_link_hash_entry *) h; |
sfpr_define (struct bfd_link_info *info, const struct sfpr_def_parms *parm) |
5182 |
|
{ |
5183 |
|
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
5184 |
|
unsigned int i; |
5185 |
|
size_t len = strlen (parm->name); |
5186 |
|
bfd_boolean writing = FALSE; |
5187 |
|
char sym[16]; |
5188 |
|
|
5189 |
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) |
memcpy (sym, parm->name, len); |
5190 |
if (p->sec == sec) |
sym[len + 2] = 0; |
|
{ |
|
|
p->count -= 1; |
|
|
if (p->count == 0) |
|
|
*pp = p->next; |
|
|
break; |
|
|
} |
|
|
} |
|
|
break; |
|
5191 |
|
|
5192 |
default: |
for (i = parm->lo; i <= parm->hi; i++) |
5193 |
break; |
{ |
5194 |
|
struct elf_link_hash_entry *h; |
5195 |
|
|
5196 |
|
sym[len + 0] = i / 10 + '0'; |
5197 |
|
sym[len + 1] = i % 10 + '0'; |
5198 |
|
h = elf_link_hash_lookup (&htab->elf, sym, FALSE, FALSE, TRUE); |
5199 |
|
if (h != NULL |
5200 |
|
&& !h->def_regular) |
5201 |
|
{ |
5202 |
|
h->root.type = bfd_link_hash_defined; |
5203 |
|
h->root.u.def.section = htab->sfpr; |
5204 |
|
h->root.u.def.value = htab->sfpr->size; |
5205 |
|
h->type = STT_FUNC; |
5206 |
|
h->def_regular = 1; |
5207 |
|
_bfd_elf_link_hash_hide_symbol (info, h, TRUE); |
5208 |
|
writing = TRUE; |
5209 |
|
if (htab->sfpr->contents == NULL) |
5210 |
|
{ |
5211 |
|
htab->sfpr->contents = bfd_alloc (htab->elf.dynobj, SFPR_MAX); |
5212 |
|
if (htab->sfpr->contents == NULL) |
5213 |
|
return FALSE; |
5214 |
|
} |
5215 |
|
} |
5216 |
|
if (writing) |
5217 |
|
{ |
5218 |
|
bfd_byte *p = htab->sfpr->contents + htab->sfpr->size; |
5219 |
|
if (i != parm->hi) |
5220 |
|
p = (*parm->write_ent) (htab->elf.dynobj, p, i); |
5221 |
|
else |
5222 |
|
p = (*parm->write_tail) (htab->elf.dynobj, p, i); |
5223 |
|
htab->sfpr->size = p - htab->sfpr->contents; |
5224 |
} |
} |
5225 |
} |
} |
5226 |
return true; |
|
5227 |
|
return TRUE; |
5228 |
|
} |
5229 |
|
|
5230 |
|
static bfd_byte * |
5231 |
|
savegpr0 (bfd *abfd, bfd_byte *p, int r) |
5232 |
|
{ |
5233 |
|
bfd_put_32 (abfd, STD_R0_0R1 + (r << 21) + (1 << 16) - (32 - r) * 8, p); |
5234 |
|
return p + 4; |
5235 |
|
} |
5236 |
|
|
5237 |
|
static bfd_byte * |
5238 |
|
savegpr0_tail (bfd *abfd, bfd_byte *p, int r) |
5239 |
|
{ |
5240 |
|
p = savegpr0 (abfd, p, r); |
5241 |
|
bfd_put_32 (abfd, STD_R0_0R1 + 16, p); |
5242 |
|
p = p + 4; |
5243 |
|
bfd_put_32 (abfd, BLR, p); |
5244 |
|
return p + 4; |
5245 |
|
} |
5246 |
|
|
5247 |
|
static bfd_byte * |
5248 |
|
restgpr0 (bfd *abfd, bfd_byte *p, int r) |
5249 |
|
{ |
5250 |
|
bfd_put_32 (abfd, LD_R0_0R1 + (r << 21) + (1 << 16) - (32 - r) * 8, p); |
5251 |
|
return p + 4; |
5252 |
|
} |
5253 |
|
|
5254 |
|
static bfd_byte * |
5255 |
|
restgpr0_tail (bfd *abfd, bfd_byte *p, int r) |
5256 |
|
{ |
5257 |
|
bfd_put_32 (abfd, LD_R0_0R1 + 16, p); |
5258 |
|
p = p + 4; |
5259 |
|
p = restgpr0 (abfd, p, r); |
5260 |
|
bfd_put_32 (abfd, MTLR_R0, p); |
5261 |
|
p = p + 4; |
5262 |
|
if (r == 29) |
5263 |
|
{ |
5264 |
|
p = restgpr0 (abfd, p, 30); |
5265 |
|
p = restgpr0 (abfd, p, 31); |
5266 |
|
} |
5267 |
|
bfd_put_32 (abfd, BLR, p); |
5268 |
|
return p + 4; |
5269 |
|
} |
5270 |
|
|
5271 |
|
static bfd_byte * |
5272 |
|
savegpr1 (bfd *abfd, bfd_byte *p, int r) |
5273 |
|
{ |
5274 |
|
bfd_put_32 (abfd, STD_R0_0R12 + (r << 21) + (1 << 16) - (32 - r) * 8, p); |
5275 |
|
return p + 4; |
5276 |
|
} |
5277 |
|
|
5278 |
|
static bfd_byte * |
5279 |
|
savegpr1_tail (bfd *abfd, bfd_byte *p, int r) |
5280 |
|
{ |
5281 |
|
p = savegpr1 (abfd, p, r); |
5282 |
|
bfd_put_32 (abfd, BLR, p); |
5283 |
|
return p + 4; |
5284 |
|
} |
5285 |
|
|
5286 |
|
static bfd_byte * |
5287 |
|
restgpr1 (bfd *abfd, bfd_byte *p, int r) |
5288 |
|
{ |
5289 |
|
bfd_put_32 (abfd, LD_R0_0R12 + (r << 21) + (1 << 16) - (32 - r) * 8, p); |
5290 |
|
return p + 4; |
5291 |
|
} |
5292 |
|
|
5293 |
|
static bfd_byte * |
5294 |
|
restgpr1_tail (bfd *abfd, bfd_byte *p, int r) |
5295 |
|
{ |
5296 |
|
p = restgpr1 (abfd, p, r); |
5297 |
|
bfd_put_32 (abfd, BLR, p); |
5298 |
|
return p + 4; |
5299 |
|
} |
5300 |
|
|
5301 |
|
static bfd_byte * |
5302 |
|
savefpr (bfd *abfd, bfd_byte *p, int r) |
5303 |
|
{ |
5304 |
|
bfd_put_32 (abfd, STFD_FR0_0R1 + (r << 21) + (1 << 16) - (32 - r) * 8, p); |
5305 |
|
return p + 4; |
5306 |
|
} |
5307 |
|
|
5308 |
|
static bfd_byte * |
5309 |
|
savefpr0_tail (bfd *abfd, bfd_byte *p, int r) |
5310 |
|
{ |
5311 |
|
p = savefpr (abfd, p, r); |
5312 |
|
bfd_put_32 (abfd, STD_R0_0R1 + 16, p); |
5313 |
|
p = p + 4; |
5314 |
|
bfd_put_32 (abfd, BLR, p); |
5315 |
|
return p + 4; |
5316 |
|
} |
5317 |
|
|
5318 |
|
static bfd_byte * |
5319 |
|
restfpr (bfd *abfd, bfd_byte *p, int r) |
5320 |
|
{ |
5321 |
|
bfd_put_32 (abfd, LFD_FR0_0R1 + (r << 21) + (1 << 16) - (32 - r) * 8, p); |
5322 |
|
return p + 4; |
5323 |
|
} |
5324 |
|
|
5325 |
|
static bfd_byte * |
5326 |
|
restfpr0_tail (bfd *abfd, bfd_byte *p, int r) |
5327 |
|
{ |
5328 |
|
bfd_put_32 (abfd, LD_R0_0R1 + 16, p); |
5329 |
|
p = p + 4; |
5330 |
|
p = restfpr (abfd, p, r); |
5331 |
|
bfd_put_32 (abfd, MTLR_R0, p); |
5332 |
|
p = p + 4; |
5333 |
|
if (r == 29) |
5334 |
|
{ |
5335 |
|
p = restfpr (abfd, p, 30); |
5336 |
|
p = restfpr (abfd, p, 31); |
5337 |
|
} |
5338 |
|
bfd_put_32 (abfd, BLR, p); |
5339 |
|
return p + 4; |
5340 |
|
} |
5341 |
|
|
5342 |
|
static bfd_byte * |
5343 |
|
savefpr1_tail (bfd *abfd, bfd_byte *p, int r) |
5344 |
|
{ |
5345 |
|
p = savefpr (abfd, p, r); |
5346 |
|
bfd_put_32 (abfd, BLR, p); |
5347 |
|
return p + 4; |
5348 |
|
} |
5349 |
|
|
5350 |
|
static bfd_byte * |
5351 |
|
restfpr1_tail (bfd *abfd, bfd_byte *p, int r) |
5352 |
|
{ |
5353 |
|
p = restfpr (abfd, p, r); |
5354 |
|
bfd_put_32 (abfd, BLR, p); |
5355 |
|
return p + 4; |
5356 |
|
} |
5357 |
|
|
5358 |
|
static bfd_byte * |
5359 |
|
savevr (bfd *abfd, bfd_byte *p, int r) |
5360 |
|
{ |
5361 |
|
bfd_put_32 (abfd, LI_R12_0 + (1 << 16) - (32 - r) * 16, p); |
5362 |
|
p = p + 4; |
5363 |
|
bfd_put_32 (abfd, STVX_VR0_R12_R0 + (r << 21), p); |
5364 |
|
return p + 4; |
5365 |
|
} |
5366 |
|
|
5367 |
|
static bfd_byte * |
5368 |
|
savevr_tail (bfd *abfd, bfd_byte *p, int r) |
5369 |
|
{ |
5370 |
|
p = savevr (abfd, p, r); |
5371 |
|
bfd_put_32 (abfd, BLR, p); |
5372 |
|
return p + 4; |
5373 |
|
} |
5374 |
|
|
5375 |
|
static bfd_byte * |
5376 |
|
restvr (bfd *abfd, bfd_byte *p, int r) |
5377 |
|
{ |
5378 |
|
bfd_put_32 (abfd, LI_R12_0 + (1 << 16) - (32 - r) * 16, p); |
5379 |
|
p = p + 4; |
5380 |
|
bfd_put_32 (abfd, LVX_VR0_R12_R0 + (r << 21), p); |
5381 |
|
return p + 4; |
5382 |
|
} |
5383 |
|
|
5384 |
|
static bfd_byte * |
5385 |
|
restvr_tail (bfd *abfd, bfd_byte *p, int r) |
5386 |
|
{ |
5387 |
|
p = restvr (abfd, p, r); |
5388 |
|
bfd_put_32 (abfd, BLR, p); |
5389 |
|
return p + 4; |
5390 |
} |
} |
5391 |
|
|
5392 |
/* Called via elf_link_hash_traverse to transfer dynamic linking |
/* Called via elf_link_hash_traverse to transfer dynamic linking |
5393 |
information on function code symbol entries to their corresponding |
information on function code symbol entries to their corresponding |
5394 |
function descriptor symbol entries. */ |
function descriptor symbol entries. */ |
5395 |
static boolean |
|
5396 |
func_desc_adjust (h, inf) |
static bfd_boolean |
5397 |
struct elf_link_hash_entry *h; |
func_desc_adjust (struct elf_link_hash_entry *h, void *inf) |
|
PTR inf; |
|
5398 |
{ |
{ |
5399 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
5400 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
5401 |
|
struct plt_entry *ent; |
5402 |
|
struct ppc_link_hash_entry *fh; |
5403 |
|
struct ppc_link_hash_entry *fdh; |
5404 |
|
bfd_boolean force_local; |
5405 |
|
|
5406 |
|
fh = (struct ppc_link_hash_entry *) h; |
5407 |
|
if (fh->elf.root.type == bfd_link_hash_indirect) |
5408 |
|
return TRUE; |
5409 |
|
|
5410 |
if (h->root.type == bfd_link_hash_indirect) |
if (fh->elf.root.type == bfd_link_hash_warning) |
5411 |
return true; |
fh = (struct ppc_link_hash_entry *) fh->elf.root.u.i.link; |
|
|
|
|
if (h->root.type == bfd_link_hash_warning) |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
|
5412 |
|
|
5413 |
info = (struct bfd_link_info *) inf; |
info = inf; |
5414 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
5415 |
|
|
5416 |
|
/* Resolve undefined references to dot-symbols as the value |
5417 |
|
in the function descriptor, if we have one in a regular object. |
5418 |
|
This is to satisfy cases like ".quad .foo". Calls to functions |
5419 |
|
in dynamic objects are handled elsewhere. */ |
5420 |
|
if (fh->elf.root.type == bfd_link_hash_undefweak |
5421 |
|
&& fh->was_undefined |
5422 |
|
&& (fh->oh->elf.root.type == bfd_link_hash_defined |
5423 |
|
|| fh->oh->elf.root.type == bfd_link_hash_defweak) |
5424 |
|
&& get_opd_info (fh->oh->elf.root.u.def.section) != NULL |
5425 |
|
&& opd_entry_value (fh->oh->elf.root.u.def.section, |
5426 |
|
fh->oh->elf.root.u.def.value, |
5427 |
|
&fh->elf.root.u.def.section, |
5428 |
|
&fh->elf.root.u.def.value) != (bfd_vma) -1) |
5429 |
|
{ |
5430 |
|
fh->elf.root.type = fh->oh->elf.root.type; |
5431 |
|
fh->elf.forced_local = 1; |
5432 |
|
} |
5433 |
|
|
5434 |
/* If this is a function code symbol, transfer dynamic linking |
/* If this is a function code symbol, transfer dynamic linking |
5435 |
information to the function descriptor symbol. */ |
information to the function descriptor symbol. */ |
5436 |
if (!((struct ppc_link_hash_entry *) h)->is_func) |
if (!fh->is_func) |
5437 |
return true; |
return TRUE; |
5438 |
|
|
5439 |
if (h->root.type == bfd_link_hash_undefweak |
for (ent = fh->elf.plt.plist; ent != NULL; ent = ent->next) |
5440 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR)) |
if (ent->plt.refcount > 0) |
5441 |
htab->have_undefweak = true; |
break; |
5442 |
|
if (ent == NULL |
5443 |
if (h->plt.refcount > 0 |
|| fh->elf.root.root.string[0] != '.' |
5444 |
&& h->root.root.string[0] == '.' |
|| fh->elf.root.root.string[1] == '\0') |
5445 |
&& h->root.root.string[1] != '\0') |
return TRUE; |
5446 |
|
|
5447 |
|
/* Find the corresponding function descriptor symbol. Create it |
5448 |
|
as undefined if necessary. */ |
5449 |
|
|
5450 |
|
fdh = get_fdh (fh, htab); |
5451 |
|
if (fdh != NULL) |
5452 |
|
while (fdh->elf.root.type == bfd_link_hash_indirect |
5453 |
|
|| fdh->elf.root.type == bfd_link_hash_warning) |
5454 |
|
fdh = (struct ppc_link_hash_entry *) fdh->elf.root.u.i.link; |
5455 |
|
|
5456 |
|
if (fdh == NULL |
5457 |
|
&& info->shared |
5458 |
|
&& (fh->elf.root.type == bfd_link_hash_undefined |
5459 |
|
|| fh->elf.root.type == bfd_link_hash_undefweak)) |
5460 |
{ |
{ |
5461 |
struct elf_link_hash_entry *fdh = ((struct ppc_link_hash_entry *) h)->oh; |
fdh = make_fdh (info, fh); |
|
boolean force_local; |
|
|
|
|
|
/* Find the corresponding function descriptor symbol. Create it |
|
|
as undefined if necessary. */ |
|
|
|
|
5462 |
if (fdh == NULL) |
if (fdh == NULL) |
5463 |
fdh = elf_link_hash_lookup (&htab->elf, h->root.root.string + 1, |
return FALSE; |
|
false, false, true); |
|
|
|
|
|
if (fdh == NULL |
|
|
&& info->shared |
|
|
&& (h->root.type == bfd_link_hash_undefined |
|
|
|| h->root.type == bfd_link_hash_undefweak)) |
|
|
{ |
|
|
bfd *abfd; |
|
|
asymbol *newsym; |
|
|
|
|
|
abfd = h->root.u.undef.abfd; |
|
|
newsym = bfd_make_empty_symbol (abfd); |
|
|
newsym->name = h->root.root.string + 1; |
|
|
newsym->section = bfd_und_section_ptr; |
|
|
newsym->value = 0; |
|
|
newsym->flags = BSF_OBJECT; |
|
|
if (h->root.type == bfd_link_hash_undefweak) |
|
|
newsym->flags |= BSF_WEAK; |
|
|
|
|
|
if ( !(_bfd_generic_link_add_one_symbol |
|
|
(info, abfd, newsym->name, newsym->flags, |
|
|
newsym->section, newsym->value, NULL, false, false, |
|
|
(struct bfd_link_hash_entry **) &fdh))) |
|
|
{ |
|
|
return false; |
|
|
} |
|
|
fdh->elf_link_hash_flags &= ~ELF_LINK_NON_ELF; |
|
|
} |
|
|
|
|
|
if (fdh != NULL |
|
|
&& (fdh->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0 |
|
|
&& (info->shared |
|
|
|| (fdh->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 |
|
|
|| (fdh->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)) |
|
|
{ |
|
|
if (fdh->dynindx == -1) |
|
|
if (! bfd_elf64_link_record_dynamic_symbol (info, fdh)) |
|
|
return false; |
|
|
fdh->elf_link_hash_flags |= (h->elf_link_hash_flags |
|
|
& (ELF_LINK_HASH_REF_REGULAR |
|
|
| ELF_LINK_HASH_REF_DYNAMIC |
|
|
| ELF_LINK_HASH_REF_REGULAR_NONWEAK |
|
|
| ELF_LINK_NON_GOT_REF)); |
|
|
if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) |
|
|
{ |
|
|
fdh->plt.refcount = h->plt.refcount; |
|
|
fdh->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; |
|
|
} |
|
|
((struct ppc_link_hash_entry *) fdh)->is_func_descriptor = 1; |
|
|
((struct ppc_link_hash_entry *) fdh)->oh = h; |
|
|
((struct ppc_link_hash_entry *) h)->oh = fdh; |
|
|
} |
|
|
|
|
|
/* Now that the info is on the function descriptor, clear the |
|
|
function code sym info. Any function code syms for which we |
|
|
don't have a definition in a regular file, we force local. |
|
|
This prevents a shared library from exporting syms that have |
|
|
been imported from another library. Function code syms that |
|
|
are really in the library we must leave global to prevent the |
|
|
linker dragging in a definition from a static library. */ |
|
|
force_local = (info->shared |
|
|
&& ((h->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR) == 0 |
|
|
|| fdh == NULL |
|
|
|| (fdh->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR) == 0 |
|
|
|| (fdh->elf_link_hash_flags |
|
|
& ELF_LINK_FORCED_LOCAL) != 0)); |
|
|
_bfd_elf_link_hash_hide_symbol (info, h, force_local); |
|
5464 |
} |
} |
5465 |
|
|
5466 |
return true; |
/* Fake function descriptors are made undefweak. If the function |
5467 |
} |
code symbol is strong undefined, make the fake sym the same. |
5468 |
|
If the function code symbol is defined, then force the fake |
5469 |
|
descriptor local; We can't support overriding of symbols in a |
5470 |
|
shared library on a fake descriptor. */ |
5471 |
|
|
5472 |
|
if (fdh != NULL |
5473 |
|
&& fdh->fake |
5474 |
|
&& fdh->elf.root.type == bfd_link_hash_undefweak) |
5475 |
|
{ |
5476 |
|
if (fh->elf.root.type == bfd_link_hash_undefined) |
5477 |
|
{ |
5478 |
|
fdh->elf.root.type = bfd_link_hash_undefined; |
5479 |
|
bfd_link_add_undef (&htab->elf.root, &fdh->elf.root); |
5480 |
|
} |
5481 |
|
else if (fh->elf.root.type == bfd_link_hash_defined |
5482 |
|
|| fh->elf.root.type == bfd_link_hash_defweak) |
5483 |
|
{ |
5484 |
|
_bfd_elf_link_hash_hide_symbol (info, &fdh->elf, TRUE); |
5485 |
|
} |
5486 |
|
} |
5487 |
|
|
5488 |
|
if (fdh != NULL |
5489 |
|
&& !fdh->elf.forced_local |
5490 |
|
&& (info->shared |
5491 |
|
|| fdh->elf.def_dynamic |
5492 |
|
|| fdh->elf.ref_dynamic |
5493 |
|
|| (fdh->elf.root.type == bfd_link_hash_undefweak |
5494 |
|
&& ELF_ST_VISIBILITY (fdh->elf.other) == STV_DEFAULT))) |
5495 |
|
{ |
5496 |
|
if (fdh->elf.dynindx == -1) |
5497 |
|
if (! bfd_elf_link_record_dynamic_symbol (info, &fdh->elf)) |
5498 |
|
return FALSE; |
5499 |
|
fdh->elf.ref_regular |= fh->elf.ref_regular; |
5500 |
|
fdh->elf.ref_dynamic |= fh->elf.ref_dynamic; |
5501 |
|
fdh->elf.ref_regular_nonweak |= fh->elf.ref_regular_nonweak; |
5502 |
|
fdh->elf.non_got_ref |= fh->elf.non_got_ref; |
5503 |
|
if (ELF_ST_VISIBILITY (fh->elf.other) == STV_DEFAULT) |
5504 |
|
{ |
5505 |
|
move_plt_plist (fh, fdh); |
5506 |
|
fdh->elf.needs_plt = 1; |
5507 |
|
} |
5508 |
|
fdh->is_func_descriptor = 1; |
5509 |
|
fdh->oh = fh; |
5510 |
|
fh->oh = fdh; |
5511 |
|
} |
5512 |
|
|
5513 |
|
/* Now that the info is on the function descriptor, clear the |
5514 |
|
function code sym info. Any function code syms for which we |
5515 |
|
don't have a definition in a regular file, we force local. |
5516 |
|
This prevents a shared library from exporting syms that have |
5517 |
|
been imported from another library. Function code syms that |
5518 |
|
are really in the library we must leave global to prevent the |
5519 |
|
linker dragging in a definition from a static library. */ |
5520 |
|
force_local = (!fh->elf.def_regular |
5521 |
|
|| fdh == NULL |
5522 |
|
|| !fdh->elf.def_regular |
5523 |
|
|| fdh->elf.forced_local); |
5524 |
|
_bfd_elf_link_hash_hide_symbol (info, &fh->elf, force_local); |
5525 |
|
|
5526 |
#define MIN_SAVE_FPR 14 |
return TRUE; |
5527 |
#define MAX_SAVE_FPR 31 |
} |
5528 |
|
|
5529 |
/* Called near the start of bfd_elf_size_dynamic_sections. We use |
/* Called near the start of bfd_elf_size_dynamic_sections. We use |
5530 |
this hook to a) provide some gcc support functions, and b) transfer |
this hook to a) provide some gcc support functions, and b) transfer |
5531 |
dynamic linking information gathered so far on function code symbol |
dynamic linking information gathered so far on function code symbol |
5532 |
entries, to their corresponding function descriptor symbol entries. */ |
entries, to their corresponding function descriptor symbol entries. */ |
5533 |
static boolean |
|
5534 |
ppc64_elf_func_desc_adjust (obfd, info) |
static bfd_boolean |
5535 |
bfd *obfd ATTRIBUTE_UNUSED; |
ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED, |
5536 |
struct bfd_link_info *info; |
struct bfd_link_info *info) |
5537 |
{ |
{ |
5538 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
|
unsigned int lowest_savef = MAX_SAVE_FPR + 2; |
|
|
unsigned int lowest_restf = MAX_SAVE_FPR + 2; |
|
5539 |
unsigned int i; |
unsigned int i; |
5540 |
struct elf_link_hash_entry *h; |
const struct sfpr_def_parms funcs[] = |
5541 |
bfd_byte *p; |
{ |
5542 |
char sym[10]; |
{ "_savegpr0_", 14, 31, savegpr0, savegpr0_tail }, |
5543 |
|
{ "_restgpr0_", 14, 29, restgpr0, restgpr0_tail }, |
5544 |
|
{ "_restgpr0_", 30, 31, restgpr0, restgpr0_tail }, |
5545 |
|
{ "_savegpr1_", 14, 31, savegpr1, savegpr1_tail }, |
5546 |
|
{ "_restgpr1_", 14, 31, restgpr1, restgpr1_tail }, |
5547 |
|
{ "_savefpr_", 14, 31, savefpr, savefpr0_tail }, |
5548 |
|
{ "_restfpr_", 14, 29, restfpr, restfpr0_tail }, |
5549 |
|
{ "_restfpr_", 30, 31, restfpr, restfpr0_tail }, |
5550 |
|
{ "._savef", 14, 31, savefpr, savefpr1_tail }, |
5551 |
|
{ "._restf", 14, 31, restfpr, restfpr1_tail }, |
5552 |
|
{ "_savevr_", 20, 31, savevr, savevr_tail }, |
5553 |
|
{ "_restvr_", 20, 31, restvr, restvr_tail } |
5554 |
|
}; |
5555 |
|
|
5556 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
|
|
|
5557 |
if (htab->sfpr == NULL) |
if (htab->sfpr == NULL) |
5558 |
/* We don't have any relocs. */ |
/* We don't have any relocs. */ |
5559 |
return true; |
return TRUE; |
5560 |
|
|
5561 |
/* First provide any missing ._savef* and ._restf* functions. */ |
/* Provide any missing _save* and _rest* functions. */ |
5562 |
memcpy (sym, "._savef14", 10); |
htab->sfpr->size = 0; |
5563 |
for (i = MIN_SAVE_FPR; i <= MAX_SAVE_FPR; i++) |
for (i = 0; i < sizeof (funcs) / sizeof (funcs[0]); i++) |
5564 |
{ |
if (!sfpr_define (info, &funcs[i])) |
5565 |
sym[7] = i / 10 + '0'; |
return FALSE; |
|
sym[8] = i % 10 + '0'; |
|
|
h = elf_link_hash_lookup (&htab->elf, sym, false, false, true); |
|
|
if (h != NULL |
|
|
&& h->root.type == bfd_link_hash_undefined) |
|
|
{ |
|
|
if (lowest_savef > i) |
|
|
lowest_savef = i; |
|
|
h->root.type = bfd_link_hash_defined; |
|
|
h->root.u.def.section = htab->sfpr; |
|
|
h->root.u.def.value = (i - lowest_savef) * 4; |
|
|
h->type = STT_FUNC; |
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; |
|
|
_bfd_elf_link_hash_hide_symbol (info, h, info->shared); |
|
|
} |
|
|
} |
|
5566 |
|
|
5567 |
memcpy (sym, "._restf14", 10); |
elf_link_hash_traverse (&htab->elf, func_desc_adjust, info); |
|
for (i = MIN_SAVE_FPR; i <= MAX_SAVE_FPR; i++) |
|
|
{ |
|
|
sym[7] = i / 10 + '0'; |
|
|
sym[8] = i % 10 + '0'; |
|
|
h = elf_link_hash_lookup (&htab->elf, sym, false, false, true); |
|
|
if (h != NULL |
|
|
&& h->root.type == bfd_link_hash_undefined) |
|
|
{ |
|
|
if (lowest_restf > i) |
|
|
lowest_restf = i; |
|
|
h->root.type = bfd_link_hash_defined; |
|
|
h->root.u.def.section = htab->sfpr; |
|
|
h->root.u.def.value = ((MAX_SAVE_FPR + 2 - lowest_savef) * 4 |
|
|
+ (i - lowest_restf) * 4); |
|
|
h->type = STT_FUNC; |
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; |
|
|
_bfd_elf_link_hash_hide_symbol (info, h, info->shared); |
|
|
} |
|
|
} |
|
5568 |
|
|
5569 |
elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info); |
if (htab->sfpr->size == 0) |
5570 |
|
_bfd_strip_section_from_output (info, htab->sfpr); |
5571 |
|
|
5572 |
htab->sfpr->_raw_size = ((MAX_SAVE_FPR + 2 - lowest_savef) * 4 |
return TRUE; |
|
+ (MAX_SAVE_FPR + 2 - lowest_restf) * 4); |
|
|
|
|
|
if (htab->sfpr->_raw_size == 0) |
|
|
{ |
|
|
if (!htab->have_undefweak) |
|
|
{ |
|
|
_bfd_strip_section_from_output (info, htab->sfpr); |
|
|
return true; |
|
|
} |
|
|
|
|
|
htab->sfpr->_raw_size = 4; |
|
|
} |
|
|
|
|
|
p = (bfd_byte *) bfd_alloc (htab->elf.dynobj, htab->sfpr->_raw_size); |
|
|
if (p == NULL) |
|
|
return false; |
|
|
htab->sfpr->contents = p; |
|
|
|
|
|
for (i = lowest_savef; i <= MAX_SAVE_FPR; i++) |
|
|
{ |
|
|
unsigned int fpr = i << 21; |
|
|
unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8; |
|
|
bfd_put_32 (htab->elf.dynobj, STFD_FR0_0R1 + fpr + stackoff, p); |
|
|
p += 4; |
|
|
} |
|
|
if (lowest_savef <= MAX_SAVE_FPR) |
|
|
{ |
|
|
bfd_put_32 (htab->elf.dynobj, BLR, p); |
|
|
p += 4; |
|
|
} |
|
|
|
|
|
for (i = lowest_restf; i <= MAX_SAVE_FPR; i++) |
|
|
{ |
|
|
unsigned int fpr = i << 21; |
|
|
unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8; |
|
|
bfd_put_32 (htab->elf.dynobj, LFD_FR0_0R1 + fpr + stackoff, p); |
|
|
p += 4; |
|
|
} |
|
|
if (lowest_restf <= MAX_SAVE_FPR |
|
|
|| htab->sfpr->_raw_size == 4) |
|
|
{ |
|
|
bfd_put_32 (htab->elf.dynobj, BLR, p); |
|
|
} |
|
|
|
|
|
return true; |
|
5573 |
} |
} |
5574 |
|
|
5575 |
/* Adjust a symbol defined by a dynamic object and referenced by a |
/* Adjust a symbol defined by a dynamic object and referenced by a |
5578 |
change the definition to something the rest of the link can |
change the definition to something the rest of the link can |
5579 |
understand. */ |
understand. */ |
5580 |
|
|
5581 |
static boolean |
static bfd_boolean |
5582 |
ppc64_elf_adjust_dynamic_symbol (info, h) |
ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, |
5583 |
struct bfd_link_info *info; |
struct elf_link_hash_entry *h) |
|
struct elf_link_hash_entry *h; |
|
5584 |
{ |
{ |
5585 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
|
struct ppc_link_hash_entry * eh; |
|
|
struct ppc_dyn_relocs *p; |
|
5586 |
asection *s; |
asection *s; |
5587 |
unsigned int power_of_two; |
unsigned int power_of_two; |
5588 |
|
|
5590 |
|
|
5591 |
/* Deal with function syms. */ |
/* Deal with function syms. */ |
5592 |
if (h->type == STT_FUNC |
if (h->type == STT_FUNC |
5593 |
|| (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) |
|| h->needs_plt) |
5594 |
{ |
{ |
5595 |
/* Clear procedure linkage table information for any symbol that |
/* Clear procedure linkage table information for any symbol that |
5596 |
won't need a .plt entry. */ |
won't need a .plt entry. */ |
5597 |
if (!((struct ppc_link_hash_entry *) h)->is_func_descriptor |
struct plt_entry *ent; |
5598 |
|| h->plt.refcount <= 0 |
for (ent = h->plt.plist; ent != NULL; ent = ent->next) |
5599 |
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0 |
if (ent->plt.refcount > 0) |
5600 |
|| (! info->shared |
break; |
5601 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 |
if (ent == NULL |
5602 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0)) |
|| SYMBOL_CALLS_LOCAL (info, h) |
5603 |
|
|| (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT |
5604 |
|
&& h->root.type == bfd_link_hash_undefweak)) |
5605 |
{ |
{ |
5606 |
h->plt.offset = (bfd_vma) -1; |
h->plt.plist = NULL; |
5607 |
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; |
h->needs_plt = 0; |
5608 |
} |
} |
|
return true; |
|
5609 |
} |
} |
5610 |
else |
else |
5611 |
h->plt.offset = (bfd_vma) -1; |
h->plt.plist = NULL; |
5612 |
|
|
5613 |
/* If this is a weak symbol, and there is a real definition, the |
/* If this is a weak symbol, and there is a real definition, the |
5614 |
processor independent code will have arranged for us to see the |
processor independent code will have arranged for us to see the |
5615 |
real definition first, and we can just use the same value. */ |
real definition first, and we can just use the same value. */ |
5616 |
if (h->weakdef != NULL) |
if (h->u.weakdef != NULL) |
5617 |
{ |
{ |
5618 |
BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined |
BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined |
5619 |
|| h->weakdef->root.type == bfd_link_hash_defweak); |
|| h->u.weakdef->root.type == bfd_link_hash_defweak); |
5620 |
h->root.u.def.section = h->weakdef->root.u.def.section; |
h->root.u.def.section = h->u.weakdef->root.u.def.section; |
5621 |
h->root.u.def.value = h->weakdef->root.u.def.value; |
h->root.u.def.value = h->u.weakdef->root.u.def.value; |
5622 |
return true; |
if (ELIMINATE_COPY_RELOCS) |
5623 |
|
h->non_got_ref = h->u.weakdef->non_got_ref; |
5624 |
|
return TRUE; |
5625 |
} |
} |
5626 |
|
|
|
/* This is a reference to a symbol defined by a dynamic object which |
|
|
is not a function. */ |
|
|
|
|
5627 |
/* If we are creating a shared library, we must presume that the |
/* If we are creating a shared library, we must presume that the |
5628 |
only references to the symbol are via the global offset table. |
only references to the symbol are via the global offset table. |
5629 |
For such cases we need not do anything here; the relocations will |
For such cases we need not do anything here; the relocations will |
5630 |
be handled correctly by relocate_section. */ |
be handled correctly by relocate_section. */ |
5631 |
if (info->shared) |
if (info->shared) |
5632 |
return true; |
return TRUE; |
5633 |
|
|
5634 |
/* If there are no references to this symbol that do not use the |
/* If there are no references to this symbol that do not use the |
5635 |
GOT, we don't need to generate a copy reloc. */ |
GOT, we don't need to generate a copy reloc. */ |
5636 |
if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0) |
if (!h->non_got_ref) |
5637 |
return true; |
return TRUE; |
5638 |
|
|
5639 |
eh = (struct ppc_link_hash_entry *) h; |
if (ELIMINATE_COPY_RELOCS) |
|
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
|
5640 |
{ |
{ |
5641 |
s = p->sec->output_section; |
struct ppc_link_hash_entry * eh; |
5642 |
if (s != NULL && (s->flags & SEC_READONLY) != 0) |
struct ppc_dyn_relocs *p; |
5643 |
break; |
|
5644 |
|
eh = (struct ppc_link_hash_entry *) h; |
5645 |
|
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
5646 |
|
{ |
5647 |
|
s = p->sec->output_section; |
5648 |
|
if (s != NULL && (s->flags & SEC_READONLY) != 0) |
5649 |
|
break; |
5650 |
|
} |
5651 |
|
|
5652 |
|
/* If we didn't find any dynamic relocs in read-only sections, then |
5653 |
|
we'll be keeping the dynamic relocs and avoiding the copy reloc. */ |
5654 |
|
if (p == NULL) |
5655 |
|
{ |
5656 |
|
h->non_got_ref = 0; |
5657 |
|
return TRUE; |
5658 |
|
} |
5659 |
} |
} |
5660 |
|
|
5661 |
/* If we didn't find any dynamic relocs in read-only sections, then |
if (h->plt.plist != NULL) |
5662 |
we'll be keeping the dynamic relocs and avoiding the copy reloc. */ |
{ |
5663 |
if (p == NULL) |
/* We should never get here, but unfortunately there are versions |
5664 |
{ |
of gcc out there that improperly (for this ABI) put initialized |
5665 |
h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF; |
function pointers, vtable refs and suchlike in read-only |
5666 |
return true; |
sections. Allow them to proceed, but warn that this might |
5667 |
|
break at runtime. */ |
5668 |
|
(*_bfd_error_handler) |
5669 |
|
(_("copy reloc against `%s' requires lazy plt linking; " |
5670 |
|
"avoid setting LD_BIND_NOW=1 or upgrade gcc"), |
5671 |
|
h->root.root.string); |
5672 |
} |
} |
5673 |
|
|
5674 |
|
/* This is a reference to a symbol defined by a dynamic object which |
5675 |
|
is not a function. */ |
5676 |
|
|
5677 |
/* We must allocate the symbol in our .dynbss section, which will |
/* We must allocate the symbol in our .dynbss section, which will |
5678 |
become part of the .bss section of the executable. There will be |
become part of the .bss section of the executable. There will be |
5679 |
an entry for this symbol in the .dynsym section. The dynamic |
an entry for this symbol in the .dynsym section. The dynamic |
5684 |
both the dynamic object and the regular object will refer to the |
both the dynamic object and the regular object will refer to the |
5685 |
same memory location for the variable. */ |
same memory location for the variable. */ |
5686 |
|
|
5687 |
/* We must generate a R_PPC_COPY reloc to tell the dynamic linker to |
/* We must generate a R_PPC64_COPY reloc to tell the dynamic linker |
5688 |
copy the initial value out of the dynamic object and into the |
to copy the initial value out of the dynamic object and into the |
5689 |
runtime process image. We need to remember the offset into the |
runtime process image. We need to remember the offset into the |
5690 |
.rela.bss section we are going to use. */ |
.rela.bss section we are going to use. */ |
5691 |
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) |
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) |
5692 |
{ |
{ |
5693 |
htab->srelbss->_raw_size += sizeof (Elf64_External_Rela); |
htab->relbss->size += sizeof (Elf64_External_Rela); |
5694 |
h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; |
h->needs_copy = 1; |
5695 |
} |
} |
5696 |
|
|
5697 |
/* We need to figure out the alignment required for this symbol. I |
/* We need to figure out the alignment required for this symbol. I |
5701 |
power_of_two = 4; |
power_of_two = 4; |
5702 |
|
|
5703 |
/* Apply the required alignment. */ |
/* Apply the required alignment. */ |
5704 |
s = htab->sdynbss; |
s = htab->dynbss; |
5705 |
s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two)); |
s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); |
5706 |
if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) |
if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) |
5707 |
{ |
{ |
5708 |
if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) |
if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) |
5709 |
return false; |
return FALSE; |
5710 |
} |
} |
5711 |
|
|
5712 |
/* Define the symbol as being at this point in the section. */ |
/* Define the symbol as being at this point in the section. */ |
5713 |
h->root.u.def.section = s; |
h->root.u.def.section = s; |
5714 |
h->root.u.def.value = s->_raw_size; |
h->root.u.def.value = s->size; |
5715 |
|
|
5716 |
/* Increment the section size to make room for the symbol. */ |
/* Increment the section size to make room for the symbol. */ |
5717 |
s->_raw_size += h->size; |
s->size += h->size; |
5718 |
|
|
5719 |
return true; |
return TRUE; |
5720 |
} |
} |
5721 |
|
|
5722 |
/* If given a function descriptor symbol, hide both the function code |
/* If given a function descriptor symbol, hide both the function code |
5723 |
sym and the descriptor. */ |
sym and the descriptor. */ |
5724 |
static void |
static void |
5725 |
ppc64_elf_hide_symbol (info, h, force_local) |
ppc64_elf_hide_symbol (struct bfd_link_info *info, |
5726 |
struct bfd_link_info *info; |
struct elf_link_hash_entry *h, |
5727 |
struct elf_link_hash_entry *h; |
bfd_boolean force_local) |
|
boolean force_local; |
|
5728 |
{ |
{ |
5729 |
|
struct ppc_link_hash_entry *eh; |
5730 |
_bfd_elf_link_hash_hide_symbol (info, h, force_local); |
_bfd_elf_link_hash_hide_symbol (info, h, force_local); |
5731 |
|
|
5732 |
if (((struct ppc_link_hash_entry *) h)->is_func_descriptor) |
eh = (struct ppc_link_hash_entry *) h; |
5733 |
|
if (eh->is_func_descriptor) |
5734 |
{ |
{ |
5735 |
struct elf_link_hash_entry *fh = ((struct ppc_link_hash_entry *) h)->oh; |
struct ppc_link_hash_entry *fh = eh->oh; |
5736 |
|
|
5737 |
if (fh == NULL) |
if (fh == NULL) |
5738 |
{ |
{ |
5746 |
when it runs out of memory. This function doesn't have a |
when it runs out of memory. This function doesn't have a |
5747 |
return status, so there's no way to gracefully return an |
return status, so there's no way to gracefully return an |
5748 |
error. So cheat. We know that string[-1] can be safely |
error. So cheat. We know that string[-1] can be safely |
5749 |
dereferenced; It's either a string in an ELF string |
accessed; It's either a string in an ELF string table, |
5750 |
table, or allocated in an objalloc structure. */ |
or allocated in an objalloc structure. */ |
5751 |
|
|
5752 |
p = h->root.root.string - 1; |
p = eh->elf.root.root.string - 1; |
5753 |
save = *p; |
save = *p; |
5754 |
*(char *) p = '.'; |
*(char *) p = '.'; |
5755 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
5756 |
fh = elf_link_hash_lookup (&htab->elf, p, false, false, false); |
fh = (struct ppc_link_hash_entry *) |
5757 |
|
elf_link_hash_lookup (&htab->elf, p, FALSE, FALSE, FALSE); |
5758 |
*(char *) p = save; |
*(char *) p = save; |
5759 |
|
|
5760 |
/* Unfortunately, if it so happens that the string we were |
/* Unfortunately, if it so happens that the string we were |
5763 |
reason the lookup should fail. */ |
reason the lookup should fail. */ |
5764 |
if (fh == NULL) |
if (fh == NULL) |
5765 |
{ |
{ |
5766 |
q = h->root.root.string + strlen (h->root.root.string); |
q = eh->elf.root.root.string + strlen (eh->elf.root.root.string); |
5767 |
while (q >= h->root.root.string && *q == *p) |
while (q >= eh->elf.root.root.string && *q == *p) |
5768 |
--q, --p; |
--q, --p; |
5769 |
if (q < h->root.root.string && *p == '.') |
if (q < eh->elf.root.root.string && *p == '.') |
5770 |
fh = elf_link_hash_lookup (&htab->elf, p, false, false, false); |
fh = (struct ppc_link_hash_entry *) |
5771 |
|
elf_link_hash_lookup (&htab->elf, p, FALSE, FALSE, FALSE); |
5772 |
} |
} |
5773 |
if (fh != NULL) |
if (fh != NULL) |
5774 |
{ |
{ |
5775 |
((struct ppc_link_hash_entry *) h)->oh = fh; |
eh->oh = fh; |
5776 |
((struct ppc_link_hash_entry *) fh)->oh = h; |
fh->oh = eh; |
5777 |
} |
} |
5778 |
} |
} |
5779 |
if (fh != NULL) |
if (fh != NULL) |
5780 |
_bfd_elf_link_hash_hide_symbol (info, fh, force_local); |
_bfd_elf_link_hash_hide_symbol (info, &fh->elf, force_local); |
5781 |
|
} |
5782 |
|
} |
5783 |
|
|
5784 |
|
static bfd_boolean |
5785 |
|
get_sym_h (struct elf_link_hash_entry **hp, |
5786 |
|
Elf_Internal_Sym **symp, |
5787 |
|
asection **symsecp, |
5788 |
|
char **tls_maskp, |
5789 |
|
Elf_Internal_Sym **locsymsp, |
5790 |
|
unsigned long r_symndx, |
5791 |
|
bfd *ibfd) |
5792 |
|
{ |
5793 |
|
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; |
5794 |
|
|
5795 |
|
if (r_symndx >= symtab_hdr->sh_info) |
5796 |
|
{ |
5797 |
|
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (ibfd); |
5798 |
|
struct elf_link_hash_entry *h; |
5799 |
|
|
5800 |
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
5801 |
|
while (h->root.type == bfd_link_hash_indirect |
5802 |
|
|| h->root.type == bfd_link_hash_warning) |
5803 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
5804 |
|
|
5805 |
|
if (hp != NULL) |
5806 |
|
*hp = h; |
5807 |
|
|
5808 |
|
if (symp != NULL) |
5809 |
|
*symp = NULL; |
5810 |
|
|
5811 |
|
if (symsecp != NULL) |
5812 |
|
{ |
5813 |
|
asection *symsec = NULL; |
5814 |
|
if (h->root.type == bfd_link_hash_defined |
5815 |
|
|| h->root.type == bfd_link_hash_defweak) |
5816 |
|
symsec = h->root.u.def.section; |
5817 |
|
*symsecp = symsec; |
5818 |
|
} |
5819 |
|
|
5820 |
|
if (tls_maskp != NULL) |
5821 |
|
{ |
5822 |
|
struct ppc_link_hash_entry *eh; |
5823 |
|
|
5824 |
|
eh = (struct ppc_link_hash_entry *) h; |
5825 |
|
*tls_maskp = &eh->tls_mask; |
5826 |
|
} |
5827 |
|
} |
5828 |
|
else |
5829 |
|
{ |
5830 |
|
Elf_Internal_Sym *sym; |
5831 |
|
Elf_Internal_Sym *locsyms = *locsymsp; |
5832 |
|
|
5833 |
|
if (locsyms == NULL) |
5834 |
|
{ |
5835 |
|
locsyms = (Elf_Internal_Sym *) symtab_hdr->contents; |
5836 |
|
if (locsyms == NULL) |
5837 |
|
locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, |
5838 |
|
symtab_hdr->sh_info, |
5839 |
|
0, NULL, NULL, NULL); |
5840 |
|
if (locsyms == NULL) |
5841 |
|
return FALSE; |
5842 |
|
*locsymsp = locsyms; |
5843 |
|
} |
5844 |
|
sym = locsyms + r_symndx; |
5845 |
|
|
5846 |
|
if (hp != NULL) |
5847 |
|
*hp = NULL; |
5848 |
|
|
5849 |
|
if (symp != NULL) |
5850 |
|
*symp = sym; |
5851 |
|
|
5852 |
|
if (symsecp != NULL) |
5853 |
|
{ |
5854 |
|
asection *symsec = NULL; |
5855 |
|
if ((sym->st_shndx != SHN_UNDEF |
5856 |
|
&& sym->st_shndx < SHN_LORESERVE) |
5857 |
|
|| sym->st_shndx > SHN_HIRESERVE) |
5858 |
|
symsec = bfd_section_from_elf_index (ibfd, sym->st_shndx); |
5859 |
|
*symsecp = symsec; |
5860 |
|
} |
5861 |
|
|
5862 |
|
if (tls_maskp != NULL) |
5863 |
|
{ |
5864 |
|
struct got_entry **lgot_ents; |
5865 |
|
char *tls_mask; |
5866 |
|
|
5867 |
|
tls_mask = NULL; |
5868 |
|
lgot_ents = elf_local_got_ents (ibfd); |
5869 |
|
if (lgot_ents != NULL) |
5870 |
|
{ |
5871 |
|
char *lgot_masks = (char *) (lgot_ents + symtab_hdr->sh_info); |
5872 |
|
tls_mask = &lgot_masks[r_symndx]; |
5873 |
|
} |
5874 |
|
*tls_maskp = tls_mask; |
5875 |
|
} |
5876 |
} |
} |
5877 |
|
return TRUE; |
5878 |
|
} |
5879 |
|
|
5880 |
|
/* Returns TLS_MASKP for the given REL symbol. Function return is 0 on |
5881 |
|
error, 2 on a toc GD type suitable for optimization, 3 on a toc LD |
5882 |
|
type suitable for optimization, and 1 otherwise. */ |
5883 |
|
|
5884 |
|
static int |
5885 |
|
get_tls_mask (char **tls_maskp, unsigned long *toc_symndx, |
5886 |
|
Elf_Internal_Sym **locsymsp, |
5887 |
|
const Elf_Internal_Rela *rel, bfd *ibfd) |
5888 |
|
{ |
5889 |
|
unsigned long r_symndx; |
5890 |
|
int next_r; |
5891 |
|
struct elf_link_hash_entry *h; |
5892 |
|
Elf_Internal_Sym *sym; |
5893 |
|
asection *sec; |
5894 |
|
bfd_vma off; |
5895 |
|
|
5896 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
5897 |
|
if (!get_sym_h (&h, &sym, &sec, tls_maskp, locsymsp, r_symndx, ibfd)) |
5898 |
|
return 0; |
5899 |
|
|
5900 |
|
if ((*tls_maskp != NULL && **tls_maskp != 0) |
5901 |
|
|| sec == NULL |
5902 |
|
|| ppc64_elf_section_data (sec)->t_symndx == NULL) |
5903 |
|
return 1; |
5904 |
|
|
5905 |
|
/* Look inside a TOC section too. */ |
5906 |
|
if (h != NULL) |
5907 |
|
{ |
5908 |
|
BFD_ASSERT (h->root.type == bfd_link_hash_defined); |
5909 |
|
off = h->root.u.def.value; |
5910 |
|
} |
5911 |
|
else |
5912 |
|
off = sym->st_value; |
5913 |
|
off += rel->r_addend; |
5914 |
|
BFD_ASSERT (off % 8 == 0); |
5915 |
|
r_symndx = ppc64_elf_section_data (sec)->t_symndx[off / 8]; |
5916 |
|
next_r = ppc64_elf_section_data (sec)->t_symndx[off / 8 + 1]; |
5917 |
|
if (!get_sym_h (&h, &sym, &sec, tls_maskp, locsymsp, r_symndx, ibfd)) |
5918 |
|
return 0; |
5919 |
|
if (toc_symndx != NULL) |
5920 |
|
*toc_symndx = r_symndx; |
5921 |
|
if ((h == NULL |
5922 |
|
|| ((h->root.type == bfd_link_hash_defined |
5923 |
|
|| h->root.type == bfd_link_hash_defweak) |
5924 |
|
&& !h->def_dynamic)) |
5925 |
|
&& (next_r == -1 || next_r == -2)) |
5926 |
|
return 1 - next_r; |
5927 |
|
return 1; |
5928 |
} |
} |
5929 |
|
|
5930 |
static boolean |
/* Adjust all global syms defined in opd sections. In gcc generated |
5931 |
edit_opd (obfd, info) |
code for the old ABI, these will already have been done. */ |
5932 |
bfd *obfd; |
|
5933 |
struct bfd_link_info *info; |
static bfd_boolean |
5934 |
|
adjust_opd_syms (struct elf_link_hash_entry *h, void *inf ATTRIBUTE_UNUSED) |
5935 |
|
{ |
5936 |
|
struct ppc_link_hash_entry *eh; |
5937 |
|
asection *sym_sec; |
5938 |
|
long *opd_adjust; |
5939 |
|
|
5940 |
|
if (h->root.type == bfd_link_hash_indirect) |
5941 |
|
return TRUE; |
5942 |
|
|
5943 |
|
if (h->root.type == bfd_link_hash_warning) |
5944 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
5945 |
|
|
5946 |
|
if (h->root.type != bfd_link_hash_defined |
5947 |
|
&& h->root.type != bfd_link_hash_defweak) |
5948 |
|
return TRUE; |
5949 |
|
|
5950 |
|
eh = (struct ppc_link_hash_entry *) h; |
5951 |
|
if (eh->adjust_done) |
5952 |
|
return TRUE; |
5953 |
|
|
5954 |
|
sym_sec = eh->elf.root.u.def.section; |
5955 |
|
opd_adjust = get_opd_info (sym_sec); |
5956 |
|
if (opd_adjust != NULL) |
5957 |
|
{ |
5958 |
|
long adjust = opd_adjust[eh->elf.root.u.def.value / 8]; |
5959 |
|
if (adjust == -1) |
5960 |
|
{ |
5961 |
|
/* This entry has been deleted. */ |
5962 |
|
asection *dsec = ppc64_elf_tdata (sym_sec->owner)->u.deleted_section; |
5963 |
|
if (dsec == NULL) |
5964 |
|
{ |
5965 |
|
for (dsec = sym_sec->owner->sections; dsec; dsec = dsec->next) |
5966 |
|
if (elf_discarded_section (dsec)) |
5967 |
|
{ |
5968 |
|
ppc64_elf_tdata (sym_sec->owner)->u.deleted_section = dsec; |
5969 |
|
break; |
5970 |
|
} |
5971 |
|
} |
5972 |
|
eh->elf.root.u.def.value = 0; |
5973 |
|
eh->elf.root.u.def.section = dsec; |
5974 |
|
} |
5975 |
|
else |
5976 |
|
eh->elf.root.u.def.value += adjust; |
5977 |
|
eh->adjust_done = 1; |
5978 |
|
} |
5979 |
|
return TRUE; |
5980 |
|
} |
5981 |
|
|
5982 |
|
/* Handles decrementing dynamic reloc counts for the reloc specified by |
5983 |
|
R_INFO in section SEC. If LOCAL_SYMS is NULL, then H and SYM_SEC |
5984 |
|
have already been determined. */ |
5985 |
|
|
5986 |
|
static bfd_boolean |
5987 |
|
dec_dynrel_count (bfd_vma r_info, |
5988 |
|
asection *sec, |
5989 |
|
struct bfd_link_info *info, |
5990 |
|
Elf_Internal_Sym **local_syms, |
5991 |
|
struct elf_link_hash_entry *h, |
5992 |
|
asection *sym_sec) |
5993 |
|
{ |
5994 |
|
enum elf_ppc64_reloc_type r_type; |
5995 |
|
struct ppc_dyn_relocs *p; |
5996 |
|
struct ppc_dyn_relocs **pp; |
5997 |
|
|
5998 |
|
/* Can this reloc be dynamic? This switch, and later tests here |
5999 |
|
should be kept in sync with the code in check_relocs. */ |
6000 |
|
r_type = ELF64_R_TYPE (r_info); |
6001 |
|
switch (r_type) |
6002 |
|
{ |
6003 |
|
default: |
6004 |
|
return TRUE; |
6005 |
|
|
6006 |
|
case R_PPC64_TPREL16: |
6007 |
|
case R_PPC64_TPREL16_LO: |
6008 |
|
case R_PPC64_TPREL16_HI: |
6009 |
|
case R_PPC64_TPREL16_HA: |
6010 |
|
case R_PPC64_TPREL16_DS: |
6011 |
|
case R_PPC64_TPREL16_LO_DS: |
6012 |
|
case R_PPC64_TPREL16_HIGHER: |
6013 |
|
case R_PPC64_TPREL16_HIGHERA: |
6014 |
|
case R_PPC64_TPREL16_HIGHEST: |
6015 |
|
case R_PPC64_TPREL16_HIGHESTA: |
6016 |
|
if (!info->shared) |
6017 |
|
return TRUE; |
6018 |
|
|
6019 |
|
case R_PPC64_TPREL64: |
6020 |
|
case R_PPC64_DTPMOD64: |
6021 |
|
case R_PPC64_DTPREL64: |
6022 |
|
case R_PPC64_ADDR64: |
6023 |
|
case R_PPC64_REL30: |
6024 |
|
case R_PPC64_REL32: |
6025 |
|
case R_PPC64_REL64: |
6026 |
|
case R_PPC64_ADDR14: |
6027 |
|
case R_PPC64_ADDR14_BRNTAKEN: |
6028 |
|
case R_PPC64_ADDR14_BRTAKEN: |
6029 |
|
case R_PPC64_ADDR16: |
6030 |
|
case R_PPC64_ADDR16_DS: |
6031 |
|
case R_PPC64_ADDR16_HA: |
6032 |
|
case R_PPC64_ADDR16_HI: |
6033 |
|
case R_PPC64_ADDR16_HIGHER: |
6034 |
|
case R_PPC64_ADDR16_HIGHERA: |
6035 |
|
case R_PPC64_ADDR16_HIGHEST: |
6036 |
|
case R_PPC64_ADDR16_HIGHESTA: |
6037 |
|
case R_PPC64_ADDR16_LO: |
6038 |
|
case R_PPC64_ADDR16_LO_DS: |
6039 |
|
case R_PPC64_ADDR24: |
6040 |
|
case R_PPC64_ADDR32: |
6041 |
|
case R_PPC64_UADDR16: |
6042 |
|
case R_PPC64_UADDR32: |
6043 |
|
case R_PPC64_UADDR64: |
6044 |
|
case R_PPC64_TOC: |
6045 |
|
break; |
6046 |
|
} |
6047 |
|
|
6048 |
|
if (local_syms != NULL) |
6049 |
|
{ |
6050 |
|
unsigned long r_symndx; |
6051 |
|
Elf_Internal_Sym *sym; |
6052 |
|
bfd *ibfd = sec->owner; |
6053 |
|
|
6054 |
|
r_symndx = ELF64_R_SYM (r_info); |
6055 |
|
if (!get_sym_h (&h, &sym, &sym_sec, NULL, local_syms, r_symndx, ibfd)) |
6056 |
|
return FALSE; |
6057 |
|
} |
6058 |
|
|
6059 |
|
if ((info->shared |
6060 |
|
&& (MUST_BE_DYN_RELOC (r_type) |
6061 |
|
|| (h != NULL |
6062 |
|
&& (!info->symbolic |
6063 |
|
|| h->root.type == bfd_link_hash_defweak |
6064 |
|
|| !h->def_regular)))) |
6065 |
|
|| (ELIMINATE_COPY_RELOCS |
6066 |
|
&& !info->shared |
6067 |
|
&& h != NULL |
6068 |
|
&& (h->root.type == bfd_link_hash_defweak |
6069 |
|
|| !h->def_regular))) |
6070 |
|
; |
6071 |
|
else |
6072 |
|
return TRUE; |
6073 |
|
|
6074 |
|
if (h != NULL) |
6075 |
|
pp = &((struct ppc_link_hash_entry *) h)->dyn_relocs; |
6076 |
|
else if (sym_sec != NULL) |
6077 |
|
pp = (struct ppc_dyn_relocs **) &elf_section_data (sym_sec)->local_dynrel; |
6078 |
|
else |
6079 |
|
pp = (struct ppc_dyn_relocs **) &elf_section_data (sec)->local_dynrel; |
6080 |
|
|
6081 |
|
while ((p = *pp) != NULL) |
6082 |
|
{ |
6083 |
|
if (p->sec == sec) |
6084 |
|
{ |
6085 |
|
if (!MUST_BE_DYN_RELOC (r_type)) |
6086 |
|
p->pc_count -= 1; |
6087 |
|
p->count -= 1; |
6088 |
|
if (p->count == 0) |
6089 |
|
*pp = p->next; |
6090 |
|
return TRUE; |
6091 |
|
} |
6092 |
|
pp = &p->next; |
6093 |
|
} |
6094 |
|
|
6095 |
|
(*_bfd_error_handler) (_("dynreloc miscount for %B, section %A"), |
6096 |
|
sec->owner, sec); |
6097 |
|
bfd_set_error (bfd_error_bad_value); |
6098 |
|
return FALSE; |
6099 |
|
} |
6100 |
|
|
6101 |
|
/* Remove unused Official Procedure Descriptor entries. Currently we |
6102 |
|
only remove those associated with functions in discarded link-once |
6103 |
|
sections, or weakly defined functions that have been overridden. It |
6104 |
|
would be possible to remove many more entries for statically linked |
6105 |
|
applications. */ |
6106 |
|
|
6107 |
|
bfd_boolean |
6108 |
|
ppc64_elf_edit_opd (bfd *obfd, struct bfd_link_info *info, |
6109 |
|
bfd_boolean no_opd_opt, |
6110 |
|
bfd_boolean non_overlapping) |
6111 |
{ |
{ |
6112 |
bfd *ibfd; |
bfd *ibfd; |
6113 |
unsigned int bfd_indx; |
bfd_boolean some_edited = FALSE; |
6114 |
|
asection *need_pad = NULL; |
6115 |
|
|
6116 |
for (bfd_indx = 0, ibfd = info->input_bfds; |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
|
ibfd != NULL; |
|
|
ibfd = ibfd->link_next, bfd_indx++) |
|
6117 |
{ |
{ |
6118 |
asection *sec; |
asection *sec; |
6119 |
Elf_Internal_Rela *relstart, *rel, *relend; |
Elf_Internal_Rela *relstart, *rel, *relend; |
6121 |
Elf_Internal_Sym *local_syms; |
Elf_Internal_Sym *local_syms; |
6122 |
struct elf_link_hash_entry **sym_hashes; |
struct elf_link_hash_entry **sym_hashes; |
6123 |
bfd_vma offset; |
bfd_vma offset; |
6124 |
long *adjust; |
bfd_size_type amt; |
6125 |
boolean need_edit; |
long *opd_adjust; |
6126 |
|
bfd_boolean need_edit, add_aux_fields; |
6127 |
|
bfd_size_type cnt_16b = 0; |
6128 |
|
|
6129 |
sec = bfd_get_section_by_name (ibfd, ".opd"); |
sec = bfd_get_section_by_name (ibfd, ".opd"); |
6130 |
if (sec == NULL) |
if (sec == NULL || sec->size == 0) |
6131 |
continue; |
continue; |
6132 |
|
|
6133 |
adjust = (long *) elf_section_data (sec)->tdata; |
amt = sec->size * sizeof (long) / 8; |
6134 |
BFD_ASSERT (adjust != NULL); |
opd_adjust = get_opd_info (sec); |
6135 |
memset (adjust, 0, (size_t) sec->_raw_size * sizeof (long) / 24); |
if (opd_adjust == NULL) |
6136 |
|
{ |
6137 |
|
/* check_relocs hasn't been called. Must be a ld -r link |
6138 |
|
or --just-symbols object. */ |
6139 |
|
opd_adjust = bfd_alloc (obfd, amt); |
6140 |
|
if (opd_adjust == NULL) |
6141 |
|
return FALSE; |
6142 |
|
ppc64_elf_section_data (sec)->opd.adjust = opd_adjust; |
6143 |
|
} |
6144 |
|
memset (opd_adjust, 0, amt); |
6145 |
|
|
6146 |
|
if (no_opd_opt) |
6147 |
|
continue; |
6148 |
|
|
6149 |
|
if (sec->sec_info_type == ELF_INFO_TYPE_JUST_SYMS) |
6150 |
|
continue; |
6151 |
|
|
6152 |
if (sec->output_section == bfd_abs_section_ptr) |
if (sec->output_section == bfd_abs_section_ptr) |
6153 |
continue; |
continue; |
6161 |
sym_hashes = elf_sym_hashes (ibfd); |
sym_hashes = elf_sym_hashes (ibfd); |
6162 |
|
|
6163 |
/* Read the relocations. */ |
/* Read the relocations. */ |
6164 |
relstart = _bfd_elf64_link_read_relocs (obfd, sec, (PTR) NULL, |
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL, |
6165 |
(Elf_Internal_Rela *) NULL, |
info->keep_memory); |
|
info->keep_memory); |
|
6166 |
if (relstart == NULL) |
if (relstart == NULL) |
6167 |
return false; |
return FALSE; |
6168 |
|
|
6169 |
/* First run through the relocs to check they are sane, and to |
/* First run through the relocs to check they are sane, and to |
6170 |
determine whether we need to edit this opd section. */ |
determine whether we need to edit this opd section. */ |
6171 |
need_edit = false; |
need_edit = FALSE; |
6172 |
|
need_pad = sec; |
6173 |
offset = 0; |
offset = 0; |
6174 |
relend = relstart + sec->reloc_count; |
relend = relstart + sec->reloc_count; |
6175 |
for (rel = relstart; rel < relend; rel++) |
for (rel = relstart; rel < relend; ) |
6176 |
{ |
{ |
6177 |
enum elf_ppc_reloc_type r_type; |
enum elf_ppc64_reloc_type r_type; |
6178 |
unsigned long r_symndx; |
unsigned long r_symndx; |
6179 |
asection *sym_sec; |
asection *sym_sec; |
6180 |
struct elf_link_hash_entry *h; |
struct elf_link_hash_entry *h; |
6181 |
Elf_Internal_Sym *sym; |
Elf_Internal_Sym *sym; |
6182 |
|
|
6183 |
/* .opd contains a regular array of 24 byte entries. We're |
/* .opd contains a regular array of 16 or 24 byte entries. We're |
6184 |
only interested in the reloc pointing to a function entry |
only interested in the reloc pointing to a function entry |
6185 |
point. */ |
point. */ |
6186 |
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); |
if (rel->r_offset != offset |
6187 |
if (r_type == R_PPC64_TOC) |
|| rel + 1 >= relend |
6188 |
continue; |
|| (rel + 1)->r_offset != offset + 8) |
|
|
|
|
if (r_type != R_PPC64_ADDR64) |
|
|
{ |
|
|
(*_bfd_error_handler) |
|
|
(_("%s: unexpected reloc type %u in .opd section"), |
|
|
bfd_archive_filename (ibfd), r_type); |
|
|
need_edit = false; |
|
|
break; |
|
|
} |
|
|
|
|
|
if (rel + 1 >= relend) |
|
|
continue; |
|
|
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE ((rel + 1)->r_info); |
|
|
if (r_type != R_PPC64_TOC) |
|
|
continue; |
|
|
|
|
|
if (rel->r_offset != offset) |
|
6189 |
{ |
{ |
6190 |
/* If someone messes with .opd alignment then after a |
/* If someone messes with .opd alignment then after a |
6191 |
"ld -r" we might have padding in the middle of .opd. |
"ld -r" we might have padding in the middle of .opd. |
6192 |
Also, there's nothing to prevent someone putting |
Also, there's nothing to prevent someone putting |
6193 |
something silly in .opd with the assembler. No .opd |
something silly in .opd with the assembler. No .opd |
6194 |
optimization for them! */ |
optimization for them! */ |
6195 |
|
broken_opd: |
6196 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
6197 |
(_("%s: .opd is not a regular array of opd entries"), |
(_("%B: .opd is not a regular array of opd entries"), ibfd); |
6198 |
bfd_archive_filename (ibfd)); |
need_edit = FALSE; |
|
need_edit = false; |
|
6199 |
break; |
break; |
6200 |
} |
} |
6201 |
|
|
6202 |
r_symndx = ELF64_R_SYM (rel->r_info); |
if ((r_type = ELF64_R_TYPE (rel->r_info)) != R_PPC64_ADDR64 |
6203 |
sym_sec = NULL; |
|| (r_type = ELF64_R_TYPE ((rel + 1)->r_info)) != R_PPC64_TOC) |
|
h = NULL; |
|
|
sym = NULL; |
|
|
if (r_symndx >= symtab_hdr->sh_info) |
|
|
{ |
|
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
|
|
while (h->root.type == bfd_link_hash_indirect |
|
|
|| h->root.type == bfd_link_hash_warning) |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
|
|
if (h->root.type == bfd_link_hash_defined |
|
|
|| h->root.type == bfd_link_hash_defweak) |
|
|
sym_sec = h->root.u.def.section; |
|
|
} |
|
|
else |
|
6204 |
{ |
{ |
6205 |
if (local_syms == NULL) |
(*_bfd_error_handler) |
6206 |
{ |
(_("%B: unexpected reloc type %u in .opd section"), |
6207 |
local_syms = (Elf_Internal_Sym *) symtab_hdr->contents; |
ibfd, r_type); |
6208 |
if (local_syms == NULL) |
need_edit = FALSE; |
6209 |
local_syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, |
break; |
|
symtab_hdr->sh_info, 0, |
|
|
NULL, NULL, NULL); |
|
|
if (local_syms == NULL) |
|
|
goto error_free_rel; |
|
|
} |
|
|
sym = local_syms + r_symndx; |
|
|
if ((sym->st_shndx != SHN_UNDEF |
|
|
&& sym->st_shndx < SHN_LORESERVE) |
|
|
|| sym->st_shndx > SHN_HIRESERVE) |
|
|
sym_sec = bfd_section_from_elf_index (ibfd, sym->st_shndx); |
|
6210 |
} |
} |
6211 |
|
|
6212 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
6213 |
|
if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms, |
6214 |
|
r_symndx, ibfd)) |
6215 |
|
goto error_ret; |
6216 |
|
|
6217 |
if (sym_sec == NULL || sym_sec->owner == NULL) |
if (sym_sec == NULL || sym_sec->owner == NULL) |
6218 |
{ |
{ |
6219 |
|
const char *sym_name; |
6220 |
|
if (h != NULL) |
6221 |
|
sym_name = h->root.root.string; |
6222 |
|
else |
6223 |
|
sym_name = bfd_elf_sym_name (ibfd, symtab_hdr, sym); |
6224 |
|
|
6225 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
6226 |
(_("%s: undefined sym `%s' in .opd section"), |
(_("%B: undefined sym `%s' in .opd section"), |
6227 |
bfd_archive_filename (ibfd), |
ibfd, sym_name); |
6228 |
h != NULL ? h->root.root.string : "<local symbol>"); |
need_edit = FALSE; |
|
need_edit = false; |
|
6229 |
break; |
break; |
6230 |
} |
} |
6231 |
|
|
6232 |
if (sym_sec->output_section == bfd_abs_section_ptr) |
/* opd entries are always for functions defined in the |
6233 |
|
current input bfd. If the symbol isn't defined in the |
6234 |
|
input bfd, then we won't be using the function in this |
6235 |
|
bfd; It must be defined in a linkonce section in another |
6236 |
|
bfd, or is weak. It's also possible that we are |
6237 |
|
discarding the function due to a linker script /DISCARD/, |
6238 |
|
which we test for via the output_section. */ |
6239 |
|
if (sym_sec->owner != ibfd |
6240 |
|
|| sym_sec->output_section == bfd_abs_section_ptr) |
6241 |
|
need_edit = TRUE; |
6242 |
|
|
6243 |
|
rel += 2; |
6244 |
|
if (rel == relend |
6245 |
|
|| (rel + 1 == relend && rel->r_offset == offset + 16)) |
6246 |
{ |
{ |
6247 |
/* OK, we've found a function that's excluded from the |
if (sec->size == offset + 24) |
6248 |
link. */ |
{ |
6249 |
need_edit = true; |
need_pad = NULL; |
6250 |
|
break; |
6251 |
|
} |
6252 |
|
if (rel == relend && sec->size == offset + 16) |
6253 |
|
{ |
6254 |
|
cnt_16b++; |
6255 |
|
break; |
6256 |
|
} |
6257 |
|
goto broken_opd; |
6258 |
} |
} |
6259 |
|
|
6260 |
offset += 24; |
if (rel->r_offset == offset + 24) |
6261 |
|
offset += 24; |
6262 |
|
else if (rel->r_offset != offset + 16) |
6263 |
|
goto broken_opd; |
6264 |
|
else if (rel + 1 < relend |
6265 |
|
&& ELF64_R_TYPE (rel[0].r_info) == R_PPC64_ADDR64 |
6266 |
|
&& ELF64_R_TYPE (rel[1].r_info) == R_PPC64_TOC) |
6267 |
|
{ |
6268 |
|
offset += 16; |
6269 |
|
cnt_16b++; |
6270 |
|
} |
6271 |
|
else if (rel + 2 < relend |
6272 |
|
&& ELF64_R_TYPE (rel[1].r_info) == R_PPC64_ADDR64 |
6273 |
|
&& ELF64_R_TYPE (rel[2].r_info) == R_PPC64_TOC) |
6274 |
|
{ |
6275 |
|
offset += 24; |
6276 |
|
rel += 1; |
6277 |
|
} |
6278 |
|
else |
6279 |
|
goto broken_opd; |
6280 |
} |
} |
6281 |
|
|
6282 |
if (need_edit) |
add_aux_fields = non_overlapping && cnt_16b > 0; |
6283 |
|
|
6284 |
|
if (need_edit || add_aux_fields) |
6285 |
{ |
{ |
6286 |
Elf_Internal_Rela *write_rel; |
Elf_Internal_Rela *write_rel; |
6287 |
bfd_byte *rptr, *wptr; |
bfd_byte *rptr, *wptr; |
6288 |
boolean skip; |
bfd_byte *new_contents = NULL; |
6289 |
|
bfd_boolean skip; |
6290 |
|
long opd_ent_size; |
6291 |
|
|
6292 |
/* This seems a waste of time as input .opd sections are all |
/* This seems a waste of time as input .opd sections are all |
6293 |
zeros as generated by gcc, but I suppose there's no reason |
zeros as generated by gcc, but I suppose there's no reason |
6295 |
the third word of .opd entries. */ |
the third word of .opd entries. */ |
6296 |
if ((sec->flags & SEC_IN_MEMORY) == 0) |
if ((sec->flags & SEC_IN_MEMORY) == 0) |
6297 |
{ |
{ |
6298 |
bfd_byte *loc = bfd_alloc (ibfd, sec->_raw_size); |
bfd_byte *loc; |
6299 |
if (loc == NULL |
if (!bfd_malloc_and_get_section (ibfd, sec, &loc)) |
|
|| !bfd_get_section_contents (ibfd, sec, loc, (bfd_vma) 0, |
|
|
sec->_raw_size)) |
|
6300 |
{ |
{ |
6301 |
|
if (loc != NULL) |
6302 |
|
free (loc); |
6303 |
|
error_ret: |
6304 |
if (local_syms != NULL |
if (local_syms != NULL |
6305 |
&& symtab_hdr->contents != (unsigned char *) local_syms) |
&& symtab_hdr->contents != (unsigned char *) local_syms) |
6306 |
free (local_syms); |
free (local_syms); |
|
error_free_rel: |
|
6307 |
if (elf_section_data (sec)->relocs != relstart) |
if (elf_section_data (sec)->relocs != relstart) |
6308 |
free (relstart); |
free (relstart); |
6309 |
return false; |
return FALSE; |
6310 |
} |
} |
6311 |
sec->contents = loc; |
sec->contents = loc; |
6312 |
sec->flags |= (SEC_IN_MEMORY | SEC_HAS_CONTENTS); |
sec->flags |= (SEC_IN_MEMORY | SEC_HAS_CONTENTS); |
6314 |
|
|
6315 |
elf_section_data (sec)->relocs = relstart; |
elf_section_data (sec)->relocs = relstart; |
6316 |
|
|
6317 |
wptr = sec->contents; |
new_contents = sec->contents; |
6318 |
|
if (add_aux_fields) |
6319 |
|
{ |
6320 |
|
new_contents = bfd_malloc (sec->size + cnt_16b * 8); |
6321 |
|
if (new_contents == NULL) |
6322 |
|
return FALSE; |
6323 |
|
need_pad = FALSE; |
6324 |
|
} |
6325 |
|
wptr = new_contents; |
6326 |
rptr = sec->contents; |
rptr = sec->contents; |
6327 |
|
|
6328 |
write_rel = relstart; |
write_rel = relstart; |
6329 |
skip = false; |
skip = FALSE; |
6330 |
offset = 0; |
offset = 0; |
6331 |
|
opd_ent_size = 0; |
6332 |
for (rel = relstart; rel < relend; rel++) |
for (rel = relstart; rel < relend; rel++) |
6333 |
{ |
{ |
6334 |
|
unsigned long r_symndx; |
6335 |
|
asection *sym_sec; |
6336 |
|
struct elf_link_hash_entry *h; |
6337 |
|
Elf_Internal_Sym *sym; |
6338 |
|
|
6339 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
6340 |
|
if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms, |
6341 |
|
r_symndx, ibfd)) |
6342 |
|
goto error_ret; |
6343 |
|
|
6344 |
if (rel->r_offset == offset) |
if (rel->r_offset == offset) |
6345 |
{ |
{ |
6346 |
unsigned long r_symndx; |
struct ppc_link_hash_entry *fdh = NULL; |
|
asection *sym_sec; |
|
|
struct elf_link_hash_entry *h; |
|
|
Elf_Internal_Sym *sym; |
|
6347 |
|
|
6348 |
r_symndx = ELF64_R_SYM (rel->r_info); |
/* See if the .opd entry is full 24 byte or |
6349 |
sym_sec = NULL; |
16 byte (with fd_aux entry overlapped with next |
6350 |
h = NULL; |
fd_func). */ |
6351 |
sym = NULL; |
opd_ent_size = 24; |
6352 |
if (r_symndx >= symtab_hdr->sh_info) |
if ((rel + 2 == relend && sec->size == offset + 16) |
6353 |
|
|| (rel + 3 < relend |
6354 |
|
&& rel[2].r_offset == offset + 16 |
6355 |
|
&& rel[3].r_offset == offset + 24 |
6356 |
|
&& ELF64_R_TYPE (rel[2].r_info) == R_PPC64_ADDR64 |
6357 |
|
&& ELF64_R_TYPE (rel[3].r_info) == R_PPC64_TOC)) |
6358 |
|
opd_ent_size = 16; |
6359 |
|
|
6360 |
|
if (h != NULL |
6361 |
|
&& h->root.root.string[0] == '.') |
6362 |
{ |
{ |
6363 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
fdh = get_fdh ((struct ppc_link_hash_entry *) h, |
6364 |
while (h->root.type == bfd_link_hash_indirect |
ppc_hash_table (info)); |
6365 |
|| h->root.type == bfd_link_hash_warning) |
if (fdh != NULL |
6366 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
&& fdh->elf.root.type != bfd_link_hash_defined |
6367 |
if (h->root.type == bfd_link_hash_defined |
&& fdh->elf.root.type != bfd_link_hash_defweak) |
6368 |
|| h->root.type == bfd_link_hash_defweak) |
fdh = NULL; |
|
sym_sec = h->root.u.def.section; |
|
6369 |
} |
} |
6370 |
else |
|
6371 |
|
skip = (sym_sec->owner != ibfd |
6372 |
|
|| sym_sec->output_section == bfd_abs_section_ptr); |
6373 |
|
if (skip) |
6374 |
{ |
{ |
6375 |
sym = local_syms + r_symndx; |
if (fdh != NULL && sym_sec->owner == ibfd) |
6376 |
if ((sym->st_shndx != SHN_UNDEF |
{ |
6377 |
&& sym->st_shndx < SHN_LORESERVE) |
/* Arrange for the function descriptor sym |
6378 |
|| sym->st_shndx > SHN_HIRESERVE) |
to be dropped. */ |
6379 |
sym_sec = bfd_section_from_elf_index (ibfd, |
fdh->elf.root.u.def.value = 0; |
6380 |
sym->st_shndx); |
fdh->elf.root.u.def.section = sym_sec; |
6381 |
|
} |
6382 |
|
opd_adjust[rel->r_offset / 8] = -1; |
6383 |
} |
} |
6384 |
|
else |
|
skip = sym_sec->output_section == bfd_abs_section_ptr; |
|
|
if (!skip) |
|
6385 |
{ |
{ |
6386 |
/* We'll be keeping this opd entry. */ |
/* We'll be keeping this opd entry. */ |
6387 |
|
|
6388 |
if (h != NULL) |
if (fdh != NULL) |
|
{ |
|
|
/* Redefine the function descriptor symbol |
|
|
to this location in the opd section. |
|
|
We've checked above that opd relocs are |
|
|
ordered. */ |
|
|
struct elf_link_hash_entry *fdh; |
|
|
struct ppc_link_hash_entry *fh; |
|
|
|
|
|
fh = (struct ppc_link_hash_entry *) h; |
|
|
BFD_ASSERT (fh->is_func); |
|
|
fdh = fh->oh; |
|
|
fdh->root.u.def.value = wptr - sec->contents; |
|
|
} |
|
|
else |
|
6389 |
{ |
{ |
6390 |
/* Local syms are a bit tricky. We could |
/* Redefine the function descriptor symbol to |
6391 |
tweak them as they can be cached, but |
this location in the opd section. It is |
6392 |
we'd need to look through the local syms |
necessary to update the value here rather |
6393 |
for the function descriptor sym which we |
than using an array of adjustments as we do |
6394 |
don't have at the moment. So keep an |
for local symbols, because various places |
6395 |
array of adjustments. */ |
in the generic ELF code use the value |
6396 |
adjust[(rel->r_offset + wptr - rptr) / 24] |
stored in u.def.value. */ |
6397 |
= wptr - rptr; |
fdh->elf.root.u.def.value = wptr - new_contents; |
6398 |
|
fdh->adjust_done = 1; |
6399 |
} |
} |
6400 |
|
|
6401 |
|
/* Local syms are a bit tricky. We could |
6402 |
|
tweak them as they can be cached, but |
6403 |
|
we'd need to look through the local syms |
6404 |
|
for the function descriptor sym which we |
6405 |
|
don't have at the moment. So keep an |
6406 |
|
array of adjustments. */ |
6407 |
|
opd_adjust[rel->r_offset / 8] |
6408 |
|
= (wptr - new_contents) - (rptr - sec->contents); |
6409 |
|
|
6410 |
if (wptr != rptr) |
if (wptr != rptr) |
6411 |
memcpy (wptr, rptr, 24); |
memcpy (wptr, rptr, opd_ent_size); |
6412 |
wptr += 24; |
wptr += opd_ent_size; |
6413 |
|
if (add_aux_fields && opd_ent_size == 16) |
6414 |
|
{ |
6415 |
|
memset (wptr, '\0', 8); |
6416 |
|
wptr += 8; |
6417 |
|
} |
6418 |
} |
} |
6419 |
rptr += 24; |
rptr += opd_ent_size; |
6420 |
offset += 24; |
offset += opd_ent_size; |
6421 |
} |
} |
6422 |
|
|
6423 |
/* We need to adjust any reloc offsets to point to the |
if (skip) |
|
new opd entries. While we're at it, we may as well |
|
|
remove redundant relocs. */ |
|
|
if (!skip) |
|
6424 |
{ |
{ |
6425 |
rel->r_offset += wptr - rptr; |
if (!dec_dynrel_count (rel->r_info, sec, info, |
6426 |
|
NULL, h, sym_sec)) |
6427 |
|
goto error_ret; |
6428 |
|
} |
6429 |
|
else |
6430 |
|
{ |
6431 |
|
/* We need to adjust any reloc offsets to point to the |
6432 |
|
new opd entries. While we're at it, we may as well |
6433 |
|
remove redundant relocs. */ |
6434 |
|
rel->r_offset += opd_adjust[(offset - opd_ent_size) / 8]; |
6435 |
if (write_rel != rel) |
if (write_rel != rel) |
6436 |
memcpy (write_rel, rel, sizeof (*rel)); |
memcpy (write_rel, rel, sizeof (*rel)); |
6437 |
++write_rel; |
++write_rel; |
6438 |
} |
} |
6439 |
} |
} |
6440 |
|
|
6441 |
sec->_cooked_size = wptr - sec->contents; |
sec->size = wptr - new_contents; |
6442 |
sec->reloc_count = write_rel - relstart; |
sec->reloc_count = write_rel - relstart; |
6443 |
|
if (add_aux_fields) |
6444 |
|
{ |
6445 |
|
free (sec->contents); |
6446 |
|
sec->contents = new_contents; |
6447 |
|
} |
6448 |
|
|
6449 |
|
/* Fudge the size too, as this is used later in |
6450 |
|
elf_bfd_final_link if we are emitting relocs. */ |
6451 |
|
elf_section_data (sec)->rel_hdr.sh_size |
6452 |
|
= sec->reloc_count * elf_section_data (sec)->rel_hdr.sh_entsize; |
6453 |
|
BFD_ASSERT (elf_section_data (sec)->rel_hdr2 == NULL); |
6454 |
|
some_edited = TRUE; |
6455 |
} |
} |
6456 |
else if (elf_section_data (sec)->relocs != relstart) |
else if (elf_section_data (sec)->relocs != relstart) |
6457 |
free (relstart); |
free (relstart); |
6466 |
} |
} |
6467 |
} |
} |
6468 |
|
|
6469 |
return true; |
if (some_edited) |
6470 |
|
elf_link_hash_traverse (elf_hash_table (info), adjust_opd_syms, NULL); |
6471 |
|
|
6472 |
|
/* If we are doing a final link and the last .opd entry is just 16 byte |
6473 |
|
long, add a 8 byte padding after it. */ |
6474 |
|
if (need_pad != NULL && !info->relocatable) |
6475 |
|
{ |
6476 |
|
bfd_byte *p; |
6477 |
|
|
6478 |
|
if ((need_pad->flags & SEC_IN_MEMORY) == 0) |
6479 |
|
{ |
6480 |
|
BFD_ASSERT (need_pad->size > 0); |
6481 |
|
|
6482 |
|
p = bfd_malloc (need_pad->size + 8); |
6483 |
|
if (p == NULL) |
6484 |
|
return FALSE; |
6485 |
|
|
6486 |
|
if (! bfd_get_section_contents (need_pad->owner, need_pad, |
6487 |
|
p, 0, need_pad->size)) |
6488 |
|
return FALSE; |
6489 |
|
|
6490 |
|
need_pad->contents = p; |
6491 |
|
need_pad->flags |= (SEC_IN_MEMORY | SEC_HAS_CONTENTS); |
6492 |
|
} |
6493 |
|
else |
6494 |
|
{ |
6495 |
|
p = bfd_realloc (need_pad->contents, need_pad->size + 8); |
6496 |
|
if (p == NULL) |
6497 |
|
return FALSE; |
6498 |
|
|
6499 |
|
need_pad->contents = p; |
6500 |
|
} |
6501 |
|
|
6502 |
|
memset (need_pad->contents + need_pad->size, 0, 8); |
6503 |
|
need_pad->size += 8; |
6504 |
|
} |
6505 |
|
|
6506 |
|
return TRUE; |
6507 |
|
} |
6508 |
|
|
6509 |
|
/* Set htab->tls_get_addr and call the generic ELF tls_setup function. */ |
6510 |
|
|
6511 |
|
asection * |
6512 |
|
ppc64_elf_tls_setup (bfd *obfd, struct bfd_link_info *info) |
6513 |
|
{ |
6514 |
|
struct ppc_link_hash_table *htab; |
6515 |
|
|
6516 |
|
htab = ppc_hash_table (info); |
6517 |
|
if (htab->tls_get_addr != NULL) |
6518 |
|
{ |
6519 |
|
struct ppc_link_hash_entry *h = htab->tls_get_addr; |
6520 |
|
|
6521 |
|
while (h->elf.root.type == bfd_link_hash_indirect |
6522 |
|
|| h->elf.root.type == bfd_link_hash_warning) |
6523 |
|
h = (struct ppc_link_hash_entry *) h->elf.root.u.i.link; |
6524 |
|
|
6525 |
|
htab->tls_get_addr = h; |
6526 |
|
|
6527 |
|
if (htab->tls_get_addr_fd == NULL |
6528 |
|
&& h->oh != NULL |
6529 |
|
&& h->oh->is_func_descriptor |
6530 |
|
&& (h->oh->elf.root.type == bfd_link_hash_defined |
6531 |
|
|| h->oh->elf.root.type == bfd_link_hash_defweak)) |
6532 |
|
htab->tls_get_addr_fd = h->oh; |
6533 |
|
} |
6534 |
|
|
6535 |
|
if (htab->tls_get_addr_fd != NULL) |
6536 |
|
{ |
6537 |
|
struct ppc_link_hash_entry *h = htab->tls_get_addr_fd; |
6538 |
|
|
6539 |
|
while (h->elf.root.type == bfd_link_hash_indirect |
6540 |
|
|| h->elf.root.type == bfd_link_hash_warning) |
6541 |
|
h = (struct ppc_link_hash_entry *) h->elf.root.u.i.link; |
6542 |
|
|
6543 |
|
htab->tls_get_addr_fd = h; |
6544 |
|
} |
6545 |
|
|
6546 |
|
return _bfd_elf_tls_setup (obfd, info); |
6547 |
|
} |
6548 |
|
|
6549 |
|
/* Run through all the TLS relocs looking for optimization |
6550 |
|
opportunities. The linker has been hacked (see ppc64elf.em) to do |
6551 |
|
a preliminary section layout so that we know the TLS segment |
6552 |
|
offsets. We can't optimize earlier because some optimizations need |
6553 |
|
to know the tp offset, and we need to optimize before allocating |
6554 |
|
dynamic relocations. */ |
6555 |
|
|
6556 |
|
bfd_boolean |
6557 |
|
ppc64_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) |
6558 |
|
{ |
6559 |
|
bfd *ibfd; |
6560 |
|
asection *sec; |
6561 |
|
struct ppc_link_hash_table *htab; |
6562 |
|
|
6563 |
|
if (info->relocatable || info->shared) |
6564 |
|
return TRUE; |
6565 |
|
|
6566 |
|
htab = ppc_hash_table (info); |
6567 |
|
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
6568 |
|
{ |
6569 |
|
Elf_Internal_Sym *locsyms = NULL; |
6570 |
|
|
6571 |
|
for (sec = ibfd->sections; sec != NULL; sec = sec->next) |
6572 |
|
if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section)) |
6573 |
|
{ |
6574 |
|
Elf_Internal_Rela *relstart, *rel, *relend; |
6575 |
|
int expecting_tls_get_addr; |
6576 |
|
|
6577 |
|
/* Read the relocations. */ |
6578 |
|
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL, |
6579 |
|
info->keep_memory); |
6580 |
|
if (relstart == NULL) |
6581 |
|
return FALSE; |
6582 |
|
|
6583 |
|
expecting_tls_get_addr = 0; |
6584 |
|
relend = relstart + sec->reloc_count; |
6585 |
|
for (rel = relstart; rel < relend; rel++) |
6586 |
|
{ |
6587 |
|
enum elf_ppc64_reloc_type r_type; |
6588 |
|
unsigned long r_symndx; |
6589 |
|
struct elf_link_hash_entry *h; |
6590 |
|
Elf_Internal_Sym *sym; |
6591 |
|
asection *sym_sec; |
6592 |
|
char *tls_mask; |
6593 |
|
char tls_set, tls_clear, tls_type = 0; |
6594 |
|
bfd_vma value; |
6595 |
|
bfd_boolean ok_tprel, is_local; |
6596 |
|
|
6597 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
6598 |
|
if (!get_sym_h (&h, &sym, &sym_sec, &tls_mask, &locsyms, |
6599 |
|
r_symndx, ibfd)) |
6600 |
|
{ |
6601 |
|
err_free_rel: |
6602 |
|
if (elf_section_data (sec)->relocs != relstart) |
6603 |
|
free (relstart); |
6604 |
|
if (locsyms != NULL |
6605 |
|
&& (elf_tdata (ibfd)->symtab_hdr.contents |
6606 |
|
!= (unsigned char *) locsyms)) |
6607 |
|
free (locsyms); |
6608 |
|
return FALSE; |
6609 |
|
} |
6610 |
|
|
6611 |
|
if (h != NULL) |
6612 |
|
{ |
6613 |
|
if (h->root.type != bfd_link_hash_defined |
6614 |
|
&& h->root.type != bfd_link_hash_defweak) |
6615 |
|
continue; |
6616 |
|
value = h->root.u.def.value; |
6617 |
|
} |
6618 |
|
else |
6619 |
|
/* Symbols referenced by TLS relocs must be of type |
6620 |
|
STT_TLS. So no need for .opd local sym adjust. */ |
6621 |
|
value = sym->st_value; |
6622 |
|
|
6623 |
|
ok_tprel = FALSE; |
6624 |
|
is_local = FALSE; |
6625 |
|
if (h == NULL |
6626 |
|
|| !h->def_dynamic) |
6627 |
|
{ |
6628 |
|
is_local = TRUE; |
6629 |
|
value += sym_sec->output_offset; |
6630 |
|
value += sym_sec->output_section->vma; |
6631 |
|
value -= htab->elf.tls_sec->vma; |
6632 |
|
ok_tprel = (value + TP_OFFSET + ((bfd_vma) 1 << 31) |
6633 |
|
< (bfd_vma) 1 << 32); |
6634 |
|
} |
6635 |
|
|
6636 |
|
r_type = ELF64_R_TYPE (rel->r_info); |
6637 |
|
switch (r_type) |
6638 |
|
{ |
6639 |
|
case R_PPC64_GOT_TLSLD16: |
6640 |
|
case R_PPC64_GOT_TLSLD16_LO: |
6641 |
|
case R_PPC64_GOT_TLSLD16_HI: |
6642 |
|
case R_PPC64_GOT_TLSLD16_HA: |
6643 |
|
/* These relocs should never be against a symbol |
6644 |
|
defined in a shared lib. Leave them alone if |
6645 |
|
that turns out to be the case. */ |
6646 |
|
ppc64_tlsld_got (ibfd)->refcount -= 1; |
6647 |
|
if (!is_local) |
6648 |
|
continue; |
6649 |
|
|
6650 |
|
/* LD -> LE */ |
6651 |
|
tls_set = 0; |
6652 |
|
tls_clear = TLS_LD; |
6653 |
|
tls_type = TLS_TLS | TLS_LD; |
6654 |
|
expecting_tls_get_addr = 1; |
6655 |
|
break; |
6656 |
|
|
6657 |
|
case R_PPC64_GOT_TLSGD16: |
6658 |
|
case R_PPC64_GOT_TLSGD16_LO: |
6659 |
|
case R_PPC64_GOT_TLSGD16_HI: |
6660 |
|
case R_PPC64_GOT_TLSGD16_HA: |
6661 |
|
if (ok_tprel) |
6662 |
|
/* GD -> LE */ |
6663 |
|
tls_set = 0; |
6664 |
|
else |
6665 |
|
/* GD -> IE */ |
6666 |
|
tls_set = TLS_TLS | TLS_TPRELGD; |
6667 |
|
tls_clear = TLS_GD; |
6668 |
|
tls_type = TLS_TLS | TLS_GD; |
6669 |
|
expecting_tls_get_addr = 1; |
6670 |
|
break; |
6671 |
|
|
6672 |
|
case R_PPC64_GOT_TPREL16_DS: |
6673 |
|
case R_PPC64_GOT_TPREL16_LO_DS: |
6674 |
|
case R_PPC64_GOT_TPREL16_HI: |
6675 |
|
case R_PPC64_GOT_TPREL16_HA: |
6676 |
|
expecting_tls_get_addr = 0; |
6677 |
|
if (ok_tprel) |
6678 |
|
{ |
6679 |
|
/* IE -> LE */ |
6680 |
|
tls_set = 0; |
6681 |
|
tls_clear = TLS_TPREL; |
6682 |
|
tls_type = TLS_TLS | TLS_TPREL; |
6683 |
|
break; |
6684 |
|
} |
6685 |
|
else |
6686 |
|
continue; |
6687 |
|
|
6688 |
|
case R_PPC64_REL14: |
6689 |
|
case R_PPC64_REL14_BRTAKEN: |
6690 |
|
case R_PPC64_REL14_BRNTAKEN: |
6691 |
|
case R_PPC64_REL24: |
6692 |
|
if (h != NULL |
6693 |
|
&& (h == &htab->tls_get_addr->elf |
6694 |
|
|| h == &htab->tls_get_addr_fd->elf)) |
6695 |
|
{ |
6696 |
|
if (!expecting_tls_get_addr |
6697 |
|
&& rel != relstart |
6698 |
|
&& ((ELF64_R_TYPE (rel[-1].r_info) |
6699 |
|
== R_PPC64_TOC16) |
6700 |
|
|| (ELF64_R_TYPE (rel[-1].r_info) |
6701 |
|
== R_PPC64_TOC16_LO))) |
6702 |
|
{ |
6703 |
|
/* Check for toc tls entries. */ |
6704 |
|
char *toc_tls; |
6705 |
|
int retval; |
6706 |
|
|
6707 |
|
retval = get_tls_mask (&toc_tls, NULL, &locsyms, |
6708 |
|
rel - 1, ibfd); |
6709 |
|
if (retval == 0) |
6710 |
|
goto err_free_rel; |
6711 |
|
if (toc_tls != NULL) |
6712 |
|
expecting_tls_get_addr = retval > 1; |
6713 |
|
} |
6714 |
|
|
6715 |
|
if (expecting_tls_get_addr) |
6716 |
|
{ |
6717 |
|
struct plt_entry *ent; |
6718 |
|
for (ent = h->plt.plist; ent; ent = ent->next) |
6719 |
|
if (ent->addend == 0) |
6720 |
|
{ |
6721 |
|
if (ent->plt.refcount > 0) |
6722 |
|
ent->plt.refcount -= 1; |
6723 |
|
break; |
6724 |
|
} |
6725 |
|
} |
6726 |
|
} |
6727 |
|
expecting_tls_get_addr = 0; |
6728 |
|
continue; |
6729 |
|
|
6730 |
|
case R_PPC64_TPREL64: |
6731 |
|
expecting_tls_get_addr = 0; |
6732 |
|
if (ok_tprel) |
6733 |
|
{ |
6734 |
|
/* IE -> LE */ |
6735 |
|
tls_set = TLS_EXPLICIT; |
6736 |
|
tls_clear = TLS_TPREL; |
6737 |
|
break; |
6738 |
|
} |
6739 |
|
else |
6740 |
|
continue; |
6741 |
|
|
6742 |
|
case R_PPC64_DTPMOD64: |
6743 |
|
expecting_tls_get_addr = 0; |
6744 |
|
if (rel + 1 < relend |
6745 |
|
&& (rel[1].r_info |
6746 |
|
== ELF64_R_INFO (r_symndx, R_PPC64_DTPREL64)) |
6747 |
|
&& rel[1].r_offset == rel->r_offset + 8) |
6748 |
|
{ |
6749 |
|
if (ok_tprel) |
6750 |
|
/* GD -> LE */ |
6751 |
|
tls_set = TLS_EXPLICIT | TLS_GD; |
6752 |
|
else |
6753 |
|
/* GD -> IE */ |
6754 |
|
tls_set = TLS_EXPLICIT | TLS_GD | TLS_TPRELGD; |
6755 |
|
tls_clear = TLS_GD; |
6756 |
|
} |
6757 |
|
else |
6758 |
|
{ |
6759 |
|
if (!is_local) |
6760 |
|
continue; |
6761 |
|
|
6762 |
|
/* LD -> LE */ |
6763 |
|
tls_set = TLS_EXPLICIT; |
6764 |
|
tls_clear = TLS_LD; |
6765 |
|
} |
6766 |
|
break; |
6767 |
|
|
6768 |
|
default: |
6769 |
|
expecting_tls_get_addr = 0; |
6770 |
|
continue; |
6771 |
|
} |
6772 |
|
|
6773 |
|
if ((tls_set & TLS_EXPLICIT) == 0) |
6774 |
|
{ |
6775 |
|
struct got_entry *ent; |
6776 |
|
|
6777 |
|
/* Adjust got entry for this reloc. */ |
6778 |
|
if (h != NULL) |
6779 |
|
ent = h->got.glist; |
6780 |
|
else |
6781 |
|
ent = elf_local_got_ents (ibfd)[r_symndx]; |
6782 |
|
|
6783 |
|
for (; ent != NULL; ent = ent->next) |
6784 |
|
if (ent->addend == rel->r_addend |
6785 |
|
&& ent->owner == ibfd |
6786 |
|
&& ent->tls_type == tls_type) |
6787 |
|
break; |
6788 |
|
if (ent == NULL) |
6789 |
|
abort (); |
6790 |
|
|
6791 |
|
if (tls_set == 0) |
6792 |
|
{ |
6793 |
|
/* We managed to get rid of a got entry. */ |
6794 |
|
if (ent->got.refcount > 0) |
6795 |
|
ent->got.refcount -= 1; |
6796 |
|
} |
6797 |
|
} |
6798 |
|
else |
6799 |
|
{ |
6800 |
|
/* If we got rid of a DTPMOD/DTPREL reloc pair then |
6801 |
|
we'll lose one or two dyn relocs. */ |
6802 |
|
if (!dec_dynrel_count (rel->r_info, sec, info, |
6803 |
|
NULL, h, sym_sec)) |
6804 |
|
return FALSE; |
6805 |
|
|
6806 |
|
if (tls_set == (TLS_EXPLICIT | TLS_GD)) |
6807 |
|
{ |
6808 |
|
if (!dec_dynrel_count ((rel + 1)->r_info, sec, info, |
6809 |
|
NULL, h, sym_sec)) |
6810 |
|
return FALSE; |
6811 |
|
} |
6812 |
|
} |
6813 |
|
|
6814 |
|
*tls_mask |= tls_set; |
6815 |
|
*tls_mask &= ~tls_clear; |
6816 |
|
} |
6817 |
|
|
6818 |
|
if (elf_section_data (sec)->relocs != relstart) |
6819 |
|
free (relstart); |
6820 |
|
} |
6821 |
|
|
6822 |
|
if (locsyms != NULL |
6823 |
|
&& (elf_tdata (ibfd)->symtab_hdr.contents |
6824 |
|
!= (unsigned char *) locsyms)) |
6825 |
|
{ |
6826 |
|
if (!info->keep_memory) |
6827 |
|
free (locsyms); |
6828 |
|
else |
6829 |
|
elf_tdata (ibfd)->symtab_hdr.contents = (unsigned char *) locsyms; |
6830 |
|
} |
6831 |
|
} |
6832 |
|
return TRUE; |
6833 |
|
} |
6834 |
|
|
6835 |
|
/* Called via elf_link_hash_traverse from ppc64_elf_edit_toc to adjust |
6836 |
|
the values of any global symbols in a toc section that has been |
6837 |
|
edited. Globals in toc sections should be a rarity, so this function |
6838 |
|
sets a flag if any are found in toc sections other than the one just |
6839 |
|
edited, so that futher hash table traversals can be avoided. */ |
6840 |
|
|
6841 |
|
struct adjust_toc_info |
6842 |
|
{ |
6843 |
|
asection *toc; |
6844 |
|
unsigned long *skip; |
6845 |
|
bfd_boolean global_toc_syms; |
6846 |
|
}; |
6847 |
|
|
6848 |
|
static bfd_boolean |
6849 |
|
adjust_toc_syms (struct elf_link_hash_entry *h, void *inf) |
6850 |
|
{ |
6851 |
|
struct ppc_link_hash_entry *eh; |
6852 |
|
struct adjust_toc_info *toc_inf = (struct adjust_toc_info *) inf; |
6853 |
|
|
6854 |
|
if (h->root.type == bfd_link_hash_indirect) |
6855 |
|
return TRUE; |
6856 |
|
|
6857 |
|
if (h->root.type == bfd_link_hash_warning) |
6858 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
6859 |
|
|
6860 |
|
if (h->root.type != bfd_link_hash_defined |
6861 |
|
&& h->root.type != bfd_link_hash_defweak) |
6862 |
|
return TRUE; |
6863 |
|
|
6864 |
|
eh = (struct ppc_link_hash_entry *) h; |
6865 |
|
if (eh->adjust_done) |
6866 |
|
return TRUE; |
6867 |
|
|
6868 |
|
if (eh->elf.root.u.def.section == toc_inf->toc) |
6869 |
|
{ |
6870 |
|
unsigned long skip = toc_inf->skip[eh->elf.root.u.def.value >> 3]; |
6871 |
|
if (skip != (unsigned long) -1) |
6872 |
|
eh->elf.root.u.def.value -= skip; |
6873 |
|
else |
6874 |
|
{ |
6875 |
|
(*_bfd_error_handler) |
6876 |
|
(_("%s defined in removed toc entry"), eh->elf.root.root.string); |
6877 |
|
eh->elf.root.u.def.section = &bfd_abs_section; |
6878 |
|
eh->elf.root.u.def.value = 0; |
6879 |
|
} |
6880 |
|
eh->adjust_done = 1; |
6881 |
|
} |
6882 |
|
else if (strcmp (eh->elf.root.u.def.section->name, ".toc") == 0) |
6883 |
|
toc_inf->global_toc_syms = TRUE; |
6884 |
|
|
6885 |
|
return TRUE; |
6886 |
|
} |
6887 |
|
|
6888 |
|
/* Examine all relocs referencing .toc sections in order to remove |
6889 |
|
unused .toc entries. */ |
6890 |
|
|
6891 |
|
bfd_boolean |
6892 |
|
ppc64_elf_edit_toc (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) |
6893 |
|
{ |
6894 |
|
bfd *ibfd; |
6895 |
|
struct adjust_toc_info toc_inf; |
6896 |
|
|
6897 |
|
toc_inf.global_toc_syms = TRUE; |
6898 |
|
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
6899 |
|
{ |
6900 |
|
asection *toc, *sec; |
6901 |
|
Elf_Internal_Shdr *symtab_hdr; |
6902 |
|
Elf_Internal_Sym *local_syms; |
6903 |
|
struct elf_link_hash_entry **sym_hashes; |
6904 |
|
Elf_Internal_Rela *relstart, *rel; |
6905 |
|
unsigned long *skip, *drop; |
6906 |
|
unsigned char *used; |
6907 |
|
unsigned char *keep, last, some_unused; |
6908 |
|
|
6909 |
|
toc = bfd_get_section_by_name (ibfd, ".toc"); |
6910 |
|
if (toc == NULL |
6911 |
|
|| toc->size == 0 |
6912 |
|
|| toc->sec_info_type == ELF_INFO_TYPE_JUST_SYMS |
6913 |
|
|| elf_discarded_section (toc)) |
6914 |
|
continue; |
6915 |
|
|
6916 |
|
local_syms = NULL; |
6917 |
|
symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; |
6918 |
|
sym_hashes = elf_sym_hashes (ibfd); |
6919 |
|
|
6920 |
|
/* Look at sections dropped from the final link. */ |
6921 |
|
skip = NULL; |
6922 |
|
relstart = NULL; |
6923 |
|
for (sec = ibfd->sections; sec != NULL; sec = sec->next) |
6924 |
|
{ |
6925 |
|
if (sec->reloc_count == 0 |
6926 |
|
|| !elf_discarded_section (sec) |
6927 |
|
|| get_opd_info (sec) |
6928 |
|
|| (sec->flags & SEC_ALLOC) == 0 |
6929 |
|
|| (sec->flags & SEC_DEBUGGING) != 0) |
6930 |
|
continue; |
6931 |
|
|
6932 |
|
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL, FALSE); |
6933 |
|
if (relstart == NULL) |
6934 |
|
goto error_ret; |
6935 |
|
|
6936 |
|
/* Run through the relocs to see which toc entries might be |
6937 |
|
unused. */ |
6938 |
|
for (rel = relstart; rel < relstart + sec->reloc_count; ++rel) |
6939 |
|
{ |
6940 |
|
enum elf_ppc64_reloc_type r_type; |
6941 |
|
unsigned long r_symndx; |
6942 |
|
asection *sym_sec; |
6943 |
|
struct elf_link_hash_entry *h; |
6944 |
|
Elf_Internal_Sym *sym; |
6945 |
|
bfd_vma val; |
6946 |
|
|
6947 |
|
r_type = ELF64_R_TYPE (rel->r_info); |
6948 |
|
switch (r_type) |
6949 |
|
{ |
6950 |
|
default: |
6951 |
|
continue; |
6952 |
|
|
6953 |
|
case R_PPC64_TOC16: |
6954 |
|
case R_PPC64_TOC16_LO: |
6955 |
|
case R_PPC64_TOC16_HI: |
6956 |
|
case R_PPC64_TOC16_HA: |
6957 |
|
case R_PPC64_TOC16_DS: |
6958 |
|
case R_PPC64_TOC16_LO_DS: |
6959 |
|
break; |
6960 |
|
} |
6961 |
|
|
6962 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
6963 |
|
if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms, |
6964 |
|
r_symndx, ibfd)) |
6965 |
|
goto error_ret; |
6966 |
|
|
6967 |
|
if (sym_sec != toc) |
6968 |
|
continue; |
6969 |
|
|
6970 |
|
if (h != NULL) |
6971 |
|
val = h->root.u.def.value; |
6972 |
|
else |
6973 |
|
val = sym->st_value; |
6974 |
|
val += rel->r_addend; |
6975 |
|
|
6976 |
|
if (val >= toc->size) |
6977 |
|
continue; |
6978 |
|
|
6979 |
|
/* Anything in the toc ought to be aligned to 8 bytes. |
6980 |
|
If not, don't mark as unused. */ |
6981 |
|
if (val & 7) |
6982 |
|
continue; |
6983 |
|
|
6984 |
|
if (skip == NULL) |
6985 |
|
{ |
6986 |
|
skip = bfd_zmalloc (sizeof (*skip) * (toc->size + 7) / 8); |
6987 |
|
if (skip == NULL) |
6988 |
|
goto error_ret; |
6989 |
|
} |
6990 |
|
|
6991 |
|
skip[val >> 3] = 1; |
6992 |
|
} |
6993 |
|
|
6994 |
|
if (elf_section_data (sec)->relocs != relstart) |
6995 |
|
free (relstart); |
6996 |
|
} |
6997 |
|
|
6998 |
|
if (skip == NULL) |
6999 |
|
continue; |
7000 |
|
|
7001 |
|
used = bfd_zmalloc (sizeof (*used) * (toc->size + 7) / 8); |
7002 |
|
if (used == NULL) |
7003 |
|
{ |
7004 |
|
error_ret: |
7005 |
|
if (local_syms != NULL |
7006 |
|
&& symtab_hdr->contents != (unsigned char *) local_syms) |
7007 |
|
free (local_syms); |
7008 |
|
if (sec != NULL |
7009 |
|
&& relstart != NULL |
7010 |
|
&& elf_section_data (sec)->relocs != relstart) |
7011 |
|
free (relstart); |
7012 |
|
if (skip != NULL) |
7013 |
|
free (skip); |
7014 |
|
return FALSE; |
7015 |
|
} |
7016 |
|
|
7017 |
|
/* Now check all kept sections that might reference the toc. */ |
7018 |
|
for (sec = ibfd->sections; |
7019 |
|
sec != NULL; |
7020 |
|
/* Check the toc itself last. */ |
7021 |
|
sec = (sec == toc ? NULL |
7022 |
|
: sec->next == toc && sec->next->next ? sec->next->next |
7023 |
|
: sec->next == NULL ? toc |
7024 |
|
: sec->next)) |
7025 |
|
{ |
7026 |
|
int repeat; |
7027 |
|
|
7028 |
|
if (sec->reloc_count == 0 |
7029 |
|
|| elf_discarded_section (sec) |
7030 |
|
|| get_opd_info (sec) |
7031 |
|
|| (sec->flags & SEC_ALLOC) == 0 |
7032 |
|
|| (sec->flags & SEC_DEBUGGING) != 0) |
7033 |
|
continue; |
7034 |
|
|
7035 |
|
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL, TRUE); |
7036 |
|
if (relstart == NULL) |
7037 |
|
goto error_ret; |
7038 |
|
|
7039 |
|
/* Mark toc entries referenced as used. */ |
7040 |
|
repeat = 0; |
7041 |
|
do |
7042 |
|
for (rel = relstart; rel < relstart + sec->reloc_count; ++rel) |
7043 |
|
{ |
7044 |
|
enum elf_ppc64_reloc_type r_type; |
7045 |
|
unsigned long r_symndx; |
7046 |
|
asection *sym_sec; |
7047 |
|
struct elf_link_hash_entry *h; |
7048 |
|
Elf_Internal_Sym *sym; |
7049 |
|
bfd_vma val; |
7050 |
|
|
7051 |
|
r_type = ELF64_R_TYPE (rel->r_info); |
7052 |
|
switch (r_type) |
7053 |
|
{ |
7054 |
|
case R_PPC64_TOC16: |
7055 |
|
case R_PPC64_TOC16_LO: |
7056 |
|
case R_PPC64_TOC16_HI: |
7057 |
|
case R_PPC64_TOC16_HA: |
7058 |
|
case R_PPC64_TOC16_DS: |
7059 |
|
case R_PPC64_TOC16_LO_DS: |
7060 |
|
/* In case we're taking addresses of toc entries. */ |
7061 |
|
case R_PPC64_ADDR64: |
7062 |
|
break; |
7063 |
|
|
7064 |
|
default: |
7065 |
|
continue; |
7066 |
|
} |
7067 |
|
|
7068 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
7069 |
|
if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms, |
7070 |
|
r_symndx, ibfd)) |
7071 |
|
{ |
7072 |
|
free (used); |
7073 |
|
goto error_ret; |
7074 |
|
} |
7075 |
|
|
7076 |
|
if (sym_sec != toc) |
7077 |
|
continue; |
7078 |
|
|
7079 |
|
if (h != NULL) |
7080 |
|
val = h->root.u.def.value; |
7081 |
|
else |
7082 |
|
val = sym->st_value; |
7083 |
|
val += rel->r_addend; |
7084 |
|
|
7085 |
|
if (val >= toc->size) |
7086 |
|
continue; |
7087 |
|
|
7088 |
|
/* For the toc section, we only mark as used if |
7089 |
|
this entry itself isn't unused. */ |
7090 |
|
if (sec == toc |
7091 |
|
&& !used[val >> 3] |
7092 |
|
&& (used[rel->r_offset >> 3] |
7093 |
|
|| !skip[rel->r_offset >> 3])) |
7094 |
|
/* Do all the relocs again, to catch reference |
7095 |
|
chains. */ |
7096 |
|
repeat = 1; |
7097 |
|
|
7098 |
|
used[val >> 3] = 1; |
7099 |
|
} |
7100 |
|
while (repeat); |
7101 |
|
} |
7102 |
|
|
7103 |
|
/* Merge the used and skip arrays. Assume that TOC |
7104 |
|
doublewords not appearing as either used or unused belong |
7105 |
|
to to an entry more than one doubleword in size. */ |
7106 |
|
for (drop = skip, keep = used, last = 0, some_unused = 0; |
7107 |
|
drop < skip + (toc->size + 7) / 8; |
7108 |
|
++drop, ++keep) |
7109 |
|
{ |
7110 |
|
if (*keep) |
7111 |
|
{ |
7112 |
|
*drop = 0; |
7113 |
|
last = 0; |
7114 |
|
} |
7115 |
|
else if (*drop) |
7116 |
|
{ |
7117 |
|
some_unused = 1; |
7118 |
|
last = 1; |
7119 |
|
} |
7120 |
|
else |
7121 |
|
*drop = last; |
7122 |
|
} |
7123 |
|
|
7124 |
|
free (used); |
7125 |
|
|
7126 |
|
if (some_unused) |
7127 |
|
{ |
7128 |
|
bfd_byte *contents, *src; |
7129 |
|
unsigned long off; |
7130 |
|
|
7131 |
|
/* Shuffle the toc contents, and at the same time convert the |
7132 |
|
skip array from booleans into offsets. */ |
7133 |
|
if (!bfd_malloc_and_get_section (ibfd, toc, &contents)) |
7134 |
|
goto error_ret; |
7135 |
|
|
7136 |
|
elf_section_data (toc)->this_hdr.contents = contents; |
7137 |
|
|
7138 |
|
for (src = contents, off = 0, drop = skip; |
7139 |
|
src < contents + toc->size; |
7140 |
|
src += 8, ++drop) |
7141 |
|
{ |
7142 |
|
if (*drop) |
7143 |
|
{ |
7144 |
|
*drop = (unsigned long) -1; |
7145 |
|
off += 8; |
7146 |
|
} |
7147 |
|
else if (off != 0) |
7148 |
|
{ |
7149 |
|
*drop = off; |
7150 |
|
memcpy (src - off, src, 8); |
7151 |
|
} |
7152 |
|
} |
7153 |
|
toc->rawsize = toc->size; |
7154 |
|
toc->size = src - contents - off; |
7155 |
|
|
7156 |
|
if (toc->reloc_count != 0) |
7157 |
|
{ |
7158 |
|
Elf_Internal_Rela *wrel; |
7159 |
|
bfd_size_type sz; |
7160 |
|
|
7161 |
|
/* Read toc relocs. */ |
7162 |
|
relstart = _bfd_elf_link_read_relocs (ibfd, toc, NULL, NULL, |
7163 |
|
TRUE); |
7164 |
|
if (relstart == NULL) |
7165 |
|
goto error_ret; |
7166 |
|
|
7167 |
|
/* Remove unused toc relocs, and adjust those we keep. */ |
7168 |
|
wrel = relstart; |
7169 |
|
for (rel = relstart; rel < relstart + toc->reloc_count; ++rel) |
7170 |
|
if (skip[rel->r_offset >> 3] != (unsigned long) -1) |
7171 |
|
{ |
7172 |
|
wrel->r_offset = rel->r_offset - skip[rel->r_offset >> 3]; |
7173 |
|
wrel->r_info = rel->r_info; |
7174 |
|
wrel->r_addend = rel->r_addend; |
7175 |
|
++wrel; |
7176 |
|
} |
7177 |
|
else if (!dec_dynrel_count (rel->r_info, toc, info, |
7178 |
|
&local_syms, NULL, NULL)) |
7179 |
|
goto error_ret; |
7180 |
|
|
7181 |
|
toc->reloc_count = wrel - relstart; |
7182 |
|
sz = elf_section_data (toc)->rel_hdr.sh_entsize; |
7183 |
|
elf_section_data (toc)->rel_hdr.sh_size = toc->reloc_count * sz; |
7184 |
|
BFD_ASSERT (elf_section_data (toc)->rel_hdr2 == NULL); |
7185 |
|
} |
7186 |
|
|
7187 |
|
/* Adjust addends for relocs against the toc section sym. */ |
7188 |
|
for (sec = ibfd->sections; sec != NULL; sec = sec->next) |
7189 |
|
{ |
7190 |
|
if (sec->reloc_count == 0 |
7191 |
|
|| elf_discarded_section (sec)) |
7192 |
|
continue; |
7193 |
|
|
7194 |
|
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL, |
7195 |
|
TRUE); |
7196 |
|
if (relstart == NULL) |
7197 |
|
goto error_ret; |
7198 |
|
|
7199 |
|
for (rel = relstart; rel < relstart + sec->reloc_count; ++rel) |
7200 |
|
{ |
7201 |
|
enum elf_ppc64_reloc_type r_type; |
7202 |
|
unsigned long r_symndx; |
7203 |
|
asection *sym_sec; |
7204 |
|
struct elf_link_hash_entry *h; |
7205 |
|
Elf_Internal_Sym *sym; |
7206 |
|
|
7207 |
|
r_type = ELF64_R_TYPE (rel->r_info); |
7208 |
|
switch (r_type) |
7209 |
|
{ |
7210 |
|
default: |
7211 |
|
continue; |
7212 |
|
|
7213 |
|
case R_PPC64_TOC16: |
7214 |
|
case R_PPC64_TOC16_LO: |
7215 |
|
case R_PPC64_TOC16_HI: |
7216 |
|
case R_PPC64_TOC16_HA: |
7217 |
|
case R_PPC64_TOC16_DS: |
7218 |
|
case R_PPC64_TOC16_LO_DS: |
7219 |
|
case R_PPC64_ADDR64: |
7220 |
|
break; |
7221 |
|
} |
7222 |
|
|
7223 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
7224 |
|
if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms, |
7225 |
|
r_symndx, ibfd)) |
7226 |
|
goto error_ret; |
7227 |
|
|
7228 |
|
if (sym_sec != toc || h != NULL || sym->st_value != 0) |
7229 |
|
continue; |
7230 |
|
|
7231 |
|
rel->r_addend -= skip[rel->r_addend >> 3]; |
7232 |
|
} |
7233 |
|
} |
7234 |
|
|
7235 |
|
/* We shouldn't have local or global symbols defined in the TOC, |
7236 |
|
but handle them anyway. */ |
7237 |
|
if (local_syms != NULL) |
7238 |
|
{ |
7239 |
|
Elf_Internal_Sym *sym; |
7240 |
|
|
7241 |
|
for (sym = local_syms; |
7242 |
|
sym < local_syms + symtab_hdr->sh_info; |
7243 |
|
++sym) |
7244 |
|
if (sym->st_shndx != SHN_UNDEF |
7245 |
|
&& (sym->st_shndx < SHN_LORESERVE |
7246 |
|
|| sym->st_shndx > SHN_HIRESERVE) |
7247 |
|
&& sym->st_value != 0 |
7248 |
|
&& bfd_section_from_elf_index (ibfd, sym->st_shndx) == toc) |
7249 |
|
{ |
7250 |
|
if (skip[sym->st_value >> 3] != (unsigned long) -1) |
7251 |
|
sym->st_value -= skip[sym->st_value >> 3]; |
7252 |
|
else |
7253 |
|
{ |
7254 |
|
(*_bfd_error_handler) |
7255 |
|
(_("%s defined in removed toc entry"), |
7256 |
|
bfd_elf_sym_name (ibfd, symtab_hdr, sym)); |
7257 |
|
sym->st_value = 0; |
7258 |
|
sym->st_shndx = SHN_ABS; |
7259 |
|
} |
7260 |
|
symtab_hdr->contents = (unsigned char *) local_syms; |
7261 |
|
} |
7262 |
|
} |
7263 |
|
|
7264 |
|
/* Finally, adjust any global syms defined in the toc. */ |
7265 |
|
if (toc_inf.global_toc_syms) |
7266 |
|
{ |
7267 |
|
toc_inf.toc = toc; |
7268 |
|
toc_inf.skip = skip; |
7269 |
|
toc_inf.global_toc_syms = FALSE; |
7270 |
|
elf_link_hash_traverse (elf_hash_table (info), adjust_toc_syms, |
7271 |
|
&toc_inf); |
7272 |
|
} |
7273 |
|
} |
7274 |
|
|
7275 |
|
if (local_syms != NULL |
7276 |
|
&& symtab_hdr->contents != (unsigned char *) local_syms) |
7277 |
|
{ |
7278 |
|
if (!info->keep_memory) |
7279 |
|
free (local_syms); |
7280 |
|
else |
7281 |
|
symtab_hdr->contents = (unsigned char *) local_syms; |
7282 |
|
} |
7283 |
|
free (skip); |
7284 |
|
} |
7285 |
|
|
7286 |
|
return TRUE; |
7287 |
} |
} |
|
|
|
|
/* This is the condition under which ppc64_elf_finish_dynamic_symbol |
|
|
will be called from elflink.h. If elflink.h doesn't call our |
|
|
finish_dynamic_symbol routine, we'll need to do something about |
|
|
initializing any .plt and .got entries in ppc64_elf_relocate_section. */ |
|
|
#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \ |
|
|
((DYN) \ |
|
|
&& ((INFO)->shared \ |
|
|
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \ |
|
|
&& ((H)->dynindx != -1 \ |
|
|
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)) |
|
7288 |
|
|
7289 |
/* Allocate space in .plt, .got and associated reloc sections for |
/* Allocate space in .plt, .got and associated reloc sections for |
7290 |
dynamic relocs. */ |
dynamic relocs. */ |
7291 |
|
|
7292 |
static boolean |
static bfd_boolean |
7293 |
allocate_dynrelocs (h, inf) |
allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) |
|
struct elf_link_hash_entry *h; |
|
|
PTR inf; |
|
7294 |
{ |
{ |
7295 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
7296 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
7297 |
asection *s; |
asection *s; |
7298 |
struct ppc_link_hash_entry *eh; |
struct ppc_link_hash_entry *eh; |
7299 |
struct ppc_dyn_relocs *p; |
struct ppc_dyn_relocs *p; |
7300 |
|
struct got_entry *gent; |
7301 |
|
|
7302 |
if (h->root.type == bfd_link_hash_indirect) |
if (h->root.type == bfd_link_hash_indirect) |
7303 |
return true; |
return TRUE; |
7304 |
|
|
7305 |
if (h->root.type == bfd_link_hash_warning) |
if (h->root.type == bfd_link_hash_warning) |
7306 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
7309 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
7310 |
|
|
7311 |
if (htab->elf.dynamic_sections_created |
if (htab->elf.dynamic_sections_created |
7312 |
&& h->plt.refcount > 0 |
&& h->dynindx != -1 |
7313 |
&& h->dynindx != -1) |
&& WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) |
7314 |
{ |
{ |
7315 |
BFD_ASSERT (((struct ppc_link_hash_entry *) h)->is_func_descriptor); |
struct plt_entry *pent; |
7316 |
|
bfd_boolean doneone = FALSE; |
7317 |
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) |
for (pent = h->plt.plist; pent != NULL; pent = pent->next) |
7318 |
{ |
if (pent->plt.refcount > 0) |
7319 |
/* If this is the first .plt entry, make room for the special |
{ |
7320 |
first entry. */ |
/* If this is the first .plt entry, make room for the special |
7321 |
s = htab->splt; |
first entry. */ |
7322 |
if (s->_raw_size == 0) |
s = htab->plt; |
7323 |
s->_raw_size += PLT_INITIAL_ENTRY_SIZE; |
if (s->size == 0) |
7324 |
|
s->size += PLT_INITIAL_ENTRY_SIZE; |
7325 |
h->plt.offset = s->_raw_size; |
|
7326 |
|
pent->plt.offset = s->size; |
7327 |
/* Make room for this entry. */ |
|
7328 |
s->_raw_size += PLT_ENTRY_SIZE; |
/* Make room for this entry. */ |
7329 |
|
s->size += PLT_ENTRY_SIZE; |
7330 |
/* Make room for the .glink code. */ |
|
7331 |
s = htab->sglink; |
/* Make room for the .glink code. */ |
7332 |
if (s->_raw_size == 0) |
s = htab->glink; |
7333 |
s->_raw_size += GLINK_CALL_STUB_SIZE; |
if (s->size == 0) |
7334 |
/* We need bigger stubs past index 32767. */ |
s->size += GLINK_CALL_STUB_SIZE; |
7335 |
if (s->_raw_size >= GLINK_CALL_STUB_SIZE + 32768*2*4) |
/* We need bigger stubs past index 32767. */ |
7336 |
s->_raw_size += 4; |
if (s->size >= GLINK_CALL_STUB_SIZE + 32768*2*4) |
7337 |
s->_raw_size += 2*4; |
s->size += 4; |
7338 |
|
s->size += 2*4; |
7339 |
/* We also need to make an entry in the .rela.plt section. */ |
|
7340 |
s = htab->srelplt; |
/* We also need to make an entry in the .rela.plt section. */ |
7341 |
s->_raw_size += sizeof (Elf64_External_Rela); |
s = htab->relplt; |
7342 |
} |
s->size += sizeof (Elf64_External_Rela); |
7343 |
else |
doneone = TRUE; |
7344 |
|
} |
7345 |
|
else |
7346 |
|
pent->plt.offset = (bfd_vma) -1; |
7347 |
|
if (!doneone) |
7348 |
{ |
{ |
7349 |
h->plt.offset = (bfd_vma) -1; |
h->plt.plist = NULL; |
7350 |
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; |
h->needs_plt = 0; |
7351 |
} |
} |
7352 |
} |
} |
7353 |
else |
else |
7354 |
{ |
{ |
7355 |
h->plt.offset = (bfd_vma) -1; |
h->plt.plist = NULL; |
7356 |
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; |
h->needs_plt = 0; |
7357 |
} |
} |
7358 |
|
|
7359 |
if (h->got.refcount > 0) |
eh = (struct ppc_link_hash_entry *) h; |
7360 |
{ |
/* Run through the TLS GD got entries first if we're changing them |
7361 |
boolean dyn; |
to TPREL. */ |
7362 |
|
if ((eh->tls_mask & TLS_TPRELGD) != 0) |
7363 |
|
for (gent = h->got.glist; gent != NULL; gent = gent->next) |
7364 |
|
if (gent->got.refcount > 0 |
7365 |
|
&& (gent->tls_type & TLS_GD) != 0) |
7366 |
|
{ |
7367 |
|
/* This was a GD entry that has been converted to TPREL. If |
7368 |
|
there happens to be a TPREL entry we can use that one. */ |
7369 |
|
struct got_entry *ent; |
7370 |
|
for (ent = h->got.glist; ent != NULL; ent = ent->next) |
7371 |
|
if (ent->got.refcount > 0 |
7372 |
|
&& (ent->tls_type & TLS_TPREL) != 0 |
7373 |
|
&& ent->addend == gent->addend |
7374 |
|
&& ent->owner == gent->owner) |
7375 |
|
{ |
7376 |
|
gent->got.refcount = 0; |
7377 |
|
break; |
7378 |
|
} |
7379 |
|
|
7380 |
/* Make sure this symbol is output as a dynamic symbol. |
/* If not, then we'll be using our own TPREL entry. */ |
7381 |
Undefined weak syms won't yet be marked as dynamic. */ |
if (gent->got.refcount != 0) |
7382 |
if (h->dynindx == -1 |
gent->tls_type = TLS_TLS | TLS_TPREL; |
|
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) |
|
|
{ |
|
|
if (! bfd_elf64_link_record_dynamic_symbol (info, h)) |
|
|
return false; |
|
7383 |
} |
} |
7384 |
|
|
7385 |
s = htab->sgot; |
for (gent = h->got.glist; gent != NULL; gent = gent->next) |
7386 |
h->got.offset = s->_raw_size; |
if (gent->got.refcount > 0) |
7387 |
s->_raw_size += 8; |
{ |
7388 |
dyn = htab->elf.dynamic_sections_created; |
bfd_boolean dyn; |
7389 |
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)) |
|
7390 |
htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); |
/* Make sure this symbol is output as a dynamic symbol. |
7391 |
} |
Undefined weak syms won't yet be marked as dynamic, |
7392 |
else |
nor will all TLS symbols. */ |
7393 |
h->got.offset = (bfd_vma) -1; |
if (h->dynindx == -1 |
7394 |
|
&& !h->forced_local) |
7395 |
|
{ |
7396 |
|
if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
7397 |
|
return FALSE; |
7398 |
|
} |
7399 |
|
|
7400 |
|
if ((gent->tls_type & TLS_LD) != 0 |
7401 |
|
&& !h->def_dynamic) |
7402 |
|
{ |
7403 |
|
gent->got.offset = ppc64_tlsld_got (gent->owner)->offset; |
7404 |
|
continue; |
7405 |
|
} |
7406 |
|
|
7407 |
|
s = ppc64_elf_tdata (gent->owner)->got; |
7408 |
|
gent->got.offset = s->size; |
7409 |
|
s->size |
7410 |
|
+= (gent->tls_type & eh->tls_mask & (TLS_GD | TLS_LD)) ? 16 : 8; |
7411 |
|
dyn = htab->elf.dynamic_sections_created; |
7412 |
|
if ((info->shared |
7413 |
|
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)) |
7414 |
|
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT |
7415 |
|
|| h->root.type != bfd_link_hash_undefweak)) |
7416 |
|
ppc64_elf_tdata (gent->owner)->relgot->size |
7417 |
|
+= (gent->tls_type & eh->tls_mask & TLS_GD |
7418 |
|
? 2 * sizeof (Elf64_External_Rela) |
7419 |
|
: sizeof (Elf64_External_Rela)); |
7420 |
|
} |
7421 |
|
else |
7422 |
|
gent->got.offset = (bfd_vma) -1; |
7423 |
|
|
|
eh = (struct ppc_link_hash_entry *) h; |
|
7424 |
if (eh->dyn_relocs == NULL) |
if (eh->dyn_relocs == NULL) |
7425 |
return true; |
return TRUE; |
7426 |
|
|
7427 |
/* In the shared -Bsymbolic case, discard space allocated for |
/* In the shared -Bsymbolic case, discard space allocated for |
7428 |
dynamic pc-relative relocs against symbols which turn out to be |
dynamic pc-relative relocs against symbols which turn out to be |
7432 |
|
|
7433 |
if (info->shared) |
if (info->shared) |
7434 |
{ |
{ |
7435 |
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0 |
/* Relocs that use pc_count are those that appear on a call insn, |
7436 |
&& ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0 |
or certain REL relocs (see MUST_BE_DYN_RELOC) that can be |
7437 |
|| info->symbolic)) |
generated via assembly. We want calls to protected symbols to |
7438 |
|
resolve directly to the function rather than going via the plt. |
7439 |
|
If people want function pointer comparisons to work as expected |
7440 |
|
then they should avoid writing weird assembly. */ |
7441 |
|
if (SYMBOL_CALLS_LOCAL (info, h)) |
7442 |
{ |
{ |
7443 |
struct ppc_dyn_relocs **pp; |
struct ppc_dyn_relocs **pp; |
7444 |
|
|
7452 |
pp = &p->next; |
pp = &p->next; |
7453 |
} |
} |
7454 |
} |
} |
7455 |
|
|
7456 |
|
/* Also discard relocs on undefined weak syms with non-default |
7457 |
|
visibility. */ |
7458 |
|
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT |
7459 |
|
&& h->root.type == bfd_link_hash_undefweak) |
7460 |
|
eh->dyn_relocs = NULL; |
7461 |
} |
} |
7462 |
else |
else if (ELIMINATE_COPY_RELOCS) |
7463 |
{ |
{ |
7464 |
/* For the non-shared case, discard space for relocs against |
/* For the non-shared case, discard space for relocs against |
7465 |
symbols which turn out to need copy relocs or are not |
symbols which turn out to need copy relocs or are not |
7466 |
dynamic. */ |
dynamic. */ |
7467 |
|
|
7468 |
if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 |
if (!h->non_got_ref |
7469 |
&& (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 |
&& h->def_dynamic |
7470 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) |
&& !h->def_regular) |
|
|| (htab->elf.dynamic_sections_created |
|
|
&& (h->root.type == bfd_link_hash_undefweak |
|
|
|| h->root.type == bfd_link_hash_undefined)))) |
|
7471 |
{ |
{ |
7472 |
/* Make sure this symbol is output as a dynamic symbol. |
/* Make sure this symbol is output as a dynamic symbol. |
7473 |
Undefined weak syms won't yet be marked as dynamic. */ |
Undefined weak syms won't yet be marked as dynamic. */ |
7474 |
if (h->dynindx == -1 |
if (h->dynindx == -1 |
7475 |
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) |
&& !h->forced_local) |
7476 |
{ |
{ |
7477 |
if (! bfd_elf64_link_record_dynamic_symbol (info, h)) |
if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
7478 |
return false; |
return FALSE; |
7479 |
} |
} |
7480 |
|
|
7481 |
/* If that succeeded, we know we'll be keeping all the |
/* If that succeeded, we know we'll be keeping all the |
7493 |
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
7494 |
{ |
{ |
7495 |
asection *sreloc = elf_section_data (p->sec)->sreloc; |
asection *sreloc = elf_section_data (p->sec)->sreloc; |
7496 |
sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela); |
sreloc->size += p->count * sizeof (Elf64_External_Rela); |
7497 |
} |
} |
7498 |
|
|
7499 |
return true; |
return TRUE; |
7500 |
} |
} |
7501 |
|
|
7502 |
/* Find any dynamic relocs that apply to read-only sections. */ |
/* Find any dynamic relocs that apply to read-only sections. */ |
7503 |
|
|
7504 |
static boolean |
static bfd_boolean |
7505 |
readonly_dynrelocs (h, inf) |
readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf) |
|
struct elf_link_hash_entry *h; |
|
|
PTR inf; |
|
7506 |
{ |
{ |
7507 |
struct ppc_link_hash_entry *eh; |
struct ppc_link_hash_entry *eh; |
7508 |
struct ppc_dyn_relocs *p; |
struct ppc_dyn_relocs *p; |
7517 |
|
|
7518 |
if (s != NULL && (s->flags & SEC_READONLY) != 0) |
if (s != NULL && (s->flags & SEC_READONLY) != 0) |
7519 |
{ |
{ |
7520 |
struct bfd_link_info *info = (struct bfd_link_info *) inf; |
struct bfd_link_info *info = inf; |
7521 |
|
|
7522 |
info->flags |= DF_TEXTREL; |
info->flags |= DF_TEXTREL; |
7523 |
|
|
7524 |
/* Not an error, just cut short the traversal. */ |
/* Not an error, just cut short the traversal. */ |
7525 |
return false; |
return FALSE; |
7526 |
} |
} |
7527 |
} |
} |
7528 |
return true; |
return TRUE; |
7529 |
} |
} |
7530 |
|
|
7531 |
/* Set the sizes of the dynamic sections. */ |
/* Set the sizes of the dynamic sections. */ |
7532 |
|
|
7533 |
static boolean |
static bfd_boolean |
7534 |
ppc64_elf_size_dynamic_sections (output_bfd, info) |
ppc64_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, |
7535 |
bfd *output_bfd ATTRIBUTE_UNUSED; |
struct bfd_link_info *info) |
|
struct bfd_link_info *info; |
|
7536 |
{ |
{ |
7537 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
7538 |
bfd *dynobj; |
bfd *dynobj; |
7539 |
asection *s; |
asection *s; |
7540 |
boolean relocs; |
bfd_boolean relocs; |
7541 |
bfd *ibfd; |
bfd *ibfd; |
7542 |
|
|
7543 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
7548 |
if (htab->elf.dynamic_sections_created) |
if (htab->elf.dynamic_sections_created) |
7549 |
{ |
{ |
7550 |
/* Set the contents of the .interp section to the interpreter. */ |
/* Set the contents of the .interp section to the interpreter. */ |
7551 |
if (! info->shared) |
if (info->executable) |
7552 |
{ |
{ |
7553 |
s = bfd_get_section_by_name (dynobj, ".interp"); |
s = bfd_get_section_by_name (dynobj, ".interp"); |
7554 |
if (s == NULL) |
if (s == NULL) |
7555 |
abort (); |
abort (); |
7556 |
s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; |
s->size = sizeof ELF_DYNAMIC_INTERPRETER; |
7557 |
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; |
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; |
7558 |
} |
} |
7559 |
} |
} |
7562 |
relocs. */ |
relocs. */ |
7563 |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
7564 |
{ |
{ |
7565 |
bfd_signed_vma *local_got; |
struct got_entry **lgot_ents; |
7566 |
bfd_signed_vma *end_local_got; |
struct got_entry **end_lgot_ents; |
7567 |
|
char *lgot_masks; |
7568 |
bfd_size_type locsymcount; |
bfd_size_type locsymcount; |
7569 |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_hdr; |
7570 |
asection *srel; |
asection *srel; |
7571 |
|
|
7572 |
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) |
if (!is_ppc64_elf_target (ibfd->xvec)) |
7573 |
continue; |
continue; |
7574 |
|
|
7575 |
|
if (ppc64_tlsld_got (ibfd)->refcount > 0) |
7576 |
|
{ |
7577 |
|
s = ppc64_elf_tdata (ibfd)->got; |
7578 |
|
ppc64_tlsld_got (ibfd)->offset = s->size; |
7579 |
|
s->size += 16; |
7580 |
|
if (info->shared) |
7581 |
|
{ |
7582 |
|
srel = ppc64_elf_tdata (ibfd)->relgot; |
7583 |
|
srel->size += sizeof (Elf64_External_Rela); |
7584 |
|
} |
7585 |
|
} |
7586 |
|
else |
7587 |
|
ppc64_tlsld_got (ibfd)->offset = (bfd_vma) -1; |
7588 |
|
|
7589 |
for (s = ibfd->sections; s != NULL; s = s->next) |
for (s = ibfd->sections; s != NULL; s = s->next) |
7590 |
{ |
{ |
7591 |
struct ppc_dyn_relocs *p; |
struct ppc_dyn_relocs *p; |
7606 |
else if (p->count != 0) |
else if (p->count != 0) |
7607 |
{ |
{ |
7608 |
srel = elf_section_data (p->sec)->sreloc; |
srel = elf_section_data (p->sec)->sreloc; |
7609 |
srel->_raw_size += p->count * sizeof (Elf64_External_Rela); |
srel->size += p->count * sizeof (Elf64_External_Rela); |
7610 |
if ((p->sec->output_section->flags & SEC_READONLY) != 0) |
if ((p->sec->output_section->flags & SEC_READONLY) != 0) |
7611 |
info->flags |= DF_TEXTREL; |
info->flags |= DF_TEXTREL; |
7612 |
} |
} |
7613 |
} |
} |
7614 |
} |
} |
7615 |
|
|
7616 |
local_got = elf_local_got_refcounts (ibfd); |
lgot_ents = elf_local_got_ents (ibfd); |
7617 |
if (!local_got) |
if (!lgot_ents) |
7618 |
continue; |
continue; |
7619 |
|
|
7620 |
symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; |
7621 |
locsymcount = symtab_hdr->sh_info; |
locsymcount = symtab_hdr->sh_info; |
7622 |
end_local_got = local_got + locsymcount; |
end_lgot_ents = lgot_ents + locsymcount; |
7623 |
s = htab->sgot; |
lgot_masks = (char *) end_lgot_ents; |
7624 |
srel = htab->srelgot; |
s = ppc64_elf_tdata (ibfd)->got; |
7625 |
for (; local_got < end_local_got; ++local_got) |
srel = ppc64_elf_tdata (ibfd)->relgot; |
7626 |
{ |
for (; lgot_ents < end_lgot_ents; ++lgot_ents, ++lgot_masks) |
7627 |
if (*local_got > 0) |
{ |
7628 |
{ |
struct got_entry *ent; |
7629 |
*local_got = s->_raw_size; |
|
7630 |
s->_raw_size += 8; |
for (ent = *lgot_ents; ent != NULL; ent = ent->next) |
7631 |
if (info->shared) |
if (ent->got.refcount > 0) |
7632 |
srel->_raw_size += sizeof (Elf64_External_Rela); |
{ |
7633 |
} |
if ((ent->tls_type & *lgot_masks & TLS_LD) != 0) |
7634 |
else |
{ |
7635 |
*local_got = (bfd_vma) -1; |
if (ppc64_tlsld_got (ibfd)->offset == (bfd_vma) -1) |
7636 |
|
{ |
7637 |
|
ppc64_tlsld_got (ibfd)->offset = s->size; |
7638 |
|
s->size += 16; |
7639 |
|
if (info->shared) |
7640 |
|
srel->size += sizeof (Elf64_External_Rela); |
7641 |
|
} |
7642 |
|
ent->got.offset = ppc64_tlsld_got (ibfd)->offset; |
7643 |
|
} |
7644 |
|
else |
7645 |
|
{ |
7646 |
|
ent->got.offset = s->size; |
7647 |
|
if ((ent->tls_type & *lgot_masks & TLS_GD) != 0) |
7648 |
|
{ |
7649 |
|
s->size += 16; |
7650 |
|
if (info->shared) |
7651 |
|
srel->size += 2 * sizeof (Elf64_External_Rela); |
7652 |
|
} |
7653 |
|
else |
7654 |
|
{ |
7655 |
|
s->size += 8; |
7656 |
|
if (info->shared) |
7657 |
|
srel->size += sizeof (Elf64_External_Rela); |
7658 |
|
} |
7659 |
|
} |
7660 |
|
} |
7661 |
|
else |
7662 |
|
ent->got.offset = (bfd_vma) -1; |
7663 |
} |
} |
7664 |
} |
} |
7665 |
|
|
|
if (!edit_opd (output_bfd, info)) |
|
|
return false; |
|
|
|
|
7666 |
/* Allocate global sym .plt and .got entries, and space for global |
/* Allocate global sym .plt and .got entries, and space for global |
7667 |
sym dynamic relocs. */ |
sym dynamic relocs. */ |
7668 |
elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info); |
elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info); |
7669 |
|
|
7670 |
/* We now have determined the sizes of the various dynamic sections. |
/* We now have determined the sizes of the various dynamic sections. |
7671 |
Allocate memory for them. */ |
Allocate memory for them. */ |
7672 |
relocs = false; |
relocs = FALSE; |
7673 |
for (s = dynobj->sections; s != NULL; s = s->next) |
for (s = dynobj->sections; s != NULL; s = s->next) |
7674 |
{ |
{ |
7675 |
if ((s->flags & SEC_LINKER_CREATED) == 0) |
if ((s->flags & SEC_LINKER_CREATED) == 0) |
7676 |
continue; |
continue; |
7677 |
|
|
7678 |
if (s == htab->sbrlt || s == htab->srelbrlt) |
if (s == htab->brlt || s == htab->relbrlt) |
7679 |
/* These haven't been allocated yet; don't strip. */ |
/* These haven't been allocated yet; don't strip. */ |
7680 |
continue; |
continue; |
7681 |
else if (s == htab->splt |
else if (s == htab->got |
7682 |
|| s == htab->sgot |
|| s == htab->plt |
7683 |
|| s == htab->sglink) |
|| s == htab->glink) |
7684 |
{ |
{ |
7685 |
/* Strip this section if we don't need it; see the |
/* Strip this section if we don't need it; see the |
7686 |
comment below. */ |
comment below. */ |
7687 |
} |
} |
7688 |
else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) |
else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) |
7689 |
{ |
{ |
7690 |
if (s->_raw_size == 0) |
if (s->size == 0) |
7691 |
{ |
{ |
7692 |
/* If we don't need this section, strip it from the |
/* If we don't need this section, strip it from the |
7693 |
output file. This is mostly to handle .rela.bss and |
output file. This is mostly to handle .rela.bss and |
7701 |
} |
} |
7702 |
else |
else |
7703 |
{ |
{ |
7704 |
if (s != htab->srelplt) |
if (s != htab->relplt) |
7705 |
relocs = true; |
relocs = TRUE; |
7706 |
|
|
7707 |
/* We use the reloc_count field as a counter if we need |
/* We use the reloc_count field as a counter if we need |
7708 |
to copy relocs into the output file. */ |
to copy relocs into the output file. */ |
7715 |
continue; |
continue; |
7716 |
} |
} |
7717 |
|
|
7718 |
if (s->_raw_size == 0) |
if (s->size == 0) |
7719 |
{ |
{ |
7720 |
_bfd_strip_section_from_output (info, s); |
_bfd_strip_section_from_output (info, s); |
7721 |
continue; |
continue; |
7722 |
} |
} |
7723 |
|
|
7724 |
/* .plt is in the bss section. We don't initialise it. */ |
/* .plt is in the bss section. We don't initialise it. */ |
7725 |
if ((s->flags & SEC_LOAD) == 0) |
if (s == htab->plt) |
7726 |
continue; |
continue; |
7727 |
|
|
7728 |
/* Allocate memory for the section contents. We use bfd_zalloc |
/* Allocate memory for the section contents. We use bfd_zalloc |
7729 |
here in case unused entries are not reclaimed before the |
here in case unused entries are not reclaimed before the |
7730 |
section's contents are written out. This should not happen, |
section's contents are written out. This should not happen, |
7731 |
but this way if it does, we get a R_PPC64_NONE reloc instead |
but this way if it does we get a R_PPC64_NONE reloc in .rela |
7732 |
of garbage. */ |
sections instead of garbage. |
7733 |
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); |
We also rely on the section contents being zero when writing |
7734 |
|
the GOT. */ |
7735 |
|
s->contents = bfd_zalloc (dynobj, s->size); |
7736 |
if (s->contents == NULL) |
if (s->contents == NULL) |
7737 |
return false; |
return FALSE; |
7738 |
|
} |
7739 |
|
|
7740 |
|
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
7741 |
|
{ |
7742 |
|
if (!is_ppc64_elf_target (ibfd->xvec)) |
7743 |
|
continue; |
7744 |
|
|
7745 |
|
s = ppc64_elf_tdata (ibfd)->got; |
7746 |
|
if (s != NULL && s != htab->got) |
7747 |
|
{ |
7748 |
|
if (s->size == 0) |
7749 |
|
_bfd_strip_section_from_output (info, s); |
7750 |
|
else |
7751 |
|
{ |
7752 |
|
s->contents = bfd_zalloc (ibfd, s->size); |
7753 |
|
if (s->contents == NULL) |
7754 |
|
return FALSE; |
7755 |
|
} |
7756 |
|
} |
7757 |
|
s = ppc64_elf_tdata (ibfd)->relgot; |
7758 |
|
if (s != NULL) |
7759 |
|
{ |
7760 |
|
if (s->size == 0) |
7761 |
|
_bfd_strip_section_from_output (info, s); |
7762 |
|
else |
7763 |
|
{ |
7764 |
|
s->contents = bfd_zalloc (ibfd, s->size); |
7765 |
|
if (s->contents == NULL) |
7766 |
|
return FALSE; |
7767 |
|
relocs = TRUE; |
7768 |
|
s->reloc_count = 0; |
7769 |
|
} |
7770 |
|
} |
7771 |
} |
} |
7772 |
|
|
7773 |
if (htab->elf.dynamic_sections_created) |
if (htab->elf.dynamic_sections_created) |
7778 |
the .dynamic section. The DT_DEBUG entry is filled in by the |
the .dynamic section. The DT_DEBUG entry is filled in by the |
7779 |
dynamic linker and used by the debugger. */ |
dynamic linker and used by the debugger. */ |
7780 |
#define add_dynamic_entry(TAG, VAL) \ |
#define add_dynamic_entry(TAG, VAL) \ |
7781 |
bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) |
_bfd_elf_add_dynamic_entry (info, TAG, VAL) |
7782 |
|
|
7783 |
if (!info->shared) |
if (info->executable) |
7784 |
{ |
{ |
7785 |
if (!add_dynamic_entry (DT_DEBUG, 0)) |
if (!add_dynamic_entry (DT_DEBUG, 0)) |
7786 |
return false; |
return FALSE; |
7787 |
} |
} |
7788 |
|
|
7789 |
if (htab->splt != NULL && htab->splt->_raw_size != 0) |
if (htab->plt != NULL && htab->plt->size != 0) |
7790 |
{ |
{ |
7791 |
if (!add_dynamic_entry (DT_PLTGOT, 0) |
if (!add_dynamic_entry (DT_PLTGOT, 0) |
7792 |
|| !add_dynamic_entry (DT_PLTRELSZ, 0) |
|| !add_dynamic_entry (DT_PLTRELSZ, 0) |
7793 |
|| !add_dynamic_entry (DT_PLTREL, DT_RELA) |
|| !add_dynamic_entry (DT_PLTREL, DT_RELA) |
7794 |
|| !add_dynamic_entry (DT_JMPREL, 0) |
|| !add_dynamic_entry (DT_JMPREL, 0) |
7795 |
|| !add_dynamic_entry (DT_PPC64_GLINK, 0)) |
|| !add_dynamic_entry (DT_PPC64_GLINK, 0)) |
7796 |
return false; |
return FALSE; |
7797 |
} |
} |
7798 |
|
|
7799 |
if (NO_OPD_RELOCS) |
if (NO_OPD_RELOCS) |
7800 |
{ |
{ |
7801 |
if (!add_dynamic_entry (DT_PPC64_OPD, 0) |
if (!add_dynamic_entry (DT_PPC64_OPD, 0) |
7802 |
|| !add_dynamic_entry (DT_PPC64_OPDSZ, 0)) |
|| !add_dynamic_entry (DT_PPC64_OPDSZ, 0)) |
7803 |
return false; |
return FALSE; |
7804 |
} |
} |
7805 |
|
|
7806 |
if (relocs) |
if (relocs) |
7808 |
if (!add_dynamic_entry (DT_RELA, 0) |
if (!add_dynamic_entry (DT_RELA, 0) |
7809 |
|| !add_dynamic_entry (DT_RELASZ, 0) |
|| !add_dynamic_entry (DT_RELASZ, 0) |
7810 |
|| !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela))) |
|| !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela))) |
7811 |
return false; |
return FALSE; |
7812 |
|
|
7813 |
/* If any dynamic relocs apply to a read-only section, |
/* If any dynamic relocs apply to a read-only section, |
7814 |
then we need a DT_TEXTREL entry. */ |
then we need a DT_TEXTREL entry. */ |
7815 |
if ((info->flags & DF_TEXTREL) == 0) |
if ((info->flags & DF_TEXTREL) == 0) |
7816 |
elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, |
elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info); |
|
(PTR) info); |
|
7817 |
|
|
7818 |
if ((info->flags & DF_TEXTREL) != 0) |
if ((info->flags & DF_TEXTREL) != 0) |
7819 |
{ |
{ |
7820 |
if (!add_dynamic_entry (DT_TEXTREL, 0)) |
if (!add_dynamic_entry (DT_TEXTREL, 0)) |
7821 |
return false; |
return FALSE; |
7822 |
} |
} |
7823 |
} |
} |
7824 |
} |
} |
7825 |
#undef add_dynamic_entry |
#undef add_dynamic_entry |
7826 |
|
|
7827 |
return true; |
return TRUE; |
7828 |
} |
} |
7829 |
|
|
7830 |
/* Determine the type of stub needed, if any, for a call. */ |
/* Determine the type of stub needed, if any, for a call. */ |
7831 |
|
|
7832 |
static INLINE enum ppc_stub_type |
static inline enum ppc_stub_type |
7833 |
ppc_type_of_stub (input_sec, rel, hash, destination) |
ppc_type_of_stub (asection *input_sec, |
7834 |
asection *input_sec; |
const Elf_Internal_Rela *rel, |
7835 |
const Elf_Internal_Rela *rel; |
struct ppc_link_hash_entry **hash, |
7836 |
struct ppc_link_hash_entry **hash; |
bfd_vma destination) |
|
bfd_vma destination; |
|
7837 |
{ |
{ |
7838 |
struct ppc_link_hash_entry *h = *hash; |
struct ppc_link_hash_entry *h = *hash; |
7839 |
bfd_vma location; |
bfd_vma location; |
7840 |
bfd_vma branch_offset; |
bfd_vma branch_offset; |
7841 |
bfd_vma max_branch_offset; |
bfd_vma max_branch_offset; |
7842 |
unsigned int r_type; |
enum elf_ppc64_reloc_type r_type; |
7843 |
|
|
7844 |
if (h != NULL) |
if (h != NULL) |
7845 |
{ |
{ |
7846 |
if (h->oh != NULL |
if (h->oh != NULL |
7847 |
&& h->oh->plt.offset != (bfd_vma) -1 |
&& h->oh->is_func_descriptor) |
7848 |
&& h->oh->dynindx != -1) |
h = h->oh; |
7849 |
|
|
7850 |
|
if (h->elf.dynindx != -1) |
7851 |
{ |
{ |
7852 |
*hash = (struct ppc_link_hash_entry *) h->oh; |
struct plt_entry *ent; |
7853 |
return ppc_stub_plt_call; |
|
7854 |
|
for (ent = h->elf.plt.plist; ent != NULL; ent = ent->next) |
7855 |
|
if (ent->addend == rel->r_addend |
7856 |
|
&& ent->plt.offset != (bfd_vma) -1) |
7857 |
|
{ |
7858 |
|
*hash = h; |
7859 |
|
return ppc_stub_plt_call; |
7860 |
|
} |
7861 |
} |
} |
7862 |
|
|
7863 |
if (h->elf.root.type == bfd_link_hash_undefweak |
if (!(h->elf.root.type == bfd_link_hash_defined |
7864 |
|| h->elf.root.type == bfd_link_hash_undefined) |
|| h->elf.root.type == bfd_link_hash_defweak) |
7865 |
|
|| h->elf.root.u.def.section->output_section == NULL) |
7866 |
return ppc_stub_none; |
return ppc_stub_none; |
7867 |
} |
} |
7868 |
|
|
7876 |
|
|
7877 |
/* Determine if a long branch stub is needed. */ |
/* Determine if a long branch stub is needed. */ |
7878 |
max_branch_offset = 1 << 25; |
max_branch_offset = 1 << 25; |
7879 |
if (r_type != (unsigned int) R_PPC64_REL24) |
if (r_type != R_PPC64_REL24) |
7880 |
max_branch_offset = 1 << 15; |
max_branch_offset = 1 << 15; |
7881 |
|
|
7882 |
if (branch_offset + max_branch_offset >= 2 * max_branch_offset) |
if (branch_offset + max_branch_offset >= 2 * max_branch_offset) |
7889 |
|
|
7890 |
/* Build a .plt call stub. */ |
/* Build a .plt call stub. */ |
7891 |
|
|
7892 |
static bfd_byte * |
static inline bfd_byte * |
7893 |
build_plt_stub (obfd, p, offset, glink) |
build_plt_stub (bfd *obfd, bfd_byte *p, int offset) |
|
bfd *obfd; |
|
|
bfd_byte *p; |
|
|
int offset; |
|
|
int glink; |
|
7894 |
{ |
{ |
7895 |
#define PPC_LO(v) ((v) & 0xffff) |
#define PPC_LO(v) ((v) & 0xffff) |
7896 |
#define PPC_HI(v) (((v) >> 16) & 0xffff) |
#define PPC_HI(v) (((v) >> 16) & 0xffff) |
7897 |
#define PPC_HA(v) PPC_HI ((v) + 0x8000) |
#define PPC_HA(v) PPC_HI ((v) + 0x8000) |
7898 |
|
|
|
if (glink) |
|
|
bfd_put_32 (obfd, LD_R2_40R1, p), p += 4; |
|
7899 |
bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p), p += 4; |
bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p), p += 4; |
7900 |
if (!glink) |
bfd_put_32 (obfd, STD_R2_40R1, p), p += 4; |
|
bfd_put_32 (obfd, STD_R2_40R1, p), p += 4; |
|
7901 |
bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p), p += 4; |
bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p), p += 4; |
7902 |
if (PPC_HA (offset + 8) != PPC_HA (offset)) |
if (PPC_HA (offset + 8) != PPC_HA (offset)) |
7903 |
bfd_put_32 (obfd, ADDIS_R12_R12_1, p), p += 4; |
bfd_put_32 (obfd, ADDIS_R12_R12 | 1, p), p += 4; |
7904 |
offset += 8; |
offset += 8; |
7905 |
bfd_put_32 (obfd, LD_R2_0R12 | PPC_LO (offset), p), p += 4; |
bfd_put_32 (obfd, LD_R2_0R12 | PPC_LO (offset), p), p += 4; |
7906 |
if (PPC_HA (offset + 8) != PPC_HA (offset)) |
if (PPC_HA (offset + 8) != PPC_HA (offset)) |
7907 |
bfd_put_32 (obfd, ADDIS_R12_R12_1, p), p += 4; |
bfd_put_32 (obfd, ADDIS_R12_R12 | 1, p), p += 4; |
7908 |
offset += 8; |
offset += 8; |
7909 |
bfd_put_32 (obfd, MTCTR_R11, p), p += 4; |
bfd_put_32 (obfd, MTCTR_R11, p), p += 4; |
7910 |
bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p), p += 4; |
bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p), p += 4; |
7912 |
return p; |
return p; |
7913 |
} |
} |
7914 |
|
|
7915 |
static boolean |
static bfd_boolean |
7916 |
ppc_build_one_stub (gen_entry, in_arg) |
ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) |
|
struct bfd_hash_entry *gen_entry; |
|
|
PTR in_arg; |
|
7917 |
{ |
{ |
7918 |
struct ppc_stub_hash_entry *stub_entry; |
struct ppc_stub_hash_entry *stub_entry; |
7919 |
struct ppc_branch_hash_entry *br_entry; |
struct ppc_branch_hash_entry *br_entry; |
7920 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
7921 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
|
asection *stub_sec; |
|
|
bfd *stub_bfd; |
|
7922 |
bfd_byte *loc; |
bfd_byte *loc; |
7923 |
bfd_byte *p; |
bfd_byte *p; |
7924 |
unsigned int indx; |
unsigned int indx; |
7925 |
bfd_vma off; |
struct plt_entry *ent; |
7926 |
|
bfd_vma dest, off; |
7927 |
int size; |
int size; |
7928 |
|
|
7929 |
/* Massage our args to the form they really have. */ |
/* Massage our args to the form they really have. */ |
7930 |
stub_entry = (struct ppc_stub_hash_entry *) gen_entry; |
stub_entry = (struct ppc_stub_hash_entry *) gen_entry; |
7931 |
info = (struct bfd_link_info *) in_arg; |
info = in_arg; |
7932 |
|
|
7933 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
|
stub_sec = stub_entry->stub_sec; |
|
7934 |
|
|
7935 |
/* Make a note of the offset within the stubs for this entry. */ |
/* Make a note of the offset within the stubs for this entry. */ |
7936 |
stub_entry->stub_offset = stub_sec->_cooked_size; |
stub_entry->stub_offset = stub_entry->stub_sec->size; |
7937 |
loc = stub_sec->contents + stub_entry->stub_offset; |
loc = stub_entry->stub_sec->contents + stub_entry->stub_offset; |
|
|
|
|
stub_bfd = stub_sec->owner; |
|
7938 |
|
|
7939 |
|
htab->stub_count[stub_entry->stub_type - 1] += 1; |
7940 |
switch (stub_entry->stub_type) |
switch (stub_entry->stub_type) |
7941 |
{ |
{ |
7942 |
case ppc_stub_long_branch: |
case ppc_stub_long_branch: |
7943 |
|
case ppc_stub_long_branch_r2off: |
7944 |
/* Branches are relative. This is where we are going to. */ |
/* Branches are relative. This is where we are going to. */ |
7945 |
off = (stub_entry->target_value |
off = dest = (stub_entry->target_value |
7946 |
+ stub_entry->target_section->output_offset |
+ stub_entry->target_section->output_offset |
7947 |
+ stub_entry->target_section->output_section->vma); |
+ stub_entry->target_section->output_section->vma); |
7948 |
|
|
7949 |
/* And this is where we are coming from. */ |
/* And this is where we are coming from. */ |
7950 |
off -= (stub_entry->stub_offset |
off -= (stub_entry->stub_offset |
7951 |
+ stub_sec->output_offset |
+ stub_entry->stub_sec->output_offset |
7952 |
+ stub_sec->output_section->vma); |
+ stub_entry->stub_sec->output_section->vma); |
7953 |
|
|
7954 |
|
if (stub_entry->stub_type != ppc_stub_long_branch_r2off) |
7955 |
|
size = 4; |
7956 |
|
else |
7957 |
|
{ |
7958 |
|
bfd_vma r2off; |
7959 |
|
|
7960 |
|
r2off = (htab->stub_group[stub_entry->target_section->id].toc_off |
7961 |
|
- htab->stub_group[stub_entry->id_sec->id].toc_off); |
7962 |
|
bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc); |
7963 |
|
loc += 4; |
7964 |
|
bfd_put_32 (htab->stub_bfd, ADDIS_R2_R2 | PPC_HA (r2off), loc); |
7965 |
|
loc += 4; |
7966 |
|
bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc); |
7967 |
|
loc += 4; |
7968 |
|
off -= 12; |
7969 |
|
size = 16; |
7970 |
|
} |
7971 |
|
bfd_put_32 (htab->stub_bfd, B_DOT | (off & 0x3fffffc), loc); |
7972 |
|
|
7973 |
BFD_ASSERT (off + (1 << 25) < (bfd_vma) (1 << 26)); |
BFD_ASSERT (off + (1 << 25) < (bfd_vma) (1 << 26)); |
7974 |
|
|
7975 |
bfd_put_32 (stub_bfd, (bfd_vma) B_DOT | (off & 0x3fffffc), loc); |
if (info->emitrelocations) |
7976 |
size = 4; |
{ |
7977 |
|
Elf_Internal_Rela *relocs, *r; |
7978 |
|
struct bfd_elf_section_data *elfsec_data; |
7979 |
|
|
7980 |
|
elfsec_data = elf_section_data (stub_entry->stub_sec); |
7981 |
|
relocs = elfsec_data->relocs; |
7982 |
|
if (relocs == NULL) |
7983 |
|
{ |
7984 |
|
bfd_size_type relsize; |
7985 |
|
relsize = stub_entry->stub_sec->reloc_count * sizeof (*relocs); |
7986 |
|
relocs = bfd_alloc (htab->stub_bfd, relsize); |
7987 |
|
if (relocs == NULL) |
7988 |
|
return FALSE; |
7989 |
|
elfsec_data->relocs = relocs; |
7990 |
|
elfsec_data->rel_hdr.sh_size = relsize; |
7991 |
|
elfsec_data->rel_hdr.sh_entsize = 24; |
7992 |
|
stub_entry->stub_sec->reloc_count = 0; |
7993 |
|
} |
7994 |
|
r = relocs + stub_entry->stub_sec->reloc_count; |
7995 |
|
stub_entry->stub_sec->reloc_count += 1; |
7996 |
|
r->r_offset = loc - stub_entry->stub_sec->contents; |
7997 |
|
r->r_info = ELF64_R_INFO (0, R_PPC64_REL24); |
7998 |
|
r->r_addend = dest; |
7999 |
|
if (stub_entry->h != NULL) |
8000 |
|
{ |
8001 |
|
struct elf_link_hash_entry **hashes; |
8002 |
|
unsigned long symndx; |
8003 |
|
struct ppc_link_hash_entry *h; |
8004 |
|
|
8005 |
|
hashes = elf_sym_hashes (htab->stub_bfd); |
8006 |
|
if (hashes == NULL) |
8007 |
|
{ |
8008 |
|
bfd_size_type hsize; |
8009 |
|
|
8010 |
|
hsize = (htab->stub_globals + 1) * sizeof (*hashes); |
8011 |
|
hashes = bfd_zalloc (htab->stub_bfd, hsize); |
8012 |
|
if (hashes == NULL) |
8013 |
|
return FALSE; |
8014 |
|
elf_sym_hashes (htab->stub_bfd) = hashes; |
8015 |
|
htab->stub_globals = 1; |
8016 |
|
} |
8017 |
|
symndx = htab->stub_globals++; |
8018 |
|
h = stub_entry->h; |
8019 |
|
hashes[symndx] = &h->elf; |
8020 |
|
r->r_info = ELF64_R_INFO (symndx, R_PPC64_REL24); |
8021 |
|
if (h->oh != NULL && h->oh->is_func) |
8022 |
|
h = h->oh; |
8023 |
|
if (h->elf.root.u.def.section != stub_entry->target_section) |
8024 |
|
/* H is an opd symbol. The addend must be zero. */ |
8025 |
|
r->r_addend = 0; |
8026 |
|
else |
8027 |
|
{ |
8028 |
|
off = (h->elf.root.u.def.value |
8029 |
|
+ h->elf.root.u.def.section->output_offset |
8030 |
|
+ h->elf.root.u.def.section->output_section->vma); |
8031 |
|
r->r_addend -= off; |
8032 |
|
} |
8033 |
|
} |
8034 |
|
} |
8035 |
break; |
break; |
8036 |
|
|
8037 |
case ppc_stub_plt_branch: |
case ppc_stub_plt_branch: |
8038 |
|
case ppc_stub_plt_branch_r2off: |
8039 |
br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table, |
br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table, |
8040 |
stub_entry->root.string + 9, |
stub_entry->root.string + 9, |
8041 |
false, false); |
FALSE, FALSE); |
8042 |
if (br_entry == NULL) |
if (br_entry == NULL) |
8043 |
{ |
{ |
8044 |
(*_bfd_error_handler) (_("can't find branch stub `%s'"), |
(*_bfd_error_handler) (_("can't find branch stub `%s'"), |
8045 |
stub_entry->root.string + 9); |
stub_entry->root.string + 9); |
8046 |
htab->stub_error = true; |
htab->stub_error = TRUE; |
8047 |
return false; |
return FALSE; |
8048 |
} |
} |
8049 |
|
|
8050 |
off = (stub_entry->target_value |
off = (stub_entry->target_value |
8051 |
+ stub_entry->target_section->output_offset |
+ stub_entry->target_section->output_offset |
8052 |
+ stub_entry->target_section->output_section->vma); |
+ stub_entry->target_section->output_section->vma); |
8053 |
|
|
8054 |
bfd_put_64 (htab->sbrlt->owner, off, |
bfd_put_64 (htab->brlt->owner, off, |
8055 |
htab->sbrlt->contents + br_entry->offset); |
htab->brlt->contents + br_entry->offset); |
8056 |
|
|
8057 |
if (info->shared) |
if (htab->relbrlt != NULL) |
8058 |
{ |
{ |
8059 |
/* Create a reloc for the branch lookup table entry. */ |
/* Create a reloc for the branch lookup table entry. */ |
8060 |
Elf_Internal_Rela rela; |
Elf_Internal_Rela rela; |
8061 |
Elf64_External_Rela *r; |
bfd_byte *rl; |
8062 |
|
|
8063 |
rela.r_offset = (br_entry->offset |
rela.r_offset = (br_entry->offset |
8064 |
+ htab->sbrlt->output_offset |
+ htab->brlt->output_offset |
8065 |
+ htab->sbrlt->output_section->vma); |
+ htab->brlt->output_section->vma); |
8066 |
rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); |
rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); |
8067 |
rela.r_addend = off; |
rela.r_addend = off; |
8068 |
|
|
8069 |
r = (Elf64_External_Rela *) htab->srelbrlt->contents; |
rl = htab->relbrlt->contents; |
8070 |
r += htab->srelbrlt->reloc_count++; |
rl += htab->relbrlt->reloc_count++ * sizeof (Elf64_External_Rela); |
8071 |
bfd_elf64_swap_reloca_out (htab->srelbrlt->owner, &rela, r); |
bfd_elf64_swap_reloca_out (htab->relbrlt->owner, &rela, rl); |
8072 |
} |
} |
8073 |
|
|
8074 |
off = (br_entry->offset |
off = (br_entry->offset |
8075 |
+ htab->sbrlt->output_offset |
+ htab->brlt->output_offset |
8076 |
+ htab->sbrlt->output_section->vma |
+ htab->brlt->output_section->vma |
8077 |
- elf_gp (htab->sbrlt->output_section->owner) |
- elf_gp (htab->brlt->output_section->owner) |
8078 |
- TOC_BASE_OFF); |
- htab->stub_group[stub_entry->id_sec->id].toc_off); |
8079 |
|
|
8080 |
if (off + 0x80000000 > 0xffffffff || (off & 7) != 0) |
if (off + 0x80008000 > 0xffffffff || (off & 7) != 0) |
8081 |
{ |
{ |
8082 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
8083 |
(_("linkage table error against `%s'"), |
(_("linkage table error against `%s'"), |
8084 |
stub_entry->root.string); |
stub_entry->root.string); |
8085 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
8086 |
htab->stub_error = true; |
htab->stub_error = TRUE; |
8087 |
return false; |
return FALSE; |
8088 |
} |
} |
8089 |
|
|
8090 |
indx = off; |
indx = off; |
8091 |
bfd_put_32 (stub_bfd, (bfd_vma) ADDIS_R12_R2 | PPC_HA (indx), loc); |
if (stub_entry->stub_type != ppc_stub_plt_branch_r2off) |
|
bfd_put_32 (stub_bfd, (bfd_vma) LD_R11_0R12 | PPC_LO (indx), loc + 4); |
|
|
bfd_put_32 (stub_bfd, (bfd_vma) MTCTR_R11, loc + 8); |
|
|
bfd_put_32 (stub_bfd, (bfd_vma) BCTR, loc + 12); |
|
|
size = 16; |
|
|
break; |
|
|
|
|
|
case ppc_stub_plt_call: |
|
|
/* Build the .glink lazy link call stub. */ |
|
|
p = htab->sglink->contents + htab->sglink->_cooked_size; |
|
|
indx = htab->sglink->reloc_count; |
|
|
if (indx < 0x8000) |
|
8092 |
{ |
{ |
8093 |
bfd_put_32 (htab->sglink->owner, LI_R0_0 | indx, p); |
bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc); |
8094 |
p += 4; |
loc += 4; |
8095 |
|
bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc); |
8096 |
|
size = 16; |
8097 |
} |
} |
8098 |
else |
else |
8099 |
{ |
{ |
8100 |
bfd_put_32 (htab->sglink->owner, LIS_R0_0 | PPC_HI (indx), p); |
bfd_vma r2off; |
|
p += 4; |
|
|
bfd_put_32 (htab->sglink->owner, ORI_R0_R0_0 | PPC_LO (indx), p); |
|
|
p += 4; |
|
|
} |
|
|
bfd_put_32 (htab->sglink->owner, |
|
|
B_DOT | ((htab->sglink->contents - p) & 0x3fffffc), p); |
|
|
p += 4; |
|
|
htab->sglink->_cooked_size = p - htab->sglink->contents; |
|
|
htab->sglink->reloc_count += 1; |
|
8101 |
|
|
8102 |
|
r2off = (htab->stub_group[stub_entry->target_section->id].toc_off |
8103 |
|
- htab->stub_group[stub_entry->id_sec->id].toc_off); |
8104 |
|
bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc); |
8105 |
|
loc += 4; |
8106 |
|
bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc); |
8107 |
|
loc += 4; |
8108 |
|
bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc); |
8109 |
|
loc += 4; |
8110 |
|
bfd_put_32 (htab->stub_bfd, ADDIS_R2_R2 | PPC_HA (r2off), loc); |
8111 |
|
loc += 4; |
8112 |
|
bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc); |
8113 |
|
size = 28; |
8114 |
|
} |
8115 |
|
loc += 4; |
8116 |
|
bfd_put_32 (htab->stub_bfd, MTCTR_R11, loc); |
8117 |
|
loc += 4; |
8118 |
|
bfd_put_32 (htab->stub_bfd, BCTR, loc); |
8119 |
|
break; |
8120 |
|
|
8121 |
|
case ppc_stub_plt_call: |
8122 |
/* Do the best we can for shared libraries built without |
/* Do the best we can for shared libraries built without |
8123 |
exporting ".foo" for each "foo". This can happen when symbol |
exporting ".foo" for each "foo". This can happen when symbol |
8124 |
versioning scripts strip all bar a subset of symbols. */ |
versioning scripts strip all bar a subset of symbols. */ |
8125 |
if (stub_entry->h->oh->root.type != bfd_link_hash_defined |
if (stub_entry->h->oh != NULL |
8126 |
&& stub_entry->h->oh->root.type != bfd_link_hash_defweak) |
&& stub_entry->h->oh->elf.root.type != bfd_link_hash_defined |
8127 |
|
&& stub_entry->h->oh->elf.root.type != bfd_link_hash_defweak) |
8128 |
{ |
{ |
8129 |
/* Point the symbol at the stub. There may be multiple stubs, |
/* Point the symbol at the stub. There may be multiple stubs, |
8130 |
we don't really care; The main thing is to make this sym |
we don't really care; The main thing is to make this sym |
8131 |
defined somewhere. */ |
defined somewhere. Maybe defining the symbol in the stub |
8132 |
stub_entry->h->oh->root.type = bfd_link_hash_defined; |
section is a silly idea. If we didn't do this, htab->top_id |
8133 |
stub_entry->h->oh->root.u.def.section = stub_entry->stub_sec; |
could disappear. */ |
8134 |
stub_entry->h->oh->root.u.def.value = stub_entry->stub_offset; |
stub_entry->h->oh->elf.root.type = bfd_link_hash_defined; |
8135 |
|
stub_entry->h->oh->elf.root.u.def.section = stub_entry->stub_sec; |
8136 |
|
stub_entry->h->oh->elf.root.u.def.value = stub_entry->stub_offset; |
8137 |
} |
} |
8138 |
|
|
8139 |
/* Now build the stub. */ |
/* Now build the stub. */ |
8140 |
off = stub_entry->h->elf.plt.offset; |
off = (bfd_vma) -1; |
8141 |
|
for (ent = stub_entry->h->elf.plt.plist; ent != NULL; ent = ent->next) |
8142 |
|
if (ent->addend == stub_entry->addend) |
8143 |
|
{ |
8144 |
|
off = ent->plt.offset; |
8145 |
|
break; |
8146 |
|
} |
8147 |
if (off >= (bfd_vma) -2) |
if (off >= (bfd_vma) -2) |
8148 |
abort (); |
abort (); |
8149 |
|
|
8150 |
off &= ~ (bfd_vma) 1; |
off &= ~ (bfd_vma) 1; |
8151 |
off += (htab->splt->output_offset |
off += (htab->plt->output_offset |
8152 |
+ htab->splt->output_section->vma |
+ htab->plt->output_section->vma |
8153 |
- elf_gp (htab->splt->output_section->owner) |
- elf_gp (htab->plt->output_section->owner) |
8154 |
- TOC_BASE_OFF); |
- htab->stub_group[stub_entry->id_sec->id].toc_off); |
8155 |
|
|
8156 |
if (off + 0x80000000 > 0xffffffff || (off & 7) != 0) |
if (off + 0x80008000 > 0xffffffff || (off & 7) != 0) |
8157 |
{ |
{ |
8158 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
8159 |
(_("linkage table error against `%s'"), |
(_("linkage table error against `%s'"), |
8160 |
stub_entry->h->elf.root.root.string); |
stub_entry->h->elf.root.root.string); |
8161 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
8162 |
htab->stub_error = true; |
htab->stub_error = TRUE; |
8163 |
return false; |
return FALSE; |
8164 |
} |
} |
8165 |
|
|
8166 |
p = build_plt_stub (stub_bfd, loc, (int) off, 0); |
p = build_plt_stub (htab->stub_bfd, loc, off); |
8167 |
size = p - loc; |
size = p - loc; |
8168 |
break; |
break; |
8169 |
|
|
8170 |
default: |
default: |
8171 |
BFD_FAIL (); |
BFD_FAIL (); |
8172 |
return false; |
return FALSE; |
8173 |
|
} |
8174 |
|
|
8175 |
|
stub_entry->stub_sec->size += size; |
8176 |
|
|
8177 |
|
if (htab->emit_stub_syms) |
8178 |
|
{ |
8179 |
|
struct elf_link_hash_entry *h; |
8180 |
|
size_t len1, len2; |
8181 |
|
char *name; |
8182 |
|
const char *const stub_str[] = { "long_branch", |
8183 |
|
"long_branch_r2off", |
8184 |
|
"plt_branch", |
8185 |
|
"plt_branch_r2off", |
8186 |
|
"plt_call" }; |
8187 |
|
|
8188 |
|
len1 = strlen (stub_str[stub_entry->stub_type - 1]); |
8189 |
|
len2 = strlen (stub_entry->root.string); |
8190 |
|
name = bfd_malloc (len1 + len2 + 2); |
8191 |
|
if (name == NULL) |
8192 |
|
return FALSE; |
8193 |
|
memcpy (name, stub_entry->root.string, 9); |
8194 |
|
memcpy (name + 9, stub_str[stub_entry->stub_type - 1], len1); |
8195 |
|
memcpy (name + len1 + 9, stub_entry->root.string + 8, len2 - 8 + 1); |
8196 |
|
h = elf_link_hash_lookup (&htab->elf, name, TRUE, FALSE, FALSE); |
8197 |
|
if (h == NULL) |
8198 |
|
return FALSE; |
8199 |
|
if (h->root.type == bfd_link_hash_new) |
8200 |
|
{ |
8201 |
|
h->root.type = bfd_link_hash_defined; |
8202 |
|
h->root.u.def.section = stub_entry->stub_sec; |
8203 |
|
h->root.u.def.value = stub_entry->stub_offset; |
8204 |
|
h->ref_regular = 1; |
8205 |
|
h->def_regular = 1; |
8206 |
|
h->ref_regular_nonweak = 1; |
8207 |
|
h->forced_local = 1; |
8208 |
|
h->non_elf = 0; |
8209 |
|
} |
8210 |
} |
} |
8211 |
|
|
8212 |
stub_sec->_cooked_size += size; |
return TRUE; |
|
return true; |
|
8213 |
} |
} |
8214 |
|
|
8215 |
/* As above, but don't actually build the stub. Just bump offset so |
/* As above, but don't actually build the stub. Just bump offset so |
8216 |
we know stub section sizes, and select plt_branch stubs where |
we know stub section sizes, and select plt_branch stubs where |
8217 |
long_branch stubs won't do. */ |
long_branch stubs won't do. */ |
8218 |
|
|
8219 |
static boolean |
static bfd_boolean |
8220 |
ppc_size_one_stub (gen_entry, in_arg) |
ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) |
|
struct bfd_hash_entry *gen_entry; |
|
|
PTR in_arg; |
|
8221 |
{ |
{ |
8222 |
struct ppc_stub_hash_entry *stub_entry; |
struct ppc_stub_hash_entry *stub_entry; |
8223 |
|
struct bfd_link_info *info; |
8224 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
8225 |
bfd_vma off; |
bfd_vma off; |
8226 |
int size; |
int size; |
8227 |
|
|
8228 |
/* Massage our args to the form they really have. */ |
/* Massage our args to the form they really have. */ |
8229 |
stub_entry = (struct ppc_stub_hash_entry *) gen_entry; |
stub_entry = (struct ppc_stub_hash_entry *) gen_entry; |
8230 |
htab = (struct ppc_link_hash_table *) in_arg; |
info = in_arg; |
8231 |
|
|
8232 |
|
htab = ppc_hash_table (info); |
8233 |
|
|
8234 |
if (stub_entry->stub_type == ppc_stub_plt_call) |
if (stub_entry->stub_type == ppc_stub_plt_call) |
8235 |
{ |
{ |
8236 |
off = stub_entry->h->elf.plt.offset & ~(bfd_vma) 1; |
struct plt_entry *ent; |
8237 |
off += (htab->splt->output_offset |
off = (bfd_vma) -1; |
8238 |
+ htab->splt->output_section->vma |
for (ent = stub_entry->h->elf.plt.plist; ent != NULL; ent = ent->next) |
8239 |
- elf_gp (htab->splt->output_section->owner) |
if (ent->addend == stub_entry->addend) |
8240 |
- TOC_BASE_OFF); |
{ |
8241 |
|
off = ent->plt.offset & ~(bfd_vma) 1; |
8242 |
|
break; |
8243 |
|
} |
8244 |
|
if (off >= (bfd_vma) -2) |
8245 |
|
abort (); |
8246 |
|
off += (htab->plt->output_offset |
8247 |
|
+ htab->plt->output_section->vma |
8248 |
|
- elf_gp (htab->plt->output_section->owner) |
8249 |
|
- htab->stub_group[stub_entry->id_sec->id].toc_off); |
8250 |
|
|
8251 |
size = 28; |
size = PLT_CALL_STUB_SIZE; |
8252 |
if (PPC_HA ((int) off + 16) != PPC_HA ((int) off)) |
if (PPC_HA (off + 16) != PPC_HA (off)) |
8253 |
size += 4; |
size += 4; |
8254 |
} |
} |
8255 |
else |
else |
8256 |
{ |
{ |
8257 |
/* ppc_stub_long_branch or ppc_stub_plt_branch. */ |
/* ppc_stub_long_branch or ppc_stub_plt_branch, or their r2off |
8258 |
stub_entry->stub_type = ppc_stub_long_branch; |
variants. */ |
|
size = 4; |
|
|
|
|
8259 |
off = (stub_entry->target_value |
off = (stub_entry->target_value |
8260 |
+ stub_entry->target_section->output_offset |
+ stub_entry->target_section->output_offset |
8261 |
+ stub_entry->target_section->output_section->vma); |
+ stub_entry->target_section->output_section->vma); |
8262 |
off -= (stub_entry->stub_sec->_raw_size |
off -= (stub_entry->stub_sec->size |
8263 |
+ stub_entry->stub_sec->output_offset |
+ stub_entry->stub_sec->output_offset |
8264 |
+ stub_entry->stub_sec->output_section->vma); |
+ stub_entry->stub_sec->output_section->vma); |
8265 |
|
|
8266 |
|
/* Reset the stub type from the plt variant in case we now |
8267 |
|
can reach with a shorter stub. */ |
8268 |
|
if (stub_entry->stub_type >= ppc_stub_plt_branch) |
8269 |
|
stub_entry->stub_type += ppc_stub_long_branch - ppc_stub_plt_branch; |
8270 |
|
|
8271 |
|
size = 4; |
8272 |
|
if (stub_entry->stub_type == ppc_stub_long_branch_r2off) |
8273 |
|
{ |
8274 |
|
off -= 12; |
8275 |
|
size = 16; |
8276 |
|
} |
8277 |
|
|
8278 |
|
/* If the branch offset if too big, use a ppc_stub_plt_branch. */ |
8279 |
if (off + (1 << 25) >= (bfd_vma) (1 << 26)) |
if (off + (1 << 25) >= (bfd_vma) (1 << 26)) |
8280 |
{ |
{ |
8281 |
struct ppc_branch_hash_entry *br_entry; |
struct ppc_branch_hash_entry *br_entry; |
8282 |
|
|
8283 |
br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table, |
br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table, |
8284 |
stub_entry->root.string + 9, |
stub_entry->root.string + 9, |
8285 |
true, false); |
TRUE, FALSE); |
8286 |
if (br_entry == NULL) |
if (br_entry == NULL) |
8287 |
{ |
{ |
8288 |
(*_bfd_error_handler) (_("can't build branch stub `%s'"), |
(*_bfd_error_handler) (_("can't build branch stub `%s'"), |
8289 |
stub_entry->root.string + 9); |
stub_entry->root.string + 9); |
8290 |
htab->stub_error = true; |
htab->stub_error = TRUE; |
8291 |
return false; |
return FALSE; |
8292 |
} |
} |
8293 |
|
|
8294 |
if (br_entry->iter != htab->stub_iteration) |
if (br_entry->iter != htab->stub_iteration) |
8295 |
{ |
{ |
8296 |
br_entry->iter = htab->stub_iteration; |
br_entry->iter = htab->stub_iteration; |
8297 |
br_entry->offset = htab->sbrlt->_raw_size; |
br_entry->offset = htab->brlt->size; |
8298 |
htab->sbrlt->_raw_size += 8; |
htab->brlt->size += 8; |
8299 |
|
|
8300 |
|
if (htab->relbrlt != NULL) |
8301 |
|
htab->relbrlt->size += sizeof (Elf64_External_Rela); |
8302 |
} |
} |
8303 |
stub_entry->stub_type = ppc_stub_plt_branch; |
|
8304 |
|
stub_entry->stub_type += ppc_stub_plt_branch - ppc_stub_long_branch; |
8305 |
size = 16; |
size = 16; |
8306 |
|
if (stub_entry->stub_type != ppc_stub_plt_branch) |
8307 |
|
size = 28; |
8308 |
} |
} |
8309 |
|
|
8310 |
|
if (info->emitrelocations |
8311 |
|
&& (stub_entry->stub_type == ppc_stub_long_branch |
8312 |
|
|| stub_entry->stub_type == ppc_stub_long_branch_r2off)) |
8313 |
|
stub_entry->stub_sec->reloc_count += 1; |
8314 |
} |
} |
8315 |
|
|
8316 |
stub_entry->stub_sec->_raw_size += size; |
stub_entry->stub_sec->size += size; |
8317 |
return true; |
return TRUE; |
8318 |
} |
} |
8319 |
|
|
8320 |
/* Set up various things so that we can make a list of input sections |
/* Set up various things so that we can make a list of input sections |
8322 |
0 when no stubs will be needed, and 1 on success. */ |
0 when no stubs will be needed, and 1 on success. */ |
8323 |
|
|
8324 |
int |
int |
8325 |
ppc64_elf_setup_section_lists (output_bfd, info) |
ppc64_elf_setup_section_lists (bfd *output_bfd, |
8326 |
bfd *output_bfd; |
struct bfd_link_info *info, |
8327 |
struct bfd_link_info *info; |
int no_multi_toc) |
8328 |
{ |
{ |
8329 |
bfd *input_bfd; |
bfd *input_bfd; |
8330 |
int top_id, top_index; |
int top_id, top_index, id; |
8331 |
asection *section; |
asection *section; |
8332 |
asection **input_list, **list; |
asection **input_list; |
8333 |
bfd_size_type amt; |
bfd_size_type amt; |
8334 |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
8335 |
|
|
8336 |
if (htab->elf.root.creator->flavour != bfd_target_elf_flavour |
htab->no_multi_toc = no_multi_toc; |
8337 |
|| htab->sbrlt == NULL) |
|
8338 |
|
if (htab->brlt == NULL) |
8339 |
return 0; |
return 0; |
8340 |
|
|
8341 |
/* Find the top input section id. */ |
/* Find the top input section id. */ |
8342 |
for (input_bfd = info->input_bfds, top_id = 0; |
for (input_bfd = info->input_bfds, top_id = 3; |
8343 |
input_bfd != NULL; |
input_bfd != NULL; |
8344 |
input_bfd = input_bfd->link_next) |
input_bfd = input_bfd->link_next) |
8345 |
{ |
{ |
8352 |
} |
} |
8353 |
} |
} |
8354 |
|
|
8355 |
|
htab->top_id = top_id; |
8356 |
amt = sizeof (struct map_stub) * (top_id + 1); |
amt = sizeof (struct map_stub) * (top_id + 1); |
8357 |
htab->stub_group = (struct map_stub *) bfd_zmalloc (amt); |
htab->stub_group = bfd_zmalloc (amt); |
8358 |
if (htab->stub_group == NULL) |
if (htab->stub_group == NULL) |
8359 |
return -1; |
return -1; |
8360 |
|
|
8361 |
|
/* Set toc_off for com, und, abs and ind sections. */ |
8362 |
|
for (id = 0; id < 3; id++) |
8363 |
|
htab->stub_group[id].toc_off = TOC_BASE_OFF; |
8364 |
|
|
8365 |
|
elf_gp (output_bfd) = htab->toc_curr = ppc64_elf_toc (output_bfd); |
8366 |
|
|
8367 |
/* We can't use output_bfd->section_count here to find the top output |
/* We can't use output_bfd->section_count here to find the top output |
8368 |
section index as some sections may have been removed, and |
section index as some sections may have been removed, and |
8369 |
_bfd_strip_section_from_output doesn't renumber the indices. */ |
_bfd_strip_section_from_output doesn't renumber the indices. */ |
8377 |
|
|
8378 |
htab->top_index = top_index; |
htab->top_index = top_index; |
8379 |
amt = sizeof (asection *) * (top_index + 1); |
amt = sizeof (asection *) * (top_index + 1); |
8380 |
input_list = (asection **) bfd_malloc (amt); |
input_list = bfd_zmalloc (amt); |
8381 |
htab->input_list = input_list; |
htab->input_list = input_list; |
8382 |
if (input_list == NULL) |
if (input_list == NULL) |
8383 |
return -1; |
return -1; |
8384 |
|
|
8385 |
/* For sections we aren't interested in, mark their entries with a |
return 1; |
8386 |
value we can check later. */ |
} |
|
list = input_list + top_index; |
|
|
do |
|
|
*list = bfd_abs_section_ptr; |
|
|
while (list-- != input_list); |
|
8387 |
|
|
8388 |
for (section = output_bfd->sections; |
/* The linker repeatedly calls this function for each TOC input section |
8389 |
section != NULL; |
and linker generated GOT section. Group input bfds such that the toc |
8390 |
section = section->next) |
within a group is less than 64k in size. Will break with cute linker |
8391 |
|
scripts that play games with dot in the output toc section. */ |
8392 |
|
|
8393 |
|
void |
8394 |
|
ppc64_elf_next_toc_section (struct bfd_link_info *info, asection *isec) |
8395 |
|
{ |
8396 |
|
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
8397 |
|
|
8398 |
|
if (!htab->no_multi_toc) |
8399 |
{ |
{ |
8400 |
if ((section->flags & SEC_CODE) != 0) |
bfd_vma addr = isec->output_offset + isec->output_section->vma; |
8401 |
input_list[section->index] = NULL; |
bfd_vma off = addr - htab->toc_curr; |
8402 |
|
|
8403 |
|
if (off + isec->size > 0x10000) |
8404 |
|
htab->toc_curr = addr; |
8405 |
|
|
8406 |
|
elf_gp (isec->owner) = (htab->toc_curr |
8407 |
|
- elf_gp (isec->output_section->owner) |
8408 |
|
+ TOC_BASE_OFF); |
8409 |
} |
} |
8410 |
|
} |
8411 |
|
|
8412 |
return 1; |
/* Called after the last call to the above function. */ |
8413 |
|
|
8414 |
|
void |
8415 |
|
ppc64_elf_reinit_toc (bfd *output_bfd, struct bfd_link_info *info) |
8416 |
|
{ |
8417 |
|
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
8418 |
|
|
8419 |
|
htab->multi_toc_needed = htab->toc_curr != elf_gp (output_bfd); |
8420 |
|
|
8421 |
|
/* toc_curr tracks the TOC offset used for code sections below in |
8422 |
|
ppc64_elf_next_input_section. Start off at 0x8000. */ |
8423 |
|
htab->toc_curr = TOC_BASE_OFF; |
8424 |
|
} |
8425 |
|
|
8426 |
|
/* No toc references were found in ISEC. If the code in ISEC makes no |
8427 |
|
calls, then there's no need to use toc adjusting stubs when branching |
8428 |
|
into ISEC. Actually, indirect calls from ISEC are OK as they will |
8429 |
|
load r2. Returns -1 on error, 0 for no stub needed, 1 for stub |
8430 |
|
needed, and 2 if a cyclical call-graph was found but no other reason |
8431 |
|
for a stub was detected. If called from the top level, a return of |
8432 |
|
2 means the same as a return of 0. */ |
8433 |
|
|
8434 |
|
static int |
8435 |
|
toc_adjusting_stub_needed (struct bfd_link_info *info, asection *isec) |
8436 |
|
{ |
8437 |
|
Elf_Internal_Rela *relstart, *rel; |
8438 |
|
Elf_Internal_Sym *local_syms; |
8439 |
|
int ret; |
8440 |
|
struct ppc_link_hash_table *htab; |
8441 |
|
|
8442 |
|
/* We know none of our code bearing sections will need toc stubs. */ |
8443 |
|
if ((isec->flags & SEC_LINKER_CREATED) != 0) |
8444 |
|
return 0; |
8445 |
|
|
8446 |
|
if (isec->size == 0) |
8447 |
|
return 0; |
8448 |
|
|
8449 |
|
if (isec->output_section == NULL) |
8450 |
|
return 0; |
8451 |
|
|
8452 |
|
/* Hack for linux kernel. .fixup contains branches, but only back to |
8453 |
|
the function that hit an exception. */ |
8454 |
|
if (strcmp (isec->name, ".fixup") == 0) |
8455 |
|
return 0; |
8456 |
|
|
8457 |
|
if (isec->reloc_count == 0) |
8458 |
|
return 0; |
8459 |
|
|
8460 |
|
relstart = _bfd_elf_link_read_relocs (isec->owner, isec, NULL, NULL, |
8461 |
|
info->keep_memory); |
8462 |
|
if (relstart == NULL) |
8463 |
|
return -1; |
8464 |
|
|
8465 |
|
/* Look for branches to outside of this section. */ |
8466 |
|
local_syms = NULL; |
8467 |
|
ret = 0; |
8468 |
|
htab = ppc_hash_table (info); |
8469 |
|
for (rel = relstart; rel < relstart + isec->reloc_count; ++rel) |
8470 |
|
{ |
8471 |
|
enum elf_ppc64_reloc_type r_type; |
8472 |
|
unsigned long r_symndx; |
8473 |
|
struct elf_link_hash_entry *h; |
8474 |
|
Elf_Internal_Sym *sym; |
8475 |
|
asection *sym_sec; |
8476 |
|
long *opd_adjust; |
8477 |
|
bfd_vma sym_value; |
8478 |
|
bfd_vma dest; |
8479 |
|
|
8480 |
|
r_type = ELF64_R_TYPE (rel->r_info); |
8481 |
|
if (r_type != R_PPC64_REL24 |
8482 |
|
&& r_type != R_PPC64_REL14 |
8483 |
|
&& r_type != R_PPC64_REL14_BRTAKEN |
8484 |
|
&& r_type != R_PPC64_REL14_BRNTAKEN) |
8485 |
|
continue; |
8486 |
|
|
8487 |
|
r_symndx = ELF64_R_SYM (rel->r_info); |
8488 |
|
if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms, r_symndx, |
8489 |
|
isec->owner)) |
8490 |
|
{ |
8491 |
|
ret = -1; |
8492 |
|
break; |
8493 |
|
} |
8494 |
|
|
8495 |
|
/* Calls to dynamic lib functions go through a plt call stub |
8496 |
|
that uses r2. Branches to undefined symbols might be a call |
8497 |
|
using old-style dot symbols that can be satisfied by a plt |
8498 |
|
call into a new-style dynamic library. */ |
8499 |
|
if (sym_sec == NULL) |
8500 |
|
{ |
8501 |
|
struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) h; |
8502 |
|
if (eh != NULL |
8503 |
|
&& eh->oh != NULL |
8504 |
|
&& eh->oh->elf.plt.plist != NULL) |
8505 |
|
{ |
8506 |
|
ret = 1; |
8507 |
|
break; |
8508 |
|
} |
8509 |
|
|
8510 |
|
/* Ignore other undefined symbols. */ |
8511 |
|
continue; |
8512 |
|
} |
8513 |
|
|
8514 |
|
/* Assume branches to other sections not included in the link need |
8515 |
|
stubs too, to cover -R and absolute syms. */ |
8516 |
|
if (sym_sec->output_section == NULL) |
8517 |
|
{ |
8518 |
|
ret = 1; |
8519 |
|
break; |
8520 |
|
} |
8521 |
|
|
8522 |
|
if (h == NULL) |
8523 |
|
sym_value = sym->st_value; |
8524 |
|
else |
8525 |
|
{ |
8526 |
|
if (h->root.type != bfd_link_hash_defined |
8527 |
|
&& h->root.type != bfd_link_hash_defweak) |
8528 |
|
abort (); |
8529 |
|
sym_value = h->root.u.def.value; |
8530 |
|
} |
8531 |
|
sym_value += rel->r_addend; |
8532 |
|
|
8533 |
|
/* If this branch reloc uses an opd sym, find the code section. */ |
8534 |
|
opd_adjust = get_opd_info (sym_sec); |
8535 |
|
if (opd_adjust != NULL) |
8536 |
|
{ |
8537 |
|
if (h == NULL) |
8538 |
|
{ |
8539 |
|
long adjust; |
8540 |
|
|
8541 |
|
adjust = opd_adjust[sym->st_value / 8]; |
8542 |
|
if (adjust == -1) |
8543 |
|
/* Assume deleted functions won't ever be called. */ |
8544 |
|
continue; |
8545 |
|
sym_value += adjust; |
8546 |
|
} |
8547 |
|
|
8548 |
|
dest = opd_entry_value (sym_sec, sym_value, &sym_sec, NULL); |
8549 |
|
if (dest == (bfd_vma) -1) |
8550 |
|
continue; |
8551 |
|
} |
8552 |
|
else |
8553 |
|
dest = (sym_value |
8554 |
|
+ sym_sec->output_offset |
8555 |
|
+ sym_sec->output_section->vma); |
8556 |
|
|
8557 |
|
/* Ignore branch to self. */ |
8558 |
|
if (sym_sec == isec) |
8559 |
|
continue; |
8560 |
|
|
8561 |
|
/* If the called function uses the toc, we need a stub. */ |
8562 |
|
if (sym_sec->has_toc_reloc |
8563 |
|
|| sym_sec->makes_toc_func_call) |
8564 |
|
{ |
8565 |
|
ret = 1; |
8566 |
|
break; |
8567 |
|
} |
8568 |
|
|
8569 |
|
/* Assume any branch that needs a long branch stub might in fact |
8570 |
|
need a plt_branch stub. A plt_branch stub uses r2. */ |
8571 |
|
else if (dest - (isec->output_offset |
8572 |
|
+ isec->output_section->vma |
8573 |
|
+ rel->r_offset) + (1 << 25) >= (2 << 25)) |
8574 |
|
{ |
8575 |
|
ret = 1; |
8576 |
|
break; |
8577 |
|
} |
8578 |
|
|
8579 |
|
/* If calling back to a section in the process of being tested, we |
8580 |
|
can't say for sure that no toc adjusting stubs are needed, so |
8581 |
|
don't return zero. */ |
8582 |
|
else if (sym_sec->call_check_in_progress) |
8583 |
|
ret = 2; |
8584 |
|
|
8585 |
|
/* Branches to another section that itself doesn't have any TOC |
8586 |
|
references are OK. Recursively call ourselves to check. */ |
8587 |
|
else if (sym_sec->id <= htab->top_id |
8588 |
|
&& htab->stub_group[sym_sec->id].toc_off == 0) |
8589 |
|
{ |
8590 |
|
int recur; |
8591 |
|
|
8592 |
|
/* Mark current section as indeterminate, so that other |
8593 |
|
sections that call back to current won't be marked as |
8594 |
|
known. */ |
8595 |
|
isec->call_check_in_progress = 1; |
8596 |
|
recur = toc_adjusting_stub_needed (info, sym_sec); |
8597 |
|
isec->call_check_in_progress = 0; |
8598 |
|
|
8599 |
|
if (recur < 0) |
8600 |
|
{ |
8601 |
|
/* An error. Exit. */ |
8602 |
|
ret = -1; |
8603 |
|
break; |
8604 |
|
} |
8605 |
|
else if (recur <= 1) |
8606 |
|
{ |
8607 |
|
/* Known result. Mark as checked and set section flag. */ |
8608 |
|
htab->stub_group[sym_sec->id].toc_off = 1; |
8609 |
|
if (recur != 0) |
8610 |
|
{ |
8611 |
|
sym_sec->makes_toc_func_call = 1; |
8612 |
|
ret = 1; |
8613 |
|
break; |
8614 |
|
} |
8615 |
|
} |
8616 |
|
else |
8617 |
|
{ |
8618 |
|
/* Unknown result. Continue checking. */ |
8619 |
|
ret = 2; |
8620 |
|
} |
8621 |
|
} |
8622 |
|
} |
8623 |
|
|
8624 |
|
if (local_syms != NULL |
8625 |
|
&& (elf_tdata (isec->owner)->symtab_hdr.contents |
8626 |
|
!= (unsigned char *) local_syms)) |
8627 |
|
free (local_syms); |
8628 |
|
if (elf_section_data (isec)->relocs != relstart) |
8629 |
|
free (relstart); |
8630 |
|
|
8631 |
|
return ret; |
8632 |
} |
} |
8633 |
|
|
8634 |
/* The linker repeatedly calls this function for each input section, |
/* The linker repeatedly calls this function for each input section, |
8636 |
Build lists of input sections to determine groupings between which |
Build lists of input sections to determine groupings between which |
8637 |
we may insert linker stubs. */ |
we may insert linker stubs. */ |
8638 |
|
|
8639 |
void |
bfd_boolean |
8640 |
ppc64_elf_next_input_section (info, isec) |
ppc64_elf_next_input_section (struct bfd_link_info *info, asection *isec) |
|
struct bfd_link_info *info; |
|
|
asection *isec; |
|
8641 |
{ |
{ |
8642 |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
8643 |
|
|
8644 |
if (isec->output_section->index <= htab->top_index) |
if ((isec->output_section->flags & SEC_CODE) != 0 |
8645 |
|
&& isec->output_section->index <= htab->top_index) |
8646 |
{ |
{ |
8647 |
asection **list = htab->input_list + isec->output_section->index; |
asection **list = htab->input_list + isec->output_section->index; |
8648 |
if (*list != bfd_abs_section_ptr) |
/* Steal the link_sec pointer for our list. */ |
|
{ |
|
|
/* Steal the link_sec pointer for our list. */ |
|
8649 |
#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec) |
#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec) |
8650 |
/* This happens to make the list in reverse order, |
/* This happens to make the list in reverse order, |
8651 |
which is what we want. */ |
which is what we want. */ |
8652 |
PREV_SEC (isec) = *list; |
PREV_SEC (isec) = *list; |
8653 |
*list = isec; |
*list = isec; |
8654 |
|
} |
8655 |
|
|
8656 |
|
if (htab->multi_toc_needed) |
8657 |
|
{ |
8658 |
|
/* If a code section has a function that uses the TOC then we need |
8659 |
|
to use the right TOC (obviously). Also, make sure that .opd gets |
8660 |
|
the correct TOC value for R_PPC64_TOC relocs that don't have or |
8661 |
|
can't find their function symbol (shouldn't ever happen now). */ |
8662 |
|
if (isec->has_toc_reloc || (isec->flags & SEC_CODE) == 0) |
8663 |
|
{ |
8664 |
|
if (elf_gp (isec->owner) != 0) |
8665 |
|
htab->toc_curr = elf_gp (isec->owner); |
8666 |
|
} |
8667 |
|
else if (htab->stub_group[isec->id].toc_off == 0) |
8668 |
|
{ |
8669 |
|
int ret = toc_adjusting_stub_needed (info, isec); |
8670 |
|
if (ret < 0) |
8671 |
|
return FALSE; |
8672 |
|
else |
8673 |
|
isec->makes_toc_func_call = ret & 1; |
8674 |
} |
} |
8675 |
} |
} |
8676 |
|
|
8677 |
|
/* Functions that don't use the TOC can belong in any TOC group. |
8678 |
|
Use the last TOC base. This happens to make _init and _fini |
8679 |
|
pasting work. */ |
8680 |
|
htab->stub_group[isec->id].toc_off = htab->toc_curr; |
8681 |
|
return TRUE; |
8682 |
} |
} |
8683 |
|
|
8684 |
/* See whether we can group stub sections together. Grouping stub |
/* See whether we can group stub sections together. Grouping stub |
8689 |
the middle of a function is not a good idea. */ |
the middle of a function is not a good idea. */ |
8690 |
|
|
8691 |
static void |
static void |
8692 |
group_sections (htab, stub_group_size, stubs_always_before_branch) |
group_sections (struct ppc_link_hash_table *htab, |
8693 |
struct ppc_link_hash_table *htab; |
bfd_size_type stub_group_size, |
8694 |
bfd_size_type stub_group_size; |
bfd_boolean stubs_always_before_branch) |
|
boolean stubs_always_before_branch; |
|
8695 |
{ |
{ |
8696 |
asection **list = htab->input_list + htab->top_index; |
asection **list = htab->input_list + htab->top_index; |
8697 |
do |
do |
8698 |
{ |
{ |
8699 |
asection *tail = *list; |
asection *tail = *list; |
|
if (tail == bfd_abs_section_ptr) |
|
|
continue; |
|
8700 |
while (tail != NULL) |
while (tail != NULL) |
8701 |
{ |
{ |
8702 |
asection *curr; |
asection *curr; |
8703 |
asection *prev; |
asection *prev; |
8704 |
bfd_size_type total; |
bfd_size_type total; |
8705 |
|
bfd_boolean big_sec; |
8706 |
|
bfd_vma curr_toc; |
8707 |
|
|
8708 |
curr = tail; |
curr = tail; |
8709 |
if (tail->_cooked_size) |
total = tail->size; |
8710 |
total = tail->_cooked_size; |
big_sec = total >= stub_group_size; |
8711 |
else |
curr_toc = htab->stub_group[tail->id].toc_off; |
8712 |
total = tail->_raw_size; |
|
8713 |
while ((prev = PREV_SEC (curr)) != NULL |
while ((prev = PREV_SEC (curr)) != NULL |
8714 |
&& ((total += curr->output_offset - prev->output_offset) |
&& ((total += curr->output_offset - prev->output_offset) |
8715 |
< stub_group_size)) |
< stub_group_size) |
8716 |
|
&& htab->stub_group[prev->id].toc_off == curr_toc) |
8717 |
curr = prev; |
curr = prev; |
8718 |
|
|
8719 |
/* OK, the size from the start of CURR to the end is less |
/* OK, the size from the start of CURR to the end is less |
8725 |
section size. That's a little tricky, and this way will |
section size. That's a little tricky, and this way will |
8726 |
only break if stubs added make the total size more than |
only break if stubs added make the total size more than |
8727 |
2^25, ie. for the default stub_group_size, if stubs total |
2^25, ie. for the default stub_group_size, if stubs total |
8728 |
more than 2834432 bytes, or over 100000 plt call stubs. */ |
more than 2097152 bytes, or nearly 75000 plt call stubs. */ |
8729 |
do |
do |
8730 |
{ |
{ |
8731 |
prev = PREV_SEC (tail); |
prev = PREV_SEC (tail); |
8735 |
while (tail != curr && (tail = prev) != NULL); |
while (tail != curr && (tail = prev) != NULL); |
8736 |
|
|
8737 |
/* But wait, there's more! Input sections up to stub_group_size |
/* But wait, there's more! Input sections up to stub_group_size |
8738 |
bytes before the stub section can be handled by it too. */ |
bytes before the stub section can be handled by it too. |
8739 |
if (!stubs_always_before_branch) |
Don't do this if we have a really large section after the |
8740 |
|
stubs, as adding more stubs increases the chance that |
8741 |
|
branches may not reach into the stub section. */ |
8742 |
|
if (!stubs_always_before_branch && !big_sec) |
8743 |
{ |
{ |
8744 |
total = 0; |
total = 0; |
8745 |
while (prev != NULL |
while (prev != NULL |
8746 |
&& ((total += tail->output_offset - prev->output_offset) |
&& ((total += tail->output_offset - prev->output_offset) |
8747 |
< stub_group_size)) |
< stub_group_size) |
8748 |
|
&& htab->stub_group[prev->id].toc_off == curr_toc) |
8749 |
{ |
{ |
8750 |
tail = prev; |
tail = prev; |
8751 |
prev = PREV_SEC (tail); |
prev = PREV_SEC (tail); |
8766 |
PC-relative calls to a target that is unreachable with a "bl" |
PC-relative calls to a target that is unreachable with a "bl" |
8767 |
instruction. */ |
instruction. */ |
8768 |
|
|
8769 |
boolean |
bfd_boolean |
8770 |
ppc64_elf_size_stubs (output_bfd, stub_bfd, info, group_size, |
ppc64_elf_size_stubs (bfd *output_bfd, |
8771 |
add_stub_section, layout_sections_again) |
struct bfd_link_info *info, |
8772 |
bfd *output_bfd; |
bfd_signed_vma group_size, |
8773 |
bfd *stub_bfd; |
asection *(*add_stub_section) (const char *, asection *), |
8774 |
struct bfd_link_info *info; |
void (*layout_sections_again) (void)) |
|
bfd_signed_vma group_size; |
|
|
asection * (*add_stub_section) PARAMS ((const char *, asection *)); |
|
|
void (*layout_sections_again) PARAMS ((void)); |
|
8775 |
{ |
{ |
8776 |
bfd_size_type stub_group_size; |
bfd_size_type stub_group_size; |
8777 |
boolean stubs_always_before_branch; |
bfd_boolean stubs_always_before_branch; |
8778 |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
8779 |
|
|
8780 |
/* Stash our params away. */ |
/* Stash our params away. */ |
|
htab->stub_bfd = stub_bfd; |
|
8781 |
htab->add_stub_section = add_stub_section; |
htab->add_stub_section = add_stub_section; |
8782 |
htab->layout_sections_again = layout_sections_again; |
htab->layout_sections_again = layout_sections_again; |
8783 |
stubs_always_before_branch = group_size < 0; |
stubs_always_before_branch = group_size < 0; |
8788 |
if (stub_group_size == 1) |
if (stub_group_size == 1) |
8789 |
{ |
{ |
8790 |
/* Default values. */ |
/* Default values. */ |
8791 |
stub_group_size = 30720000; |
if (stubs_always_before_branch) |
8792 |
if (htab->has_14bit_branch) |
{ |
8793 |
stub_group_size = 30000; |
stub_group_size = 0x1e00000; |
8794 |
|
if (htab->has_14bit_branch) |
8795 |
|
stub_group_size = 0x7800; |
8796 |
|
} |
8797 |
|
else |
8798 |
|
{ |
8799 |
|
stub_group_size = 0x1c00000; |
8800 |
|
if (htab->has_14bit_branch) |
8801 |
|
stub_group_size = 0x7000; |
8802 |
|
} |
8803 |
} |
} |
8804 |
|
|
8805 |
group_sections (htab, stub_group_size, stubs_always_before_branch); |
group_sections (htab, stub_group_size, stubs_always_before_branch); |
8809 |
bfd *input_bfd; |
bfd *input_bfd; |
8810 |
unsigned int bfd_indx; |
unsigned int bfd_indx; |
8811 |
asection *stub_sec; |
asection *stub_sec; |
8812 |
boolean stub_changed; |
bfd_boolean stub_changed; |
8813 |
|
|
8814 |
htab->stub_iteration += 1; |
htab->stub_iteration += 1; |
8815 |
stub_changed = false; |
stub_changed = FALSE; |
8816 |
|
|
8817 |
for (input_bfd = info->input_bfds, bfd_indx = 0; |
for (input_bfd = info->input_bfds, bfd_indx = 0; |
8818 |
input_bfd != NULL; |
input_bfd != NULL; |
8848 |
|
|
8849 |
/* Get the relocs. */ |
/* Get the relocs. */ |
8850 |
internal_relocs |
internal_relocs |
8851 |
= _bfd_elf64_link_read_relocs (input_bfd, section, NULL, |
= _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL, |
8852 |
(Elf_Internal_Rela *) NULL, |
info->keep_memory); |
|
info->keep_memory); |
|
8853 |
if (internal_relocs == NULL) |
if (internal_relocs == NULL) |
8854 |
goto error_ret_free_local; |
goto error_ret_free_local; |
8855 |
|
|
8858 |
irelaend = irela + section->reloc_count; |
irelaend = irela + section->reloc_count; |
8859 |
for (; irela < irelaend; irela++) |
for (; irela < irelaend; irela++) |
8860 |
{ |
{ |
8861 |
unsigned int r_type, r_indx; |
enum elf_ppc64_reloc_type r_type; |
8862 |
|
unsigned int r_indx; |
8863 |
enum ppc_stub_type stub_type; |
enum ppc_stub_type stub_type; |
8864 |
struct ppc_stub_hash_entry *stub_entry; |
struct ppc_stub_hash_entry *stub_entry; |
8865 |
asection *sym_sec; |
asection *sym_sec, *code_sec; |
8866 |
bfd_vma sym_value; |
bfd_vma sym_value; |
8867 |
bfd_vma destination; |
bfd_vma destination; |
8868 |
|
bfd_boolean ok_dest; |
8869 |
struct ppc_link_hash_entry *hash; |
struct ppc_link_hash_entry *hash; |
8870 |
|
struct ppc_link_hash_entry *fdh; |
8871 |
|
struct elf_link_hash_entry *h; |
8872 |
|
Elf_Internal_Sym *sym; |
8873 |
char *stub_name; |
char *stub_name; |
8874 |
const asection *id_sec; |
const asection *id_sec; |
8875 |
|
long *opd_adjust; |
8876 |
|
|
8877 |
r_type = ELF64_R_TYPE (irela->r_info); |
r_type = ELF64_R_TYPE (irela->r_info); |
8878 |
r_indx = ELF64_R_SYM (irela->r_info); |
r_indx = ELF64_R_SYM (irela->r_info); |
8879 |
|
|
8880 |
if (r_type >= (unsigned int) R_PPC_max) |
if (r_type >= R_PPC64_max) |
8881 |
{ |
{ |
8882 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
8883 |
goto error_ret_free_internal; |
goto error_ret_free_internal; |
8884 |
} |
} |
8885 |
|
|
8886 |
/* Only look for stubs on branch instructions. */ |
/* Only look for stubs on branch instructions. */ |
8887 |
if (r_type != (unsigned int) R_PPC64_REL24 |
if (r_type != R_PPC64_REL24 |
8888 |
&& r_type != (unsigned int) R_PPC64_REL14 |
&& r_type != R_PPC64_REL14 |
8889 |
&& r_type != (unsigned int) R_PPC64_REL14_BRTAKEN |
&& r_type != R_PPC64_REL14_BRTAKEN |
8890 |
&& r_type != (unsigned int) R_PPC64_REL14_BRNTAKEN) |
&& r_type != R_PPC64_REL14_BRNTAKEN) |
8891 |
continue; |
continue; |
8892 |
|
|
8893 |
/* Now determine the call target, its name, value, |
/* Now determine the call target, its name, value, |
8894 |
section. */ |
section. */ |
8895 |
sym_sec = NULL; |
if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms, |
8896 |
sym_value = 0; |
r_indx, input_bfd)) |
8897 |
destination = 0; |
goto error_ret_free_internal; |
8898 |
hash = NULL; |
hash = (struct ppc_link_hash_entry *) h; |
|
if (r_indx < symtab_hdr->sh_info) |
|
|
{ |
|
|
/* It's a local symbol. */ |
|
|
Elf_Internal_Sym *sym; |
|
|
Elf_Internal_Shdr *hdr; |
|
8899 |
|
|
8900 |
if (local_syms == NULL) |
ok_dest = FALSE; |
8901 |
{ |
fdh = NULL; |
8902 |
local_syms |
if (hash == NULL) |
8903 |
= (Elf_Internal_Sym *) symtab_hdr->contents; |
{ |
8904 |
if (local_syms == NULL) |
sym_value = sym->st_value; |
8905 |
local_syms |
ok_dest = TRUE; |
|
= bfd_elf_get_elf_syms (input_bfd, symtab_hdr, |
|
|
symtab_hdr->sh_info, 0, |
|
|
NULL, NULL, NULL); |
|
|
if (local_syms == NULL) |
|
|
goto error_ret_free_internal; |
|
|
} |
|
|
sym = local_syms + r_indx; |
|
|
hdr = elf_elfsections (input_bfd)[sym->st_shndx]; |
|
|
sym_sec = hdr->bfd_section; |
|
|
if (ELF_ST_TYPE (sym->st_info) != STT_SECTION) |
|
|
sym_value = sym->st_value; |
|
|
destination = (sym_value + irela->r_addend |
|
|
+ sym_sec->output_offset |
|
|
+ sym_sec->output_section->vma); |
|
8906 |
} |
} |
8907 |
else |
else |
8908 |
{ |
{ |
8909 |
/* It's an external symbol. */ |
sym_value = 0; |
8910 |
int e_indx; |
/* Recognise an old ABI func code entry sym, and |
8911 |
|
use the func descriptor sym instead. */ |
8912 |
e_indx = r_indx - symtab_hdr->sh_info; |
if (hash->elf.root.root.string[0] == '.' |
8913 |
hash = ((struct ppc_link_hash_entry *) |
&& (fdh = get_fdh (hash, htab)) != NULL) |
8914 |
elf_sym_hashes (input_bfd)[e_indx]); |
{ |
8915 |
|
if (fdh->elf.root.type == bfd_link_hash_defined |
8916 |
while (hash->elf.root.type == bfd_link_hash_indirect |
|| fdh->elf.root.type == bfd_link_hash_defweak) |
8917 |
|| hash->elf.root.type == bfd_link_hash_warning) |
{ |
8918 |
hash = ((struct ppc_link_hash_entry *) |
sym_sec = fdh->elf.root.u.def.section; |
8919 |
hash->elf.root.u.i.link); |
sym_value = fdh->elf.root.u.def.value; |
8920 |
|
if (sym_sec->output_section != NULL) |
8921 |
if (hash->elf.root.type == bfd_link_hash_defined |
ok_dest = TRUE; |
8922 |
|| hash->elf.root.type == bfd_link_hash_defweak) |
} |
8923 |
|
else |
8924 |
|
fdh = NULL; |
8925 |
|
} |
8926 |
|
else if (hash->elf.root.type == bfd_link_hash_defined |
8927 |
|
|| hash->elf.root.type == bfd_link_hash_defweak) |
8928 |
{ |
{ |
|
sym_sec = hash->elf.root.u.def.section; |
|
8929 |
sym_value = hash->elf.root.u.def.value; |
sym_value = hash->elf.root.u.def.value; |
8930 |
if (sym_sec->output_section != NULL) |
if (sym_sec->output_section != NULL) |
8931 |
destination = (sym_value + irela->r_addend |
ok_dest = TRUE; |
|
+ sym_sec->output_offset |
|
|
+ sym_sec->output_section->vma); |
|
8932 |
} |
} |
8933 |
else if (hash->elf.root.type == bfd_link_hash_undefweak) |
else if (hash->elf.root.type == bfd_link_hash_undefweak) |
8934 |
; |
; |
8941 |
} |
} |
8942 |
} |
} |
8943 |
|
|
8944 |
|
destination = 0; |
8945 |
|
if (ok_dest) |
8946 |
|
{ |
8947 |
|
sym_value += irela->r_addend; |
8948 |
|
destination = (sym_value |
8949 |
|
+ sym_sec->output_offset |
8950 |
|
+ sym_sec->output_section->vma); |
8951 |
|
} |
8952 |
|
|
8953 |
|
code_sec = sym_sec; |
8954 |
|
opd_adjust = get_opd_info (sym_sec); |
8955 |
|
if (opd_adjust != NULL) |
8956 |
|
{ |
8957 |
|
bfd_vma dest; |
8958 |
|
|
8959 |
|
if (hash == NULL) |
8960 |
|
{ |
8961 |
|
long adjust = opd_adjust[sym_value / 8]; |
8962 |
|
if (adjust == -1) |
8963 |
|
continue; |
8964 |
|
sym_value += adjust; |
8965 |
|
} |
8966 |
|
dest = opd_entry_value (sym_sec, sym_value, |
8967 |
|
&code_sec, &sym_value); |
8968 |
|
if (dest != (bfd_vma) -1) |
8969 |
|
{ |
8970 |
|
destination = dest; |
8971 |
|
if (fdh != NULL) |
8972 |
|
{ |
8973 |
|
/* Fixup old ABI sym to point at code |
8974 |
|
entry. */ |
8975 |
|
hash->elf.root.type = bfd_link_hash_defweak; |
8976 |
|
hash->elf.root.u.def.section = code_sec; |
8977 |
|
hash->elf.root.u.def.value = sym_value; |
8978 |
|
} |
8979 |
|
} |
8980 |
|
} |
8981 |
|
|
8982 |
/* Determine what (if any) linker stub is needed. */ |
/* Determine what (if any) linker stub is needed. */ |
8983 |
stub_type = ppc_type_of_stub (section, irela, &hash, |
stub_type = ppc_type_of_stub (section, irela, &hash, |
8984 |
destination); |
destination); |
8985 |
|
|
8986 |
|
if (stub_type != ppc_stub_plt_call) |
8987 |
|
{ |
8988 |
|
/* Check whether we need a TOC adjusting stub. |
8989 |
|
Since the linker pastes together pieces from |
8990 |
|
different object files when creating the |
8991 |
|
_init and _fini functions, it may be that a |
8992 |
|
call to what looks like a local sym is in |
8993 |
|
fact a call needing a TOC adjustment. */ |
8994 |
|
if (code_sec != NULL |
8995 |
|
&& code_sec->output_section != NULL |
8996 |
|
&& (htab->stub_group[code_sec->id].toc_off |
8997 |
|
!= htab->stub_group[section->id].toc_off) |
8998 |
|
&& (code_sec->has_toc_reloc |
8999 |
|
|| code_sec->makes_toc_func_call)) |
9000 |
|
stub_type = ppc_stub_long_branch_r2off; |
9001 |
|
} |
9002 |
|
|
9003 |
if (stub_type == ppc_stub_none) |
if (stub_type == ppc_stub_none) |
9004 |
continue; |
continue; |
9005 |
|
|
9006 |
|
/* __tls_get_addr calls might be eliminated. */ |
9007 |
|
if (stub_type != ppc_stub_plt_call |
9008 |
|
&& hash != NULL |
9009 |
|
&& (hash == htab->tls_get_addr |
9010 |
|
|| hash == htab->tls_get_addr_fd) |
9011 |
|
&& section->has_tls_reloc |
9012 |
|
&& irela != internal_relocs) |
9013 |
|
{ |
9014 |
|
/* Get tls info. */ |
9015 |
|
char *tls_mask; |
9016 |
|
|
9017 |
|
if (!get_tls_mask (&tls_mask, NULL, &local_syms, |
9018 |
|
irela - 1, input_bfd)) |
9019 |
|
goto error_ret_free_internal; |
9020 |
|
if (*tls_mask != 0) |
9021 |
|
continue; |
9022 |
|
} |
9023 |
|
|
9024 |
/* Support for grouping stub sections. */ |
/* Support for grouping stub sections. */ |
9025 |
id_sec = htab->stub_group[section->id].link_sec; |
id_sec = htab->stub_group[section->id].link_sec; |
9026 |
|
|
9030 |
goto error_ret_free_internal; |
goto error_ret_free_internal; |
9031 |
|
|
9032 |
stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, |
stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, |
9033 |
stub_name, false, false); |
stub_name, FALSE, FALSE); |
9034 |
if (stub_entry != NULL) |
if (stub_entry != NULL) |
9035 |
{ |
{ |
9036 |
/* The proper stub has already been created. */ |
/* The proper stub has already been created. */ |
9050 |
&& (symtab_hdr->contents |
&& (symtab_hdr->contents |
9051 |
!= (unsigned char *) local_syms)) |
!= (unsigned char *) local_syms)) |
9052 |
free (local_syms); |
free (local_syms); |
9053 |
return false; |
return FALSE; |
9054 |
} |
} |
9055 |
|
|
|
stub_entry->target_value = sym_value; |
|
|
stub_entry->target_section = sym_sec; |
|
9056 |
stub_entry->stub_type = stub_type; |
stub_entry->stub_type = stub_type; |
9057 |
|
stub_entry->target_value = sym_value; |
9058 |
|
stub_entry->target_section = code_sec; |
9059 |
stub_entry->h = hash; |
stub_entry->h = hash; |
9060 |
stub_changed = true; |
stub_entry->addend = irela->r_addend; |
9061 |
|
|
9062 |
|
if (stub_entry->h != NULL) |
9063 |
|
htab->stub_globals += 1; |
9064 |
|
|
9065 |
|
stub_changed = TRUE; |
9066 |
} |
} |
9067 |
|
|
9068 |
/* We're done with the internal relocs, free them. */ |
/* We're done with the internal relocs, free them. */ |
9088 |
for (stub_sec = htab->stub_bfd->sections; |
for (stub_sec = htab->stub_bfd->sections; |
9089 |
stub_sec != NULL; |
stub_sec != NULL; |
9090 |
stub_sec = stub_sec->next) |
stub_sec = stub_sec->next) |
9091 |
{ |
if ((stub_sec->flags & SEC_LINKER_CREATED) == 0) |
9092 |
stub_sec->_raw_size = 0; |
{ |
9093 |
stub_sec->_cooked_size = 0; |
stub_sec->size = 0; |
9094 |
} |
stub_sec->reloc_count = 0; |
9095 |
htab->sbrlt->_raw_size = 0; |
} |
9096 |
htab->sbrlt->_cooked_size = 0; |
|
9097 |
|
htab->brlt->size = 0; |
9098 |
|
if (htab->relbrlt != NULL) |
9099 |
|
htab->relbrlt->size = 0; |
9100 |
|
|
9101 |
bfd_hash_traverse (&htab->stub_hash_table, ppc_size_one_stub, htab); |
bfd_hash_traverse (&htab->stub_hash_table, ppc_size_one_stub, info); |
9102 |
|
|
9103 |
/* Ask the linker to do its stuff. */ |
/* Ask the linker to do its stuff. */ |
9104 |
(*htab->layout_sections_again) (); |
(*htab->layout_sections_again) (); |
9109 |
the dynamic symbol table is corrupted since the section symbol |
the dynamic symbol table is corrupted since the section symbol |
9110 |
for the stripped section isn't written. */ |
for the stripped section isn't written. */ |
9111 |
|
|
9112 |
return true; |
return TRUE; |
9113 |
} |
} |
9114 |
|
|
9115 |
/* Called after we have determined section placement. If sections |
/* Called after we have determined section placement. If sections |
9116 |
move, we'll be called again. Provide a value for TOCstart. */ |
move, we'll be called again. Provide a value for TOCstart. */ |
9117 |
|
|
9118 |
bfd_vma |
bfd_vma |
9119 |
ppc64_elf_toc (obfd) |
ppc64_elf_toc (bfd *obfd) |
|
bfd *obfd; |
|
9120 |
{ |
{ |
9121 |
asection *s; |
asection *s; |
9122 |
bfd_vma TOCstart; |
bfd_vma TOCstart; |
9172 |
The stubs are kept in a hash table attached to the main linker |
The stubs are kept in a hash table attached to the main linker |
9173 |
hash table. This function is called via gldelf64ppc_finish. */ |
hash table. This function is called via gldelf64ppc_finish. */ |
9174 |
|
|
9175 |
boolean |
bfd_boolean |
9176 |
ppc64_elf_build_stubs (info) |
ppc64_elf_build_stubs (bfd_boolean emit_stub_syms, |
9177 |
struct bfd_link_info *info; |
struct bfd_link_info *info, |
9178 |
|
char **stats) |
9179 |
{ |
{ |
9180 |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
9181 |
asection *stub_sec; |
asection *stub_sec; |
|
bfd_vma plt_r2; |
|
9182 |
bfd_byte *p; |
bfd_byte *p; |
9183 |
|
int stub_sec_count = 0; |
9184 |
|
|
9185 |
|
htab->emit_stub_syms = emit_stub_syms; |
9186 |
|
|
9187 |
|
/* Allocate memory to hold the linker stubs. */ |
9188 |
for (stub_sec = htab->stub_bfd->sections; |
for (stub_sec = htab->stub_bfd->sections; |
9189 |
stub_sec != NULL; |
stub_sec != NULL; |
9190 |
stub_sec = stub_sec->next) |
stub_sec = stub_sec->next) |
9191 |
|
if ((stub_sec->flags & SEC_LINKER_CREATED) == 0 |
9192 |
|
&& stub_sec->size != 0) |
9193 |
|
{ |
9194 |
|
stub_sec->contents = bfd_zalloc (htab->stub_bfd, stub_sec->size); |
9195 |
|
if (stub_sec->contents == NULL) |
9196 |
|
return FALSE; |
9197 |
|
/* We want to check that built size is the same as calculated |
9198 |
|
size. rawsize is a convenient location to use. */ |
9199 |
|
stub_sec->rawsize = stub_sec->size; |
9200 |
|
stub_sec->size = 0; |
9201 |
|
} |
9202 |
|
|
9203 |
|
if (htab->plt != NULL) |
9204 |
{ |
{ |
9205 |
bfd_size_type size; |
unsigned int indx; |
9206 |
|
bfd_vma plt0; |
9207 |
|
|
9208 |
/* Allocate memory to hold the linker stubs. */ |
/* Build the .glink plt call stub. */ |
9209 |
size = stub_sec->_raw_size; |
plt0 = (htab->plt->output_section->vma |
9210 |
if (size != 0) |
+ htab->plt->output_offset |
9211 |
|
- (htab->glink->output_section->vma |
9212 |
|
+ htab->glink->output_offset |
9213 |
|
+ GLINK_CALL_STUB_SIZE)); |
9214 |
|
if (plt0 + 0x80008000 > 0xffffffff) |
9215 |
{ |
{ |
9216 |
stub_sec->contents = (bfd_byte *) bfd_zalloc (htab->stub_bfd, size); |
(*_bfd_error_handler) (_(".glink and .plt too far apart")); |
9217 |
if (stub_sec->contents == NULL) |
bfd_set_error (bfd_error_bad_value); |
9218 |
return false; |
return FALSE; |
9219 |
} |
} |
|
stub_sec->_cooked_size = 0; |
|
|
} |
|
9220 |
|
|
9221 |
if (htab->splt != NULL) |
if (htab->emit_stub_syms) |
|
{ |
|
|
/* Build the .glink plt call stub. */ |
|
|
plt_r2 = (htab->splt->output_offset |
|
|
+ htab->splt->output_section->vma |
|
|
- elf_gp (htab->splt->output_section->owner) |
|
|
- TOC_BASE_OFF); |
|
|
p = htab->sglink->contents; |
|
|
p = build_plt_stub (htab->sglink->owner, p, (int) plt_r2, 1); |
|
|
while (p - htab->sglink->contents < GLINK_CALL_STUB_SIZE) |
|
9222 |
{ |
{ |
9223 |
bfd_put_32 (htab->sglink->owner, NOP, p); |
struct elf_link_hash_entry *h; |
9224 |
p += 4; |
h = elf_link_hash_lookup (&htab->elf, "__glink", TRUE, FALSE, FALSE); |
9225 |
|
if (h == NULL) |
9226 |
|
return FALSE; |
9227 |
|
if (h->root.type == bfd_link_hash_new) |
9228 |
|
{ |
9229 |
|
h->root.type = bfd_link_hash_defined; |
9230 |
|
h->root.u.def.section = htab->glink; |
9231 |
|
h->root.u.def.value = 0; |
9232 |
|
h->ref_regular = 1; |
9233 |
|
h->def_regular = 1; |
9234 |
|
h->ref_regular_nonweak = 1; |
9235 |
|
h->forced_local = 1; |
9236 |
|
h->non_elf = 0; |
9237 |
|
} |
9238 |
} |
} |
9239 |
htab->sglink->_cooked_size = p - htab->sglink->contents; |
p = htab->glink->contents; |
9240 |
|
bfd_put_32 (htab->glink->owner, MFCTR_R12, p); |
9241 |
|
p += 4; |
9242 |
|
bfd_put_32 (htab->glink->owner, SLDI_R11_R0_3, p); |
9243 |
|
p += 4; |
9244 |
|
bfd_put_32 (htab->glink->owner, ADDIC_R2_R0_32K, p); |
9245 |
|
p += 4; |
9246 |
|
bfd_put_32 (htab->glink->owner, SUB_R12_R12_R11, p); |
9247 |
|
p += 4; |
9248 |
|
bfd_put_32 (htab->glink->owner, SRADI_R2_R2_63, p); |
9249 |
|
p += 4; |
9250 |
|
bfd_put_32 (htab->glink->owner, SLDI_R11_R0_2, p); |
9251 |
|
p += 4; |
9252 |
|
bfd_put_32 (htab->glink->owner, AND_R2_R2_R11, p); |
9253 |
|
p += 4; |
9254 |
|
bfd_put_32 (htab->glink->owner, SUB_R12_R12_R11, p); |
9255 |
|
p += 4; |
9256 |
|
bfd_put_32 (htab->glink->owner, ADD_R12_R12_R2, p); |
9257 |
|
p += 4; |
9258 |
|
bfd_put_32 (htab->glink->owner, ADDIS_R12_R12 | PPC_HA (plt0), p); |
9259 |
|
p += 4; |
9260 |
|
bfd_put_32 (htab->glink->owner, LD_R11_0R12 | PPC_LO (plt0), p); |
9261 |
|
p += 4; |
9262 |
|
bfd_put_32 (htab->glink->owner, ADDI_R12_R12 | PPC_LO (plt0), p); |
9263 |
|
p += 4; |
9264 |
|
bfd_put_32 (htab->glink->owner, LD_R2_0R12 | 8, p); |
9265 |
|
p += 4; |
9266 |
|
bfd_put_32 (htab->glink->owner, MTCTR_R11, p); |
9267 |
|
p += 4; |
9268 |
|
bfd_put_32 (htab->glink->owner, LD_R11_0R12 | 16, p); |
9269 |
|
p += 4; |
9270 |
|
bfd_put_32 (htab->glink->owner, BCTR, p); |
9271 |
|
p += 4; |
9272 |
|
|
9273 |
/* Use reloc_count to count entries. */ |
/* Build the .glink lazy link call stubs. */ |
9274 |
htab->sglink->reloc_count = 0; |
indx = 0; |
9275 |
|
while (p < htab->glink->contents + htab->glink->size) |
9276 |
|
{ |
9277 |
|
if (indx < 0x8000) |
9278 |
|
{ |
9279 |
|
bfd_put_32 (htab->glink->owner, LI_R0_0 | indx, p); |
9280 |
|
p += 4; |
9281 |
|
} |
9282 |
|
else |
9283 |
|
{ |
9284 |
|
bfd_put_32 (htab->glink->owner, LIS_R0_0 | PPC_HI (indx), p); |
9285 |
|
p += 4; |
9286 |
|
bfd_put_32 (htab->glink->owner, ORI_R0_R0_0 | PPC_LO (indx), p); |
9287 |
|
p += 4; |
9288 |
|
} |
9289 |
|
bfd_put_32 (htab->glink->owner, |
9290 |
|
B_DOT | ((htab->glink->contents - p) & 0x3fffffc), p); |
9291 |
|
indx++; |
9292 |
|
p += 4; |
9293 |
|
} |
9294 |
|
htab->glink->rawsize = p - htab->glink->contents; |
9295 |
} |
} |
9296 |
|
|
9297 |
if (htab->sbrlt->_raw_size != 0) |
if (htab->brlt->size != 0) |
9298 |
|
{ |
9299 |
|
htab->brlt->contents = bfd_zalloc (htab->brlt->owner, |
9300 |
|
htab->brlt->size); |
9301 |
|
if (htab->brlt->contents == NULL) |
9302 |
|
return FALSE; |
9303 |
|
} |
9304 |
|
if (htab->relbrlt != NULL && htab->relbrlt->size != 0) |
9305 |
{ |
{ |
9306 |
htab->sbrlt->contents = (bfd_byte *) bfd_zalloc (htab->sbrlt->owner, |
htab->relbrlt->contents = bfd_zalloc (htab->relbrlt->owner, |
9307 |
htab->sbrlt->_raw_size); |
htab->relbrlt->size); |
9308 |
if (htab->sbrlt->contents == NULL) |
if (htab->relbrlt->contents == NULL) |
9309 |
return false; |
return FALSE; |
9310 |
} |
} |
9311 |
|
|
9312 |
/* Build the stubs as directed by the stub hash table. */ |
/* Build the stubs as directed by the stub hash table. */ |
9313 |
bfd_hash_traverse (&htab->stub_hash_table, ppc_build_one_stub, info); |
bfd_hash_traverse (&htab->stub_hash_table, ppc_build_one_stub, info); |
|
htab->sglink->reloc_count = 0; |
|
9314 |
|
|
9315 |
for (stub_sec = htab->stub_bfd->sections; |
for (stub_sec = htab->stub_bfd->sections; |
9316 |
stub_sec != NULL; |
stub_sec != NULL; |
9317 |
stub_sec = stub_sec->next) |
stub_sec = stub_sec->next) |
9318 |
{ |
if ((stub_sec->flags & SEC_LINKER_CREATED) == 0) |
9319 |
if (stub_sec->_raw_size != stub_sec->_cooked_size) |
{ |
9320 |
break; |
stub_sec_count += 1; |
9321 |
} |
if (stub_sec->rawsize != stub_sec->size) |
9322 |
|
break; |
9323 |
|
} |
9324 |
|
|
9325 |
if (stub_sec != NULL |
if (stub_sec != NULL |
9326 |
|| htab->sglink->_raw_size != htab->sglink->_cooked_size) |
|| htab->glink->rawsize != htab->glink->size) |
9327 |
{ |
{ |
9328 |
htab->stub_error = true; |
htab->stub_error = TRUE; |
9329 |
(*_bfd_error_handler) (_("stubs don't match calculated size")); |
(*_bfd_error_handler) (_("stubs don't match calculated size")); |
9330 |
} |
} |
9331 |
|
|
9332 |
return !htab->stub_error; |
if (htab->stub_error) |
9333 |
|
return FALSE; |
9334 |
|
|
9335 |
|
if (stats != NULL) |
9336 |
|
{ |
9337 |
|
*stats = bfd_malloc (500); |
9338 |
|
if (*stats == NULL) |
9339 |
|
return FALSE; |
9340 |
|
|
9341 |
|
sprintf (*stats, _("linker stubs in %u group%s\n" |
9342 |
|
" branch %lu\n" |
9343 |
|
" toc adjust %lu\n" |
9344 |
|
" long branch %lu\n" |
9345 |
|
" long toc adj %lu\n" |
9346 |
|
" plt call %lu"), |
9347 |
|
stub_sec_count, |
9348 |
|
stub_sec_count == 1 ? "" : "s", |
9349 |
|
htab->stub_count[ppc_stub_long_branch - 1], |
9350 |
|
htab->stub_count[ppc_stub_long_branch_r2off - 1], |
9351 |
|
htab->stub_count[ppc_stub_plt_branch - 1], |
9352 |
|
htab->stub_count[ppc_stub_plt_branch_r2off - 1], |
9353 |
|
htab->stub_count[ppc_stub_plt_call - 1]); |
9354 |
|
} |
9355 |
|
return TRUE; |
9356 |
|
} |
9357 |
|
|
9358 |
|
/* This function undoes the changes made by add_symbol_adjust. */ |
9359 |
|
|
9360 |
|
static bfd_boolean |
9361 |
|
undo_symbol_twiddle (struct elf_link_hash_entry *h, void *inf ATTRIBUTE_UNUSED) |
9362 |
|
{ |
9363 |
|
struct ppc_link_hash_entry *eh; |
9364 |
|
|
9365 |
|
if (h->root.type == bfd_link_hash_indirect) |
9366 |
|
return TRUE; |
9367 |
|
|
9368 |
|
if (h->root.type == bfd_link_hash_warning) |
9369 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
9370 |
|
|
9371 |
|
eh = (struct ppc_link_hash_entry *) h; |
9372 |
|
if (eh->elf.root.type != bfd_link_hash_undefweak || !eh->was_undefined) |
9373 |
|
return TRUE; |
9374 |
|
|
9375 |
|
eh->elf.root.type = bfd_link_hash_undefined; |
9376 |
|
return TRUE; |
9377 |
|
} |
9378 |
|
|
9379 |
|
void |
9380 |
|
ppc64_elf_restore_symbols (struct bfd_link_info *info) |
9381 |
|
{ |
9382 |
|
struct ppc_link_hash_table *htab = ppc_hash_table (info); |
9383 |
|
elf_link_hash_traverse (&htab->elf, undo_symbol_twiddle, info); |
9384 |
} |
} |
9385 |
|
|
9386 |
/* The RELOCATE_SECTION function is called by the ELF backend linker |
/* The RELOCATE_SECTION function is called by the ELF backend linker |
9392 |
|
|
9393 |
This function is responsible for adjust the section contents as |
This function is responsible for adjust the section contents as |
9394 |
necessary, and (if using Rela relocs and generating a |
necessary, and (if using Rela relocs and generating a |
9395 |
relocateable output file) adjusting the reloc addend as |
relocatable output file) adjusting the reloc addend as |
9396 |
necessary. |
necessary. |
9397 |
|
|
9398 |
This function does not have to worry about setting the reloc |
This function does not have to worry about setting the reloc |
9406 |
The global hash table entry for the global symbols can be found |
The global hash table entry for the global symbols can be found |
9407 |
via elf_sym_hashes (input_bfd). |
via elf_sym_hashes (input_bfd). |
9408 |
|
|
9409 |
When generating relocateable output, this function must handle |
When generating relocatable output, this function must handle |
9410 |
STB_LOCAL/STT_SECTION symbols specially. The output symbol is |
STB_LOCAL/STT_SECTION symbols specially. The output symbol is |
9411 |
going to be the section symbol corresponding to the output |
going to be the section symbol corresponding to the output |
9412 |
section, which means that the addend must be adjusted |
section, which means that the addend must be adjusted |
9413 |
accordingly. */ |
accordingly. */ |
9414 |
|
|
9415 |
static boolean |
static bfd_boolean |
9416 |
ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, |
ppc64_elf_relocate_section (bfd *output_bfd, |
9417 |
contents, relocs, local_syms, local_sections) |
struct bfd_link_info *info, |
9418 |
bfd *output_bfd; |
bfd *input_bfd, |
9419 |
struct bfd_link_info *info; |
asection *input_section, |
9420 |
bfd *input_bfd; |
bfd_byte *contents, |
9421 |
asection *input_section; |
Elf_Internal_Rela *relocs, |
9422 |
bfd_byte *contents; |
Elf_Internal_Sym *local_syms, |
9423 |
Elf_Internal_Rela *relocs; |
asection **local_sections) |
|
Elf_Internal_Sym *local_syms; |
|
|
asection **local_sections; |
|
9424 |
{ |
{ |
9425 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
9426 |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_hdr; |
9427 |
struct elf_link_hash_entry **sym_hashes; |
struct elf_link_hash_entry **sym_hashes; |
9428 |
Elf_Internal_Rela *rel; |
Elf_Internal_Rela *rel; |
9429 |
Elf_Internal_Rela *relend; |
Elf_Internal_Rela *relend; |
9430 |
bfd_vma *local_got_offsets; |
Elf_Internal_Rela outrel; |
9431 |
|
bfd_byte *loc; |
9432 |
|
struct got_entry **local_got_ents; |
9433 |
bfd_vma TOCstart; |
bfd_vma TOCstart; |
9434 |
boolean ret = true; |
bfd_boolean ret = TRUE; |
9435 |
boolean is_opd; |
bfd_boolean is_opd; |
9436 |
/* Disabled until we sort out how ld should choose 'y' vs 'at'. */ |
/* Disabled until we sort out how ld should choose 'y' vs 'at'. */ |
9437 |
boolean is_power4 = false; |
bfd_boolean is_power4 = FALSE; |
9438 |
|
|
9439 |
if (info->relocateable) |
if (info->relocatable) |
9440 |
return true; |
return TRUE; |
9441 |
|
|
9442 |
/* Initialize howto table if needed. */ |
/* Initialize howto table if needed. */ |
9443 |
if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) |
if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) |
9444 |
ppc_howto_init (); |
ppc_howto_init (); |
9445 |
|
|
9446 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
9447 |
local_got_offsets = elf_local_got_offsets (input_bfd); |
|
9448 |
|
/* Don't relocate stub sections. */ |
9449 |
|
if (input_section->owner == htab->stub_bfd) |
9450 |
|
return TRUE; |
9451 |
|
|
9452 |
|
local_got_ents = elf_local_got_ents (input_bfd); |
9453 |
TOCstart = elf_gp (output_bfd); |
TOCstart = elf_gp (output_bfd); |
9454 |
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; |
9455 |
sym_hashes = elf_sym_hashes (input_bfd); |
sym_hashes = elf_sym_hashes (input_bfd); |
9456 |
is_opd = elf_section_data (input_section)->tdata != NULL; |
is_opd = ppc64_elf_section_data (input_section)->opd.adjust != NULL; |
9457 |
|
|
9458 |
rel = relocs; |
rel = relocs; |
9459 |
relend = relocs + input_section->reloc_count; |
relend = relocs + input_section->reloc_count; |
9460 |
for (; rel < relend; rel++) |
for (; rel < relend; rel++) |
9461 |
{ |
{ |
9462 |
enum elf_ppc_reloc_type r_type; |
enum elf_ppc64_reloc_type r_type; |
|
bfd_vma offset; |
|
9463 |
bfd_vma addend; |
bfd_vma addend; |
9464 |
bfd_reloc_status_type r; |
bfd_reloc_status_type r; |
9465 |
Elf_Internal_Sym *sym; |
Elf_Internal_Sym *sym; |
9466 |
asection *sec; |
asection *sec; |
9467 |
struct elf_link_hash_entry *h; |
struct elf_link_hash_entry *h_elf; |
9468 |
struct elf_link_hash_entry *fdh; |
struct ppc_link_hash_entry *h; |
9469 |
|
struct ppc_link_hash_entry *fdh; |
9470 |
const char *sym_name; |
const char *sym_name; |
9471 |
unsigned long r_symndx; |
unsigned long r_symndx, toc_symndx; |
9472 |
|
char tls_mask, tls_gd, tls_type; |
9473 |
|
char sym_type; |
9474 |
bfd_vma relocation; |
bfd_vma relocation; |
9475 |
boolean unresolved_reloc; |
bfd_boolean unresolved_reloc; |
9476 |
boolean warned; |
bfd_boolean warned; |
9477 |
long insn; |
unsigned long insn, mask; |
9478 |
struct ppc_stub_hash_entry *stub_entry; |
struct ppc_stub_hash_entry *stub_entry; |
9479 |
bfd_vma max_br_offset; |
bfd_vma max_br_offset; |
9480 |
bfd_vma from; |
bfd_vma from; |
9481 |
|
|
9482 |
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); |
r_type = ELF64_R_TYPE (rel->r_info); |
9483 |
r_symndx = ELF64_R_SYM (rel->r_info); |
r_symndx = ELF64_R_SYM (rel->r_info); |
|
offset = rel->r_offset; |
|
|
addend = rel->r_addend; |
|
|
r = bfd_reloc_other; |
|
|
sym = (Elf_Internal_Sym *) 0; |
|
|
sec = (asection *) 0; |
|
|
h = (struct elf_link_hash_entry *) 0; |
|
|
sym_name = (const char *) 0; |
|
|
unresolved_reloc = false; |
|
|
warned = false; |
|
9484 |
|
|
9485 |
if (r_type == R_PPC64_TOC) |
/* For old style R_PPC64_TOC relocs with a zero symbol, use the |
9486 |
{ |
symbol of the previous ADDR64 reloc. The symbol gives us the |
9487 |
/* Relocation value is TOC base. Symbol is ignored. */ |
proper TOC base to use. */ |
9488 |
relocation = TOCstart + TOC_BASE_OFF; |
if (rel->r_info == ELF64_R_INFO (0, R_PPC64_TOC) |
9489 |
} |
&& rel != relocs |
9490 |
else if (r_symndx < symtab_hdr->sh_info) |
&& ELF64_R_TYPE (rel[-1].r_info) == R_PPC64_ADDR64 |
9491 |
|
&& is_opd) |
9492 |
|
r_symndx = ELF64_R_SYM (rel[-1].r_info); |
9493 |
|
|
9494 |
|
sym = NULL; |
9495 |
|
sec = NULL; |
9496 |
|
h_elf = NULL; |
9497 |
|
sym_name = NULL; |
9498 |
|
unresolved_reloc = FALSE; |
9499 |
|
warned = FALSE; |
9500 |
|
|
9501 |
|
if (r_symndx < symtab_hdr->sh_info) |
9502 |
{ |
{ |
9503 |
/* It's a local symbol. */ |
/* It's a local symbol. */ |
9504 |
|
long *opd_adjust; |
9505 |
|
|
9506 |
sym = local_syms + r_symndx; |
sym = local_syms + r_symndx; |
9507 |
sec = local_sections[r_symndx]; |
sec = local_sections[r_symndx]; |
9508 |
sym_name = "<local symbol>"; |
sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym); |
9509 |
|
sym_type = ELF64_ST_TYPE (sym->st_info); |
9510 |
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); |
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); |
9511 |
/* rel may have changed, update our copy of addend. */ |
opd_adjust = get_opd_info (sec); |
9512 |
addend = rel->r_addend; |
if (opd_adjust != NULL) |
9513 |
|
{ |
9514 |
if (elf_section_data (sec) != NULL) |
long adjust = opd_adjust[(sym->st_value + rel->r_addend) / 8]; |
9515 |
{ |
if (adjust == -1) |
9516 |
long *opd_sym_adjust; |
relocation = 0; |
9517 |
|
else |
9518 |
opd_sym_adjust = (long *) elf_section_data (sec)->tdata; |
relocation += adjust; |
|
if (opd_sym_adjust != NULL && sym->st_value % 24 == 0) |
|
|
relocation += opd_sym_adjust[sym->st_value / 24]; |
|
9519 |
} |
} |
9520 |
} |
} |
9521 |
else |
else |
9522 |
{ |
{ |
9523 |
/* It's a global symbol. */ |
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, |
9524 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
r_symndx, symtab_hdr, sym_hashes, |
9525 |
while (h->root.type == bfd_link_hash_indirect |
h_elf, sec, relocation, |
9526 |
|| h->root.type == bfd_link_hash_warning) |
unresolved_reloc, warned); |
9527 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
sym_name = h_elf->root.root.string; |
9528 |
sym_name = h->root.root.string; |
sym_type = h_elf->type; |
9529 |
relocation = 0; |
} |
9530 |
if (h->root.type == bfd_link_hash_defined |
h = (struct ppc_link_hash_entry *) h_elf; |
9531 |
|| h->root.type == bfd_link_hash_defweak) |
|
9532 |
|
/* TLS optimizations. Replace instruction sequences and relocs |
9533 |
|
based on information we collected in tls_optimize. We edit |
9534 |
|
RELOCS so that --emit-relocs will output something sensible |
9535 |
|
for the final instruction stream. */ |
9536 |
|
tls_mask = 0; |
9537 |
|
tls_gd = 0; |
9538 |
|
toc_symndx = 0; |
9539 |
|
if (IS_PPC64_TLS_RELOC (r_type)) |
9540 |
|
{ |
9541 |
|
if (h != NULL) |
9542 |
|
tls_mask = h->tls_mask; |
9543 |
|
else if (local_got_ents != NULL) |
9544 |
{ |
{ |
9545 |
sec = h->root.u.def.section; |
char *lgot_masks; |
9546 |
if (sec->output_section == NULL) |
lgot_masks = (char *) (local_got_ents + symtab_hdr->sh_info); |
9547 |
/* Set a flag that will be cleared later if we find a |
tls_mask = lgot_masks[r_symndx]; |
|
relocation value for this symbol. output_section |
|
|
is typically NULL for symbols satisfied by a shared |
|
|
library. */ |
|
|
unresolved_reloc = true; |
|
|
else |
|
|
relocation = (h->root.u.def.value |
|
|
+ sec->output_section->vma |
|
|
+ sec->output_offset); |
|
9548 |
} |
} |
9549 |
else if (h->root.type == bfd_link_hash_undefweak) |
if (tls_mask == 0 && r_type == R_PPC64_TLS) |
9550 |
; |
{ |
9551 |
else if (info->shared |
/* Check for toc tls entries. */ |
9552 |
&& (!info->symbolic || info->allow_shlib_undefined) |
char *toc_tls; |
9553 |
&& !info->no_undefined |
|
9554 |
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) |
if (!get_tls_mask (&toc_tls, &toc_symndx, &local_syms, |
9555 |
|
rel, input_bfd)) |
9556 |
|
return FALSE; |
9557 |
|
|
9558 |
|
if (toc_tls) |
9559 |
|
tls_mask = *toc_tls; |
9560 |
|
} |
9561 |
|
} |
9562 |
|
|
9563 |
|
/* Check that tls relocs are used with tls syms, and non-tls |
9564 |
|
relocs are used with non-tls syms. */ |
9565 |
|
if (r_symndx != 0 |
9566 |
|
&& r_type != R_PPC64_NONE |
9567 |
|
&& (h == NULL |
9568 |
|
|| h->elf.root.type == bfd_link_hash_defined |
9569 |
|
|| h->elf.root.type == bfd_link_hash_defweak) |
9570 |
|
&& IS_PPC64_TLS_RELOC (r_type) != (sym_type == STT_TLS)) |
9571 |
|
{ |
9572 |
|
if (r_type == R_PPC64_TLS && tls_mask != 0) |
9573 |
|
/* R_PPC64_TLS is OK against a symbol in the TOC. */ |
9574 |
; |
; |
9575 |
else |
else |
9576 |
|
(*_bfd_error_handler) |
9577 |
|
(sym_type == STT_TLS |
9578 |
|
? _("%B(%A+0x%lx): %s used with TLS symbol %s") |
9579 |
|
: _("%B(%A+0x%lx): %s used with non-TLS symbol %s"), |
9580 |
|
input_bfd, |
9581 |
|
input_section, |
9582 |
|
(long) rel->r_offset, |
9583 |
|
ppc64_elf_howto_table[r_type]->name, |
9584 |
|
sym_name); |
9585 |
|
} |
9586 |
|
|
9587 |
|
/* Ensure reloc mapping code below stays sane. */ |
9588 |
|
if (R_PPC64_TOC16_LO_DS != R_PPC64_TOC16_DS + 1 |
9589 |
|
|| R_PPC64_TOC16_LO != R_PPC64_TOC16 + 1 |
9590 |
|
|| (R_PPC64_GOT_TLSLD16 & 3) != (R_PPC64_GOT_TLSGD16 & 3) |
9591 |
|
|| (R_PPC64_GOT_TLSLD16_LO & 3) != (R_PPC64_GOT_TLSGD16_LO & 3) |
9592 |
|
|| (R_PPC64_GOT_TLSLD16_HI & 3) != (R_PPC64_GOT_TLSGD16_HI & 3) |
9593 |
|
|| (R_PPC64_GOT_TLSLD16_HA & 3) != (R_PPC64_GOT_TLSGD16_HA & 3) |
9594 |
|
|| (R_PPC64_GOT_TLSLD16 & 3) != (R_PPC64_GOT_TPREL16_DS & 3) |
9595 |
|
|| (R_PPC64_GOT_TLSLD16_LO & 3) != (R_PPC64_GOT_TPREL16_LO_DS & 3) |
9596 |
|
|| (R_PPC64_GOT_TLSLD16_HI & 3) != (R_PPC64_GOT_TPREL16_HI & 3) |
9597 |
|
|| (R_PPC64_GOT_TLSLD16_HA & 3) != (R_PPC64_GOT_TPREL16_HA & 3)) |
9598 |
|
abort (); |
9599 |
|
|
9600 |
|
switch (r_type) |
9601 |
|
{ |
9602 |
|
default: |
9603 |
|
break; |
9604 |
|
|
9605 |
|
case R_PPC64_TOC16: |
9606 |
|
case R_PPC64_TOC16_LO: |
9607 |
|
case R_PPC64_TOC16_DS: |
9608 |
|
case R_PPC64_TOC16_LO_DS: |
9609 |
|
{ |
9610 |
|
/* Check for toc tls entries. */ |
9611 |
|
char *toc_tls; |
9612 |
|
int retval; |
9613 |
|
|
9614 |
|
retval = get_tls_mask (&toc_tls, &toc_symndx, &local_syms, |
9615 |
|
rel, input_bfd); |
9616 |
|
if (retval == 0) |
9617 |
|
return FALSE; |
9618 |
|
|
9619 |
|
if (toc_tls) |
9620 |
|
{ |
9621 |
|
tls_mask = *toc_tls; |
9622 |
|
if (r_type == R_PPC64_TOC16_DS |
9623 |
|
|| r_type == R_PPC64_TOC16_LO_DS) |
9624 |
|
{ |
9625 |
|
if (tls_mask != 0 |
9626 |
|
&& (tls_mask & (TLS_DTPREL | TLS_TPREL)) == 0) |
9627 |
|
goto toctprel; |
9628 |
|
} |
9629 |
|
else |
9630 |
|
{ |
9631 |
|
/* If we found a GD reloc pair, then we might be |
9632 |
|
doing a GD->IE transition. */ |
9633 |
|
if (retval == 2) |
9634 |
|
{ |
9635 |
|
tls_gd = TLS_TPRELGD; |
9636 |
|
if (tls_mask != 0 && (tls_mask & TLS_GD) == 0) |
9637 |
|
goto tls_get_addr_check; |
9638 |
|
} |
9639 |
|
else if (retval == 3) |
9640 |
|
{ |
9641 |
|
if (tls_mask != 0 && (tls_mask & TLS_LD) == 0) |
9642 |
|
goto tls_get_addr_check; |
9643 |
|
} |
9644 |
|
} |
9645 |
|
} |
9646 |
|
} |
9647 |
|
break; |
9648 |
|
|
9649 |
|
case R_PPC64_GOT_TPREL16_DS: |
9650 |
|
case R_PPC64_GOT_TPREL16_LO_DS: |
9651 |
|
if (tls_mask != 0 |
9652 |
|
&& (tls_mask & TLS_TPREL) == 0) |
9653 |
|
{ |
9654 |
|
toctprel: |
9655 |
|
insn = bfd_get_32 (output_bfd, contents + rel->r_offset - 2); |
9656 |
|
insn &= 31 << 21; |
9657 |
|
insn |= 0x3c0d0000; /* addis 0,13,0 */ |
9658 |
|
bfd_put_32 (output_bfd, insn, contents + rel->r_offset - 2); |
9659 |
|
r_type = R_PPC64_TPREL16_HA; |
9660 |
|
if (toc_symndx != 0) |
9661 |
|
{ |
9662 |
|
rel->r_info = ELF64_R_INFO (toc_symndx, r_type); |
9663 |
|
/* We changed the symbol. Start over in order to |
9664 |
|
get h, sym, sec etc. right. */ |
9665 |
|
rel--; |
9666 |
|
continue; |
9667 |
|
} |
9668 |
|
else |
9669 |
|
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9670 |
|
} |
9671 |
|
break; |
9672 |
|
|
9673 |
|
case R_PPC64_TLS: |
9674 |
|
if (tls_mask != 0 |
9675 |
|
&& (tls_mask & TLS_TPREL) == 0) |
9676 |
|
{ |
9677 |
|
bfd_vma rtra; |
9678 |
|
insn = bfd_get_32 (output_bfd, contents + rel->r_offset); |
9679 |
|
if ((insn & ((0x3f << 26) | (31 << 11))) |
9680 |
|
== ((31 << 26) | (13 << 11))) |
9681 |
|
rtra = insn & ((1 << 26) - (1 << 16)); |
9682 |
|
else if ((insn & ((0x3f << 26) | (31 << 16))) |
9683 |
|
== ((31 << 26) | (13 << 16))) |
9684 |
|
rtra = (insn & (31 << 21)) | ((insn & (31 << 11)) << 5); |
9685 |
|
else |
9686 |
|
abort (); |
9687 |
|
if ((insn & ((1 << 11) - (1 << 1))) == 266 << 1) |
9688 |
|
/* add -> addi. */ |
9689 |
|
insn = 14 << 26; |
9690 |
|
else if ((insn & (31 << 1)) == 23 << 1 |
9691 |
|
&& ((insn & (31 << 6)) < 14 << 6 |
9692 |
|
|| ((insn & (31 << 6)) >= 16 << 6 |
9693 |
|
&& (insn & (31 << 6)) < 24 << 6))) |
9694 |
|
/* load and store indexed -> dform. */ |
9695 |
|
insn = (32 | ((insn >> 6) & 31)) << 26; |
9696 |
|
else if ((insn & (31 << 1)) == 21 << 1 |
9697 |
|
&& (insn & (0x1a << 6)) == 0) |
9698 |
|
/* ldx, ldux, stdx, stdux -> ld, ldu, std, stdu. */ |
9699 |
|
insn = (((58 | ((insn >> 6) & 4)) << 26) |
9700 |
|
| ((insn >> 6) & 1)); |
9701 |
|
else if ((insn & (31 << 1)) == 21 << 1 |
9702 |
|
&& (insn & ((1 << 11) - (1 << 1))) == 341 << 1) |
9703 |
|
/* lwax -> lwa. */ |
9704 |
|
insn = (58 << 26) | 2; |
9705 |
|
else |
9706 |
|
abort (); |
9707 |
|
insn |= rtra; |
9708 |
|
bfd_put_32 (output_bfd, insn, contents + rel->r_offset); |
9709 |
|
/* Was PPC64_TLS which sits on insn boundary, now |
9710 |
|
PPC64_TPREL16_LO which is at insn+2. */ |
9711 |
|
rel->r_offset += 2; |
9712 |
|
r_type = R_PPC64_TPREL16_LO; |
9713 |
|
if (toc_symndx != 0) |
9714 |
|
{ |
9715 |
|
rel->r_info = ELF64_R_INFO (toc_symndx, r_type); |
9716 |
|
/* We changed the symbol. Start over in order to |
9717 |
|
get h, sym, sec etc. right. */ |
9718 |
|
rel--; |
9719 |
|
continue; |
9720 |
|
} |
9721 |
|
else |
9722 |
|
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9723 |
|
} |
9724 |
|
break; |
9725 |
|
|
9726 |
|
case R_PPC64_GOT_TLSGD16_HI: |
9727 |
|
case R_PPC64_GOT_TLSGD16_HA: |
9728 |
|
tls_gd = TLS_TPRELGD; |
9729 |
|
if (tls_mask != 0 && (tls_mask & TLS_GD) == 0) |
9730 |
|
goto tls_gdld_hi; |
9731 |
|
break; |
9732 |
|
|
9733 |
|
case R_PPC64_GOT_TLSLD16_HI: |
9734 |
|
case R_PPC64_GOT_TLSLD16_HA: |
9735 |
|
if (tls_mask != 0 && (tls_mask & TLS_LD) == 0) |
9736 |
|
{ |
9737 |
|
tls_gdld_hi: |
9738 |
|
if ((tls_mask & tls_gd) != 0) |
9739 |
|
r_type = (((r_type - (R_PPC64_GOT_TLSGD16 & 3)) & 3) |
9740 |
|
+ R_PPC64_GOT_TPREL16_DS); |
9741 |
|
else |
9742 |
|
{ |
9743 |
|
bfd_put_32 (output_bfd, NOP, contents + rel->r_offset); |
9744 |
|
rel->r_offset -= 2; |
9745 |
|
r_type = R_PPC64_NONE; |
9746 |
|
} |
9747 |
|
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9748 |
|
} |
9749 |
|
break; |
9750 |
|
|
9751 |
|
case R_PPC64_GOT_TLSGD16: |
9752 |
|
case R_PPC64_GOT_TLSGD16_LO: |
9753 |
|
tls_gd = TLS_TPRELGD; |
9754 |
|
if (tls_mask != 0 && (tls_mask & TLS_GD) == 0) |
9755 |
|
goto tls_get_addr_check; |
9756 |
|
break; |
9757 |
|
|
9758 |
|
case R_PPC64_GOT_TLSLD16: |
9759 |
|
case R_PPC64_GOT_TLSLD16_LO: |
9760 |
|
if (tls_mask != 0 && (tls_mask & TLS_LD) == 0) |
9761 |
|
{ |
9762 |
|
tls_get_addr_check: |
9763 |
|
if (rel + 1 < relend) |
9764 |
|
{ |
9765 |
|
enum elf_ppc64_reloc_type r_type2; |
9766 |
|
unsigned long r_symndx2; |
9767 |
|
struct elf_link_hash_entry *h2; |
9768 |
|
bfd_vma insn1, insn2, insn3; |
9769 |
|
bfd_vma offset; |
9770 |
|
|
9771 |
|
/* The next instruction should be a call to |
9772 |
|
__tls_get_addr. Peek at the reloc to be sure. */ |
9773 |
|
r_type2 = ELF64_R_TYPE (rel[1].r_info); |
9774 |
|
r_symndx2 = ELF64_R_SYM (rel[1].r_info); |
9775 |
|
if (r_symndx2 < symtab_hdr->sh_info |
9776 |
|
|| (r_type2 != R_PPC64_REL14 |
9777 |
|
&& r_type2 != R_PPC64_REL14_BRTAKEN |
9778 |
|
&& r_type2 != R_PPC64_REL14_BRNTAKEN |
9779 |
|
&& r_type2 != R_PPC64_REL24)) |
9780 |
|
break; |
9781 |
|
|
9782 |
|
h2 = sym_hashes[r_symndx2 - symtab_hdr->sh_info]; |
9783 |
|
while (h2->root.type == bfd_link_hash_indirect |
9784 |
|
|| h2->root.type == bfd_link_hash_warning) |
9785 |
|
h2 = (struct elf_link_hash_entry *) h2->root.u.i.link; |
9786 |
|
if (h2 == NULL || (h2 != &htab->tls_get_addr->elf |
9787 |
|
&& h2 != &htab->tls_get_addr_fd->elf)) |
9788 |
|
break; |
9789 |
|
|
9790 |
|
/* OK, it checks out. Replace the call. */ |
9791 |
|
offset = rel[1].r_offset; |
9792 |
|
insn1 = bfd_get_32 (output_bfd, |
9793 |
|
contents + rel->r_offset - 2); |
9794 |
|
insn3 = bfd_get_32 (output_bfd, |
9795 |
|
contents + offset + 4); |
9796 |
|
if ((tls_mask & tls_gd) != 0) |
9797 |
|
{ |
9798 |
|
/* IE */ |
9799 |
|
insn1 &= (1 << 26) - (1 << 2); |
9800 |
|
insn1 |= 58 << 26; /* ld */ |
9801 |
|
insn2 = 0x7c636a14; /* add 3,3,13 */ |
9802 |
|
rel[1].r_info = ELF64_R_INFO (r_symndx2, R_PPC64_NONE); |
9803 |
|
if ((tls_mask & TLS_EXPLICIT) == 0) |
9804 |
|
r_type = (((r_type - (R_PPC64_GOT_TLSGD16 & 3)) & 3) |
9805 |
|
+ R_PPC64_GOT_TPREL16_DS); |
9806 |
|
else |
9807 |
|
r_type += R_PPC64_TOC16_DS - R_PPC64_TOC16; |
9808 |
|
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9809 |
|
} |
9810 |
|
else |
9811 |
|
{ |
9812 |
|
/* LE */ |
9813 |
|
insn1 = 0x3c6d0000; /* addis 3,13,0 */ |
9814 |
|
insn2 = 0x38630000; /* addi 3,3,0 */ |
9815 |
|
if (tls_gd == 0) |
9816 |
|
{ |
9817 |
|
/* Was an LD reloc. */ |
9818 |
|
r_symndx = 0; |
9819 |
|
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET; |
9820 |
|
rel[1].r_addend = htab->elf.tls_sec->vma + DTP_OFFSET; |
9821 |
|
} |
9822 |
|
else if (toc_symndx != 0) |
9823 |
|
r_symndx = toc_symndx; |
9824 |
|
r_type = R_PPC64_TPREL16_HA; |
9825 |
|
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9826 |
|
rel[1].r_info = ELF64_R_INFO (r_symndx, |
9827 |
|
R_PPC64_TPREL16_LO); |
9828 |
|
rel[1].r_offset += 2; |
9829 |
|
} |
9830 |
|
if (insn3 == NOP |
9831 |
|
|| insn3 == CROR_151515 || insn3 == CROR_313131) |
9832 |
|
{ |
9833 |
|
insn3 = insn2; |
9834 |
|
insn2 = NOP; |
9835 |
|
rel[1].r_offset += 4; |
9836 |
|
} |
9837 |
|
bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - 2); |
9838 |
|
bfd_put_32 (output_bfd, insn2, contents + offset); |
9839 |
|
bfd_put_32 (output_bfd, insn3, contents + offset + 4); |
9840 |
|
if (tls_gd == 0 || toc_symndx != 0) |
9841 |
|
{ |
9842 |
|
/* We changed the symbol. Start over in order |
9843 |
|
to get h, sym, sec etc. right. */ |
9844 |
|
rel--; |
9845 |
|
continue; |
9846 |
|
} |
9847 |
|
} |
9848 |
|
} |
9849 |
|
break; |
9850 |
|
|
9851 |
|
case R_PPC64_DTPMOD64: |
9852 |
|
if (rel + 1 < relend |
9853 |
|
&& rel[1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_DTPREL64) |
9854 |
|
&& rel[1].r_offset == rel->r_offset + 8) |
9855 |
|
{ |
9856 |
|
if ((tls_mask & TLS_GD) == 0) |
9857 |
|
{ |
9858 |
|
rel[1].r_info = ELF64_R_INFO (r_symndx, R_PPC64_NONE); |
9859 |
|
if ((tls_mask & TLS_TPRELGD) != 0) |
9860 |
|
r_type = R_PPC64_TPREL64; |
9861 |
|
else |
9862 |
|
{ |
9863 |
|
bfd_put_64 (output_bfd, 1, contents + rel->r_offset); |
9864 |
|
r_type = R_PPC64_NONE; |
9865 |
|
} |
9866 |
|
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9867 |
|
} |
9868 |
|
} |
9869 |
|
else |
9870 |
{ |
{ |
9871 |
if (! ((*info->callbacks->undefined_symbol) |
if ((tls_mask & TLS_LD) == 0) |
9872 |
(info, h->root.root.string, input_bfd, input_section, |
{ |
9873 |
offset, (!info->shared |
bfd_put_64 (output_bfd, 1, contents + rel->r_offset); |
9874 |
|| info->no_undefined |
r_type = R_PPC64_NONE; |
9875 |
|| ELF_ST_VISIBILITY (h->other))))) |
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9876 |
return false; |
} |
|
warned = true; |
|
9877 |
} |
} |
9878 |
|
break; |
9879 |
|
|
9880 |
|
case R_PPC64_TPREL64: |
9881 |
|
if ((tls_mask & TLS_TPREL) == 0) |
9882 |
|
{ |
9883 |
|
r_type = R_PPC64_NONE; |
9884 |
|
rel->r_info = ELF64_R_INFO (r_symndx, r_type); |
9885 |
|
} |
9886 |
|
break; |
9887 |
} |
} |
9888 |
|
|
9889 |
/* First handle relocations that tweak non-addend part of insn. */ |
/* Handle other relocations that tweak non-addend part of insn. */ |
9890 |
insn = 0; |
insn = 0; |
9891 |
|
max_br_offset = 1 << 25; |
9892 |
|
addend = rel->r_addend; |
9893 |
switch (r_type) |
switch (r_type) |
9894 |
{ |
{ |
9895 |
default: |
default: |
9904 |
/* Branch not taken prediction relocations. */ |
/* Branch not taken prediction relocations. */ |
9905 |
case R_PPC64_ADDR14_BRNTAKEN: |
case R_PPC64_ADDR14_BRNTAKEN: |
9906 |
case R_PPC64_REL14_BRNTAKEN: |
case R_PPC64_REL14_BRNTAKEN: |
9907 |
insn |= bfd_get_32 (output_bfd, contents + offset) & ~(0x01 << 21); |
insn |= bfd_get_32 (output_bfd, |
9908 |
if (is_power4) |
contents + rel->r_offset) & ~(0x01 << 21); |
9909 |
{ |
/* Fall thru. */ |
|
/* Set 'a' bit. This is 0b00010 in BO field for branch |
|
|
on CR(BI) insns (BO == 001at or 011at), and 0b01000 |
|
|
for branch on CTR insns (BO == 1a00t or 1a01t). */ |
|
|
if ((insn & (0x14 << 21)) == (0x04 << 21)) |
|
|
insn |= 0x02 << 21; |
|
|
else if ((insn & (0x14 << 21)) == (0x10 << 21)) |
|
|
insn |= 0x08 << 21; |
|
|
else |
|
|
break; |
|
|
} |
|
|
else |
|
|
{ |
|
|
from = (offset |
|
|
+ input_section->output_offset |
|
|
+ input_section->output_section->vma); |
|
|
|
|
|
/* Invert 'y' bit if not the default. */ |
|
|
if ((bfd_signed_vma) (relocation + addend - from) < 0) |
|
|
insn ^= 0x01 << 21; |
|
|
} |
|
9910 |
|
|
9911 |
bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset); |
case R_PPC64_REL14: |
9912 |
break; |
max_br_offset = 1 << 15; |
9913 |
|
/* Fall thru. */ |
9914 |
|
|
9915 |
case R_PPC64_REL24: |
case R_PPC64_REL24: |
9916 |
/* A REL24 branching to a linkage function is followed by a |
/* Calls to functions with a different TOC, such as calls to |
9917 |
nop. We replace the nop with a ld in order to restore |
shared objects, need to alter the TOC pointer. This is |
9918 |
the TOC base pointer. Only calls to shared objects need |
done using a linkage stub. A REL24 branching to these |
9919 |
to alter the TOC base. These are recognized by their |
linkage stubs needs to be followed by a nop, as the nop |
9920 |
need for a PLT entry. */ |
will be replaced with an instruction to restore the TOC |
9921 |
if (h != NULL |
base pointer. */ |
9922 |
&& (fdh = ((struct ppc_link_hash_entry *) h)->oh) != NULL |
stub_entry = NULL; |
9923 |
&& fdh->plt.offset != (bfd_vma) -1 |
fdh = h; |
9924 |
|
if (((h != NULL |
9925 |
|
&& (((fdh = h->oh) != NULL |
9926 |
|
&& fdh->elf.plt.plist != NULL) |
9927 |
|
|| (fdh = h)->elf.plt.plist != NULL)) |
9928 |
|
|| (sec != NULL |
9929 |
|
&& sec->output_section != NULL |
9930 |
|
&& sec->id <= htab->top_id |
9931 |
|
&& (htab->stub_group[sec->id].toc_off |
9932 |
|
!= htab->stub_group[input_section->id].toc_off))) |
9933 |
&& (stub_entry = ppc_get_stub_entry (input_section, sec, fdh, |
&& (stub_entry = ppc_get_stub_entry (input_section, sec, fdh, |
9934 |
rel, htab)) != NULL) |
rel, htab)) != NULL |
9935 |
|
&& (stub_entry->stub_type == ppc_stub_plt_call |
9936 |
|
|| stub_entry->stub_type == ppc_stub_plt_branch_r2off |
9937 |
|
|| stub_entry->stub_type == ppc_stub_long_branch_r2off)) |
9938 |
{ |
{ |
9939 |
boolean can_plt_call = 0; |
bfd_boolean can_plt_call = FALSE; |
9940 |
|
|
9941 |
if (offset + 8 <= input_section->_cooked_size) |
if (rel->r_offset + 8 <= input_section->size) |
9942 |
{ |
{ |
9943 |
insn = bfd_get_32 (input_bfd, contents + offset + 4); |
unsigned long nop; |
9944 |
if (insn == NOP |
nop = bfd_get_32 (input_bfd, contents + rel->r_offset + 4); |
9945 |
|| insn == CROR_151515 || insn == CROR_313131) |
if (nop == NOP |
9946 |
|
|| nop == CROR_151515 || nop == CROR_313131) |
9947 |
{ |
{ |
9948 |
bfd_put_32 (input_bfd, (bfd_vma) LD_R2_40R1, |
bfd_put_32 (input_bfd, LD_R2_40R1, |
9949 |
contents + offset + 4); |
contents + rel->r_offset + 4); |
9950 |
can_plt_call = 1; |
can_plt_call = TRUE; |
9951 |
} |
} |
9952 |
} |
} |
9953 |
|
|
9954 |
if (!can_plt_call) |
if (!can_plt_call) |
9955 |
{ |
{ |
9956 |
/* If this is a plain branch rather than a branch |
if (stub_entry->stub_type == ppc_stub_plt_call) |
9957 |
and link, don't require a nop. */ |
{ |
9958 |
insn = bfd_get_32 (input_bfd, contents + offset); |
/* If this is a plain branch rather than a branch |
9959 |
if ((insn & 1) == 0) |
and link, don't require a nop. */ |
9960 |
can_plt_call = 1; |
unsigned long br; |
9961 |
|
br = bfd_get_32 (input_bfd, contents + rel->r_offset); |
9962 |
|
if ((br & 1) == 0) |
9963 |
|
can_plt_call = TRUE; |
9964 |
|
} |
9965 |
|
else if (h != NULL |
9966 |
|
&& strcmp (h->elf.root.root.string, |
9967 |
|
".__libc_start_main") == 0) |
9968 |
|
{ |
9969 |
|
/* Allow crt1 branch to go via a toc adjusting stub. */ |
9970 |
|
can_plt_call = TRUE; |
9971 |
|
} |
9972 |
|
else |
9973 |
|
{ |
9974 |
|
if (strcmp (input_section->output_section->name, |
9975 |
|
".init") == 0 |
9976 |
|
|| strcmp (input_section->output_section->name, |
9977 |
|
".fini") == 0) |
9978 |
|
(*_bfd_error_handler) |
9979 |
|
(_("%B(%A+0x%lx): automatic multiple TOCs " |
9980 |
|
"not supported using your crt files; " |
9981 |
|
"recompile with -mminimal-toc or upgrade gcc"), |
9982 |
|
input_bfd, |
9983 |
|
input_section, |
9984 |
|
(long) rel->r_offset); |
9985 |
|
else |
9986 |
|
(*_bfd_error_handler) |
9987 |
|
(_("%B(%A+0x%lx): sibling call optimization to `%s' " |
9988 |
|
"does not allow automatic multiple TOCs; " |
9989 |
|
"recompile with -mminimal-toc or " |
9990 |
|
"-fno-optimize-sibling-calls, " |
9991 |
|
"or make `%s' extern"), |
9992 |
|
input_bfd, |
9993 |
|
input_section, |
9994 |
|
(long) rel->r_offset, |
9995 |
|
sym_name, |
9996 |
|
sym_name); |
9997 |
|
bfd_set_error (bfd_error_bad_value); |
9998 |
|
ret = FALSE; |
9999 |
|
} |
10000 |
} |
} |
10001 |
|
|
10002 |
if (can_plt_call) |
if (can_plt_call |
10003 |
{ |
&& stub_entry->stub_type == ppc_stub_plt_call) |
10004 |
relocation = (stub_entry->stub_offset |
unresolved_reloc = FALSE; |
10005 |
+ stub_entry->stub_sec->output_offset |
} |
10006 |
+ stub_entry->stub_sec->output_section->vma); |
|
10007 |
|
if (stub_entry == NULL |
10008 |
|
&& get_opd_info (sec) != NULL) |
10009 |
|
{ |
10010 |
|
/* The branch destination is the value of the opd entry. */ |
10011 |
|
bfd_vma off = (relocation - sec->output_section->vma |
10012 |
|
- sec->output_offset + rel->r_addend); |
10013 |
|
bfd_vma dest = opd_entry_value (sec, off, NULL, NULL); |
10014 |
|
if (dest != (bfd_vma) -1) |
10015 |
|
{ |
10016 |
|
relocation = dest; |
10017 |
addend = 0; |
addend = 0; |
|
unresolved_reloc = false; |
|
10018 |
} |
} |
10019 |
} |
} |
10020 |
|
|
10021 |
if (h != NULL |
/* If the branch is out of reach we ought to have a long |
10022 |
&& h->root.type == bfd_link_hash_undefweak |
branch stub. */ |
10023 |
&& relocation == 0 |
from = (rel->r_offset |
10024 |
&& addend == 0) |
+ input_section->output_offset |
10025 |
{ |
+ input_section->output_section->vma); |
10026 |
/* Tweak calls to undefined weak functions to point at a |
|
10027 |
blr. We can thus call a weak function without first |
if (stub_entry == NULL |
10028 |
checking whether the function is defined. We have a |
&& (relocation + rel->r_addend - from + max_br_offset |
10029 |
blr at the end of .sfpr. */ |
>= 2 * max_br_offset) |
10030 |
BFD_ASSERT (htab->sfpr->_raw_size != 0); |
&& r_type != R_PPC64_ADDR14_BRTAKEN |
10031 |
relocation = (htab->sfpr->_raw_size - 4 |
&& r_type != R_PPC64_ADDR14_BRNTAKEN) |
10032 |
+ htab->sfpr->output_offset |
stub_entry = ppc_get_stub_entry (input_section, sec, h, rel, |
10033 |
+ htab->sfpr->output_section->vma); |
htab); |
10034 |
from = (offset |
|
10035 |
+ input_section->output_offset |
if (stub_entry != NULL) |
10036 |
+ input_section->output_section->vma); |
{ |
10037 |
|
/* Munge up the value and addend so that we call the stub |
10038 |
/* But let's not be silly about it. If the blr isn't in |
rather than the procedure directly. */ |
10039 |
reach, just go to the next instruction. */ |
relocation = (stub_entry->stub_offset |
10040 |
if (relocation - from + (1 << 25) >= (1 << 26) |
+ stub_entry->stub_sec->output_offset |
10041 |
|| htab->sfpr->_raw_size == 0) |
+ stub_entry->stub_sec->output_section->vma); |
10042 |
relocation = from + 4; |
addend = 0; |
10043 |
|
} |
10044 |
|
|
10045 |
|
if (insn != 0) |
10046 |
|
{ |
10047 |
|
if (is_power4) |
10048 |
|
{ |
10049 |
|
/* Set 'a' bit. This is 0b00010 in BO field for branch |
10050 |
|
on CR(BI) insns (BO == 001at or 011at), and 0b01000 |
10051 |
|
for branch on CTR insns (BO == 1a00t or 1a01t). */ |
10052 |
|
if ((insn & (0x14 << 21)) == (0x04 << 21)) |
10053 |
|
insn |= 0x02 << 21; |
10054 |
|
else if ((insn & (0x14 << 21)) == (0x10 << 21)) |
10055 |
|
insn |= 0x08 << 21; |
10056 |
|
else |
10057 |
|
break; |
10058 |
|
} |
10059 |
|
else |
10060 |
|
{ |
10061 |
|
/* Invert 'y' bit if not the default. */ |
10062 |
|
if ((bfd_signed_vma) (relocation + rel->r_addend - from) < 0) |
10063 |
|
insn ^= 0x01 << 21; |
10064 |
|
} |
10065 |
|
|
10066 |
|
bfd_put_32 (output_bfd, insn, contents + rel->r_offset); |
10067 |
|
} |
10068 |
|
|
10069 |
|
/* NOP out calls to undefined weak functions. |
10070 |
|
We can thus call a weak function without first |
10071 |
|
checking whether the function is defined. */ |
10072 |
|
else if (h != NULL |
10073 |
|
&& h->elf.root.type == bfd_link_hash_undefweak |
10074 |
|
&& r_type == R_PPC64_REL24 |
10075 |
|
&& relocation == 0 |
10076 |
|
&& rel->r_addend == 0) |
10077 |
|
{ |
10078 |
|
bfd_put_32 (output_bfd, NOP, contents + rel->r_offset); |
10079 |
|
continue; |
10080 |
} |
} |
10081 |
break; |
break; |
10082 |
} |
} |
10083 |
|
|
10084 |
/* Set `addend'. */ |
/* Set `addend'. */ |
10085 |
|
tls_type = 0; |
10086 |
switch (r_type) |
switch (r_type) |
10087 |
{ |
{ |
10088 |
default: |
default: |
10089 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
10090 |
(_("%s: unknown relocation type %d for symbol %s"), |
(_("%B: unknown relocation type %d for symbol %s"), |
10091 |
bfd_archive_filename (input_bfd), (int) r_type, sym_name); |
input_bfd, (int) r_type, sym_name); |
10092 |
|
|
10093 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
10094 |
ret = false; |
ret = FALSE; |
10095 |
continue; |
continue; |
10096 |
|
|
10097 |
case R_PPC64_NONE: |
case R_PPC64_NONE: |
10098 |
case R_PPC_GNU_VTINHERIT: |
case R_PPC64_TLS: |
10099 |
case R_PPC_GNU_VTENTRY: |
case R_PPC64_GNU_VTINHERIT: |
10100 |
|
case R_PPC64_GNU_VTENTRY: |
10101 |
continue; |
continue; |
10102 |
|
|
10103 |
/* GOT16 relocations. Like an ADDR16 using the symbol's |
/* GOT16 relocations. Like an ADDR16 using the symbol's |
10104 |
address in the GOT as relocation value instead of the |
address in the GOT as relocation value instead of the |
10105 |
symbols value itself. Also, create a GOT entry for the |
symbol's value itself. Also, create a GOT entry for the |
10106 |
symbol and put the symbol value there. */ |
symbol and put the symbol value there. */ |
10107 |
|
case R_PPC64_GOT_TLSGD16: |
10108 |
|
case R_PPC64_GOT_TLSGD16_LO: |
10109 |
|
case R_PPC64_GOT_TLSGD16_HI: |
10110 |
|
case R_PPC64_GOT_TLSGD16_HA: |
10111 |
|
tls_type = TLS_TLS | TLS_GD; |
10112 |
|
goto dogot; |
10113 |
|
|
10114 |
|
case R_PPC64_GOT_TLSLD16: |
10115 |
|
case R_PPC64_GOT_TLSLD16_LO: |
10116 |
|
case R_PPC64_GOT_TLSLD16_HI: |
10117 |
|
case R_PPC64_GOT_TLSLD16_HA: |
10118 |
|
tls_type = TLS_TLS | TLS_LD; |
10119 |
|
goto dogot; |
10120 |
|
|
10121 |
|
case R_PPC64_GOT_TPREL16_DS: |
10122 |
|
case R_PPC64_GOT_TPREL16_LO_DS: |
10123 |
|
case R_PPC64_GOT_TPREL16_HI: |
10124 |
|
case R_PPC64_GOT_TPREL16_HA: |
10125 |
|
tls_type = TLS_TLS | TLS_TPREL; |
10126 |
|
goto dogot; |
10127 |
|
|
10128 |
|
case R_PPC64_GOT_DTPREL16_DS: |
10129 |
|
case R_PPC64_GOT_DTPREL16_LO_DS: |
10130 |
|
case R_PPC64_GOT_DTPREL16_HI: |
10131 |
|
case R_PPC64_GOT_DTPREL16_HA: |
10132 |
|
tls_type = TLS_TLS | TLS_DTPREL; |
10133 |
|
goto dogot; |
10134 |
|
|
10135 |
case R_PPC64_GOT16: |
case R_PPC64_GOT16: |
10136 |
case R_PPC64_GOT16_LO: |
case R_PPC64_GOT16_LO: |
10137 |
case R_PPC64_GOT16_HI: |
case R_PPC64_GOT16_HI: |
10138 |
case R_PPC64_GOT16_HA: |
case R_PPC64_GOT16_HA: |
10139 |
case R_PPC64_GOT16_DS: |
case R_PPC64_GOT16_DS: |
10140 |
case R_PPC64_GOT16_LO_DS: |
case R_PPC64_GOT16_LO_DS: |
10141 |
|
dogot: |
10142 |
{ |
{ |
10143 |
/* Relocation is to the entry for this symbol in the global |
/* Relocation is to the entry for this symbol in the global |
10144 |
offset table. */ |
offset table. */ |
10145 |
|
asection *got; |
10146 |
|
bfd_vma *offp; |
10147 |
bfd_vma off; |
bfd_vma off; |
10148 |
|
unsigned long indx = 0; |
10149 |
|
|
10150 |
if (htab->sgot == NULL) |
if (tls_type == (TLS_TLS | TLS_LD) |
10151 |
abort (); |
&& (h == NULL |
10152 |
|
|| !h->elf.def_dynamic)) |
10153 |
if (h != NULL) |
offp = &ppc64_tlsld_got (input_bfd)->offset; |
10154 |
|
else |
10155 |
{ |
{ |
10156 |
boolean dyn; |
struct got_entry *ent; |
10157 |
|
|
10158 |
off = h->got.offset; |
if (h != NULL) |
|
dyn = htab->elf.dynamic_sections_created; |
|
|
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h) |
|
|
|| (info->shared |
|
|
&& (info->symbolic |
|
|
|| h->dynindx == -1 |
|
|
|| (h->elf_link_hash_flags |
|
|
& ELF_LINK_FORCED_LOCAL)) |
|
|
&& (h->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR))) |
|
10159 |
{ |
{ |
10160 |
/* This is actually a static link, or it is a |
bfd_boolean dyn = htab->elf.dynamic_sections_created; |
10161 |
-Bsymbolic link and the symbol is defined |
if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, |
10162 |
locally, or the symbol was forced to be local |
&h->elf) |
10163 |
because of a version file. We must initialize |
|| (info->shared |
10164 |
this entry in the global offset table. Since the |
&& SYMBOL_REFERENCES_LOCAL (info, &h->elf))) |
10165 |
offset must always be a multiple of 8, we use the |
/* This is actually a static link, or it is a |
10166 |
least significant bit to record whether we have |
-Bsymbolic link and the symbol is defined |
10167 |
initialized it already. |
locally, or the symbol was forced to be local |
10168 |
|
because of a version file. */ |
10169 |
When doing a dynamic link, we create a .rel.got |
; |
|
relocation entry to initialize the value. This |
|
|
is done in the finish_dynamic_symbol routine. */ |
|
|
if ((off & 1) != 0) |
|
|
off &= ~1; |
|
10170 |
else |
else |
10171 |
{ |
{ |
10172 |
bfd_put_64 (output_bfd, relocation, |
indx = h->elf.dynindx; |
10173 |
htab->sgot->contents + off); |
unresolved_reloc = FALSE; |
|
h->got.offset |= 1; |
|
10174 |
} |
} |
10175 |
|
ent = h->elf.got.glist; |
10176 |
} |
} |
10177 |
else |
else |
10178 |
unresolved_reloc = false; |
{ |
10179 |
|
if (local_got_ents == NULL) |
10180 |
|
abort (); |
10181 |
|
ent = local_got_ents[r_symndx]; |
10182 |
|
} |
10183 |
|
|
10184 |
|
for (; ent != NULL; ent = ent->next) |
10185 |
|
if (ent->addend == rel->r_addend |
10186 |
|
&& ent->owner == input_bfd |
10187 |
|
&& ent->tls_type == tls_type) |
10188 |
|
break; |
10189 |
|
if (ent == NULL) |
10190 |
|
abort (); |
10191 |
|
offp = &ent->got.offset; |
10192 |
} |
} |
10193 |
|
|
10194 |
|
got = ppc64_elf_tdata (input_bfd)->got; |
10195 |
|
if (got == NULL) |
10196 |
|
abort (); |
10197 |
|
|
10198 |
|
/* The offset must always be a multiple of 8. We use the |
10199 |
|
least significant bit to record whether we have already |
10200 |
|
processed this entry. */ |
10201 |
|
off = *offp; |
10202 |
|
if ((off & 1) != 0) |
10203 |
|
off &= ~1; |
10204 |
else |
else |
10205 |
{ |
{ |
10206 |
if (local_got_offsets == NULL) |
/* Generate relocs for the dynamic linker, except in |
10207 |
abort (); |
the case of TLSLD where we'll use one entry per |
10208 |
|
module. */ |
10209 |
|
asection *relgot = ppc64_elf_tdata (input_bfd)->relgot; |
10210 |
|
|
10211 |
|
*offp = off | 1; |
10212 |
|
if ((info->shared || indx != 0) |
10213 |
|
&& (h == NULL |
10214 |
|
|| ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT |
10215 |
|
|| h->elf.root.type != bfd_link_hash_undefweak)) |
10216 |
|
{ |
10217 |
|
outrel.r_offset = (got->output_section->vma |
10218 |
|
+ got->output_offset |
10219 |
|
+ off); |
10220 |
|
outrel.r_addend = rel->r_addend; |
10221 |
|
if (tls_type & (TLS_LD | TLS_GD)) |
10222 |
|
{ |
10223 |
|
outrel.r_addend = 0; |
10224 |
|
outrel.r_info = ELF64_R_INFO (indx, R_PPC64_DTPMOD64); |
10225 |
|
if (tls_type == (TLS_TLS | TLS_GD)) |
10226 |
|
{ |
10227 |
|
loc = relgot->contents; |
10228 |
|
loc += (relgot->reloc_count++ |
10229 |
|
* sizeof (Elf64_External_Rela)); |
10230 |
|
bfd_elf64_swap_reloca_out (output_bfd, |
10231 |
|
&outrel, loc); |
10232 |
|
outrel.r_offset += 8; |
10233 |
|
outrel.r_addend = rel->r_addend; |
10234 |
|
outrel.r_info |
10235 |
|
= ELF64_R_INFO (indx, R_PPC64_DTPREL64); |
10236 |
|
} |
10237 |
|
} |
10238 |
|
else if (tls_type == (TLS_TLS | TLS_DTPREL)) |
10239 |
|
outrel.r_info = ELF64_R_INFO (indx, R_PPC64_DTPREL64); |
10240 |
|
else if (tls_type == (TLS_TLS | TLS_TPREL)) |
10241 |
|
outrel.r_info = ELF64_R_INFO (indx, R_PPC64_TPREL64); |
10242 |
|
else if (indx == 0) |
10243 |
|
{ |
10244 |
|
outrel.r_info = ELF64_R_INFO (indx, R_PPC64_RELATIVE); |
10245 |
|
|
10246 |
off = local_got_offsets[r_symndx]; |
/* Write the .got section contents for the sake |
10247 |
|
of prelink. */ |
10248 |
|
loc = got->contents + off; |
10249 |
|
bfd_put_64 (output_bfd, outrel.r_addend + relocation, |
10250 |
|
loc); |
10251 |
|
} |
10252 |
|
else |
10253 |
|
outrel.r_info = ELF64_R_INFO (indx, R_PPC64_GLOB_DAT); |
10254 |
|
|
10255 |
|
if (indx == 0 && tls_type != (TLS_TLS | TLS_LD)) |
10256 |
|
{ |
10257 |
|
outrel.r_addend += relocation; |
10258 |
|
if (tls_type & (TLS_GD | TLS_DTPREL | TLS_TPREL)) |
10259 |
|
outrel.r_addend -= htab->elf.tls_sec->vma; |
10260 |
|
} |
10261 |
|
loc = relgot->contents; |
10262 |
|
loc += (relgot->reloc_count++ |
10263 |
|
* sizeof (Elf64_External_Rela)); |
10264 |
|
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); |
10265 |
|
} |
10266 |
|
|
10267 |
/* The offset must always be a multiple of 8. We use |
/* Init the .got section contents here if we're not |
10268 |
the least significant bit to record whether we have |
emitting a reloc. */ |
|
already processed this entry. */ |
|
|
if ((off & 1) != 0) |
|
|
off &= ~1; |
|
10269 |
else |
else |
10270 |
{ |
{ |
10271 |
bfd_put_64 (output_bfd, relocation, |
relocation += rel->r_addend; |
10272 |
htab->sgot->contents + off); |
if (tls_type == (TLS_TLS | TLS_LD)) |
10273 |
|
relocation = 1; |
10274 |
if (info->shared) |
else if (tls_type != 0) |
10275 |
{ |
{ |
10276 |
Elf_Internal_Rela outrel; |
relocation -= htab->elf.tls_sec->vma + DTP_OFFSET; |
10277 |
Elf64_External_Rela *loc; |
if (tls_type == (TLS_TLS | TLS_TPREL)) |
10278 |
|
relocation += DTP_OFFSET - TP_OFFSET; |
10279 |
/* We need to generate a R_PPC64_RELATIVE reloc |
|
10280 |
for the dynamic linker. */ |
if (tls_type == (TLS_TLS | TLS_GD)) |
10281 |
outrel.r_offset = (htab->sgot->output_section->vma |
{ |
10282 |
+ htab->sgot->output_offset |
bfd_put_64 (output_bfd, relocation, |
10283 |
+ off); |
got->contents + off + 8); |
10284 |
outrel.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); |
relocation = 1; |
10285 |
outrel.r_addend = relocation; |
} |
|
loc = (Elf64_External_Rela *) htab->srelgot->contents; |
|
|
loc += htab->srelgot->reloc_count++; |
|
|
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); |
|
10286 |
} |
} |
10287 |
|
|
10288 |
local_got_offsets[r_symndx] |= 1; |
bfd_put_64 (output_bfd, relocation, |
10289 |
|
got->contents + off); |
10290 |
} |
} |
10291 |
} |
} |
10292 |
|
|
10293 |
if (off >= (bfd_vma) -2) |
if (off >= (bfd_vma) -2) |
10294 |
abort (); |
abort (); |
10295 |
|
|
10296 |
relocation = htab->sgot->output_offset + off; |
relocation = got->output_offset + off; |
10297 |
|
|
10298 |
/* TOC base (r2) is TOC start plus 0x8000. */ |
/* TOC base (r2) is TOC start plus 0x8000. */ |
10299 |
addend -= TOC_BASE_OFF; |
addend = -TOC_BASE_OFF; |
10300 |
} |
} |
10301 |
break; |
break; |
10302 |
|
|
10313 |
if (h == NULL) |
if (h == NULL) |
10314 |
break; |
break; |
10315 |
|
|
10316 |
if (h->plt.offset == (bfd_vma) -1 |
/* It's possible that we didn't make a PLT entry for this |
10317 |
|| htab->splt == NULL) |
symbol. This happens when statically linking PIC code, |
10318 |
{ |
or when using -Bsymbolic. Go find a match if there is a |
10319 |
/* We didn't make a PLT entry for this symbol. This |
PLT entry. */ |
10320 |
happens when statically linking PIC code, or when |
if (htab->plt != NULL) |
10321 |
using -Bsymbolic. */ |
{ |
10322 |
break; |
struct plt_entry *ent; |
10323 |
|
for (ent = h->elf.plt.plist; ent != NULL; ent = ent->next) |
10324 |
|
if (ent->addend == rel->r_addend |
10325 |
|
&& ent->plt.offset != (bfd_vma) -1) |
10326 |
|
{ |
10327 |
|
relocation = (htab->plt->output_section->vma |
10328 |
|
+ htab->plt->output_offset |
10329 |
|
+ ent->plt.offset); |
10330 |
|
unresolved_reloc = FALSE; |
10331 |
|
} |
10332 |
} |
} |
|
|
|
|
relocation = (htab->splt->output_section->vma |
|
|
+ htab->splt->output_offset |
|
|
+ h->plt.offset); |
|
|
unresolved_reloc = false; |
|
10333 |
break; |
break; |
10334 |
|
|
10335 |
|
case R_PPC64_TOC: |
10336 |
|
/* Relocation value is TOC base. */ |
10337 |
|
relocation = TOCstart; |
10338 |
|
if (r_symndx == 0) |
10339 |
|
relocation += htab->stub_group[input_section->id].toc_off; |
10340 |
|
else if (unresolved_reloc) |
10341 |
|
; |
10342 |
|
else if (sec != NULL && sec->id <= htab->top_id) |
10343 |
|
relocation += htab->stub_group[sec->id].toc_off; |
10344 |
|
else |
10345 |
|
unresolved_reloc = TRUE; |
10346 |
|
goto dodyn2; |
10347 |
|
|
10348 |
/* TOC16 relocs. We want the offset relative to the TOC base, |
/* TOC16 relocs. We want the offset relative to the TOC base, |
10349 |
which is the address of the start of the TOC plus 0x8000. |
which is the address of the start of the TOC plus 0x8000. |
10350 |
The TOC consists of sections .got, .toc, .tocbss, and .plt, |
The TOC consists of sections .got, .toc, .tocbss, and .plt, |
10355 |
case R_PPC64_TOC16_DS: |
case R_PPC64_TOC16_DS: |
10356 |
case R_PPC64_TOC16_LO_DS: |
case R_PPC64_TOC16_LO_DS: |
10357 |
case R_PPC64_TOC16_HA: |
case R_PPC64_TOC16_HA: |
10358 |
addend -= TOCstart + TOC_BASE_OFF; |
addend -= TOCstart + htab->stub_group[input_section->id].toc_off; |
10359 |
break; |
break; |
10360 |
|
|
10361 |
/* Relocate against the beginning of the section. */ |
/* Relocate against the beginning of the section. */ |
10365 |
case R_PPC64_SECTOFF_DS: |
case R_PPC64_SECTOFF_DS: |
10366 |
case R_PPC64_SECTOFF_LO_DS: |
case R_PPC64_SECTOFF_LO_DS: |
10367 |
case R_PPC64_SECTOFF_HA: |
case R_PPC64_SECTOFF_HA: |
10368 |
if (sec != (asection *) 0) |
if (sec != NULL) |
10369 |
addend -= sec->output_section->vma; |
addend -= sec->output_section->vma; |
10370 |
break; |
break; |
10371 |
|
|
10375 |
case R_PPC64_REL24: |
case R_PPC64_REL24: |
10376 |
break; |
break; |
10377 |
|
|
10378 |
|
case R_PPC64_TPREL16: |
10379 |
|
case R_PPC64_TPREL16_LO: |
10380 |
|
case R_PPC64_TPREL16_HI: |
10381 |
|
case R_PPC64_TPREL16_HA: |
10382 |
|
case R_PPC64_TPREL16_DS: |
10383 |
|
case R_PPC64_TPREL16_LO_DS: |
10384 |
|
case R_PPC64_TPREL16_HIGHER: |
10385 |
|
case R_PPC64_TPREL16_HIGHERA: |
10386 |
|
case R_PPC64_TPREL16_HIGHEST: |
10387 |
|
case R_PPC64_TPREL16_HIGHESTA: |
10388 |
|
addend -= htab->elf.tls_sec->vma + TP_OFFSET; |
10389 |
|
if (info->shared) |
10390 |
|
/* The TPREL16 relocs shouldn't really be used in shared |
10391 |
|
libs as they will result in DT_TEXTREL being set, but |
10392 |
|
support them anyway. */ |
10393 |
|
goto dodyn; |
10394 |
|
break; |
10395 |
|
|
10396 |
|
case R_PPC64_DTPREL16: |
10397 |
|
case R_PPC64_DTPREL16_LO: |
10398 |
|
case R_PPC64_DTPREL16_HI: |
10399 |
|
case R_PPC64_DTPREL16_HA: |
10400 |
|
case R_PPC64_DTPREL16_DS: |
10401 |
|
case R_PPC64_DTPREL16_LO_DS: |
10402 |
|
case R_PPC64_DTPREL16_HIGHER: |
10403 |
|
case R_PPC64_DTPREL16_HIGHERA: |
10404 |
|
case R_PPC64_DTPREL16_HIGHEST: |
10405 |
|
case R_PPC64_DTPREL16_HIGHESTA: |
10406 |
|
addend -= htab->elf.tls_sec->vma + DTP_OFFSET; |
10407 |
|
break; |
10408 |
|
|
10409 |
|
case R_PPC64_DTPMOD64: |
10410 |
|
relocation = 1; |
10411 |
|
addend = 0; |
10412 |
|
goto dodyn; |
10413 |
|
|
10414 |
|
case R_PPC64_TPREL64: |
10415 |
|
addend -= htab->elf.tls_sec->vma + TP_OFFSET; |
10416 |
|
goto dodyn; |
10417 |
|
|
10418 |
|
case R_PPC64_DTPREL64: |
10419 |
|
addend -= htab->elf.tls_sec->vma + DTP_OFFSET; |
10420 |
|
/* Fall thru */ |
10421 |
|
|
10422 |
/* Relocations that may need to be propagated if this is a |
/* Relocations that may need to be propagated if this is a |
10423 |
dynamic object. */ |
dynamic object. */ |
10424 |
|
case R_PPC64_REL30: |
10425 |
case R_PPC64_REL32: |
case R_PPC64_REL32: |
10426 |
case R_PPC64_REL64: |
case R_PPC64_REL64: |
10427 |
case R_PPC64_ADDR14: |
case R_PPC64_ADDR14: |
10438 |
case R_PPC64_ADDR16_LO: |
case R_PPC64_ADDR16_LO: |
10439 |
case R_PPC64_ADDR16_LO_DS: |
case R_PPC64_ADDR16_LO_DS: |
10440 |
case R_PPC64_ADDR24: |
case R_PPC64_ADDR24: |
|
case R_PPC64_ADDR30: |
|
10441 |
case R_PPC64_ADDR32: |
case R_PPC64_ADDR32: |
10442 |
case R_PPC64_ADDR64: |
case R_PPC64_ADDR64: |
10443 |
case R_PPC64_UADDR16: |
case R_PPC64_UADDR16: |
10446 |
/* r_symndx will be zero only for relocs against symbols |
/* r_symndx will be zero only for relocs against symbols |
10447 |
from removed linkonce sections, or sections discarded by |
from removed linkonce sections, or sections discarded by |
10448 |
a linker script. */ |
a linker script. */ |
10449 |
|
dodyn: |
10450 |
if (r_symndx == 0) |
if (r_symndx == 0) |
10451 |
break; |
break; |
10452 |
/* Fall thru. */ |
/* Fall thru. */ |
10453 |
|
|
10454 |
case R_PPC64_TOC: |
dodyn2: |
10455 |
if ((input_section->flags & SEC_ALLOC) == 0) |
if ((input_section->flags & SEC_ALLOC) == 0) |
10456 |
break; |
break; |
10457 |
|
|
10459 |
break; |
break; |
10460 |
|
|
10461 |
if ((info->shared |
if ((info->shared |
10462 |
&& (IS_ABSOLUTE_RELOC (r_type) |
&& (h == NULL |
10463 |
|| (h != NULL |
|| ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT |
10464 |
&& h->dynindx != -1 |
|| h->elf.root.type != bfd_link_hash_undefweak) |
10465 |
&& (! info->symbolic |
&& (MUST_BE_DYN_RELOC (r_type) |
10466 |
|| (h->elf_link_hash_flags |
|| !SYMBOL_CALLS_LOCAL (info, &h->elf))) |
10467 |
& ELF_LINK_HASH_DEF_REGULAR) == 0)))) |
|| (ELIMINATE_COPY_RELOCS |
10468 |
|| (!info->shared |
&& !info->shared |
10469 |
&& h != NULL |
&& h != NULL |
10470 |
&& h->dynindx != -1 |
&& h->elf.dynindx != -1 |
10471 |
&& (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 |
&& !h->elf.non_got_ref |
10472 |
&& (((h->elf_link_hash_flags |
&& h->elf.def_dynamic |
10473 |
& ELF_LINK_HASH_DEF_DYNAMIC) != 0 |
&& !h->elf.def_regular)) |
|
&& (h->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR) == 0) |
|
|
|| h->root.type == bfd_link_hash_undefweak |
|
|
|| h->root.type == bfd_link_hash_undefined))) |
|
10474 |
{ |
{ |
10475 |
Elf_Internal_Rela outrel; |
Elf_Internal_Rela outrel; |
10476 |
boolean skip, relocate; |
bfd_boolean skip, relocate; |
10477 |
asection *sreloc; |
asection *sreloc; |
10478 |
Elf64_External_Rela *loc; |
bfd_byte *loc; |
10479 |
|
bfd_vma out_off; |
10480 |
|
|
10481 |
/* When generating a dynamic object, these relocations |
/* When generating a dynamic object, these relocations |
10482 |
are copied into the output file to be resolved at run |
are copied into the output file to be resolved at run |
10483 |
time. */ |
time. */ |
10484 |
|
|
10485 |
skip = false; |
skip = FALSE; |
10486 |
relocate = false; |
relocate = FALSE; |
10487 |
|
|
10488 |
outrel.r_offset = |
out_off = _bfd_elf_section_offset (output_bfd, info, |
10489 |
_bfd_elf_section_offset (output_bfd, info, input_section, |
input_section, rel->r_offset); |
10490 |
rel->r_offset); |
if (out_off == (bfd_vma) -1) |
10491 |
if (outrel.r_offset == (bfd_vma) -1) |
skip = TRUE; |
10492 |
skip = true; |
else if (out_off == (bfd_vma) -2) |
10493 |
else if (outrel.r_offset == (bfd_vma) -2) |
skip = TRUE, relocate = TRUE; |
10494 |
skip = true, relocate = true; |
out_off += (input_section->output_section->vma |
10495 |
outrel.r_offset += (input_section->output_section->vma |
+ input_section->output_offset); |
10496 |
+ input_section->output_offset); |
outrel.r_offset = out_off; |
10497 |
outrel.r_addend = addend; |
outrel.r_addend = rel->r_addend; |
10498 |
|
|
10499 |
|
/* Optimize unaligned reloc use. */ |
10500 |
|
if ((r_type == R_PPC64_ADDR64 && (out_off & 7) != 0) |
10501 |
|
|| (r_type == R_PPC64_UADDR64 && (out_off & 7) == 0)) |
10502 |
|
r_type ^= R_PPC64_ADDR64 ^ R_PPC64_UADDR64; |
10503 |
|
else if ((r_type == R_PPC64_ADDR32 && (out_off & 3) != 0) |
10504 |
|
|| (r_type == R_PPC64_UADDR32 && (out_off & 3) == 0)) |
10505 |
|
r_type ^= R_PPC64_ADDR32 ^ R_PPC64_UADDR32; |
10506 |
|
else if ((r_type == R_PPC64_ADDR16 && (out_off & 1) != 0) |
10507 |
|
|| (r_type == R_PPC64_UADDR16 && (out_off & 1) == 0)) |
10508 |
|
r_type ^= R_PPC64_ADDR16 ^ R_PPC64_UADDR16; |
10509 |
|
|
10510 |
if (skip) |
if (skip) |
10511 |
memset (&outrel, 0, sizeof outrel); |
memset (&outrel, 0, sizeof outrel); |
10512 |
else if (h != NULL |
else if (!SYMBOL_REFERENCES_LOCAL (info, &h->elf) |
|
&& h->dynindx != -1 |
|
10513 |
&& !is_opd |
&& !is_opd |
10514 |
&& (!IS_ABSOLUTE_RELOC (r_type) |
&& r_type != R_PPC64_TOC) |
10515 |
|| !info->shared |
outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type); |
|
|| !info->symbolic |
|
|
|| (h->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR) == 0)) |
|
|
outrel.r_info = ELF64_R_INFO (h->dynindx, r_type); |
|
10516 |
else |
else |
10517 |
{ |
{ |
10518 |
/* This symbol is local, or marked to become local, |
/* This symbol is local, or marked to become local, |
10519 |
or this is an opd section reloc which must point |
or this is an opd section reloc which must point |
10520 |
at a local function. */ |
at a local function. */ |
10521 |
outrel.r_addend += relocation; |
outrel.r_addend += relocation; |
|
relocate = true; |
|
10522 |
if (r_type == R_PPC64_ADDR64 || r_type == R_PPC64_TOC) |
if (r_type == R_PPC64_ADDR64 || r_type == R_PPC64_TOC) |
10523 |
{ |
{ |
10524 |
if (is_opd && h != NULL) |
if (is_opd && h != NULL) |
10533 |
bug in binutils handling of weak syms.) |
bug in binutils handling of weak syms.) |
10534 |
In these cases we won't use the opd |
In these cases we won't use the opd |
10535 |
entry in this lib. */ |
entry in this lib. */ |
10536 |
unresolved_reloc = false; |
unresolved_reloc = FALSE; |
10537 |
} |
} |
10538 |
outrel.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); |
outrel.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); |
10539 |
|
|
10540 |
|
/* We need to relocate .opd contents for ld.so. |
10541 |
|
Prelink also wants simple and consistent rules |
10542 |
|
for relocs. This make all RELATIVE relocs have |
10543 |
|
*r_offset equal to r_addend. */ |
10544 |
|
relocate = TRUE; |
10545 |
} |
} |
10546 |
else |
else |
10547 |
{ |
{ |
10552 |
else if (sec == NULL || sec->owner == NULL) |
else if (sec == NULL || sec->owner == NULL) |
10553 |
{ |
{ |
10554 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
10555 |
return false; |
return FALSE; |
10556 |
} |
} |
10557 |
else |
else |
10558 |
{ |
{ |
10577 |
if (sreloc == NULL) |
if (sreloc == NULL) |
10578 |
abort (); |
abort (); |
10579 |
|
|
10580 |
loc = (Elf64_External_Rela *) sreloc->contents; |
loc = sreloc->contents; |
10581 |
loc += sreloc->reloc_count++; |
loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela); |
10582 |
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); |
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); |
10583 |
|
|
10584 |
/* If this reloc is against an external symbol, it will |
/* If this reloc is against an external symbol, it will |
10585 |
be computed at runtime, so there's no need to do |
be computed at runtime, so there's no need to do |
10586 |
anything now. */ |
anything now. However, for the sake of prelink ensure |
10587 |
|
that the section contents are a known value. */ |
10588 |
if (! relocate) |
if (! relocate) |
10589 |
continue; |
{ |
10590 |
|
unresolved_reloc = FALSE; |
10591 |
|
/* The value chosen here is quite arbitrary as ld.so |
10592 |
|
ignores section contents except for the special |
10593 |
|
case of .opd where the contents might be accessed |
10594 |
|
before relocation. Choose zero, as that won't |
10595 |
|
cause reloc overflow. */ |
10596 |
|
relocation = 0; |
10597 |
|
addend = 0; |
10598 |
|
/* Use *r_offset == r_addend for R_PPC64_ADDR64 relocs |
10599 |
|
to improve backward compatibility with older |
10600 |
|
versions of ld. */ |
10601 |
|
if (r_type == R_PPC64_ADDR64) |
10602 |
|
addend = outrel.r_addend; |
10603 |
|
/* Adjust pc_relative relocs to have zero in *r_offset. */ |
10604 |
|
else if (ppc64_elf_howto_table[r_type]->pc_relative) |
10605 |
|
addend = (input_section->output_section->vma |
10606 |
|
+ input_section->output_offset |
10607 |
|
+ rel->r_offset); |
10608 |
|
} |
10609 |
} |
} |
10610 |
break; |
break; |
10611 |
|
|
10615 |
case R_PPC64_RELATIVE: |
case R_PPC64_RELATIVE: |
10616 |
/* We shouldn't ever see these dynamic relocs in relocatable |
/* We shouldn't ever see these dynamic relocs in relocatable |
10617 |
files. */ |
files. */ |
10618 |
/* Fall thru */ |
/* Fall through. */ |
10619 |
|
|
10620 |
case R_PPC64_PLTGOT16: |
case R_PPC64_PLTGOT16: |
10621 |
case R_PPC64_PLTGOT16_DS: |
case R_PPC64_PLTGOT16_DS: |
10628 |
/* These ones haven't been implemented yet. */ |
/* These ones haven't been implemented yet. */ |
10629 |
|
|
10630 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
10631 |
(_("%s: Relocation %s is not supported for symbol %s."), |
(_("%B: relocation %s is not supported for symbol %s."), |
10632 |
bfd_archive_filename (input_bfd), |
input_bfd, |
10633 |
ppc64_elf_howto_table[(int) r_type]->name, sym_name); |
ppc64_elf_howto_table[r_type]->name, sym_name); |
10634 |
|
|
10635 |
bfd_set_error (bfd_error_invalid_operation); |
bfd_set_error (bfd_error_invalid_operation); |
10636 |
ret = false; |
ret = FALSE; |
10637 |
continue; |
continue; |
10638 |
} |
} |
10639 |
|
|
10646 |
case R_PPC64_ADDR16_HA: |
case R_PPC64_ADDR16_HA: |
10647 |
case R_PPC64_ADDR16_HIGHERA: |
case R_PPC64_ADDR16_HIGHERA: |
10648 |
case R_PPC64_ADDR16_HIGHESTA: |
case R_PPC64_ADDR16_HIGHESTA: |
10649 |
|
case R_PPC64_GOT16_HA: |
10650 |
|
case R_PPC64_PLTGOT16_HA: |
10651 |
case R_PPC64_PLT16_HA: |
case R_PPC64_PLT16_HA: |
10652 |
case R_PPC64_TOC16_HA: |
case R_PPC64_TOC16_HA: |
10653 |
case R_PPC64_SECTOFF_HA: |
case R_PPC64_SECTOFF_HA: |
10654 |
|
case R_PPC64_TPREL16_HA: |
10655 |
|
case R_PPC64_DTPREL16_HA: |
10656 |
|
case R_PPC64_GOT_TLSGD16_HA: |
10657 |
|
case R_PPC64_GOT_TLSLD16_HA: |
10658 |
|
case R_PPC64_GOT_TPREL16_HA: |
10659 |
|
case R_PPC64_GOT_DTPREL16_HA: |
10660 |
|
case R_PPC64_TPREL16_HIGHER: |
10661 |
|
case R_PPC64_TPREL16_HIGHERA: |
10662 |
|
case R_PPC64_TPREL16_HIGHEST: |
10663 |
|
case R_PPC64_TPREL16_HIGHESTA: |
10664 |
|
case R_PPC64_DTPREL16_HIGHER: |
10665 |
|
case R_PPC64_DTPREL16_HIGHERA: |
10666 |
|
case R_PPC64_DTPREL16_HIGHEST: |
10667 |
|
case R_PPC64_DTPREL16_HIGHESTA: |
10668 |
/* It's just possible that this symbol is a weak symbol |
/* It's just possible that this symbol is a weak symbol |
10669 |
that's not actually defined anywhere. In that case, |
that's not actually defined anywhere. In that case, |
10670 |
'sec' would be NULL, and we should leave the symbol |
'sec' would be NULL, and we should leave the symbol |
10671 |
alone (it will be set to zero elsewhere in the link). */ |
alone (it will be set to zero elsewhere in the link). */ |
10672 |
if (sec != NULL) |
if (sec != NULL) |
10673 |
/* Add 0x10000 if sign bit in 0:15 is set. */ |
/* Add 0x10000 if sign bit in 0:15 is set. |
10674 |
addend += ((relocation + addend) & 0x8000) << 1; |
Bits 0:15 are not used. */ |
10675 |
|
addend += 0x8000; |
10676 |
break; |
break; |
10677 |
|
|
10678 |
case R_PPC64_ADDR16_DS: |
case R_PPC64_ADDR16_DS: |
10686 |
case R_PPC64_TOC16_LO_DS: |
case R_PPC64_TOC16_LO_DS: |
10687 |
case R_PPC64_PLTGOT16_DS: |
case R_PPC64_PLTGOT16_DS: |
10688 |
case R_PPC64_PLTGOT16_LO_DS: |
case R_PPC64_PLTGOT16_LO_DS: |
10689 |
if (((relocation + addend) & 3) != 0) |
case R_PPC64_GOT_TPREL16_DS: |
10690 |
|
case R_PPC64_GOT_TPREL16_LO_DS: |
10691 |
|
case R_PPC64_GOT_DTPREL16_DS: |
10692 |
|
case R_PPC64_GOT_DTPREL16_LO_DS: |
10693 |
|
case R_PPC64_TPREL16_DS: |
10694 |
|
case R_PPC64_TPREL16_LO_DS: |
10695 |
|
case R_PPC64_DTPREL16_DS: |
10696 |
|
case R_PPC64_DTPREL16_LO_DS: |
10697 |
|
insn = bfd_get_32 (input_bfd, contents + (rel->r_offset & ~3)); |
10698 |
|
mask = 3; |
10699 |
|
/* If this reloc is against an lq insn, then the value must be |
10700 |
|
a multiple of 16. This is somewhat of a hack, but the |
10701 |
|
"correct" way to do this by defining _DQ forms of all the |
10702 |
|
_DS relocs bloats all reloc switches in this file. It |
10703 |
|
doesn't seem to make much sense to use any of these relocs |
10704 |
|
in data, so testing the insn should be safe. */ |
10705 |
|
if ((insn & (0x3f << 26)) == (56u << 26)) |
10706 |
|
mask = 15; |
10707 |
|
if (((relocation + addend) & mask) != 0) |
10708 |
{ |
{ |
10709 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
10710 |
(_("%s: error: relocation %s not a multiple of 4"), |
(_("%B: error: relocation %s not a multiple of %d"), |
10711 |
bfd_archive_filename (input_bfd), |
input_bfd, |
10712 |
ppc64_elf_howto_table[(int) r_type]->name); |
ppc64_elf_howto_table[r_type]->name, |
10713 |
|
mask + 1); |
10714 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
10715 |
ret = false; |
ret = FALSE; |
10716 |
continue; |
continue; |
10717 |
} |
} |
10718 |
break; |
break; |
|
|
|
|
case R_PPC64_REL14: |
|
|
case R_PPC64_REL14_BRNTAKEN: |
|
|
case R_PPC64_REL14_BRTAKEN: |
|
|
max_br_offset = 1 << 15; |
|
|
goto branch_check; |
|
|
|
|
|
case R_PPC64_REL24: |
|
|
max_br_offset = 1 << 25; |
|
|
|
|
|
branch_check: |
|
|
/* If the branch is out of reach, then redirect the |
|
|
call to the local stub for this function. */ |
|
|
from = (offset |
|
|
+ input_section->output_offset |
|
|
+ input_section->output_section->vma); |
|
|
if (relocation + addend - from + max_br_offset >= 2 * max_br_offset |
|
|
&& (stub_entry = ppc_get_stub_entry (input_section, sec, h, |
|
|
rel, htab)) != NULL) |
|
|
{ |
|
|
/* Munge up the value and addend so that we call the stub |
|
|
rather than the procedure directly. */ |
|
|
relocation = (stub_entry->stub_offset |
|
|
+ stub_entry->stub_sec->output_offset |
|
|
+ stub_entry->stub_sec->output_section->vma); |
|
|
addend = 0; |
|
|
} |
|
|
break; |
|
10719 |
} |
} |
10720 |
|
|
10721 |
/* Dynamic relocs are not propagated for SEC_DEBUGGING sections |
/* Dynamic relocs are not propagated for SEC_DEBUGGING sections |
10723 |
not process them. */ |
not process them. */ |
10724 |
if (unresolved_reloc |
if (unresolved_reloc |
10725 |
&& !((input_section->flags & SEC_DEBUGGING) != 0 |
&& !((input_section->flags & SEC_DEBUGGING) != 0 |
10726 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) |
&& h->elf.def_dynamic)) |
10727 |
{ |
{ |
10728 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
10729 |
(_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), |
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"), |
10730 |
bfd_archive_filename (input_bfd), |
input_bfd, |
10731 |
bfd_get_section_name (input_bfd, input_section), |
input_section, |
10732 |
(long) rel->r_offset, |
(long) rel->r_offset, |
10733 |
h->root.root.string); |
ppc64_elf_howto_table[(int) r_type]->name, |
10734 |
ret = false; |
h->elf.root.root.string); |
10735 |
|
ret = FALSE; |
10736 |
} |
} |
10737 |
|
|
10738 |
r = _bfd_final_link_relocate (ppc64_elf_howto_table[(int) r_type], |
r = _bfd_final_link_relocate (ppc64_elf_howto_table[(int) r_type], |
10739 |
input_bfd, |
input_bfd, |
10740 |
input_section, |
input_section, |
10741 |
contents, |
contents, |
10742 |
offset, |
rel->r_offset, |
10743 |
relocation, |
relocation, |
10744 |
addend); |
addend); |
10745 |
|
|
10746 |
if (r != bfd_reloc_ok) |
if (r != bfd_reloc_ok) |
10747 |
{ |
{ |
10748 |
const char *name; |
if (sym_name == NULL) |
10749 |
|
sym_name = "(null)"; |
10750 |
if (h != NULL) |
if (r == bfd_reloc_overflow) |
10751 |
{ |
{ |
10752 |
if (h->root.type == bfd_link_hash_undefweak |
if (warned) |
10753 |
&& ppc64_elf_howto_table[(int) r_type]->pc_relative) |
continue; |
10754 |
|
if (h != NULL |
10755 |
|
&& h->elf.root.type == bfd_link_hash_undefweak |
10756 |
|
&& ppc64_elf_howto_table[r_type]->pc_relative) |
10757 |
{ |
{ |
10758 |
/* Assume this is a call protected by other code that |
/* Assume this is a call protected by other code that |
10759 |
detects the symbol is undefined. If this is the case, |
detects the symbol is undefined. If this is the case, |
10764 |
continue; |
continue; |
10765 |
} |
} |
10766 |
|
|
|
name = h->root.root.string; |
|
|
} |
|
|
else |
|
|
{ |
|
|
name = bfd_elf_string_from_elf_section (input_bfd, |
|
|
symtab_hdr->sh_link, |
|
|
sym->st_name); |
|
|
if (name == NULL) |
|
|
continue; |
|
|
if (*name == '\0') |
|
|
name = bfd_section_name (input_bfd, sec); |
|
|
} |
|
|
|
|
|
if (r == bfd_reloc_overflow) |
|
|
{ |
|
|
if (warned) |
|
|
continue; |
|
10767 |
if (!((*info->callbacks->reloc_overflow) |
if (!((*info->callbacks->reloc_overflow) |
10768 |
(info, name, ppc64_elf_howto_table[(int) r_type]->name, |
(info, (h ? &h->elf.root : NULL), sym_name, |
10769 |
rel->r_addend, input_bfd, input_section, offset))) |
ppc64_elf_howto_table[r_type]->name, |
10770 |
return false; |
rel->r_addend, input_bfd, input_section, rel->r_offset))) |
10771 |
|
return FALSE; |
10772 |
} |
} |
10773 |
else |
else |
10774 |
{ |
{ |
10775 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
10776 |
(_("%s(%s+0x%lx): reloc against `%s': error %d"), |
(_("%B(%A+0x%lx): %s reloc against `%s': error %d"), |
10777 |
bfd_archive_filename (input_bfd), |
input_bfd, |
10778 |
bfd_get_section_name (input_bfd, input_section), |
input_section, |
10779 |
(long) rel->r_offset, name, (int) r); |
(long) rel->r_offset, |
10780 |
ret = false; |
ppc64_elf_howto_table[r_type]->name, |
10781 |
|
sym_name, |
10782 |
|
(int) r); |
10783 |
|
ret = FALSE; |
10784 |
} |
} |
10785 |
} |
} |
10786 |
} |
} |
10787 |
|
|
10788 |
|
/* If we're emitting relocations, then shortly after this function |
10789 |
|
returns, reloc offsets and addends for this section will be |
10790 |
|
adjusted. Worse, reloc symbol indices will be for the output |
10791 |
|
file rather than the input. Save a copy of the relocs for |
10792 |
|
opd_entry_value. */ |
10793 |
|
if (is_opd && info->emitrelocations) |
10794 |
|
{ |
10795 |
|
bfd_size_type amt; |
10796 |
|
amt = input_section->reloc_count * sizeof (Elf_Internal_Rela); |
10797 |
|
rel = bfd_alloc (input_bfd, amt); |
10798 |
|
BFD_ASSERT (ppc64_elf_tdata (input_bfd)->opd_relocs == NULL); |
10799 |
|
ppc64_elf_tdata (input_bfd)->opd_relocs = rel; |
10800 |
|
if (rel == NULL) |
10801 |
|
return FALSE; |
10802 |
|
memcpy (rel, relocs, amt); |
10803 |
|
} |
10804 |
return ret; |
return ret; |
10805 |
} |
} |
10806 |
|
|
10807 |
|
/* Adjust the value of any local symbols in opd sections. */ |
10808 |
|
|
10809 |
|
static bfd_boolean |
10810 |
|
ppc64_elf_output_symbol_hook (struct bfd_link_info *info, |
10811 |
|
const char *name ATTRIBUTE_UNUSED, |
10812 |
|
Elf_Internal_Sym *elfsym, |
10813 |
|
asection *input_sec, |
10814 |
|
struct elf_link_hash_entry *h) |
10815 |
|
{ |
10816 |
|
long *opd_adjust, adjust; |
10817 |
|
bfd_vma value; |
10818 |
|
|
10819 |
|
if (h != NULL) |
10820 |
|
return TRUE; |
10821 |
|
|
10822 |
|
opd_adjust = get_opd_info (input_sec); |
10823 |
|
if (opd_adjust == NULL) |
10824 |
|
return TRUE; |
10825 |
|
|
10826 |
|
value = elfsym->st_value - input_sec->output_offset; |
10827 |
|
if (!info->relocatable) |
10828 |
|
value -= input_sec->output_section->vma; |
10829 |
|
|
10830 |
|
adjust = opd_adjust[value / 8]; |
10831 |
|
if (adjust == -1) |
10832 |
|
elfsym->st_value = 0; |
10833 |
|
else |
10834 |
|
elfsym->st_value += adjust; |
10835 |
|
return TRUE; |
10836 |
|
} |
10837 |
|
|
10838 |
/* Finish up dynamic symbol handling. We set the contents of various |
/* Finish up dynamic symbol handling. We set the contents of various |
10839 |
dynamic sections here. */ |
dynamic sections here. */ |
10840 |
|
|
10841 |
static boolean |
static bfd_boolean |
10842 |
ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) |
ppc64_elf_finish_dynamic_symbol (bfd *output_bfd, |
10843 |
bfd *output_bfd; |
struct bfd_link_info *info, |
10844 |
struct bfd_link_info *info; |
struct elf_link_hash_entry *h, |
10845 |
struct elf_link_hash_entry *h; |
Elf_Internal_Sym *sym) |
|
Elf_Internal_Sym *sym; |
|
10846 |
{ |
{ |
10847 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
10848 |
bfd *dynobj; |
bfd *dynobj; |
10849 |
|
struct plt_entry *ent; |
10850 |
|
Elf_Internal_Rela rela; |
10851 |
|
bfd_byte *loc; |
10852 |
|
|
10853 |
htab = ppc_hash_table (info); |
htab = ppc_hash_table (info); |
10854 |
dynobj = htab->elf.dynobj; |
dynobj = htab->elf.dynobj; |
10855 |
|
|
10856 |
if (h->plt.offset != (bfd_vma) -1 |
for (ent = h->plt.plist; ent != NULL; ent = ent->next) |
10857 |
&& ((struct ppc_link_hash_entry *) h)->is_func_descriptor) |
if (ent->plt.offset != (bfd_vma) -1) |
10858 |
{ |
{ |
10859 |
Elf_Internal_Rela rela; |
/* This symbol has an entry in the procedure linkage |
10860 |
Elf64_External_Rela *loc; |
table. Set it up. */ |
10861 |
|
|
10862 |
/* This symbol has an entry in the procedure linkage table. Set |
if (htab->plt == NULL |
10863 |
it up. */ |
|| htab->relplt == NULL |
10864 |
|
|| htab->glink == NULL) |
10865 |
if (htab->splt == NULL |
abort (); |
10866 |
|| htab->srelplt == NULL |
|
10867 |
|| htab->sglink == NULL) |
/* Create a JMP_SLOT reloc to inform the dynamic linker to |
10868 |
abort (); |
fill in the PLT entry. */ |
10869 |
|
rela.r_offset = (htab->plt->output_section->vma |
10870 |
/* Create a JMP_SLOT reloc to inform the dynamic linker to |
+ htab->plt->output_offset |
10871 |
fill in the PLT entry. */ |
+ ent->plt.offset); |
10872 |
|
rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_JMP_SLOT); |
10873 |
rela.r_offset = (htab->splt->output_section->vma |
rela.r_addend = ent->addend; |
10874 |
+ htab->splt->output_offset |
|
10875 |
+ h->plt.offset); |
loc = htab->relplt->contents; |
10876 |
rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_JMP_SLOT); |
loc += ((ent->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE |
10877 |
rela.r_addend = 0; |
* sizeof (Elf64_External_Rela)); |
10878 |
|
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); |
10879 |
loc = (Elf64_External_Rela *) htab->srelplt->contents; |
} |
|
loc += (h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE; |
|
|
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); |
|
|
} |
|
|
|
|
|
if (h->got.offset != (bfd_vma) -1) |
|
|
{ |
|
|
Elf_Internal_Rela rela; |
|
|
Elf64_External_Rela *loc; |
|
|
|
|
|
/* This symbol has an entry in the global offset table. Set it |
|
|
up. */ |
|
|
|
|
|
if (htab->sgot == NULL || htab->srelgot == NULL) |
|
|
abort (); |
|
|
|
|
|
rela.r_offset = (htab->sgot->output_section->vma |
|
|
+ htab->sgot->output_offset |
|
|
+ (h->got.offset &~ (bfd_vma) 1)); |
|
|
|
|
|
/* If this is a static link, or it is a -Bsymbolic link and the |
|
|
symbol is defined locally or was forced to be local because |
|
|
of a version file, we just want to emit a RELATIVE reloc. |
|
|
The entry in the global offset table will already have been |
|
|
initialized in the relocate_section function. */ |
|
|
if (info->shared |
|
|
&& (info->symbolic |
|
|
|| h->dynindx == -1 |
|
|
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)) |
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) |
|
|
{ |
|
|
BFD_ASSERT((h->got.offset & 1) != 0); |
|
|
rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); |
|
|
rela.r_addend = (h->root.u.def.value |
|
|
+ h->root.u.def.section->output_section->vma |
|
|
+ h->root.u.def.section->output_offset); |
|
|
} |
|
|
else |
|
|
{ |
|
|
BFD_ASSERT ((h->got.offset & 1) == 0); |
|
|
bfd_put_64 (output_bfd, (bfd_vma) 0, |
|
|
htab->sgot->contents + h->got.offset); |
|
|
rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_GLOB_DAT); |
|
|
rela.r_addend = 0; |
|
|
} |
|
|
|
|
|
loc = (Elf64_External_Rela *) htab->srelgot->contents; |
|
|
loc += htab->srelgot->reloc_count++; |
|
|
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); |
|
|
} |
|
10880 |
|
|
10881 |
if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0) |
if (h->needs_copy) |
10882 |
{ |
{ |
10883 |
Elf_Internal_Rela rela; |
Elf_Internal_Rela rela; |
10884 |
Elf64_External_Rela *loc; |
bfd_byte *loc; |
10885 |
|
|
10886 |
/* This symbol needs a copy reloc. Set it up. */ |
/* This symbol needs a copy reloc. Set it up. */ |
10887 |
|
|
10888 |
if (h->dynindx == -1 |
if (h->dynindx == -1 |
10889 |
|| (h->root.type != bfd_link_hash_defined |
|| (h->root.type != bfd_link_hash_defined |
10890 |
&& h->root.type != bfd_link_hash_defweak) |
&& h->root.type != bfd_link_hash_defweak) |
10891 |
|| htab->srelbss == NULL) |
|| htab->relbss == NULL) |
10892 |
abort (); |
abort (); |
10893 |
|
|
10894 |
rela.r_offset = (h->root.u.def.value |
rela.r_offset = (h->root.u.def.value |
10896 |
+ h->root.u.def.section->output_offset); |
+ h->root.u.def.section->output_offset); |
10897 |
rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_COPY); |
rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_COPY); |
10898 |
rela.r_addend = 0; |
rela.r_addend = 0; |
10899 |
loc = (Elf64_External_Rela *) htab->srelbss->contents; |
loc = htab->relbss->contents; |
10900 |
loc += htab->srelbss->reloc_count++; |
loc += htab->relbss->reloc_count++ * sizeof (Elf64_External_Rela); |
10901 |
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); |
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); |
10902 |
} |
} |
10903 |
|
|
10905 |
if (strcmp (h->root.root.string, "_DYNAMIC") == 0) |
if (strcmp (h->root.root.string, "_DYNAMIC") == 0) |
10906 |
sym->st_shndx = SHN_ABS; |
sym->st_shndx = SHN_ABS; |
10907 |
|
|
10908 |
return true; |
return TRUE; |
10909 |
} |
} |
10910 |
|
|
10911 |
/* Used to decide how to sort relocs in an optimal manner for the |
/* Used to decide how to sort relocs in an optimal manner for the |
10912 |
dynamic linker, before writing them out. */ |
dynamic linker, before writing them out. */ |
10913 |
|
|
10914 |
static enum elf_reloc_type_class |
static enum elf_reloc_type_class |
10915 |
ppc64_elf_reloc_type_class (rela) |
ppc64_elf_reloc_type_class (const Elf_Internal_Rela *rela) |
|
const Elf_Internal_Rela *rela; |
|
10916 |
{ |
{ |
10917 |
enum elf_ppc_reloc_type r_type; |
enum elf_ppc64_reloc_type r_type; |
10918 |
|
|
10919 |
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rela->r_info); |
r_type = ELF64_R_TYPE (rela->r_info); |
10920 |
switch (r_type) |
switch (r_type) |
10921 |
{ |
{ |
10922 |
case R_PPC64_RELATIVE: |
case R_PPC64_RELATIVE: |
10932 |
|
|
10933 |
/* Finish up the dynamic sections. */ |
/* Finish up the dynamic sections. */ |
10934 |
|
|
10935 |
static boolean |
static bfd_boolean |
10936 |
ppc64_elf_finish_dynamic_sections (output_bfd, info) |
ppc64_elf_finish_dynamic_sections (bfd *output_bfd, |
10937 |
bfd *output_bfd; |
struct bfd_link_info *info) |
|
struct bfd_link_info *info; |
|
10938 |
{ |
{ |
10939 |
struct ppc_link_hash_table *htab; |
struct ppc_link_hash_table *htab; |
10940 |
bfd *dynobj; |
bfd *dynobj; |
10948 |
{ |
{ |
10949 |
Elf64_External_Dyn *dyncon, *dynconend; |
Elf64_External_Dyn *dyncon, *dynconend; |
10950 |
|
|
10951 |
if (sdyn == NULL || htab->sgot == NULL) |
if (sdyn == NULL || htab->got == NULL) |
10952 |
abort (); |
abort (); |
10953 |
|
|
10954 |
dyncon = (Elf64_External_Dyn *) sdyn->contents; |
dyncon = (Elf64_External_Dyn *) sdyn->contents; |
10955 |
dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); |
dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); |
10956 |
for (; dyncon < dynconend; dyncon++) |
for (; dyncon < dynconend; dyncon++) |
10957 |
{ |
{ |
10958 |
Elf_Internal_Dyn dyn; |
Elf_Internal_Dyn dyn; |
10966 |
continue; |
continue; |
10967 |
|
|
10968 |
case DT_PPC64_GLINK: |
case DT_PPC64_GLINK: |
10969 |
dyn.d_un.d_ptr = (htab->sglink->output_section->vma |
s = htab->glink; |
10970 |
+ htab->sglink->output_offset); |
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; |
10971 |
|
/* We stupidly defined DT_PPC64_GLINK to be the start |
10972 |
|
of glink rather than the first entry point, which is |
10973 |
|
what ld.so needs, and now have a bigger stub to |
10974 |
|
support automatic multiple TOCs. */ |
10975 |
|
dyn.d_un.d_ptr += GLINK_CALL_STUB_SIZE - 32; |
10976 |
break; |
break; |
10977 |
|
|
10978 |
case DT_PPC64_OPD: |
case DT_PPC64_OPD: |
10979 |
s = bfd_get_section_by_name (output_bfd, ".opd"); |
s = bfd_get_section_by_name (output_bfd, ".opd"); |
10980 |
if (s != NULL) |
if (s == NULL) |
10981 |
dyn.d_un.d_ptr = s->vma; |
continue; |
10982 |
|
dyn.d_un.d_ptr = s->vma; |
10983 |
break; |
break; |
10984 |
|
|
10985 |
case DT_PPC64_OPDSZ: |
case DT_PPC64_OPDSZ: |
10986 |
s = bfd_get_section_by_name (output_bfd, ".opd"); |
s = bfd_get_section_by_name (output_bfd, ".opd"); |
10987 |
if (s != NULL) |
if (s == NULL) |
10988 |
dyn.d_un.d_val = s->_raw_size; |
continue; |
10989 |
|
dyn.d_un.d_val = s->size; |
10990 |
break; |
break; |
10991 |
|
|
10992 |
case DT_PLTGOT: |
case DT_PLTGOT: |
10993 |
dyn.d_un.d_ptr = (htab->splt->output_section->vma |
s = htab->plt; |
10994 |
+ htab->splt->output_offset); |
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; |
10995 |
break; |
break; |
10996 |
|
|
10997 |
case DT_JMPREL: |
case DT_JMPREL: |
10998 |
dyn.d_un.d_ptr = (htab->srelplt->output_section->vma |
s = htab->relplt; |
10999 |
+ htab->srelplt->output_offset); |
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; |
11000 |
break; |
break; |
11001 |
|
|
11002 |
case DT_PLTRELSZ: |
case DT_PLTRELSZ: |
11003 |
dyn.d_un.d_val = htab->srelplt->_raw_size; |
dyn.d_un.d_val = htab->relplt->size; |
11004 |
break; |
break; |
11005 |
|
|
11006 |
case DT_RELASZ: |
case DT_RELASZ: |
11007 |
/* Don't count procedure linkage table relocs in the |
/* Don't count procedure linkage table relocs in the |
11008 |
overall reloc count. */ |
overall reloc count. */ |
11009 |
if (htab->srelplt != NULL) |
s = htab->relplt; |
11010 |
dyn.d_un.d_val -= htab->srelplt->_raw_size; |
if (s == NULL) |
11011 |
|
continue; |
11012 |
|
dyn.d_un.d_val -= s->size; |
11013 |
|
break; |
11014 |
|
|
11015 |
|
case DT_RELA: |
11016 |
|
/* We may not be using the standard ELF linker script. |
11017 |
|
If .rela.plt is the first .rela section, we adjust |
11018 |
|
DT_RELA to not include it. */ |
11019 |
|
s = htab->relplt; |
11020 |
|
if (s == NULL) |
11021 |
|
continue; |
11022 |
|
if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset) |
11023 |
|
continue; |
11024 |
|
dyn.d_un.d_ptr += s->size; |
11025 |
break; |
break; |
11026 |
} |
} |
11027 |
|
|
11029 |
} |
} |
11030 |
} |
} |
11031 |
|
|
11032 |
if (htab->sgot != NULL && htab->sgot->_raw_size != 0) |
if (htab->got != NULL && htab->got->size != 0) |
11033 |
{ |
{ |
11034 |
/* Fill in the first entry in the global offset table. |
/* Fill in the first entry in the global offset table. |
11035 |
We use it to hold the link-time TOCbase. */ |
We use it to hold the link-time TOCbase. */ |
11036 |
bfd_put_64 (output_bfd, |
bfd_put_64 (output_bfd, |
11037 |
elf_gp (output_bfd) + TOC_BASE_OFF, |
elf_gp (output_bfd) + TOC_BASE_OFF, |
11038 |
htab->sgot->contents); |
htab->got->contents); |
11039 |
|
|
11040 |
/* Set .got entry size. */ |
/* Set .got entry size. */ |
11041 |
elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 8; |
elf_section_data (htab->got->output_section)->this_hdr.sh_entsize = 8; |
11042 |
} |
} |
11043 |
|
|
11044 |
if (htab->splt != NULL && htab->splt->_raw_size != 0) |
if (htab->plt != NULL && htab->plt->size != 0) |
11045 |
{ |
{ |
11046 |
/* Set .plt entry size. */ |
/* Set .plt entry size. */ |
11047 |
elf_section_data (htab->splt->output_section)->this_hdr.sh_entsize |
elf_section_data (htab->plt->output_section)->this_hdr.sh_entsize |
11048 |
= PLT_ENTRY_SIZE; |
= PLT_ENTRY_SIZE; |
11049 |
} |
} |
11050 |
|
|
11051 |
return true; |
/* We need to handle writing out multiple GOT sections ourselves, |
11052 |
} |
since we didn't add them to DYNOBJ. We know dynobj is the first |
11053 |
|
bfd. */ |
11054 |
#define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec |
while ((dynobj = dynobj->link_next) != NULL) |
11055 |
#define TARGET_LITTLE_NAME "elf64-powerpcle" |
{ |
11056 |
#define TARGET_BIG_SYM bfd_elf64_powerpc_vec |
asection *s; |
|
#define TARGET_BIG_NAME "elf64-powerpc" |
|
|
#define ELF_ARCH bfd_arch_powerpc |
|
|
#define ELF_MACHINE_CODE EM_PPC64 |
|
|
#define ELF_MAXPAGESIZE 0x10000 |
|
|
#define elf_info_to_howto ppc64_elf_info_to_howto |
|
|
|
|
|
#ifdef EM_CYGNUS_POWERPC |
|
|
#define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC |
|
|
#endif |
|
|
|
|
|
#ifdef EM_PPC_OLD |
|
|
#define ELF_MACHINE_ALT2 EM_PPC_OLD |
|
|
#endif |
|
11057 |
|
|
11058 |
#define elf_backend_want_got_sym 0 |
if (!is_ppc64_elf_target (dynobj->xvec)) |
11059 |
#define elf_backend_want_plt_sym 0 |
continue; |
|
#define elf_backend_plt_alignment 3 |
|
|
#define elf_backend_plt_not_loaded 1 |
|
|
#define elf_backend_got_symbol_offset 0 |
|
|
#define elf_backend_got_header_size 8 |
|
|
#define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE |
|
|
#define elf_backend_can_gc_sections 1 |
|
|
#define elf_backend_can_refcount 1 |
|
|
#define elf_backend_rela_normal 1 |
|
11060 |
|
|
11061 |
#define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup |
s = ppc64_elf_tdata (dynobj)->got; |
11062 |
#define bfd_elf64_bfd_merge_private_bfd_data ppc64_elf_merge_private_bfd_data |
if (s != NULL |
11063 |
#define bfd_elf64_bfd_link_hash_table_create ppc64_elf_link_hash_table_create |
&& s->size != 0 |
11064 |
#define bfd_elf64_bfd_link_hash_table_free ppc64_elf_link_hash_table_free |
&& s->output_section != bfd_abs_section_ptr |
11065 |
|
&& !bfd_set_section_contents (output_bfd, s->output_section, |
11066 |
|
s->contents, s->output_offset, |
11067 |
|
s->size)) |
11068 |
|
return FALSE; |
11069 |
|
s = ppc64_elf_tdata (dynobj)->relgot; |
11070 |
|
if (s != NULL |
11071 |
|
&& s->size != 0 |
11072 |
|
&& s->output_section != bfd_abs_section_ptr |
11073 |
|
&& !bfd_set_section_contents (output_bfd, s->output_section, |
11074 |
|
s->contents, s->output_offset, |
11075 |
|
s->size)) |
11076 |
|
return FALSE; |
11077 |
|
} |
11078 |
|
|
11079 |
#define elf_backend_object_p ppc64_elf_object_p |
return TRUE; |
11080 |
#define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections |
} |
|
#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol |
|
|
#define elf_backend_check_relocs ppc64_elf_check_relocs |
|
|
#define elf_backend_gc_mark_hook ppc64_elf_gc_mark_hook |
|
|
#define elf_backend_gc_sweep_hook ppc64_elf_gc_sweep_hook |
|
|
#define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol |
|
|
#define elf_backend_hide_symbol ppc64_elf_hide_symbol |
|
|
#define elf_backend_always_size_sections ppc64_elf_func_desc_adjust |
|
|
#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections |
|
|
#define elf_backend_relocate_section ppc64_elf_relocate_section |
|
|
#define elf_backend_finish_dynamic_symbol ppc64_elf_finish_dynamic_symbol |
|
|
#define elf_backend_reloc_type_class ppc64_elf_reloc_type_class |
|
|
#define elf_backend_finish_dynamic_sections ppc64_elf_finish_dynamic_sections |
|
11081 |
|
|
11082 |
#include "elf64-target.h" |
#include "elf64-target.h" |