1 /* IBM S/390-specific support for 64-bit ELF
2 Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
3 2010, 2011, 2012 Free Software Foundation, Inc.
4 Contributed Martin Schwidefsky (schwidefsky@de.ibm.com).
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
30 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
31 from smaller values. Start with zero, widen, *then* decrement. */
32 #define MINUS_ONE (((bfd_vma)0) - 1)
34 static bfd_reloc_status_type
35 s390_tls_reloc (bfd
*, arelent
*, asymbol
*, void *,
36 asection
*, bfd
*, char **);
37 static bfd_reloc_status_type
38 s390_elf_ldisp_reloc (bfd
*, arelent
*, asymbol
*, void *,
39 asection
*, bfd
*, char **);
41 /* The relocation "howto" table. */
42 static reloc_howto_type elf_howto_table
[] =
44 HOWTO (R_390_NONE
, /* type */
46 0, /* size (0 = byte, 1 = short, 2 = long) */
48 FALSE
, /* pc_relative */
50 complain_overflow_dont
, /* complain_on_overflow */
51 bfd_elf_generic_reloc
, /* special_function */
52 "R_390_NONE", /* name */
53 FALSE
, /* partial_inplace */
56 FALSE
), /* pcrel_offset */
58 HOWTO(R_390_8
, 0, 0, 8, FALSE
, 0, complain_overflow_bitfield
,
59 bfd_elf_generic_reloc
, "R_390_8", FALSE
, 0,0x000000ff, FALSE
),
60 HOWTO(R_390_12
, 0, 1, 12, FALSE
, 0, complain_overflow_dont
,
61 bfd_elf_generic_reloc
, "R_390_12", FALSE
, 0,0x00000fff, FALSE
),
62 HOWTO(R_390_16
, 0, 1, 16, FALSE
, 0, complain_overflow_bitfield
,
63 bfd_elf_generic_reloc
, "R_390_16", FALSE
, 0,0x0000ffff, FALSE
),
64 HOWTO(R_390_32
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
65 bfd_elf_generic_reloc
, "R_390_32", FALSE
, 0,0xffffffff, FALSE
),
66 HOWTO(R_390_PC32
, 0, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
67 bfd_elf_generic_reloc
, "R_390_PC32", FALSE
, 0,0xffffffff, TRUE
),
68 HOWTO(R_390_GOT12
, 0, 1, 12, FALSE
, 0, complain_overflow_bitfield
,
69 bfd_elf_generic_reloc
, "R_390_GOT12", FALSE
, 0,0x00000fff, FALSE
),
70 HOWTO(R_390_GOT32
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
71 bfd_elf_generic_reloc
, "R_390_GOT32", FALSE
, 0,0xffffffff, FALSE
),
72 HOWTO(R_390_PLT32
, 0, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
73 bfd_elf_generic_reloc
, "R_390_PLT32", FALSE
, 0,0xffffffff, TRUE
),
74 HOWTO(R_390_COPY
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
75 bfd_elf_generic_reloc
, "R_390_COPY", FALSE
, 0,MINUS_ONE
, FALSE
),
76 HOWTO(R_390_GLOB_DAT
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
77 bfd_elf_generic_reloc
, "R_390_GLOB_DAT", FALSE
, 0,MINUS_ONE
, FALSE
),
78 HOWTO(R_390_JMP_SLOT
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
79 bfd_elf_generic_reloc
, "R_390_JMP_SLOT", FALSE
, 0,MINUS_ONE
, FALSE
),
80 HOWTO(R_390_RELATIVE
, 0, 4, 64, TRUE
, 0, complain_overflow_bitfield
,
81 bfd_elf_generic_reloc
, "R_390_RELATIVE", FALSE
, 0,MINUS_ONE
, FALSE
),
82 HOWTO(R_390_GOTOFF32
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
83 bfd_elf_generic_reloc
, "R_390_GOTOFF32", FALSE
, 0,MINUS_ONE
, FALSE
),
84 HOWTO(R_390_GOTPC
, 0, 4, 64, TRUE
, 0, complain_overflow_bitfield
,
85 bfd_elf_generic_reloc
, "R_390_GOTPC", FALSE
, 0,MINUS_ONE
, TRUE
),
86 HOWTO(R_390_GOT16
, 0, 1, 16, FALSE
, 0, complain_overflow_bitfield
,
87 bfd_elf_generic_reloc
, "R_390_GOT16", FALSE
, 0,0x0000ffff, FALSE
),
88 HOWTO(R_390_PC16
, 0, 1, 16, TRUE
, 0, complain_overflow_bitfield
,
89 bfd_elf_generic_reloc
, "R_390_PC16", FALSE
, 0,0x0000ffff, TRUE
),
90 HOWTO(R_390_PC16DBL
, 1, 1, 16, TRUE
, 0, complain_overflow_bitfield
,
91 bfd_elf_generic_reloc
, "R_390_PC16DBL", FALSE
, 0,0x0000ffff, TRUE
),
92 HOWTO(R_390_PLT16DBL
, 1, 1, 16, TRUE
, 0, complain_overflow_bitfield
,
93 bfd_elf_generic_reloc
, "R_390_PLT16DBL", FALSE
, 0,0x0000ffff, TRUE
),
94 HOWTO(R_390_PC32DBL
, 1, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
95 bfd_elf_generic_reloc
, "R_390_PC32DBL", FALSE
, 0,0xffffffff, TRUE
),
96 HOWTO(R_390_PLT32DBL
, 1, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
97 bfd_elf_generic_reloc
, "R_390_PLT32DBL", FALSE
, 0,0xffffffff, TRUE
),
98 HOWTO(R_390_GOTPCDBL
, 1, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
99 bfd_elf_generic_reloc
, "R_390_GOTPCDBL", FALSE
, 0,MINUS_ONE
, TRUE
),
100 HOWTO(R_390_64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
101 bfd_elf_generic_reloc
, "R_390_64", FALSE
, 0,MINUS_ONE
, FALSE
),
102 HOWTO(R_390_PC64
, 0, 4, 64, TRUE
, 0, complain_overflow_bitfield
,
103 bfd_elf_generic_reloc
, "R_390_PC64", FALSE
, 0,MINUS_ONE
, TRUE
),
104 HOWTO(R_390_GOT64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
105 bfd_elf_generic_reloc
, "R_390_GOT64", FALSE
, 0,MINUS_ONE
, FALSE
),
106 HOWTO(R_390_PLT64
, 0, 4, 64, TRUE
, 0, complain_overflow_bitfield
,
107 bfd_elf_generic_reloc
, "R_390_PLT64", FALSE
, 0,MINUS_ONE
, TRUE
),
108 HOWTO(R_390_GOTENT
, 1, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
109 bfd_elf_generic_reloc
, "R_390_GOTENT", FALSE
, 0,MINUS_ONE
, TRUE
),
110 HOWTO(R_390_GOTOFF16
, 0, 1, 16, FALSE
, 0, complain_overflow_bitfield
,
111 bfd_elf_generic_reloc
, "R_390_GOTOFF16", FALSE
, 0,0x0000ffff, FALSE
),
112 HOWTO(R_390_GOTOFF64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
113 bfd_elf_generic_reloc
, "R_390_GOTOFF64", FALSE
, 0,MINUS_ONE
, FALSE
),
114 HOWTO(R_390_GOTPLT12
, 0, 1, 12, FALSE
, 0, complain_overflow_dont
,
115 bfd_elf_generic_reloc
, "R_390_GOTPLT12", FALSE
, 0,0x00000fff, FALSE
),
116 HOWTO(R_390_GOTPLT16
, 0, 1, 16, FALSE
, 0, complain_overflow_bitfield
,
117 bfd_elf_generic_reloc
, "R_390_GOTPLT16", FALSE
, 0,0x0000ffff, FALSE
),
118 HOWTO(R_390_GOTPLT32
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
119 bfd_elf_generic_reloc
, "R_390_GOTPLT32", FALSE
, 0,0xffffffff, FALSE
),
120 HOWTO(R_390_GOTPLT64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
121 bfd_elf_generic_reloc
, "R_390_GOTPLT64", FALSE
, 0,MINUS_ONE
, FALSE
),
122 HOWTO(R_390_GOTPLTENT
, 1, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
123 bfd_elf_generic_reloc
, "R_390_GOTPLTENT",FALSE
, 0,MINUS_ONE
, TRUE
),
124 HOWTO(R_390_PLTOFF16
, 0, 1, 16, FALSE
, 0, complain_overflow_bitfield
,
125 bfd_elf_generic_reloc
, "R_390_PLTOFF16", FALSE
, 0,0x0000ffff, FALSE
),
126 HOWTO(R_390_PLTOFF32
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
127 bfd_elf_generic_reloc
, "R_390_PLTOFF32", FALSE
, 0,0xffffffff, FALSE
),
128 HOWTO(R_390_PLTOFF64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
129 bfd_elf_generic_reloc
, "R_390_PLTOFF64", FALSE
, 0,MINUS_ONE
, FALSE
),
130 HOWTO(R_390_TLS_LOAD
, 0, 0, 0, FALSE
, 0, complain_overflow_dont
,
131 s390_tls_reloc
, "R_390_TLS_LOAD", FALSE
, 0, 0, FALSE
),
132 HOWTO(R_390_TLS_GDCALL
, 0, 0, 0, FALSE
, 0, complain_overflow_dont
,
133 s390_tls_reloc
, "R_390_TLS_GDCALL", FALSE
, 0, 0, FALSE
),
134 HOWTO(R_390_TLS_LDCALL
, 0, 0, 0, FALSE
, 0, complain_overflow_dont
,
135 s390_tls_reloc
, "R_390_TLS_LDCALL", FALSE
, 0, 0, FALSE
),
136 EMPTY_HOWTO (R_390_TLS_GD32
), /* Empty entry for R_390_TLS_GD32. */
137 HOWTO(R_390_TLS_GD64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
138 bfd_elf_generic_reloc
, "R_390_TLS_GD64", FALSE
, 0, MINUS_ONE
, FALSE
),
139 HOWTO(R_390_TLS_GOTIE12
, 0, 1, 12, FALSE
, 0, complain_overflow_dont
,
140 bfd_elf_generic_reloc
, "R_390_TLS_GOTIE12", FALSE
, 0, 0x00000fff, FALSE
),
141 EMPTY_HOWTO (R_390_TLS_GOTIE32
), /* Empty entry for R_390_TLS_GOTIE32. */
142 HOWTO(R_390_TLS_GOTIE64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
143 bfd_elf_generic_reloc
, "R_390_TLS_GOTIE64", FALSE
, 0, MINUS_ONE
, FALSE
),
144 EMPTY_HOWTO (R_390_TLS_LDM32
), /* Empty entry for R_390_TLS_LDM32. */
145 HOWTO(R_390_TLS_LDM64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
146 bfd_elf_generic_reloc
, "R_390_TLS_LDM64", FALSE
, 0, MINUS_ONE
, FALSE
),
147 EMPTY_HOWTO (R_390_TLS_IE32
), /* Empty entry for R_390_TLS_IE32. */
148 HOWTO(R_390_TLS_IE64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
149 bfd_elf_generic_reloc
, "R_390_TLS_IE64", FALSE
, 0, MINUS_ONE
, FALSE
),
150 HOWTO(R_390_TLS_IEENT
, 1, 2, 32, TRUE
, 0, complain_overflow_bitfield
,
151 bfd_elf_generic_reloc
, "R_390_TLS_IEENT", FALSE
, 0, MINUS_ONE
, TRUE
),
152 EMPTY_HOWTO (R_390_TLS_LE32
), /* Empty entry for R_390_TLS_LE32. */
153 HOWTO(R_390_TLS_LE64
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
154 bfd_elf_generic_reloc
, "R_390_TLS_LE64", FALSE
, 0, MINUS_ONE
, FALSE
),
155 EMPTY_HOWTO (R_390_TLS_LDO32
), /* Empty entry for R_390_TLS_LDO32. */
156 HOWTO(R_390_TLS_LDO64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
157 bfd_elf_generic_reloc
, "R_390_TLS_LDO64", FALSE
, 0, MINUS_ONE
, FALSE
),
158 HOWTO(R_390_TLS_DTPMOD
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
159 bfd_elf_generic_reloc
, "R_390_TLS_DTPMOD", FALSE
, 0, MINUS_ONE
, FALSE
),
160 HOWTO(R_390_TLS_DTPOFF
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
161 bfd_elf_generic_reloc
, "R_390_TLS_DTPOFF", FALSE
, 0, MINUS_ONE
, FALSE
),
162 HOWTO(R_390_TLS_TPOFF
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
163 bfd_elf_generic_reloc
, "R_390_TLS_TPOFF", FALSE
, 0, MINUS_ONE
, FALSE
),
164 HOWTO(R_390_20
, 0, 2, 20, FALSE
, 8, complain_overflow_dont
,
165 s390_elf_ldisp_reloc
, "R_390_20", FALSE
, 0,0x0fffff00, FALSE
),
166 HOWTO(R_390_GOT20
, 0, 2, 20, FALSE
, 8, complain_overflow_dont
,
167 s390_elf_ldisp_reloc
, "R_390_GOT20", FALSE
, 0,0x0fffff00, FALSE
),
168 HOWTO(R_390_GOTPLT20
, 0, 2, 20, FALSE
, 8, complain_overflow_dont
,
169 s390_elf_ldisp_reloc
, "R_390_GOTPLT20", FALSE
, 0,0x0fffff00, FALSE
),
170 HOWTO(R_390_TLS_GOTIE20
, 0, 2, 20, FALSE
, 8, complain_overflow_dont
,
171 s390_elf_ldisp_reloc
, "R_390_TLS_GOTIE20", FALSE
, 0,0x0fffff00, FALSE
),
174 /* GNU extension to record C++ vtable hierarchy. */
175 static reloc_howto_type elf64_s390_vtinherit_howto
=
176 HOWTO (R_390_GNU_VTINHERIT
, 0,4,0,FALSE
,0,complain_overflow_dont
, NULL
, "R_390_GNU_VTINHERIT", FALSE
,0, 0, FALSE
);
177 static reloc_howto_type elf64_s390_vtentry_howto
=
178 HOWTO (R_390_GNU_VTENTRY
, 0,4,0,FALSE
,0,complain_overflow_dont
, _bfd_elf_rel_vtable_reloc_fn
,"R_390_GNU_VTENTRY", FALSE
,0,0, FALSE
);
180 static reloc_howto_type
*
181 elf_s390_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
182 bfd_reloc_code_real_type code
)
187 return &elf_howto_table
[(int) R_390_NONE
];
189 return &elf_howto_table
[(int) R_390_8
];
190 case BFD_RELOC_390_12
:
191 return &elf_howto_table
[(int) R_390_12
];
193 return &elf_howto_table
[(int) R_390_16
];
195 return &elf_howto_table
[(int) R_390_32
];
197 return &elf_howto_table
[(int) R_390_32
];
198 case BFD_RELOC_32_PCREL
:
199 return &elf_howto_table
[(int) R_390_PC32
];
200 case BFD_RELOC_390_GOT12
:
201 return &elf_howto_table
[(int) R_390_GOT12
];
202 case BFD_RELOC_32_GOT_PCREL
:
203 return &elf_howto_table
[(int) R_390_GOT32
];
204 case BFD_RELOC_390_PLT32
:
205 return &elf_howto_table
[(int) R_390_PLT32
];
206 case BFD_RELOC_390_COPY
:
207 return &elf_howto_table
[(int) R_390_COPY
];
208 case BFD_RELOC_390_GLOB_DAT
:
209 return &elf_howto_table
[(int) R_390_GLOB_DAT
];
210 case BFD_RELOC_390_JMP_SLOT
:
211 return &elf_howto_table
[(int) R_390_JMP_SLOT
];
212 case BFD_RELOC_390_RELATIVE
:
213 return &elf_howto_table
[(int) R_390_RELATIVE
];
214 case BFD_RELOC_32_GOTOFF
:
215 return &elf_howto_table
[(int) R_390_GOTOFF32
];
216 case BFD_RELOC_390_GOTPC
:
217 return &elf_howto_table
[(int) R_390_GOTPC
];
218 case BFD_RELOC_390_GOT16
:
219 return &elf_howto_table
[(int) R_390_GOT16
];
220 case BFD_RELOC_16_PCREL
:
221 return &elf_howto_table
[(int) R_390_PC16
];
222 case BFD_RELOC_390_PC16DBL
:
223 return &elf_howto_table
[(int) R_390_PC16DBL
];
224 case BFD_RELOC_390_PLT16DBL
:
225 return &elf_howto_table
[(int) R_390_PLT16DBL
];
226 case BFD_RELOC_390_PC32DBL
:
227 return &elf_howto_table
[(int) R_390_PC32DBL
];
228 case BFD_RELOC_390_PLT32DBL
:
229 return &elf_howto_table
[(int) R_390_PLT32DBL
];
230 case BFD_RELOC_390_GOTPCDBL
:
231 return &elf_howto_table
[(int) R_390_GOTPCDBL
];
233 return &elf_howto_table
[(int) R_390_64
];
234 case BFD_RELOC_64_PCREL
:
235 return &elf_howto_table
[(int) R_390_PC64
];
236 case BFD_RELOC_390_GOT64
:
237 return &elf_howto_table
[(int) R_390_GOT64
];
238 case BFD_RELOC_390_PLT64
:
239 return &elf_howto_table
[(int) R_390_PLT64
];
240 case BFD_RELOC_390_GOTENT
:
241 return &elf_howto_table
[(int) R_390_GOTENT
];
242 case BFD_RELOC_16_GOTOFF
:
243 return &elf_howto_table
[(int) R_390_GOTOFF16
];
244 case BFD_RELOC_390_GOTOFF64
:
245 return &elf_howto_table
[(int) R_390_GOTOFF64
];
246 case BFD_RELOC_390_GOTPLT12
:
247 return &elf_howto_table
[(int) R_390_GOTPLT12
];
248 case BFD_RELOC_390_GOTPLT16
:
249 return &elf_howto_table
[(int) R_390_GOTPLT16
];
250 case BFD_RELOC_390_GOTPLT32
:
251 return &elf_howto_table
[(int) R_390_GOTPLT32
];
252 case BFD_RELOC_390_GOTPLT64
:
253 return &elf_howto_table
[(int) R_390_GOTPLT64
];
254 case BFD_RELOC_390_GOTPLTENT
:
255 return &elf_howto_table
[(int) R_390_GOTPLTENT
];
256 case BFD_RELOC_390_PLTOFF16
:
257 return &elf_howto_table
[(int) R_390_PLTOFF16
];
258 case BFD_RELOC_390_PLTOFF32
:
259 return &elf_howto_table
[(int) R_390_PLTOFF32
];
260 case BFD_RELOC_390_PLTOFF64
:
261 return &elf_howto_table
[(int) R_390_PLTOFF64
];
262 case BFD_RELOC_390_TLS_LOAD
:
263 return &elf_howto_table
[(int) R_390_TLS_LOAD
];
264 case BFD_RELOC_390_TLS_GDCALL
:
265 return &elf_howto_table
[(int) R_390_TLS_GDCALL
];
266 case BFD_RELOC_390_TLS_LDCALL
:
267 return &elf_howto_table
[(int) R_390_TLS_LDCALL
];
268 case BFD_RELOC_390_TLS_GD64
:
269 return &elf_howto_table
[(int) R_390_TLS_GD64
];
270 case BFD_RELOC_390_TLS_GOTIE12
:
271 return &elf_howto_table
[(int) R_390_TLS_GOTIE12
];
272 case BFD_RELOC_390_TLS_GOTIE64
:
273 return &elf_howto_table
[(int) R_390_TLS_GOTIE64
];
274 case BFD_RELOC_390_TLS_LDM64
:
275 return &elf_howto_table
[(int) R_390_TLS_LDM64
];
276 case BFD_RELOC_390_TLS_IE64
:
277 return &elf_howto_table
[(int) R_390_TLS_IE64
];
278 case BFD_RELOC_390_TLS_IEENT
:
279 return &elf_howto_table
[(int) R_390_TLS_IEENT
];
280 case BFD_RELOC_390_TLS_LE64
:
281 return &elf_howto_table
[(int) R_390_TLS_LE64
];
282 case BFD_RELOC_390_TLS_LDO64
:
283 return &elf_howto_table
[(int) R_390_TLS_LDO64
];
284 case BFD_RELOC_390_TLS_DTPMOD
:
285 return &elf_howto_table
[(int) R_390_TLS_DTPMOD
];
286 case BFD_RELOC_390_TLS_DTPOFF
:
287 return &elf_howto_table
[(int) R_390_TLS_DTPOFF
];
288 case BFD_RELOC_390_TLS_TPOFF
:
289 return &elf_howto_table
[(int) R_390_TLS_TPOFF
];
290 case BFD_RELOC_390_20
:
291 return &elf_howto_table
[(int) R_390_20
];
292 case BFD_RELOC_390_GOT20
:
293 return &elf_howto_table
[(int) R_390_GOT20
];
294 case BFD_RELOC_390_GOTPLT20
:
295 return &elf_howto_table
[(int) R_390_GOTPLT20
];
296 case BFD_RELOC_390_TLS_GOTIE20
:
297 return &elf_howto_table
[(int) R_390_TLS_GOTIE20
];
298 case BFD_RELOC_VTABLE_INHERIT
:
299 return &elf64_s390_vtinherit_howto
;
300 case BFD_RELOC_VTABLE_ENTRY
:
301 return &elf64_s390_vtentry_howto
;
308 static reloc_howto_type
*
309 elf_s390_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
315 i
< sizeof (elf_howto_table
) / sizeof (elf_howto_table
[0]);
317 if (elf_howto_table
[i
].name
!= NULL
318 && strcasecmp (elf_howto_table
[i
].name
, r_name
) == 0)
319 return &elf_howto_table
[i
];
321 if (strcasecmp (elf64_s390_vtinherit_howto
.name
, r_name
) == 0)
322 return &elf64_s390_vtinherit_howto
;
323 if (strcasecmp (elf64_s390_vtentry_howto
.name
, r_name
) == 0)
324 return &elf64_s390_vtentry_howto
;
329 /* We need to use ELF64_R_TYPE so we have our own copy of this function,
330 and elf64-s390.c has its own copy. */
333 elf_s390_info_to_howto (bfd
*abfd ATTRIBUTE_UNUSED
,
335 Elf_Internal_Rela
*dst
)
337 unsigned int r_type
= ELF64_R_TYPE(dst
->r_info
);
340 case R_390_GNU_VTINHERIT
:
341 cache_ptr
->howto
= &elf64_s390_vtinherit_howto
;
344 case R_390_GNU_VTENTRY
:
345 cache_ptr
->howto
= &elf64_s390_vtentry_howto
;
349 if (r_type
>= sizeof (elf_howto_table
) / sizeof (elf_howto_table
[0]))
351 (*_bfd_error_handler
) (_("%B: invalid relocation type %d"),
355 cache_ptr
->howto
= &elf_howto_table
[r_type
];
359 /* A relocation function which doesn't do anything. */
360 static bfd_reloc_status_type
361 s390_tls_reloc (bfd
*abfd ATTRIBUTE_UNUSED
,
362 arelent
*reloc_entry
,
363 asymbol
*symbol ATTRIBUTE_UNUSED
,
364 void * data ATTRIBUTE_UNUSED
,
365 asection
*input_section
,
367 char **error_message ATTRIBUTE_UNUSED
)
370 reloc_entry
->address
+= input_section
->output_offset
;
374 /* Handle the large displacement relocs. */
375 static bfd_reloc_status_type
376 s390_elf_ldisp_reloc (bfd
*abfd
,
377 arelent
*reloc_entry
,
380 asection
*input_section
,
382 char **error_message ATTRIBUTE_UNUSED
)
384 reloc_howto_type
*howto
= reloc_entry
->howto
;
388 if (output_bfd
!= (bfd
*) NULL
389 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
390 && (! howto
->partial_inplace
391 || reloc_entry
->addend
== 0))
393 reloc_entry
->address
+= input_section
->output_offset
;
396 if (output_bfd
!= NULL
)
397 return bfd_reloc_continue
;
399 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
400 return bfd_reloc_outofrange
;
402 relocation
= (symbol
->value
403 + symbol
->section
->output_section
->vma
404 + symbol
->section
->output_offset
);
405 relocation
+= reloc_entry
->addend
;
406 if (howto
->pc_relative
)
408 relocation
-= (input_section
->output_section
->vma
409 + input_section
->output_offset
);
410 relocation
-= reloc_entry
->address
;
413 insn
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
414 insn
|= (relocation
& 0xfff) << 16 | (relocation
& 0xff000) >> 4;
415 bfd_put_32 (abfd
, insn
, (bfd_byte
*) data
+ reloc_entry
->address
);
417 if ((bfd_signed_vma
) relocation
< - 0x80000
418 || (bfd_signed_vma
) relocation
> 0x7ffff)
419 return bfd_reloc_overflow
;
425 elf_s390_is_local_label_name (bfd
*abfd
, const char *name
)
427 if (name
[0] == '.' && (name
[1] == 'X' || name
[1] == 'L'))
430 return _bfd_elf_is_local_label_name (abfd
, name
);
433 /* Functions for the 390 ELF linker. */
435 /* The name of the dynamic interpreter. This is put in the .interp
438 #define ELF_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
440 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
441 copying dynamic variables from a shared lib into an app's dynbss
442 section, and instead use a dynamic relocation to point into the
444 #define ELIMINATE_COPY_RELOCS 1
446 /* The size in bytes of the first entry in the procedure linkage table. */
447 #define PLT_FIRST_ENTRY_SIZE 32
448 /* The size in bytes of an entry in the procedure linkage table. */
449 #define PLT_ENTRY_SIZE 32
451 #define GOT_ENTRY_SIZE 8
453 /* The first three entries in a procedure linkage table are reserved,
454 and the initial contents are unimportant (we zero them out).
455 Subsequent entries look like this. See the SVR4 ABI 386
456 supplement to see how this works. */
458 /* For the s390, simple addr offset can only be 0 - 4096.
459 To use the full 16777216 TB address space, several instructions
460 are needed to load an address in a register and execute
461 a branch( or just saving the address)
463 Furthermore, only r 0 and 1 are free to use!!! */
465 /* The first 3 words in the GOT are then reserved.
466 Word 0 is the address of the dynamic table.
467 Word 1 is a pointer to a structure describing the object
468 Word 2 is used to point to the loader entry address.
470 The code for PLT entries looks like this:
472 The GOT holds the address in the PLT to be executed.
473 The loader then gets:
474 24(15) = Pointer to the structure describing the object.
475 28(15) = Offset in symbol table
476 The loader must then find the module where the function is
477 and insert the address in the GOT.
479 PLT1: LARL 1,<fn>@GOTENT # 6 bytes Load address of GOT entry in r1
480 LG 1,0(1) # 6 bytes Load address from GOT in r1
481 BCR 15,1 # 2 bytes Jump to address
482 RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
483 LGF 1,12(1) # 6 bytes Load offset in symbl table in r1
484 BRCL 15,-x # 6 bytes Jump to start of PLT
485 .long ? # 4 bytes offset into .rela.plt
487 Total = 32 bytes per PLT entry
488 Fixup at offset 2: relative address to GOT entry
489 Fixup at offset 22: relative branch to PLT0
490 Fixup at offset 28: 32 bit offset into .rela.plt
492 A 32 bit offset into the symbol table is enough. It allows for
493 .rela.plt sections up to a size of 2 gigabyte. A single dynamic
494 object (the main program, any shared library) is limited to 4GB in
495 size. Having a .rela.plt of 2GB would already make the .plt
496 section bigger than 8GB. */
498 static const bfd_byte elf_s390x_plt_entry
[PLT_ENTRY_SIZE
] =
500 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, /* larl %r1,. */
501 0xe3, 0x10, 0x10, 0x00, 0x00, 0x04, /* lg %r1,0(%r1) */
502 0x07, 0xf1, /* br %r1 */
503 0x0d, 0x10, /* basr %r1,%r0 */
504 0xe3, 0x10, 0x10, 0x0c, 0x00, 0x14, /* lgf %r1,12(%r1) */
505 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg first plt */
506 0x00, 0x00, 0x00, 0x00 /* .long 0x00000000 */
509 /* The first PLT entry pushes the offset into the symbol table
510 from R1 onto the stack at 56(15) and the loader object info
511 at 48(15), loads the loader address in R1 and jumps to it. */
513 /* The first entry in the PLT:
516 STG 1,56(15) # r1 contains the offset into the symbol table
517 LARL 1,_GLOBAL_OFFSET_TABLE # load address of global offset table
518 MVC 48(8,15),8(1) # move loader ino (object struct address) to stack
519 LG 1,16(1) # get entry address of loader
520 BCR 15,1 # jump to loader
522 Fixup at offset 8: relative address to start of GOT. */
524 static const bfd_byte elf_s390x_first_plt_entry
[PLT_FIRST_ENTRY_SIZE
] =
526 0xe3, 0x10, 0xf0, 0x38, 0x00, 0x24, /* stg %r1,56(%r15) */
527 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, /* larl %r1,. */
528 0xd2, 0x07, 0xf0, 0x30, 0x10, 0x08, /* mvc 48(8,%r15),8(%r1) */
529 0xe3, 0x10, 0x10, 0x10, 0x00, 0x04, /* lg %r1,16(%r1) */
530 0x07, 0xf1, /* br %r1 */
531 0x07, 0x00, /* nopr %r0 */
532 0x07, 0x00, /* nopr %r0 */
533 0x07, 0x00 /* nopr %r0 */
537 /* s390 ELF linker hash entry. */
539 struct elf_s390_link_hash_entry
541 struct elf_link_hash_entry elf
;
543 /* Track dynamic relocs copied for this symbol. */
544 struct elf_dyn_relocs
*dyn_relocs
;
546 /* Number of GOTPLT references for a function. */
547 bfd_signed_vma gotplt_refcount
;
549 #define GOT_UNKNOWN 0
553 #define GOT_TLS_IE_NLT 3
554 unsigned char tls_type
;
557 #define elf_s390_hash_entry(ent) \
558 ((struct elf_s390_link_hash_entry *)(ent))
560 /* NOTE: Keep this structure in sync with
561 the one declared in elf32-s390.c. */
562 struct elf_s390_obj_tdata
564 struct elf_obj_tdata root
;
566 /* TLS type for each local got entry. */
567 char *local_got_tls_type
;
570 #define elf_s390_tdata(abfd) \
571 ((struct elf_s390_obj_tdata *) (abfd)->tdata.any)
573 #define elf_s390_local_got_tls_type(abfd) \
574 (elf_s390_tdata (abfd)->local_got_tls_type)
576 #define is_s390_elf(bfd) \
577 (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
578 && elf_tdata (bfd) != NULL \
579 && elf_object_id (bfd) == S390_ELF_DATA)
582 elf_s390_mkobject (bfd
*abfd
)
584 return bfd_elf_allocate_object (abfd
, sizeof (struct elf_s390_obj_tdata
),
589 elf_s390_object_p (bfd
*abfd
)
591 /* Set the right machine number for an s390 elf32 file. */
592 return bfd_default_set_arch_mach (abfd
, bfd_arch_s390
, bfd_mach_s390_64
);
595 /* s390 ELF linker hash table. */
597 struct elf_s390_link_hash_table
599 struct elf_link_hash_table elf
;
601 /* Short-cuts to get to dynamic linker sections. */
606 bfd_signed_vma refcount
;
610 /* Small local sym cache. */
611 struct sym_cache sym_cache
;
614 /* Get the s390 ELF linker hash table from a link_info structure. */
616 #define elf_s390_hash_table(p) \
617 (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
618 == S390_ELF_DATA ? ((struct elf_s390_link_hash_table *) ((p)->hash)) : NULL)
620 /* Create an entry in an s390 ELF linker hash table. */
622 static struct bfd_hash_entry
*
623 link_hash_newfunc (struct bfd_hash_entry
*entry
,
624 struct bfd_hash_table
*table
,
627 /* Allocate the structure if it has not already been allocated by a
631 entry
= bfd_hash_allocate (table
,
632 sizeof (struct elf_s390_link_hash_entry
));
637 /* Call the allocation method of the superclass. */
638 entry
= _bfd_elf_link_hash_newfunc (entry
, table
, string
);
641 struct elf_s390_link_hash_entry
*eh
;
643 eh
= (struct elf_s390_link_hash_entry
*) entry
;
644 eh
->dyn_relocs
= NULL
;
645 eh
->gotplt_refcount
= 0;
646 eh
->tls_type
= GOT_UNKNOWN
;
652 /* Create an s390 ELF linker hash table. */
654 static struct bfd_link_hash_table
*
655 elf_s390_link_hash_table_create (bfd
*abfd
)
657 struct elf_s390_link_hash_table
*ret
;
658 bfd_size_type amt
= sizeof (struct elf_s390_link_hash_table
);
660 ret
= (struct elf_s390_link_hash_table
*) bfd_malloc (amt
);
664 if (!_bfd_elf_link_hash_table_init (&ret
->elf
, abfd
, link_hash_newfunc
,
665 sizeof (struct elf_s390_link_hash_entry
),
672 ret
->elf
.sgot
= NULL
;
673 ret
->elf
.sgotplt
= NULL
;
674 ret
->elf
.srelgot
= NULL
;
675 ret
->elf
.splt
= NULL
;
676 ret
->elf
.srelplt
= NULL
;
679 ret
->tls_ldm_got
.refcount
= 0;
680 ret
->sym_cache
.abfd
= NULL
;
682 return &ret
->elf
.root
;
685 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
686 shortcuts to them in our hash table. */
689 create_got_section (bfd
*dynobj
,
690 struct bfd_link_info
*info
)
692 struct elf_s390_link_hash_table
*htab
;
694 if (! _bfd_elf_create_got_section (dynobj
, info
))
697 htab
= elf_s390_hash_table (info
);
701 htab
->elf
.sgot
= bfd_get_linker_section (dynobj
, ".got");
702 htab
->elf
.sgotplt
= bfd_get_linker_section (dynobj
, ".got.plt");
703 htab
->elf
.srelgot
= bfd_get_linker_section (dynobj
, ".rela.got");
704 if (!htab
->elf
.sgot
|| !htab
->elf
.sgotplt
|| !htab
->elf
.srelgot
)
709 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
710 .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
714 elf_s390_create_dynamic_sections (bfd
*dynobj
,
715 struct bfd_link_info
*info
)
717 struct elf_s390_link_hash_table
*htab
;
719 htab
= elf_s390_hash_table (info
);
723 if (!htab
->elf
.sgot
&& !create_got_section (dynobj
, info
))
726 if (!_bfd_elf_create_dynamic_sections (dynobj
, info
))
729 htab
->elf
.splt
= bfd_get_linker_section (dynobj
, ".plt");
730 htab
->elf
.srelplt
= bfd_get_linker_section (dynobj
, ".rela.plt");
731 htab
->sdynbss
= bfd_get_linker_section (dynobj
, ".dynbss");
733 htab
->srelbss
= bfd_get_linker_section (dynobj
, ".rela.bss");
735 if (!htab
->elf
.splt
|| !htab
->elf
.srelplt
|| !htab
->sdynbss
736 || (!info
->shared
&& !htab
->srelbss
))
742 /* Copy the extra info we tack onto an elf_link_hash_entry. */
745 elf_s390_copy_indirect_symbol (struct bfd_link_info
*info
,
746 struct elf_link_hash_entry
*dir
,
747 struct elf_link_hash_entry
*ind
)
749 struct elf_s390_link_hash_entry
*edir
, *eind
;
751 edir
= (struct elf_s390_link_hash_entry
*) dir
;
752 eind
= (struct elf_s390_link_hash_entry
*) ind
;
754 if (eind
->dyn_relocs
!= NULL
)
756 if (edir
->dyn_relocs
!= NULL
)
758 struct elf_dyn_relocs
**pp
;
759 struct elf_dyn_relocs
*p
;
761 /* Add reloc counts against the indirect sym to the direct sym
762 list. Merge any entries against the same section. */
763 for (pp
= &eind
->dyn_relocs
; (p
= *pp
) != NULL
; )
765 struct elf_dyn_relocs
*q
;
767 for (q
= edir
->dyn_relocs
; q
!= NULL
; q
= q
->next
)
768 if (q
->sec
== p
->sec
)
770 q
->pc_count
+= p
->pc_count
;
771 q
->count
+= p
->count
;
778 *pp
= edir
->dyn_relocs
;
781 edir
->dyn_relocs
= eind
->dyn_relocs
;
782 eind
->dyn_relocs
= NULL
;
785 if (ind
->root
.type
== bfd_link_hash_indirect
786 && dir
->got
.refcount
<= 0)
788 edir
->tls_type
= eind
->tls_type
;
789 eind
->tls_type
= GOT_UNKNOWN
;
792 if (ELIMINATE_COPY_RELOCS
793 && ind
->root
.type
!= bfd_link_hash_indirect
794 && dir
->dynamic_adjusted
)
796 /* If called to transfer flags for a weakdef during processing
797 of elf_adjust_dynamic_symbol, don't copy non_got_ref.
798 We clear it ourselves for ELIMINATE_COPY_RELOCS. */
799 dir
->ref_dynamic
|= ind
->ref_dynamic
;
800 dir
->ref_regular
|= ind
->ref_regular
;
801 dir
->ref_regular_nonweak
|= ind
->ref_regular_nonweak
;
802 dir
->needs_plt
|= ind
->needs_plt
;
805 _bfd_elf_link_hash_copy_indirect (info
, dir
, ind
);
809 elf_s390_tls_transition (struct bfd_link_info
*info
,
821 return R_390_TLS_LE64
;
822 return R_390_TLS_IE64
;
823 case R_390_TLS_GOTIE64
:
825 return R_390_TLS_LE64
;
826 return R_390_TLS_GOTIE64
;
827 case R_390_TLS_LDM64
:
828 return R_390_TLS_LE64
;
834 /* Look through the relocs for a section during the first phase, and
835 allocate space in the global offset table or procedure linkage
839 elf_s390_check_relocs (bfd
*abfd
,
840 struct bfd_link_info
*info
,
842 const Elf_Internal_Rela
*relocs
)
844 struct elf_s390_link_hash_table
*htab
;
845 Elf_Internal_Shdr
*symtab_hdr
;
846 struct elf_link_hash_entry
**sym_hashes
;
847 const Elf_Internal_Rela
*rel
;
848 const Elf_Internal_Rela
*rel_end
;
850 bfd_signed_vma
*local_got_refcounts
;
851 int tls_type
, old_tls_type
;
853 if (info
->relocatable
)
856 BFD_ASSERT (is_s390_elf (abfd
));
858 htab
= elf_s390_hash_table (info
);
862 symtab_hdr
= &elf_symtab_hdr (abfd
);
863 sym_hashes
= elf_sym_hashes (abfd
);
864 local_got_refcounts
= elf_local_got_refcounts (abfd
);
868 rel_end
= relocs
+ sec
->reloc_count
;
869 for (rel
= relocs
; rel
< rel_end
; rel
++)
872 unsigned long r_symndx
;
873 struct elf_link_hash_entry
*h
;
875 r_symndx
= ELF64_R_SYM (rel
->r_info
);
877 if (r_symndx
>= NUM_SHDR_ENTRIES (symtab_hdr
))
879 (*_bfd_error_handler
) (_("%B: bad symbol index: %d"),
885 if (r_symndx
< symtab_hdr
->sh_info
)
889 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
890 while (h
->root
.type
== bfd_link_hash_indirect
891 || h
->root
.type
== bfd_link_hash_warning
)
892 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
895 /* Create got section and local_got_refcounts array if they
897 r_type
= elf_s390_tls_transition (info
,
898 ELF64_R_TYPE (rel
->r_info
),
913 case R_390_GOTPLTENT
:
915 case R_390_TLS_GOTIE12
:
916 case R_390_TLS_GOTIE20
:
917 case R_390_TLS_GOTIE64
:
918 case R_390_TLS_IEENT
:
920 case R_390_TLS_LDM64
:
922 && local_got_refcounts
== NULL
)
926 size
= symtab_hdr
->sh_info
;
927 size
*= (sizeof (bfd_signed_vma
) + sizeof(char));
928 local_got_refcounts
= ((bfd_signed_vma
*)
929 bfd_zalloc (abfd
, size
));
930 if (local_got_refcounts
== NULL
)
932 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
933 elf_s390_local_got_tls_type (abfd
)
934 = (char *) (local_got_refcounts
+ symtab_hdr
->sh_info
);
942 if (htab
->elf
.sgot
== NULL
)
944 if (htab
->elf
.dynobj
== NULL
)
945 htab
->elf
.dynobj
= abfd
;
946 if (!create_got_section (htab
->elf
.dynobj
, info
))
958 /* Got is created, nothing to be done. */
968 /* This symbol requires a procedure linkage table entry. We
969 actually build the entry in adjust_dynamic_symbol,
970 because this might be a case of linking PIC code which is
971 never referenced by a dynamic object, in which case we
972 don't need to generate a procedure linkage table entry
975 /* If this is a local symbol, we resolve it directly without
976 creating a procedure linkage table entry. */
980 h
->plt
.refcount
+= 1;
989 case R_390_GOTPLTENT
:
990 /* This symbol requires either a procedure linkage table entry
991 or an entry in the local got. We actually build the entry
992 in adjust_dynamic_symbol because whether this is really a
993 global reference can change and with it the fact if we have
994 to create a plt entry or a local got entry. To be able to
995 make a once global symbol a local one we have to keep track
996 of the number of gotplt references that exist for this
1000 ((struct elf_s390_link_hash_entry
*) h
)->gotplt_refcount
++;
1002 h
->plt
.refcount
+= 1;
1005 local_got_refcounts
[r_symndx
] += 1;
1008 case R_390_TLS_LDM64
:
1009 htab
->tls_ldm_got
.refcount
+= 1;
1012 case R_390_TLS_IE64
:
1013 case R_390_TLS_GOTIE12
:
1014 case R_390_TLS_GOTIE20
:
1015 case R_390_TLS_GOTIE64
:
1016 case R_390_TLS_IEENT
:
1018 info
->flags
|= DF_STATIC_TLS
;
1027 case R_390_TLS_GD64
:
1028 /* This symbol requires a global offset table entry. */
1037 tls_type
= GOT_NORMAL
;
1039 case R_390_TLS_GD64
:
1040 tls_type
= GOT_TLS_GD
;
1042 case R_390_TLS_IE64
:
1043 case R_390_TLS_GOTIE64
:
1044 tls_type
= GOT_TLS_IE
;
1046 case R_390_TLS_GOTIE12
:
1047 case R_390_TLS_GOTIE20
:
1048 case R_390_TLS_IEENT
:
1049 tls_type
= GOT_TLS_IE_NLT
;
1055 h
->got
.refcount
+= 1;
1056 old_tls_type
= elf_s390_hash_entry(h
)->tls_type
;
1060 local_got_refcounts
[r_symndx
] += 1;
1061 old_tls_type
= elf_s390_local_got_tls_type (abfd
) [r_symndx
];
1063 /* If a TLS symbol is accessed using IE at least once,
1064 there is no point to use dynamic model for it. */
1065 if (old_tls_type
!= tls_type
&& old_tls_type
!= GOT_UNKNOWN
)
1067 if (old_tls_type
== GOT_NORMAL
|| tls_type
== GOT_NORMAL
)
1069 (*_bfd_error_handler
)
1070 (_("%B: `%s' accessed both as normal and thread local symbol"),
1071 abfd
, h
->root
.root
.string
);
1074 if (old_tls_type
> tls_type
)
1075 tls_type
= old_tls_type
;
1078 if (old_tls_type
!= tls_type
)
1081 elf_s390_hash_entry (h
)->tls_type
= tls_type
;
1083 elf_s390_local_got_tls_type (abfd
) [r_symndx
] = tls_type
;
1086 if (r_type
!= R_390_TLS_IE64
)
1090 case R_390_TLS_LE64
:
1093 info
->flags
|= DF_STATIC_TLS
;
1105 if (h
!= NULL
&& !info
->shared
)
1107 /* If this reloc is in a read-only section, we might
1108 need a copy reloc. We can't check reliably at this
1109 stage whether the section is read-only, as input
1110 sections have not yet been mapped to output sections.
1111 Tentatively set the flag for now, and correct in
1112 adjust_dynamic_symbol. */
1115 /* We may need a .plt entry if the function this reloc
1116 refers to is in a shared lib. */
1117 h
->plt
.refcount
+= 1;
1120 /* If we are creating a shared library, and this is a reloc
1121 against a global symbol, or a non PC relative reloc
1122 against a local symbol, then we need to copy the reloc
1123 into the shared library. However, if we are linking with
1124 -Bsymbolic, we do not need to copy a reloc against a
1125 global symbol which is defined in an object we are
1126 including in the link (i.e., DEF_REGULAR is set). At
1127 this point we have not seen all the input files, so it is
1128 possible that DEF_REGULAR is not set now but will be set
1129 later (it is never cleared). In case of a weak definition,
1130 DEF_REGULAR may be cleared later by a strong definition in
1131 a shared library. We account for that possibility below by
1132 storing information in the relocs_copied field of the hash
1133 table entry. A similar situation occurs when creating
1134 shared libraries and symbol visibility changes render the
1137 If on the other hand, we are creating an executable, we
1138 may need to keep relocations for symbols satisfied by a
1139 dynamic library if we manage to avoid copy relocs for the
1142 && (sec
->flags
& SEC_ALLOC
) != 0
1143 && ((ELF64_R_TYPE (rel
->r_info
) != R_390_PC16
1144 && ELF64_R_TYPE (rel
->r_info
) != R_390_PC16DBL
1145 && ELF64_R_TYPE (rel
->r_info
) != R_390_PC32
1146 && ELF64_R_TYPE (rel
->r_info
) != R_390_PC32DBL
1147 && ELF64_R_TYPE (rel
->r_info
) != R_390_PC64
)
1149 && (! SYMBOLIC_BIND (info
, h
)
1150 || h
->root
.type
== bfd_link_hash_defweak
1151 || !h
->def_regular
))))
1152 || (ELIMINATE_COPY_RELOCS
1154 && (sec
->flags
& SEC_ALLOC
) != 0
1156 && (h
->root
.type
== bfd_link_hash_defweak
1157 || !h
->def_regular
)))
1159 struct elf_dyn_relocs
*p
;
1160 struct elf_dyn_relocs
**head
;
1162 /* We must copy these reloc types into the output file.
1163 Create a reloc section in dynobj and make room for
1167 if (htab
->elf
.dynobj
== NULL
)
1168 htab
->elf
.dynobj
= abfd
;
1170 sreloc
= _bfd_elf_make_dynamic_reloc_section
1171 (sec
, htab
->elf
.dynobj
, 3, abfd
, /*rela?*/ TRUE
);
1177 /* If this is a global symbol, we count the number of
1178 relocations we need for this symbol. */
1181 head
= &((struct elf_s390_link_hash_entry
*) h
)->dyn_relocs
;
1185 /* Track dynamic relocs needed for local syms too.
1186 We really need local syms available to do this
1190 Elf_Internal_Sym
*isym
;
1192 isym
= bfd_sym_from_r_symndx (&htab
->sym_cache
,
1197 s
= bfd_section_from_elf_index (abfd
, isym
->st_shndx
);
1201 vpp
= &elf_section_data (s
)->local_dynrel
;
1202 head
= (struct elf_dyn_relocs
**) vpp
;
1206 if (p
== NULL
|| p
->sec
!= sec
)
1208 bfd_size_type amt
= sizeof *p
;
1209 p
= ((struct elf_dyn_relocs
*)
1210 bfd_alloc (htab
->elf
.dynobj
, amt
));
1221 if (ELF64_R_TYPE (rel
->r_info
) == R_390_PC16
1222 || ELF64_R_TYPE (rel
->r_info
) == R_390_PC16DBL
1223 || ELF64_R_TYPE (rel
->r_info
) == R_390_PC32
1224 || ELF64_R_TYPE (rel
->r_info
) == R_390_PC32DBL
1225 || ELF64_R_TYPE (rel
->r_info
) == R_390_PC64
)
1230 /* This relocation describes the C++ object vtable hierarchy.
1231 Reconstruct it for later use during GC. */
1232 case R_390_GNU_VTINHERIT
:
1233 if (!bfd_elf_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
1237 /* This relocation describes which C++ vtable entries are actually
1238 used. Record for later use during GC. */
1239 case R_390_GNU_VTENTRY
:
1240 BFD_ASSERT (h
!= NULL
);
1242 && !bfd_elf_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
1254 /* Return the section that should be marked against GC for a given
1258 elf_s390_gc_mark_hook (asection
*sec
,
1259 struct bfd_link_info
*info
,
1260 Elf_Internal_Rela
*rel
,
1261 struct elf_link_hash_entry
*h
,
1262 Elf_Internal_Sym
*sym
)
1265 switch (ELF64_R_TYPE (rel
->r_info
))
1267 case R_390_GNU_VTINHERIT
:
1268 case R_390_GNU_VTENTRY
:
1272 return _bfd_elf_gc_mark_hook (sec
, info
, rel
, h
, sym
);
1275 /* Update the got entry reference counts for the section being removed. */
1278 elf_s390_gc_sweep_hook (bfd
*abfd
,
1279 struct bfd_link_info
*info
,
1281 const Elf_Internal_Rela
*relocs
)
1283 struct elf_s390_link_hash_table
*htab
;
1284 Elf_Internal_Shdr
*symtab_hdr
;
1285 struct elf_link_hash_entry
**sym_hashes
;
1286 bfd_signed_vma
*local_got_refcounts
;
1287 const Elf_Internal_Rela
*rel
, *relend
;
1289 if (info
->relocatable
)
1292 htab
= elf_s390_hash_table (info
);
1296 elf_section_data (sec
)->local_dynrel
= NULL
;
1298 symtab_hdr
= &elf_symtab_hdr (abfd
);
1299 sym_hashes
= elf_sym_hashes (abfd
);
1300 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1302 relend
= relocs
+ sec
->reloc_count
;
1303 for (rel
= relocs
; rel
< relend
; rel
++)
1305 unsigned long r_symndx
;
1306 unsigned int r_type
;
1307 struct elf_link_hash_entry
*h
= NULL
;
1309 r_symndx
= ELF64_R_SYM (rel
->r_info
);
1310 if (r_symndx
>= symtab_hdr
->sh_info
)
1312 struct elf_s390_link_hash_entry
*eh
;
1313 struct elf_dyn_relocs
**pp
;
1314 struct elf_dyn_relocs
*p
;
1316 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1317 while (h
->root
.type
== bfd_link_hash_indirect
1318 || h
->root
.type
== bfd_link_hash_warning
)
1319 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1320 eh
= (struct elf_s390_link_hash_entry
*) h
;
1322 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; pp
= &p
->next
)
1325 /* Everything must go for SEC. */
1331 r_type
= ELF64_R_TYPE (rel
->r_info
);
1332 r_type
= elf_s390_tls_transition (info
, r_type
, h
!= NULL
);
1335 case R_390_TLS_LDM64
:
1336 if (htab
->tls_ldm_got
.refcount
> 0)
1337 htab
->tls_ldm_got
.refcount
-= 1;
1340 case R_390_TLS_GD64
:
1341 case R_390_TLS_IE64
:
1342 case R_390_TLS_GOTIE12
:
1343 case R_390_TLS_GOTIE20
:
1344 case R_390_TLS_GOTIE64
:
1345 case R_390_TLS_IEENT
:
1351 case R_390_GOTOFF16
:
1352 case R_390_GOTOFF32
:
1353 case R_390_GOTOFF64
:
1355 case R_390_GOTPCDBL
:
1359 if (h
->got
.refcount
> 0)
1360 h
->got
.refcount
-= 1;
1362 else if (local_got_refcounts
!= NULL
)
1364 if (local_got_refcounts
[r_symndx
] > 0)
1365 local_got_refcounts
[r_symndx
] -= 1;
1384 case R_390_PLT16DBL
:
1386 case R_390_PLT32DBL
:
1388 case R_390_PLTOFF16
:
1389 case R_390_PLTOFF32
:
1390 case R_390_PLTOFF64
:
1393 if (h
->plt
.refcount
> 0)
1394 h
->plt
.refcount
-= 1;
1398 case R_390_GOTPLT12
:
1399 case R_390_GOTPLT16
:
1400 case R_390_GOTPLT20
:
1401 case R_390_GOTPLT32
:
1402 case R_390_GOTPLT64
:
1403 case R_390_GOTPLTENT
:
1406 if (h
->plt
.refcount
> 0)
1408 ((struct elf_s390_link_hash_entry
*) h
)->gotplt_refcount
--;
1409 h
->plt
.refcount
-= 1;
1412 else if (local_got_refcounts
!= NULL
)
1414 if (local_got_refcounts
[r_symndx
] > 0)
1415 local_got_refcounts
[r_symndx
] -= 1;
1427 /* Make sure we emit a GOT entry if the symbol was supposed to have a PLT
1428 entry but we found we will not create any. Called when we find we will
1429 not have any PLT for this symbol, by for example
1430 elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link,
1431 or elf_s390_size_dynamic_sections if no dynamic sections will be
1432 created (we're only linking static objects). */
1435 elf_s390_adjust_gotplt (struct elf_s390_link_hash_entry
*h
)
1437 if (h
->elf
.root
.type
== bfd_link_hash_warning
)
1438 h
= (struct elf_s390_link_hash_entry
*) h
->elf
.root
.u
.i
.link
;
1440 if (h
->gotplt_refcount
<= 0)
1443 /* We simply add the number of gotplt references to the number
1444 * of got references for this symbol. */
1445 h
->elf
.got
.refcount
+= h
->gotplt_refcount
;
1446 h
->gotplt_refcount
= -1;
1449 /* Adjust a symbol defined by a dynamic object and referenced by a
1450 regular object. The current definition is in some section of the
1451 dynamic object, but we're not including those sections. We have to
1452 change the definition to something the rest of the link can
1456 elf_s390_adjust_dynamic_symbol (struct bfd_link_info
*info
,
1457 struct elf_link_hash_entry
*h
)
1459 struct elf_s390_link_hash_table
*htab
;
1462 /* If this is a function, put it in the procedure linkage table. We
1463 will fill in the contents of the procedure linkage table later
1464 (although we could actually do it here). */
1465 if (h
->type
== STT_FUNC
1468 if (h
->plt
.refcount
<= 0
1469 || SYMBOL_CALLS_LOCAL (info
, h
)
1470 || (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
1471 && h
->root
.type
== bfd_link_hash_undefweak
))
1473 /* This case can occur if we saw a PLT32 reloc in an input
1474 file, but the symbol was never referred to by a dynamic
1475 object, or if all references were garbage collected. In
1476 such a case, we don't actually need to build a procedure
1477 linkage table, and we can just do a PC32 reloc instead. */
1478 h
->plt
.offset
= (bfd_vma
) -1;
1480 elf_s390_adjust_gotplt((struct elf_s390_link_hash_entry
*) h
);
1486 /* It's possible that we incorrectly decided a .plt reloc was
1487 needed for an R_390_PC32 reloc to a non-function sym in
1488 check_relocs. We can't decide accurately between function and
1489 non-function syms in check-relocs; Objects loaded later in
1490 the link may change h->type. So fix it now. */
1491 h
->plt
.offset
= (bfd_vma
) -1;
1493 /* If this is a weak symbol, and there is a real definition, the
1494 processor independent code will have arranged for us to see the
1495 real definition first, and we can just use the same value. */
1496 if (h
->u
.weakdef
!= NULL
)
1498 BFD_ASSERT (h
->u
.weakdef
->root
.type
== bfd_link_hash_defined
1499 || h
->u
.weakdef
->root
.type
== bfd_link_hash_defweak
);
1500 h
->root
.u
.def
.section
= h
->u
.weakdef
->root
.u
.def
.section
;
1501 h
->root
.u
.def
.value
= h
->u
.weakdef
->root
.u
.def
.value
;
1502 if (ELIMINATE_COPY_RELOCS
|| info
->nocopyreloc
)
1503 h
->non_got_ref
= h
->u
.weakdef
->non_got_ref
;
1507 /* This is a reference to a symbol defined by a dynamic object which
1508 is not a function. */
1510 /* If we are creating a shared library, we must presume that the
1511 only references to the symbol are via the global offset table.
1512 For such cases we need not do anything here; the relocations will
1513 be handled correctly by relocate_section. */
1517 /* If there are no references to this symbol that do not use the
1518 GOT, we don't need to generate a copy reloc. */
1519 if (!h
->non_got_ref
)
1522 /* If -z nocopyreloc was given, we won't generate them either. */
1523 if (info
->nocopyreloc
)
1529 if (ELIMINATE_COPY_RELOCS
)
1531 struct elf_s390_link_hash_entry
* eh
;
1532 struct elf_dyn_relocs
*p
;
1534 eh
= (struct elf_s390_link_hash_entry
*) h
;
1535 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
1537 s
= p
->sec
->output_section
;
1538 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
1542 /* If we didn't find any dynamic relocs in read-only sections, then
1543 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1551 /* We must allocate the symbol in our .dynbss section, which will
1552 become part of the .bss section of the executable. There will be
1553 an entry for this symbol in the .dynsym section. The dynamic
1554 object will contain position independent code, so all references
1555 from the dynamic object to this symbol will go through the global
1556 offset table. The dynamic linker will use the .dynsym entry to
1557 determine the address it must put in the global offset table, so
1558 both the dynamic object and the regular object will refer to the
1559 same memory location for the variable. */
1561 htab
= elf_s390_hash_table (info
);
1565 /* We must generate a R_390_COPY reloc to tell the dynamic linker to
1566 copy the initial value out of the dynamic object and into the
1567 runtime process image. */
1568 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0 && h
->size
!= 0)
1570 htab
->srelbss
->size
+= sizeof (Elf64_External_Rela
);
1576 return _bfd_elf_adjust_dynamic_copy (h
, s
);
1579 /* Allocate space in .plt, .got and associated reloc sections for
1583 allocate_dynrelocs (struct elf_link_hash_entry
*h
,
1586 struct bfd_link_info
*info
;
1587 struct elf_s390_link_hash_table
*htab
;
1588 struct elf_s390_link_hash_entry
*eh
;
1589 struct elf_dyn_relocs
*p
;
1591 if (h
->root
.type
== bfd_link_hash_indirect
)
1594 info
= (struct bfd_link_info
*) inf
;
1595 htab
= elf_s390_hash_table (info
);
1599 if (htab
->elf
.dynamic_sections_created
1600 && h
->plt
.refcount
> 0)
1602 /* Make sure this symbol is output as a dynamic symbol.
1603 Undefined weak syms won't yet be marked as dynamic. */
1604 if (h
->dynindx
== -1
1605 && !h
->forced_local
)
1607 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
1612 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h
))
1614 asection
*s
= htab
->elf
.splt
;
1616 /* If this is the first .plt entry, make room for the special
1619 s
->size
+= PLT_FIRST_ENTRY_SIZE
;
1621 h
->plt
.offset
= s
->size
;
1623 /* If this symbol is not defined in a regular file, and we are
1624 not generating a shared library, then set the symbol to this
1625 location in the .plt. This is required to make function
1626 pointers compare as equal between the normal executable and
1627 the shared library. */
1631 h
->root
.u
.def
.section
= s
;
1632 h
->root
.u
.def
.value
= h
->plt
.offset
;
1635 /* Make room for this entry. */
1636 s
->size
+= PLT_ENTRY_SIZE
;
1638 /* We also need to make an entry in the .got.plt section, which
1639 will be placed in the .got section by the linker script. */
1640 htab
->elf
.sgotplt
->size
+= GOT_ENTRY_SIZE
;
1642 /* We also need to make an entry in the .rela.plt section. */
1643 htab
->elf
.srelplt
->size
+= sizeof (Elf64_External_Rela
);
1647 h
->plt
.offset
= (bfd_vma
) -1;
1649 elf_s390_adjust_gotplt((struct elf_s390_link_hash_entry
*) h
);
1654 h
->plt
.offset
= (bfd_vma
) -1;
1656 elf_s390_adjust_gotplt((struct elf_s390_link_hash_entry
*) h
);
1659 /* If R_390_TLS_{IE64,GOTIE64,GOTIE12,IEENT} symbol is now local to
1660 the binary, we can optimize a bit. IE64 and GOTIE64 get converted
1661 to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT
1662 we can save the dynamic TLS relocation. */
1663 if (h
->got
.refcount
> 0
1666 && elf_s390_hash_entry(h
)->tls_type
>= GOT_TLS_IE
)
1668 if (elf_s390_hash_entry(h
)->tls_type
== GOT_TLS_IE_NLT
)
1669 /* For the GOTIE access without a literal pool entry the offset has
1670 to be stored somewhere. The immediate value in the instruction
1671 is not bit enough so the value is stored in the got. */
1673 h
->got
.offset
= htab
->elf
.sgot
->size
;
1674 htab
->elf
.sgot
->size
+= GOT_ENTRY_SIZE
;
1677 h
->got
.offset
= (bfd_vma
) -1;
1679 else if (h
->got
.refcount
> 0)
1683 int tls_type
= elf_s390_hash_entry(h
)->tls_type
;
1685 /* Make sure this symbol is output as a dynamic symbol.
1686 Undefined weak syms won't yet be marked as dynamic. */
1687 if (h
->dynindx
== -1
1688 && !h
->forced_local
)
1690 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
1695 h
->got
.offset
= s
->size
;
1696 s
->size
+= GOT_ENTRY_SIZE
;
1697 /* R_390_TLS_GD64 needs 2 consecutive GOT slots. */
1698 if (tls_type
== GOT_TLS_GD
)
1699 s
->size
+= GOT_ENTRY_SIZE
;
1700 dyn
= htab
->elf
.dynamic_sections_created
;
1701 /* R_390_TLS_IE64 needs one dynamic relocation,
1702 R_390_TLS_GD64 needs one if local symbol and two if global. */
1703 if ((tls_type
== GOT_TLS_GD
&& h
->dynindx
== -1)
1704 || tls_type
>= GOT_TLS_IE
)
1705 htab
->elf
.srelgot
->size
+= sizeof (Elf64_External_Rela
);
1706 else if (tls_type
== GOT_TLS_GD
)
1707 htab
->elf
.srelgot
->size
+= 2 * sizeof (Elf64_External_Rela
);
1708 else if ((ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
1709 || h
->root
.type
!= bfd_link_hash_undefweak
)
1711 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, 0, h
)))
1712 htab
->elf
.srelgot
->size
+= sizeof (Elf64_External_Rela
);
1715 h
->got
.offset
= (bfd_vma
) -1;
1717 eh
= (struct elf_s390_link_hash_entry
*) h
;
1718 if (eh
->dyn_relocs
== NULL
)
1721 /* In the shared -Bsymbolic case, discard space allocated for
1722 dynamic pc-relative relocs against symbols which turn out to be
1723 defined in regular objects. For the normal shared case, discard
1724 space for pc-relative relocs that have become local due to symbol
1725 visibility changes. */
1729 if (SYMBOL_CALLS_LOCAL (info
, h
))
1731 struct elf_dyn_relocs
**pp
;
1733 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; )
1735 p
->count
-= p
->pc_count
;
1744 /* Also discard relocs on undefined weak syms with non-default
1746 if (eh
->dyn_relocs
!= NULL
1747 && h
->root
.type
== bfd_link_hash_undefweak
)
1749 if (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
)
1750 eh
->dyn_relocs
= NULL
;
1752 /* Make sure undefined weak symbols are output as a dynamic
1754 else if (h
->dynindx
== -1
1755 && !h
->forced_local
)
1757 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
1762 else if (ELIMINATE_COPY_RELOCS
)
1764 /* For the non-shared case, discard space for relocs against
1765 symbols which turn out to need copy relocs or are not
1771 || (htab
->elf
.dynamic_sections_created
1772 && (h
->root
.type
== bfd_link_hash_undefweak
1773 || h
->root
.type
== bfd_link_hash_undefined
))))
1775 /* Make sure this symbol is output as a dynamic symbol.
1776 Undefined weak syms won't yet be marked as dynamic. */
1777 if (h
->dynindx
== -1
1778 && !h
->forced_local
)
1780 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
1784 /* If that succeeded, we know we'll be keeping all the
1786 if (h
->dynindx
!= -1)
1790 eh
->dyn_relocs
= NULL
;
1795 /* Finally, allocate space. */
1796 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
1798 asection
*sreloc
= elf_section_data (p
->sec
)->sreloc
;
1799 sreloc
->size
+= p
->count
* sizeof (Elf64_External_Rela
);
1805 /* Find any dynamic relocs that apply to read-only sections. */
1808 readonly_dynrelocs (struct elf_link_hash_entry
*h
, void * inf
)
1810 struct elf_s390_link_hash_entry
*eh
;
1811 struct elf_dyn_relocs
*p
;
1813 eh
= (struct elf_s390_link_hash_entry
*) h
;
1814 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
1816 asection
*s
= p
->sec
->output_section
;
1818 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
1820 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
1822 info
->flags
|= DF_TEXTREL
;
1824 /* Not an error, just cut short the traversal. */
1831 /* Set the sizes of the dynamic sections. */
1834 elf_s390_size_dynamic_sections (bfd
*output_bfd ATTRIBUTE_UNUSED
,
1835 struct bfd_link_info
*info
)
1837 struct elf_s390_link_hash_table
*htab
;
1843 htab
= elf_s390_hash_table (info
);
1847 dynobj
= htab
->elf
.dynobj
;
1851 if (htab
->elf
.dynamic_sections_created
)
1853 /* Set the contents of the .interp section to the interpreter. */
1854 if (info
->executable
)
1856 s
= bfd_get_linker_section (dynobj
, ".interp");
1859 s
->size
= sizeof ELF_DYNAMIC_INTERPRETER
;
1860 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
1864 /* Set up .got offsets for local syms, and space for local dynamic
1866 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
1868 bfd_signed_vma
*local_got
;
1869 bfd_signed_vma
*end_local_got
;
1870 char *local_tls_type
;
1871 bfd_size_type locsymcount
;
1872 Elf_Internal_Shdr
*symtab_hdr
;
1875 if (! is_s390_elf (ibfd
))
1878 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
1880 struct elf_dyn_relocs
*p
;
1882 for (p
= elf_section_data (s
)->local_dynrel
; p
!= NULL
; p
= p
->next
)
1884 if (!bfd_is_abs_section (p
->sec
)
1885 && bfd_is_abs_section (p
->sec
->output_section
))
1887 /* Input section has been discarded, either because
1888 it is a copy of a linkonce section or due to
1889 linker script /DISCARD/, so we'll be discarding
1892 else if (p
->count
!= 0)
1894 srela
= elf_section_data (p
->sec
)->sreloc
;
1895 srela
->size
+= p
->count
* sizeof (Elf64_External_Rela
);
1896 if ((p
->sec
->output_section
->flags
& SEC_READONLY
) != 0)
1897 info
->flags
|= DF_TEXTREL
;
1902 local_got
= elf_local_got_refcounts (ibfd
);
1906 symtab_hdr
= &elf_symtab_hdr (ibfd
);
1907 locsymcount
= symtab_hdr
->sh_info
;
1908 end_local_got
= local_got
+ locsymcount
;
1909 local_tls_type
= elf_s390_local_got_tls_type (ibfd
);
1911 srela
= htab
->elf
.srelgot
;
1912 for (; local_got
< end_local_got
; ++local_got
, ++local_tls_type
)
1916 *local_got
= s
->size
;
1917 s
->size
+= GOT_ENTRY_SIZE
;
1918 if (*local_tls_type
== GOT_TLS_GD
)
1919 s
->size
+= GOT_ENTRY_SIZE
;
1921 srela
->size
+= sizeof (Elf64_External_Rela
);
1924 *local_got
= (bfd_vma
) -1;
1928 if (htab
->tls_ldm_got
.refcount
> 0)
1930 /* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM64
1932 htab
->tls_ldm_got
.offset
= htab
->elf
.sgot
->size
;
1933 htab
->elf
.sgot
->size
+= 2 * GOT_ENTRY_SIZE
;
1934 htab
->elf
.srelgot
->size
+= sizeof (Elf64_External_Rela
);
1937 htab
->tls_ldm_got
.offset
= -1;
1939 /* Allocate global sym .plt and .got entries, and space for global
1940 sym dynamic relocs. */
1941 elf_link_hash_traverse (&htab
->elf
, allocate_dynrelocs
, info
);
1943 /* We now have determined the sizes of the various dynamic sections.
1944 Allocate memory for them. */
1946 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
1948 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
1951 if (s
== htab
->elf
.splt
1952 || s
== htab
->elf
.sgot
1953 || s
== htab
->elf
.sgotplt
1954 || s
== htab
->sdynbss
)
1956 /* Strip this section if we don't need it; see the
1959 else if (CONST_STRNEQ (bfd_get_section_name (dynobj
, s
), ".rela"))
1961 if (s
->size
!= 0 && s
!= htab
->elf
.srelplt
)
1964 /* We use the reloc_count field as a counter if we need
1965 to copy relocs into the output file. */
1970 /* It's not one of our sections, so don't allocate space. */
1976 /* If we don't need this section, strip it from the
1977 output file. This is to handle .rela.bss and
1978 .rela.plt. We must create it in
1979 create_dynamic_sections, because it must be created
1980 before the linker maps input sections to output
1981 sections. The linker does that before
1982 adjust_dynamic_symbol is called, and it is that
1983 function which decides whether anything needs to go
1984 into these sections. */
1986 s
->flags
|= SEC_EXCLUDE
;
1990 if ((s
->flags
& SEC_HAS_CONTENTS
) == 0)
1993 /* Allocate memory for the section contents. We use bfd_zalloc
1994 here in case unused entries are not reclaimed before the
1995 section's contents are written out. This should not happen,
1996 but this way if it does, we get a R_390_NONE reloc instead
1998 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->size
);
1999 if (s
->contents
== NULL
)
2003 if (htab
->elf
.dynamic_sections_created
)
2005 /* Add some entries to the .dynamic section. We fill in the
2006 values later, in elf_s390_finish_dynamic_sections, but we
2007 must add the entries now so that we get the correct size for
2008 the .dynamic section. The DT_DEBUG entry is filled in by the
2009 dynamic linker and used by the debugger. */
2010 #define add_dynamic_entry(TAG, VAL) \
2011 _bfd_elf_add_dynamic_entry (info, TAG, VAL)
2013 if (info
->executable
)
2015 if (!add_dynamic_entry (DT_DEBUG
, 0))
2019 if (htab
->elf
.splt
->size
!= 0)
2021 if (!add_dynamic_entry (DT_PLTGOT
, 0)
2022 || !add_dynamic_entry (DT_PLTRELSZ
, 0)
2023 || !add_dynamic_entry (DT_PLTREL
, DT_RELA
)
2024 || !add_dynamic_entry (DT_JMPREL
, 0))
2030 if (!add_dynamic_entry (DT_RELA
, 0)
2031 || !add_dynamic_entry (DT_RELASZ
, 0)
2032 || !add_dynamic_entry (DT_RELAENT
, sizeof (Elf64_External_Rela
)))
2035 /* If any dynamic relocs apply to a read-only section,
2036 then we need a DT_TEXTREL entry. */
2037 if ((info
->flags
& DF_TEXTREL
) == 0)
2038 elf_link_hash_traverse (&htab
->elf
, readonly_dynrelocs
,
2041 if ((info
->flags
& DF_TEXTREL
) != 0)
2043 if (!add_dynamic_entry (DT_TEXTREL
, 0))
2048 #undef add_dynamic_entry
2053 /* Return the base VMA address which should be subtracted from real addresses
2054 when resolving @dtpoff relocation.
2055 This is PT_TLS segment p_vaddr. */
2058 dtpoff_base (struct bfd_link_info
*info
)
2060 /* If tls_sec is NULL, we should have signalled an error already. */
2061 if (elf_hash_table (info
)->tls_sec
== NULL
)
2063 return elf_hash_table (info
)->tls_sec
->vma
;
2066 /* Return the relocation value for @tpoff relocation
2067 if STT_TLS virtual address is ADDRESS. */
2070 tpoff (struct bfd_link_info
*info
, bfd_vma address
)
2072 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
2074 /* If tls_sec is NULL, we should have signalled an error already. */
2075 if (htab
->tls_sec
== NULL
)
2077 return htab
->tls_size
+ htab
->tls_sec
->vma
- address
;
2080 /* Complain if TLS instruction relocation is against an invalid
2084 invalid_tls_insn (bfd
*input_bfd
,
2085 asection
*input_section
,
2086 Elf_Internal_Rela
*rel
)
2088 reloc_howto_type
*howto
;
2090 howto
= elf_howto_table
+ ELF64_R_TYPE (rel
->r_info
);
2091 (*_bfd_error_handler
)
2092 (_("%B(%A+0x%lx): invalid instruction for TLS relocation %s"),
2095 (long) rel
->r_offset
,
2097 bfd_set_error (bfd_error_bad_value
);
2100 /* Relocate a 390 ELF section. */
2103 elf_s390_relocate_section (bfd
*output_bfd
,
2104 struct bfd_link_info
*info
,
2106 asection
*input_section
,
2108 Elf_Internal_Rela
*relocs
,
2109 Elf_Internal_Sym
*local_syms
,
2110 asection
**local_sections
)
2112 struct elf_s390_link_hash_table
*htab
;
2113 Elf_Internal_Shdr
*symtab_hdr
;
2114 struct elf_link_hash_entry
**sym_hashes
;
2115 bfd_vma
*local_got_offsets
;
2116 Elf_Internal_Rela
*rel
;
2117 Elf_Internal_Rela
*relend
;
2119 BFD_ASSERT (is_s390_elf (input_bfd
));
2121 htab
= elf_s390_hash_table (info
);
2125 symtab_hdr
= &elf_symtab_hdr (input_bfd
);
2126 sym_hashes
= elf_sym_hashes (input_bfd
);
2127 local_got_offsets
= elf_local_got_offsets (input_bfd
);
2130 relend
= relocs
+ input_section
->reloc_count
;
2131 for (; rel
< relend
; rel
++)
2133 unsigned int r_type
;
2134 reloc_howto_type
*howto
;
2135 unsigned long r_symndx
;
2136 struct elf_link_hash_entry
*h
;
2137 Elf_Internal_Sym
*sym
;
2141 bfd_boolean unresolved_reloc
;
2142 bfd_reloc_status_type r
;
2145 r_type
= ELF64_R_TYPE (rel
->r_info
);
2146 if (r_type
== (int) R_390_GNU_VTINHERIT
2147 || r_type
== (int) R_390_GNU_VTENTRY
)
2149 if (r_type
>= (int) R_390_max
)
2151 bfd_set_error (bfd_error_bad_value
);
2155 howto
= elf_howto_table
+ r_type
;
2156 r_symndx
= ELF64_R_SYM (rel
->r_info
);
2161 unresolved_reloc
= FALSE
;
2162 if (r_symndx
< symtab_hdr
->sh_info
)
2164 sym
= local_syms
+ r_symndx
;
2165 sec
= local_sections
[r_symndx
];
2166 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
2170 bfd_boolean warned ATTRIBUTE_UNUSED
;
2172 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
2173 r_symndx
, symtab_hdr
, sym_hashes
,
2175 unresolved_reloc
, warned
);
2178 if (sec
!= NULL
&& discarded_section (sec
))
2179 RELOC_AGAINST_DISCARDED_SECTION (info
, input_bfd
, input_section
,
2180 rel
, 1, relend
, howto
, 0, contents
);
2182 if (info
->relocatable
)
2187 case R_390_GOTPLT12
:
2188 case R_390_GOTPLT16
:
2189 case R_390_GOTPLT20
:
2190 case R_390_GOTPLT32
:
2191 case R_390_GOTPLT64
:
2192 case R_390_GOTPLTENT
:
2193 /* There are three cases for a GOTPLT relocation. 1) The
2194 relocation is against the jump slot entry of a plt that
2195 will get emitted to the output file. 2) The relocation
2196 is against the jump slot of a plt entry that has been
2197 removed. elf_s390_adjust_gotplt has created a GOT entry
2198 as replacement. 3) The relocation is against a local symbol.
2199 Cases 2) and 3) are the same as the GOT relocation code
2200 so we just have to test for case 1 and fall through for
2202 if (h
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
2207 Current offset - size first entry / entry size. */
2208 plt_index
= (h
->plt
.offset
- PLT_FIRST_ENTRY_SIZE
) /
2211 /* Offset in GOT is PLT index plus GOT headers(3) times 4,
2213 relocation
= (plt_index
+ 3) * GOT_ENTRY_SIZE
;
2214 unresolved_reloc
= FALSE
;
2216 if (r_type
== R_390_GOTPLTENT
)
2217 relocation
+= htab
->elf
.sgot
->output_section
->vma
;
2228 /* Relocation is to the entry for this symbol in the global
2230 if (htab
->elf
.sgot
== NULL
)
2237 off
= h
->got
.offset
;
2238 dyn
= htab
->elf
.dynamic_sections_created
;
2239 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
2241 && SYMBOL_REFERENCES_LOCAL (info
, h
))
2242 || (ELF_ST_VISIBILITY (h
->other
)
2243 && h
->root
.type
== bfd_link_hash_undefweak
))
2245 /* This is actually a static link, or it is a
2246 -Bsymbolic link and the symbol is defined
2247 locally, or the symbol was forced to be local
2248 because of a version file. We must initialize
2249 this entry in the global offset table. Since the
2250 offset must always be a multiple of 2, we use the
2251 least significant bit to record whether we have
2252 initialized it already.
2254 When doing a dynamic link, we create a .rel.got
2255 relocation entry to initialize the value. This
2256 is done in the finish_dynamic_symbol routine. */
2261 bfd_put_64 (output_bfd
, relocation
,
2262 htab
->elf
.sgot
->contents
+ off
);
2267 unresolved_reloc
= FALSE
;
2271 if (local_got_offsets
== NULL
)
2274 off
= local_got_offsets
[r_symndx
];
2276 /* The offset must always be a multiple of 8. We use
2277 the least significant bit to record whether we have
2278 already generated the necessary reloc. */
2283 bfd_put_64 (output_bfd
, relocation
,
2284 htab
->elf
.sgot
->contents
+ off
);
2289 Elf_Internal_Rela outrel
;
2292 s
= htab
->elf
.srelgot
;
2296 outrel
.r_offset
= (htab
->elf
.sgot
->output_section
->vma
2297 + htab
->elf
.sgot
->output_offset
2299 outrel
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
2300 outrel
.r_addend
= relocation
;
2302 loc
+= s
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2303 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2306 local_got_offsets
[r_symndx
] |= 1;
2310 if (off
>= (bfd_vma
) -2)
2313 relocation
= htab
->elf
.sgot
->output_offset
+ off
;
2315 /* For @GOTENT the relocation is against the offset between
2316 the instruction and the symbols entry in the GOT and not
2317 between the start of the GOT and the symbols entry. We
2318 add the vma of the GOT to get the correct value. */
2319 if ( r_type
== R_390_GOTENT
2320 || r_type
== R_390_GOTPLTENT
)
2321 relocation
+= htab
->elf
.sgot
->output_section
->vma
;
2325 case R_390_GOTOFF16
:
2326 case R_390_GOTOFF32
:
2327 case R_390_GOTOFF64
:
2328 /* Relocation is relative to the start of the global offset
2331 /* Note that sgot->output_offset is not involved in this
2332 calculation. We always want the start of .got. If we
2333 defined _GLOBAL_OFFSET_TABLE in a different way, as is
2334 permitted by the ABI, we might have to change this
2336 relocation
-= htab
->elf
.sgot
->output_section
->vma
;
2340 case R_390_GOTPCDBL
:
2341 /* Use global offset table as symbol value. */
2342 relocation
= htab
->elf
.sgot
->output_section
->vma
;
2343 unresolved_reloc
= FALSE
;
2346 case R_390_PLT16DBL
:
2348 case R_390_PLT32DBL
:
2350 /* Relocation is to the entry for this symbol in the
2351 procedure linkage table. */
2353 /* Resolve a PLT32 reloc against a local symbol directly,
2354 without using the procedure linkage table. */
2358 if (h
->plt
.offset
== (bfd_vma
) -1
2359 || htab
->elf
.splt
== NULL
)
2361 /* We didn't make a PLT entry for this symbol. This
2362 happens when statically linking PIC code, or when
2363 using -Bsymbolic. */
2367 relocation
= (htab
->elf
.splt
->output_section
->vma
2368 + htab
->elf
.splt
->output_offset
2370 unresolved_reloc
= FALSE
;
2373 case R_390_PLTOFF16
:
2374 case R_390_PLTOFF32
:
2375 case R_390_PLTOFF64
:
2376 /* Relocation is to the entry for this symbol in the
2377 procedure linkage table relative to the start of the GOT. */
2379 /* For local symbols or if we didn't make a PLT entry for
2380 this symbol resolve the symbol directly. */
2382 || h
->plt
.offset
== (bfd_vma
) -1
2383 || htab
->elf
.splt
== NULL
)
2385 relocation
-= htab
->elf
.sgot
->output_section
->vma
;
2389 relocation
= (htab
->elf
.splt
->output_section
->vma
2390 + htab
->elf
.splt
->output_offset
2392 - htab
->elf
.sgot
->output_section
->vma
);
2393 unresolved_reloc
= FALSE
;
2405 if ((input_section
->flags
& SEC_ALLOC
) == 0)
2410 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
2411 || h
->root
.type
!= bfd_link_hash_undefweak
)
2412 && ((r_type
!= R_390_PC16
2413 && r_type
!= R_390_PC16DBL
2414 && r_type
!= R_390_PC32
2415 && r_type
!= R_390_PC32DBL
2416 && r_type
!= R_390_PC64
)
2417 || !SYMBOL_CALLS_LOCAL (info
, h
)))
2418 || (ELIMINATE_COPY_RELOCS
2425 || h
->root
.type
== bfd_link_hash_undefweak
2426 || h
->root
.type
== bfd_link_hash_undefined
)))
2428 Elf_Internal_Rela outrel
;
2429 bfd_boolean skip
, relocate
;
2433 /* When generating a shared object, these relocations
2434 are copied into the output file to be resolved at run
2440 _bfd_elf_section_offset (output_bfd
, info
, input_section
,
2442 if (outrel
.r_offset
== (bfd_vma
) -1)
2444 else if (outrel
.r_offset
== (bfd_vma
) -2)
2445 skip
= TRUE
, relocate
= TRUE
;
2447 outrel
.r_offset
+= (input_section
->output_section
->vma
2448 + input_section
->output_offset
);
2451 memset (&outrel
, 0, sizeof outrel
);
2454 && (r_type
== R_390_PC16
2455 || r_type
== R_390_PC16DBL
2456 || r_type
== R_390_PC32
2457 || r_type
== R_390_PC32DBL
2458 || r_type
== R_390_PC64
2460 || !SYMBOLIC_BIND (info
, h
)
2461 || !h
->def_regular
))
2463 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, r_type
);
2464 outrel
.r_addend
= rel
->r_addend
;
2468 /* This symbol is local, or marked to become local. */
2469 outrel
.r_addend
= relocation
+ rel
->r_addend
;
2470 if (r_type
== R_390_64
)
2473 outrel
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
2479 if (bfd_is_abs_section (sec
))
2481 else if (sec
== NULL
|| sec
->owner
== NULL
)
2483 bfd_set_error(bfd_error_bad_value
);
2490 osec
= sec
->output_section
;
2491 sindx
= elf_section_data (osec
)->dynindx
;
2495 osec
= htab
->elf
.text_index_section
;
2496 sindx
= elf_section_data (osec
)->dynindx
;
2498 BFD_ASSERT (sindx
!= 0);
2500 /* We are turning this relocation into one
2501 against a section symbol, so subtract out
2502 the output section's address but not the
2503 offset of the input section in the output
2505 outrel
.r_addend
-= osec
->vma
;
2507 outrel
.r_info
= ELF64_R_INFO (sindx
, r_type
);
2511 sreloc
= elf_section_data (input_section
)->sreloc
;
2515 loc
= sreloc
->contents
;
2516 loc
+= sreloc
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2517 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2519 /* If this reloc is against an external symbol, we do
2520 not want to fiddle with the addend. Otherwise, we
2521 need to include the symbol value so that it becomes
2522 an addend for the dynamic reloc. */
2529 /* Relocations for tls literal pool entries. */
2530 case R_390_TLS_IE64
:
2533 Elf_Internal_Rela outrel
;
2537 outrel
.r_offset
= rel
->r_offset
2538 + input_section
->output_section
->vma
2539 + input_section
->output_offset
;
2540 outrel
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
2541 sreloc
= elf_section_data (input_section
)->sreloc
;
2544 loc
= sreloc
->contents
;
2545 loc
+= sreloc
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2546 bfd_elf64_swap_reloc_out (output_bfd
, &outrel
, loc
);
2550 case R_390_TLS_GD64
:
2551 case R_390_TLS_GOTIE64
:
2552 r_type
= elf_s390_tls_transition (info
, r_type
, h
== NULL
);
2553 tls_type
= GOT_UNKNOWN
;
2554 if (h
== NULL
&& local_got_offsets
)
2555 tls_type
= elf_s390_local_got_tls_type (input_bfd
) [r_symndx
];
2558 tls_type
= elf_s390_hash_entry(h
)->tls_type
;
2559 if (!info
->shared
&& h
->dynindx
== -1 && tls_type
>= GOT_TLS_IE
)
2560 r_type
= R_390_TLS_LE64
;
2562 if (r_type
== R_390_TLS_GD64
&& tls_type
>= GOT_TLS_IE
)
2563 r_type
= R_390_TLS_IE64
;
2565 if (r_type
== R_390_TLS_LE64
)
2567 /* This relocation gets optimized away by the local exec
2568 access optimization. */
2569 BFD_ASSERT (! unresolved_reloc
);
2570 bfd_put_64 (output_bfd
, -tpoff (info
, relocation
),
2571 contents
+ rel
->r_offset
);
2575 if (htab
->elf
.sgot
== NULL
)
2579 off
= h
->got
.offset
;
2582 if (local_got_offsets
== NULL
)
2585 off
= local_got_offsets
[r_symndx
];
2594 Elf_Internal_Rela outrel
;
2598 if (htab
->elf
.srelgot
== NULL
)
2601 outrel
.r_offset
= (htab
->elf
.sgot
->output_section
->vma
2602 + htab
->elf
.sgot
->output_offset
+ off
);
2604 indx
= h
&& h
->dynindx
!= -1 ? h
->dynindx
: 0;
2605 if (r_type
== R_390_TLS_GD64
)
2606 dr_type
= R_390_TLS_DTPMOD
;
2608 dr_type
= R_390_TLS_TPOFF
;
2609 if (dr_type
== R_390_TLS_TPOFF
&& indx
== 0)
2610 outrel
.r_addend
= relocation
- dtpoff_base (info
);
2612 outrel
.r_addend
= 0;
2613 outrel
.r_info
= ELF64_R_INFO (indx
, dr_type
);
2614 loc
= htab
->elf
.srelgot
->contents
;
2615 loc
+= htab
->elf
.srelgot
->reloc_count
++
2616 * sizeof (Elf64_External_Rela
);
2617 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2619 if (r_type
== R_390_TLS_GD64
)
2623 BFD_ASSERT (! unresolved_reloc
);
2624 bfd_put_64 (output_bfd
,
2625 relocation
- dtpoff_base (info
),
2626 htab
->elf
.sgot
->contents
+ off
+ GOT_ENTRY_SIZE
);
2630 outrel
.r_info
= ELF64_R_INFO (indx
, R_390_TLS_DTPOFF
);
2631 outrel
.r_offset
+= GOT_ENTRY_SIZE
;
2632 outrel
.r_addend
= 0;
2633 htab
->elf
.srelgot
->reloc_count
++;
2634 loc
+= sizeof (Elf64_External_Rela
);
2635 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2642 local_got_offsets
[r_symndx
] |= 1;
2645 if (off
>= (bfd_vma
) -2)
2647 if (r_type
== ELF64_R_TYPE (rel
->r_info
))
2649 relocation
= htab
->elf
.sgot
->output_offset
+ off
;
2650 if (r_type
== R_390_TLS_IE64
|| r_type
== R_390_TLS_IEENT
)
2651 relocation
+= htab
->elf
.sgot
->output_section
->vma
;
2652 unresolved_reloc
= FALSE
;
2656 bfd_put_64 (output_bfd
, htab
->elf
.sgot
->output_offset
+ off
,
2657 contents
+ rel
->r_offset
);
2662 case R_390_TLS_GOTIE12
:
2663 case R_390_TLS_GOTIE20
:
2664 case R_390_TLS_IEENT
:
2667 if (local_got_offsets
== NULL
)
2669 off
= local_got_offsets
[r_symndx
];
2671 goto emit_tls_relocs
;
2675 off
= h
->got
.offset
;
2676 tls_type
= elf_s390_hash_entry(h
)->tls_type
;
2677 if (info
->shared
|| h
->dynindx
!= -1 || tls_type
< GOT_TLS_IE
)
2678 goto emit_tls_relocs
;
2681 if (htab
->elf
.sgot
== NULL
)
2684 BFD_ASSERT (! unresolved_reloc
);
2685 bfd_put_64 (output_bfd
, -tpoff (info
, relocation
),
2686 htab
->elf
.sgot
->contents
+ off
);
2687 relocation
= htab
->elf
.sgot
->output_offset
+ off
;
2688 if (r_type
== R_390_TLS_IEENT
)
2689 relocation
+= htab
->elf
.sgot
->output_section
->vma
;
2690 unresolved_reloc
= FALSE
;
2693 case R_390_TLS_LDM64
:
2695 /* The literal pool entry this relocation refers to gets ignored
2696 by the optimized code of the local exec model. Do nothing
2697 and the value will turn out zero. */
2700 if (htab
->elf
.sgot
== NULL
)
2703 off
= htab
->tls_ldm_got
.offset
;
2708 Elf_Internal_Rela outrel
;
2711 if (htab
->elf
.srelgot
== NULL
)
2714 outrel
.r_offset
= (htab
->elf
.sgot
->output_section
->vma
2715 + htab
->elf
.sgot
->output_offset
+ off
);
2717 bfd_put_64 (output_bfd
, 0,
2718 htab
->elf
.sgot
->contents
+ off
+ GOT_ENTRY_SIZE
);
2719 outrel
.r_info
= ELF64_R_INFO (0, R_390_TLS_DTPMOD
);
2720 outrel
.r_addend
= 0;
2721 loc
= htab
->elf
.srelgot
->contents
;
2722 loc
+= htab
->elf
.srelgot
->reloc_count
++
2723 * sizeof (Elf64_External_Rela
);
2724 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2725 htab
->tls_ldm_got
.offset
|= 1;
2727 relocation
= htab
->elf
.sgot
->output_offset
+ off
;
2728 unresolved_reloc
= FALSE
;
2731 case R_390_TLS_LE64
:
2734 /* Linking a shared library with non-fpic code requires
2735 a R_390_TLS_TPOFF relocation. */
2736 Elf_Internal_Rela outrel
;
2741 outrel
.r_offset
= rel
->r_offset
2742 + input_section
->output_section
->vma
2743 + input_section
->output_offset
;
2744 if (h
!= NULL
&& h
->dynindx
!= -1)
2748 outrel
.r_info
= ELF64_R_INFO (indx
, R_390_TLS_TPOFF
);
2750 outrel
.r_addend
= relocation
- dtpoff_base (info
);
2752 outrel
.r_addend
= 0;
2753 sreloc
= elf_section_data (input_section
)->sreloc
;
2756 loc
= sreloc
->contents
;
2757 loc
+= sreloc
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2758 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2762 BFD_ASSERT (! unresolved_reloc
);
2763 bfd_put_64 (output_bfd
, -tpoff (info
, relocation
),
2764 contents
+ rel
->r_offset
);
2768 case R_390_TLS_LDO64
:
2769 if (info
->shared
|| (input_section
->flags
& SEC_DEBUGGING
))
2770 relocation
-= dtpoff_base (info
);
2772 /* When converting LDO to LE, we must negate. */
2773 relocation
= -tpoff (info
, relocation
);
2776 /* Relocations for tls instructions. */
2777 case R_390_TLS_LOAD
:
2778 case R_390_TLS_GDCALL
:
2779 case R_390_TLS_LDCALL
:
2780 tls_type
= GOT_UNKNOWN
;
2781 if (h
== NULL
&& local_got_offsets
)
2782 tls_type
= elf_s390_local_got_tls_type (input_bfd
) [r_symndx
];
2784 tls_type
= elf_s390_hash_entry(h
)->tls_type
;
2786 if (tls_type
== GOT_TLS_GD
)
2789 if (r_type
== R_390_TLS_LOAD
)
2791 if (!info
->shared
&& (h
== NULL
|| h
->dynindx
== -1))
2793 /* IE->LE transition. Four valid cases:
2794 lg %rx,(0,%ry) -> sllg %rx,%ry,0
2795 lg %rx,(%ry,0) -> sllg %rx,%ry,0
2796 lg %rx,(%ry,%r12) -> sllg %rx,%ry,0
2797 lg %rx,(%r12,%ry) -> sllg %rx,%ry,0 */
2798 unsigned int insn0
, insn1
, ry
;
2800 insn0
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
2801 insn1
= bfd_get_16 (input_bfd
, contents
+ rel
->r_offset
+ 4);
2802 if (insn1
!= 0x0004)
2803 invalid_tls_insn (input_bfd
, input_section
, rel
);
2805 if ((insn0
& 0xff00f000) == 0xe3000000)
2806 /* lg %rx,0(%ry,0) -> sllg %rx,%ry,0 */
2807 ry
= (insn0
& 0x000f0000);
2808 else if ((insn0
& 0xff0f0000) == 0xe3000000)
2809 /* lg %rx,0(0,%ry) -> sllg %rx,%ry,0 */
2810 ry
= (insn0
& 0x0000f000) << 4;
2811 else if ((insn0
& 0xff00f000) == 0xe300c000)
2812 /* lg %rx,0(%ry,%r12) -> sllg %rx,%ry,0 */
2813 ry
= (insn0
& 0x000f0000);
2814 else if ((insn0
& 0xff0f0000) == 0xe30c0000)
2815 /* lg %rx,0(%r12,%ry) -> sllg %rx,%ry,0 */
2816 ry
= (insn0
& 0x0000f000) << 4;
2818 invalid_tls_insn (input_bfd
, input_section
, rel
);
2819 insn0
= 0xeb000000 | (insn0
& 0x00f00000) | ry
;
2821 bfd_put_32 (output_bfd
, insn0
, contents
+ rel
->r_offset
);
2822 bfd_put_16 (output_bfd
, insn1
, contents
+ rel
->r_offset
+ 4);
2825 else if (r_type
== R_390_TLS_GDCALL
)
2827 unsigned int insn0
, insn1
;
2829 insn0
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
2830 insn1
= bfd_get_16 (input_bfd
, contents
+ rel
->r_offset
+ 4);
2831 if ((insn0
& 0xffff0000) != 0xc0e50000)
2832 invalid_tls_insn (input_bfd
, input_section
, rel
);
2833 if (!info
->shared
&& (h
== NULL
|| h
->dynindx
== -1))
2835 /* GD->LE transition.
2836 brasl %r14,__tls_get_addr@plt -> brcl 0,. */
2842 /* GD->IE transition.
2843 brasl %r14,__tls_get_addr@plt -> lg %r2,0(%r2,%r12) */
2847 bfd_put_32 (output_bfd
, insn0
, contents
+ rel
->r_offset
);
2848 bfd_put_16 (output_bfd
, insn1
, contents
+ rel
->r_offset
+ 4);
2850 else if (r_type
== R_390_TLS_LDCALL
)
2854 unsigned int insn0
, insn1
;
2856 insn0
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
2857 insn1
= bfd_get_16 (input_bfd
, contents
+ rel
->r_offset
+ 4);
2858 if ((insn0
& 0xffff0000) != 0xc0e50000)
2859 invalid_tls_insn (input_bfd
, input_section
, rel
);
2860 /* LD->LE transition.
2861 brasl %r14,__tls_get_addr@plt -> brcl 0,. */
2864 bfd_put_32 (output_bfd
, insn0
, contents
+ rel
->r_offset
);
2865 bfd_put_16 (output_bfd
, insn1
, contents
+ rel
->r_offset
+ 4);
2874 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
2875 because such sections are not SEC_ALLOC and thus ld.so will
2876 not process them. */
2877 if (unresolved_reloc
2878 && !((input_section
->flags
& SEC_DEBUGGING
) != 0
2880 && _bfd_elf_section_offset (output_bfd
, info
, input_section
,
2881 rel
->r_offset
) != (bfd_vma
) -1)
2882 (*_bfd_error_handler
)
2883 (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
2886 (long) rel
->r_offset
,
2888 h
->root
.root
.string
);
2890 if (r_type
== R_390_20
2891 || r_type
== R_390_GOT20
2892 || r_type
== R_390_GOTPLT20
2893 || r_type
== R_390_TLS_GOTIE20
)
2895 relocation
+= rel
->r_addend
;
2896 relocation
= (relocation
&0xfff) << 8 | (relocation
&0xff000) >> 12;
2897 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
2898 contents
, rel
->r_offset
,
2902 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
2903 contents
, rel
->r_offset
,
2904 relocation
, rel
->r_addend
);
2906 if (r
!= bfd_reloc_ok
)
2911 name
= h
->root
.root
.string
;
2914 name
= bfd_elf_string_from_elf_section (input_bfd
,
2915 symtab_hdr
->sh_link
,
2920 name
= bfd_section_name (input_bfd
, sec
);
2923 if (r
== bfd_reloc_overflow
)
2926 if (! ((*info
->callbacks
->reloc_overflow
)
2927 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
,
2928 (bfd_vma
) 0, input_bfd
, input_section
,
2934 (*_bfd_error_handler
)
2935 (_("%B(%A+0x%lx): reloc against `%s': error %d"),
2936 input_bfd
, input_section
,
2937 (long) rel
->r_offset
, name
, (int) r
);
2946 /* Finish up dynamic symbol handling. We set the contents of various
2947 dynamic sections here. */
2950 elf_s390_finish_dynamic_symbol (bfd
*output_bfd
,
2951 struct bfd_link_info
*info
,
2952 struct elf_link_hash_entry
*h
,
2953 Elf_Internal_Sym
*sym
)
2955 struct elf_s390_link_hash_table
*htab
;
2957 htab
= elf_s390_hash_table (info
);
2961 if (h
->plt
.offset
!= (bfd_vma
) -1)
2965 Elf_Internal_Rela rela
;
2968 /* This symbol has an entry in the procedure linkage table. Set
2971 if (h
->dynindx
== -1
2972 || htab
->elf
.splt
== NULL
2973 || htab
->elf
.sgotplt
== NULL
2974 || htab
->elf
.srelplt
== NULL
)
2978 Current offset - size first entry / entry size. */
2979 plt_index
= (h
->plt
.offset
- PLT_FIRST_ENTRY_SIZE
) / PLT_ENTRY_SIZE
;
2981 /* Offset in GOT is PLT index plus GOT headers(3) times 8,
2983 got_offset
= (plt_index
+ 3) * GOT_ENTRY_SIZE
;
2985 /* Fill in the blueprint of a PLT. */
2986 memcpy (htab
->elf
.splt
->contents
+ h
->plt
.offset
, elf_s390x_plt_entry
,
2989 /* Fixup the relative address to the GOT entry */
2990 bfd_put_32 (output_bfd
,
2991 (htab
->elf
.sgotplt
->output_section
->vma
+
2992 htab
->elf
.sgotplt
->output_offset
+ got_offset
2993 - (htab
->elf
.splt
->output_section
->vma
+ h
->plt
.offset
))/2,
2994 htab
->elf
.splt
->contents
+ h
->plt
.offset
+ 2);
2995 /* Fixup the relative branch to PLT 0 */
2996 bfd_put_32 (output_bfd
, - (PLT_FIRST_ENTRY_SIZE
+
2997 (PLT_ENTRY_SIZE
* plt_index
) + 22)/2,
2998 htab
->elf
.splt
->contents
+ h
->plt
.offset
+ 24);
2999 /* Fixup offset into .rela.plt section. */
3000 bfd_put_32 (output_bfd
, plt_index
* sizeof (Elf64_External_Rela
),
3001 htab
->elf
.splt
->contents
+ h
->plt
.offset
+ 28);
3003 /* Fill in the entry in the global offset table.
3004 Points to instruction after GOT offset. */
3005 bfd_put_64 (output_bfd
,
3006 (htab
->elf
.splt
->output_section
->vma
3007 + htab
->elf
.splt
->output_offset
3010 htab
->elf
.sgotplt
->contents
+ got_offset
);
3012 /* Fill in the entry in the .rela.plt section. */
3013 rela
.r_offset
= (htab
->elf
.sgotplt
->output_section
->vma
3014 + htab
->elf
.sgotplt
->output_offset
3016 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_JMP_SLOT
);
3018 loc
= htab
->elf
.srelplt
->contents
+ plt_index
* sizeof (Elf64_External_Rela
);
3019 bfd_elf64_swap_reloca_out (output_bfd
, &rela
, loc
);
3021 if (!h
->def_regular
)
3023 /* Mark the symbol as undefined, rather than as defined in
3024 the .plt section. Leave the value alone. This is a clue
3025 for the dynamic linker, to make function pointer
3026 comparisons work between an application and shared
3028 sym
->st_shndx
= SHN_UNDEF
;
3032 if (h
->got
.offset
!= (bfd_vma
) -1
3033 && elf_s390_hash_entry(h
)->tls_type
!= GOT_TLS_GD
3034 && elf_s390_hash_entry(h
)->tls_type
!= GOT_TLS_IE
3035 && elf_s390_hash_entry(h
)->tls_type
!= GOT_TLS_IE_NLT
)
3037 Elf_Internal_Rela rela
;
3040 /* This symbol has an entry in the global offset table. Set it
3042 if (htab
->elf
.sgot
== NULL
|| htab
->elf
.srelgot
== NULL
)
3045 rela
.r_offset
= (htab
->elf
.sgot
->output_section
->vma
3046 + htab
->elf
.sgot
->output_offset
3047 + (h
->got
.offset
&~ (bfd_vma
) 1));
3049 /* If this is a static link, or it is a -Bsymbolic link and the
3050 symbol is defined locally or was forced to be local because
3051 of a version file, we just want to emit a RELATIVE reloc.
3052 The entry in the global offset table will already have been
3053 initialized in the relocate_section function. */
3055 && SYMBOL_REFERENCES_LOCAL (info
, h
))
3057 if (!h
->def_regular
)
3059 BFD_ASSERT((h
->got
.offset
& 1) != 0);
3060 rela
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
3061 rela
.r_addend
= (h
->root
.u
.def
.value
3062 + h
->root
.u
.def
.section
->output_section
->vma
3063 + h
->root
.u
.def
.section
->output_offset
);
3067 BFD_ASSERT((h
->got
.offset
& 1) == 0);
3068 bfd_put_64 (output_bfd
, (bfd_vma
) 0, htab
->elf
.sgot
->contents
+ h
->got
.offset
);
3069 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_GLOB_DAT
);
3073 loc
= htab
->elf
.srelgot
->contents
;
3074 loc
+= htab
->elf
.srelgot
->reloc_count
++ * sizeof (Elf64_External_Rela
);
3075 bfd_elf64_swap_reloca_out (output_bfd
, &rela
, loc
);
3080 Elf_Internal_Rela rela
;
3083 /* This symbols needs a copy reloc. Set it up. */
3085 if (h
->dynindx
== -1
3086 || (h
->root
.type
!= bfd_link_hash_defined
3087 && h
->root
.type
!= bfd_link_hash_defweak
)
3088 || htab
->srelbss
== NULL
)
3091 rela
.r_offset
= (h
->root
.u
.def
.value
3092 + h
->root
.u
.def
.section
->output_section
->vma
3093 + h
->root
.u
.def
.section
->output_offset
);
3094 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_COPY
);
3096 loc
= htab
->srelbss
->contents
;
3097 loc
+= htab
->srelbss
->reloc_count
++ * sizeof (Elf64_External_Rela
);
3098 bfd_elf64_swap_reloca_out (output_bfd
, &rela
, loc
);
3101 /* Mark some specially defined symbols as absolute. */
3102 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
3103 || h
== htab
->elf
.hgot
3104 || h
== htab
->elf
.hplt
)
3105 sym
->st_shndx
= SHN_ABS
;
3110 /* Used to decide how to sort relocs in an optimal manner for the
3111 dynamic linker, before writing them out. */
3113 static enum elf_reloc_type_class
3114 elf_s390_reloc_type_class (const Elf_Internal_Rela
*rela
)
3116 switch ((int) ELF64_R_TYPE (rela
->r_info
))
3118 case R_390_RELATIVE
:
3119 return reloc_class_relative
;
3120 case R_390_JMP_SLOT
:
3121 return reloc_class_plt
;
3123 return reloc_class_copy
;
3125 return reloc_class_normal
;
3129 /* Finish up the dynamic sections. */
3132 elf_s390_finish_dynamic_sections (bfd
*output_bfd
,
3133 struct bfd_link_info
*info
)
3135 struct elf_s390_link_hash_table
*htab
;
3139 htab
= elf_s390_hash_table (info
);
3143 dynobj
= htab
->elf
.dynobj
;
3144 sdyn
= bfd_get_linker_section (dynobj
, ".dynamic");
3146 if (htab
->elf
.dynamic_sections_created
)
3148 Elf64_External_Dyn
*dyncon
, *dynconend
;
3150 if (sdyn
== NULL
|| htab
->elf
.sgot
== NULL
)
3153 dyncon
= (Elf64_External_Dyn
*) sdyn
->contents
;
3154 dynconend
= (Elf64_External_Dyn
*) (sdyn
->contents
+ sdyn
->size
);
3155 for (; dyncon
< dynconend
; dyncon
++)
3157 Elf_Internal_Dyn dyn
;
3160 bfd_elf64_swap_dyn_in (dynobj
, dyncon
, &dyn
);
3168 dyn
.d_un
.d_ptr
= htab
->elf
.sgot
->output_section
->vma
;
3172 dyn
.d_un
.d_ptr
= htab
->elf
.srelplt
->output_section
->vma
;
3176 s
= htab
->elf
.srelplt
->output_section
;
3177 dyn
.d_un
.d_val
= s
->size
;
3181 /* The procedure linkage table relocs (DT_JMPREL) should
3182 not be included in the overall relocs (DT_RELA).
3183 Therefore, we override the DT_RELASZ entry here to
3184 make it not include the JMPREL relocs. Since the
3185 linker script arranges for .rela.plt to follow all
3186 other relocation sections, we don't have to worry
3187 about changing the DT_RELA entry. */
3188 s
= htab
->elf
.srelplt
->output_section
;
3189 dyn
.d_un
.d_val
-= s
->size
;
3193 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
3196 /* Fill in the special first entry in the procedure linkage table. */
3197 if (htab
->elf
.splt
&& htab
->elf
.splt
->size
> 0)
3199 /* fill in blueprint for plt 0 entry */
3200 memcpy (htab
->elf
.splt
->contents
, elf_s390x_first_plt_entry
,
3201 PLT_FIRST_ENTRY_SIZE
);
3202 /* Fixup relative address to start of GOT */
3203 bfd_put_32 (output_bfd
,
3204 (htab
->elf
.sgotplt
->output_section
->vma
+
3205 htab
->elf
.sgotplt
->output_offset
3206 - htab
->elf
.splt
->output_section
->vma
- 6)/2,
3207 htab
->elf
.splt
->contents
+ 8);
3209 elf_section_data (htab
->elf
.splt
->output_section
)
3210 ->this_hdr
.sh_entsize
= PLT_ENTRY_SIZE
;
3213 if (htab
->elf
.sgotplt
)
3215 /* Fill in the first three entries in the global offset table. */
3216 if (htab
->elf
.sgotplt
->size
> 0)
3218 bfd_put_64 (output_bfd
,
3219 (sdyn
== NULL
? (bfd_vma
) 0
3220 : sdyn
->output_section
->vma
+ sdyn
->output_offset
),
3221 htab
->elf
.sgotplt
->contents
);
3222 /* One entry for shared object struct ptr. */
3223 bfd_put_64 (output_bfd
, (bfd_vma
) 0, htab
->elf
.sgotplt
->contents
+ 8);
3224 /* One entry for _dl_runtime_resolve. */
3225 bfd_put_64 (output_bfd
, (bfd_vma
) 0, htab
->elf
.sgotplt
->contents
+ 12);
3228 elf_section_data (htab
->elf
.sgot
->output_section
)
3229 ->this_hdr
.sh_entsize
= 8;
3234 /* Return address for Ith PLT stub in section PLT, for relocation REL
3235 or (bfd_vma) -1 if it should not be included. */
3238 elf_s390_plt_sym_val (bfd_vma i
, const asection
*plt
,
3239 const arelent
*rel ATTRIBUTE_UNUSED
)
3241 return plt
->vma
+ PLT_FIRST_ENTRY_SIZE
+ i
* PLT_ENTRY_SIZE
;
3245 /* Why was the hash table entry size definition changed from
3246 ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
3247 this is the only reason for the s390_elf64_size_info structure. */
3249 const struct elf_size_info s390_elf64_size_info
=
3251 sizeof (Elf64_External_Ehdr
),
3252 sizeof (Elf64_External_Phdr
),
3253 sizeof (Elf64_External_Shdr
),
3254 sizeof (Elf64_External_Rel
),
3255 sizeof (Elf64_External_Rela
),
3256 sizeof (Elf64_External_Sym
),
3257 sizeof (Elf64_External_Dyn
),
3258 sizeof (Elf_External_Note
),
3259 8, /* hash-table entry size. */
3260 1, /* internal relocations per external relocations. */
3261 64, /* arch_size. */
3262 3, /* log_file_align. */
3263 ELFCLASS64
, EV_CURRENT
,
3264 bfd_elf64_write_out_phdrs
,
3265 bfd_elf64_write_shdrs_and_ehdr
,
3266 bfd_elf64_checksum_contents
,
3267 bfd_elf64_write_relocs
,
3268 bfd_elf64_swap_symbol_in
,
3269 bfd_elf64_swap_symbol_out
,
3270 bfd_elf64_slurp_reloc_table
,
3271 bfd_elf64_slurp_symbol_table
,
3272 bfd_elf64_swap_dyn_in
,
3273 bfd_elf64_swap_dyn_out
,
3274 bfd_elf64_swap_reloc_in
,
3275 bfd_elf64_swap_reloc_out
,
3276 bfd_elf64_swap_reloca_in
,
3277 bfd_elf64_swap_reloca_out
3280 #define TARGET_BIG_SYM bfd_elf64_s390_vec
3281 #define TARGET_BIG_NAME "elf64-s390"
3282 #define ELF_ARCH bfd_arch_s390
3283 #define ELF_TARGET_ID S390_ELF_DATA
3284 #define ELF_MACHINE_CODE EM_S390
3285 #define ELF_MACHINE_ALT1 EM_S390_OLD
3286 #define ELF_MAXPAGESIZE 0x1000
3288 #define elf_backend_size_info s390_elf64_size_info
3290 #define elf_backend_can_gc_sections 1
3291 #define elf_backend_can_refcount 1
3292 #define elf_backend_want_got_plt 1
3293 #define elf_backend_plt_readonly 1
3294 #define elf_backend_want_plt_sym 0
3295 #define elf_backend_got_header_size 24
3296 #define elf_backend_rela_normal 1
3298 #define elf_info_to_howto elf_s390_info_to_howto
3300 #define bfd_elf64_bfd_is_local_label_name elf_s390_is_local_label_name
3301 #define bfd_elf64_bfd_link_hash_table_create elf_s390_link_hash_table_create
3302 #define bfd_elf64_bfd_reloc_type_lookup elf_s390_reloc_type_lookup
3303 #define bfd_elf64_bfd_reloc_name_lookup elf_s390_reloc_name_lookup
3305 #define elf_backend_adjust_dynamic_symbol elf_s390_adjust_dynamic_symbol
3306 #define elf_backend_check_relocs elf_s390_check_relocs
3307 #define elf_backend_copy_indirect_symbol elf_s390_copy_indirect_symbol
3308 #define elf_backend_create_dynamic_sections elf_s390_create_dynamic_sections
3309 #define elf_backend_finish_dynamic_sections elf_s390_finish_dynamic_sections
3310 #define elf_backend_finish_dynamic_symbol elf_s390_finish_dynamic_symbol
3311 #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
3312 #define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
3313 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
3314 #define elf_backend_relocate_section elf_s390_relocate_section
3315 #define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
3316 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
3317 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
3318 #define elf_backend_plt_sym_val elf_s390_plt_sym_val
3320 #define bfd_elf64_mkobject elf_s390_mkobject
3321 #define elf_backend_object_p elf_s390_object_p
3323 /* Enable ELF64 archive functions. */
3324 #define bfd_elf64_archive_functions
3325 extern bfd_boolean
bfd_elf64_archive_slurp_armap (bfd
*);
3326 extern bfd_boolean
bfd_elf64_archive_write_armap (bfd
*, unsigned int, struct orl
*, unsigned int, int);
3328 #define bfd_elf64_archive_slurp_extended_name_table _bfd_archive_coff_slurp_extended_name_table
3329 #define bfd_elf64_archive_construct_extended_name_table _bfd_archive_coff_construct_extended_name_table
3330 #define bfd_elf64_archive_truncate_arname _bfd_archive_coff_truncate_arname
3331 #define bfd_elf64_archive_read_ar_hdr _bfd_archive_coff_read_ar_hdr
3332 #define bfd_elf64_archive_write_ar_hdr _bfd_archive_coff_write_ar_hdr
3333 #define bfd_elf64_archive_openr_next_archived_file _bfd_archive_coff_openr_next_archived_file
3334 #define bfd_elf64_archive_get_elt_at_index _bfd_archive_coff_get_elt_at_index
3335 #define bfd_elf64_archive_generic_stat_arch_elt _bfd_archive_coff_generic_stat_arch_elt
3336 #define bfd_elf64_archive_update_armap_timestamp _bfd_archive_coff_update_armap_timestamp
3338 #include "elf64-target.h"