Fix definitions of wddata[bwl].
[deliverable/binutils-gdb.git] / bfd / elf32-s390.c
1 /* IBM S/390-specific support for 32-bit ELF
2 Copyright 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Carl B. Pedersen and Martin Schwidefsky.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "bfdlink.h"
25 #include "libbfd.h"
26 #include "elf-bfd.h"
27
28 static reloc_howto_type *elf_s390_reloc_type_lookup
29 PARAMS ((bfd *, bfd_reloc_code_real_type));
30 static void elf_s390_info_to_howto
31 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
32 static boolean elf_s390_is_local_label_name
33 PARAMS ((bfd *, const char *));
34 static struct bfd_hash_entry *link_hash_newfunc
35 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
36 static struct bfd_link_hash_table *elf_s390_link_hash_table_create
37 PARAMS ((bfd *));
38 static boolean create_got_section
39 PARAMS((bfd *, struct bfd_link_info *));
40 static boolean elf_s390_create_dynamic_sections
41 PARAMS((bfd *, struct bfd_link_info *));
42 static void elf_s390_copy_indirect_symbol
43 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
44 static boolean elf_s390_check_relocs
45 PARAMS ((bfd *, struct bfd_link_info *, asection *,
46 const Elf_Internal_Rela *));
47 static asection *elf_s390_gc_mark_hook
48 PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
49 struct elf_link_hash_entry *, Elf_Internal_Sym *));
50 static boolean elf_s390_gc_sweep_hook
51 PARAMS ((bfd *, struct bfd_link_info *, asection *,
52 const Elf_Internal_Rela *));
53 static boolean elf_s390_adjust_dynamic_symbol
54 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
55 static boolean allocate_dynrelocs
56 PARAMS ((struct elf_link_hash_entry *, PTR));
57 static boolean readonly_dynrelocs
58 PARAMS ((struct elf_link_hash_entry *, PTR));
59 static boolean elf_s390_size_dynamic_sections
60 PARAMS ((bfd *, struct bfd_link_info *));
61 static boolean elf_s390_relocate_section
62 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
63 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
64 static boolean elf_s390_finish_dynamic_symbol
65 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
66 Elf_Internal_Sym *));
67 static enum elf_reloc_type_class elf_s390_reloc_type_class
68 PARAMS ((const Elf_Internal_Rela *));
69 static boolean elf_s390_finish_dynamic_sections
70 PARAMS ((bfd *, struct bfd_link_info *));
71 static boolean elf_s390_object_p PARAMS ((bfd *));
72
73 #define USE_RELA 1 /* We want RELA relocations, not REL. */
74
75 #include "elf/s390.h"
76
77 /* The relocation "howto" table. */
78
79 static reloc_howto_type elf_howto_table[] =
80 {
81 HOWTO (R_390_NONE, /* type */
82 0, /* rightshift */
83 0, /* size (0 = byte, 1 = short, 2 = long) */
84 0, /* bitsize */
85 false, /* pc_relative */
86 0, /* bitpos */
87 complain_overflow_dont, /* complain_on_overflow */
88 bfd_elf_generic_reloc, /* special_function */
89 "R_390_NONE", /* name */
90 false, /* partial_inplace */
91 0, /* src_mask */
92 0, /* dst_mask */
93 false), /* pcrel_offset */
94
95 HOWTO(R_390_8, 0, 0, 8, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_8", false, 0,0x000000ff, false),
96 HOWTO(R_390_12, 0, 1, 12, false, 0, complain_overflow_dont, bfd_elf_generic_reloc, "R_390_12", false, 0,0x00000fff, false),
97 HOWTO(R_390_16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_16", false, 0,0x0000ffff, false),
98 HOWTO(R_390_32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_32", false, 0,0xffffffff, false),
99 HOWTO(R_390_PC32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC32", false, 0,0xffffffff, true),
100 HOWTO(R_390_GOT12, 0, 1, 12, false, 0, complain_overflow_dont, bfd_elf_generic_reloc, "R_390_GOT12", false, 0,0x00000fff, false),
101 HOWTO(R_390_GOT32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT32", false, 0,0xffffffff, false),
102 HOWTO(R_390_PLT32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT32", false, 0,0xffffffff, true),
103 HOWTO(R_390_COPY, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_COPY", false, 0,0xffffffff, false),
104 HOWTO(R_390_GLOB_DAT, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GLOB_DAT",false, 0,0xffffffff, false),
105 HOWTO(R_390_JMP_SLOT, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_JMP_SLOT",false, 0,0xffffffff, false),
106 HOWTO(R_390_RELATIVE, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_RELATIVE",false, 0,0xffffffff, false),
107 HOWTO(R_390_GOTOFF, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTOFF", false, 0,0xffffffff, false),
108 HOWTO(R_390_GOTPC, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTPC", false, 0,0xffffffff, true),
109 HOWTO(R_390_GOT16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT16", false, 0,0x0000ffff, false),
110 HOWTO(R_390_PC16, 0, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16", false, 0,0x0000ffff, true),
111 HOWTO(R_390_PC16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16DBL", false, 0,0x0000ffff, true),
112 HOWTO(R_390_PLT16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT16DBL", false, 0,0x0000ffff, true),
113 };
114
115 /* GNU extension to record C++ vtable hierarchy. */
116 static reloc_howto_type elf32_s390_vtinherit_howto =
117 HOWTO (R_390_GNU_VTINHERIT, 0,2,0,false,0,complain_overflow_dont, NULL, "R_390_GNU_VTINHERIT", false,0, 0, false);
118 static reloc_howto_type elf32_s390_vtentry_howto =
119 HOWTO (R_390_GNU_VTENTRY, 0,2,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", false,0,0, false);
120
121 static reloc_howto_type *
122 elf_s390_reloc_type_lookup (abfd, code)
123 bfd *abfd ATTRIBUTE_UNUSED;
124 bfd_reloc_code_real_type code;
125 {
126 switch (code)
127 {
128 case BFD_RELOC_NONE:
129 return &elf_howto_table[(int) R_390_NONE];
130 case BFD_RELOC_8:
131 return &elf_howto_table[(int) R_390_8];
132 case BFD_RELOC_390_12:
133 return &elf_howto_table[(int) R_390_12];
134 case BFD_RELOC_16:
135 return &elf_howto_table[(int) R_390_16];
136 case BFD_RELOC_32:
137 return &elf_howto_table[(int) R_390_32];
138 case BFD_RELOC_CTOR:
139 return &elf_howto_table[(int) R_390_32];
140 case BFD_RELOC_32_PCREL:
141 return &elf_howto_table[(int) R_390_PC32];
142 case BFD_RELOC_390_GOT12:
143 return &elf_howto_table[(int) R_390_GOT12];
144 case BFD_RELOC_32_GOT_PCREL:
145 return &elf_howto_table[(int) R_390_GOT32];
146 case BFD_RELOC_390_PLT32:
147 return &elf_howto_table[(int) R_390_PLT32];
148 case BFD_RELOC_390_COPY:
149 return &elf_howto_table[(int) R_390_COPY];
150 case BFD_RELOC_390_GLOB_DAT:
151 return &elf_howto_table[(int) R_390_GLOB_DAT];
152 case BFD_RELOC_390_JMP_SLOT:
153 return &elf_howto_table[(int) R_390_JMP_SLOT];
154 case BFD_RELOC_390_RELATIVE:
155 return &elf_howto_table[(int) R_390_RELATIVE];
156 case BFD_RELOC_32_GOTOFF:
157 return &elf_howto_table[(int) R_390_GOTOFF];
158 case BFD_RELOC_390_GOTPC:
159 return &elf_howto_table[(int) R_390_GOTPC];
160 case BFD_RELOC_390_GOT16:
161 return &elf_howto_table[(int) R_390_GOT16];
162 case BFD_RELOC_16_PCREL:
163 return &elf_howto_table[(int) R_390_PC16];
164 case BFD_RELOC_390_PC16DBL:
165 return &elf_howto_table[(int) R_390_PC16DBL];
166 case BFD_RELOC_390_PLT16DBL:
167 return &elf_howto_table[(int) R_390_PLT16DBL];
168 case BFD_RELOC_VTABLE_INHERIT:
169 return &elf32_s390_vtinherit_howto;
170 case BFD_RELOC_VTABLE_ENTRY:
171 return &elf32_s390_vtentry_howto;
172 default:
173 break;
174 }
175 return 0;
176 }
177
178 /* We need to use ELF32_R_TYPE so we have our own copy of this function,
179 and elf32-s390.c has its own copy. */
180
181 static void
182 elf_s390_info_to_howto (abfd, cache_ptr, dst)
183 bfd *abfd ATTRIBUTE_UNUSED;
184 arelent *cache_ptr;
185 Elf_Internal_Rela *dst;
186 {
187 switch (ELF32_R_TYPE(dst->r_info))
188 {
189 case R_390_GNU_VTINHERIT:
190 cache_ptr->howto = &elf32_s390_vtinherit_howto;
191 break;
192
193 case R_390_GNU_VTENTRY:
194 cache_ptr->howto = &elf32_s390_vtentry_howto;
195 break;
196
197 default:
198 BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_390_max);
199 cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
200 }
201 }
202
203 static boolean
204 elf_s390_is_local_label_name (abfd, name)
205 bfd *abfd;
206 const char *name;
207 {
208 if (name[0] == '.' && (name[1] == 'X' || name[1] == 'L'))
209 return true;
210
211 return _bfd_elf_is_local_label_name (abfd, name);
212 }
213
214 /* Functions for the 390 ELF linker. */
215
216 /* The name of the dynamic interpreter. This is put in the .interp
217 section. */
218
219 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
220
221 /* The size in bytes of the first entry in the procedure linkage table. */
222 #define PLT_FIRST_ENTRY_SIZE 32
223 /* The size in bytes of an entry in the procedure linkage table. */
224 #define PLT_ENTRY_SIZE 32
225
226 #define GOT_ENTRY_SIZE 4
227
228 /* The first three entries in a procedure linkage table are reserved,
229 and the initial contents are unimportant (we zero them out).
230 Subsequent entries look like this. See the SVR4 ABI 386
231 supplement to see how this works. */
232
233 /* For the s390, simple addr offset can only be 0 - 4096.
234 To use the full 2 GB address space, several instructions
235 are needed to load an address in a register and execute
236 a branch( or just saving the address)
237
238 Furthermore, only r 0 and 1 are free to use!!! */
239
240 /* The first 3 words in the GOT are then reserved.
241 Word 0 is the address of the dynamic table.
242 Word 1 is a pointer to a structure describing the object
243 Word 2 is used to point to the loader entry address.
244
245 The code for position independand PLT entries looks like this:
246
247 r12 holds addr of the current GOT at entry to the PLT
248
249 The GOT holds the address in the PLT to be executed.
250 The loader then gets:
251 24(15) = Pointer to the structure describing the object.
252 28(15) = Offset in symbol table
253
254 The loader must then find the module where the function is
255 and insert the address in the GOT.
256
257 Note: 390 can only address +- 64 K relative.
258 We check if offset > 65536, then make a relative branch -64xxx
259 back to a previous defined branch
260
261 PLT1: BASR 1,0 # 2 bytes
262 L 1,22(1) # 4 bytes Load offset in GOT in r 1
263 L 1,(1,12) # 4 bytes Load address from GOT in r1
264 BCR 15,1 # 2 bytes Jump to address
265 RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
266 L 1,14(1) # 4 bytes Load offset in symol table in r1
267 BRC 15,-x # 4 bytes Jump to start of PLT
268 .word 0 # 2 bytes filler
269 .long ? # 4 bytes offset in GOT
270 .long ? # 4 bytes offset into symbol table
271
272 This was the general case. There are two additional, optimizes PLT
273 definitions. One for GOT offsets < 4096 and one for GOT offsets < 32768.
274 First the one for GOT offsets < 4096:
275
276 PLT1: L 1,<offset>(12) # 4 bytes Load address from GOT in R1
277 BCR 15,1 # 2 bytes Jump to address
278 .word 0,0,0 # 6 bytes filler
279 RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
280 L 1,14(1) # 4 bytes Load offset in symbol table in r1
281 BRC 15,-x # 4 bytes Jump to start of PLT
282 .word 0,0,0 # 6 bytes filler
283 .long ? # 4 bytes offset into symbol table
284
285 Second the one for GOT offsets < 32768:
286
287 PLT1: LHI 1,<offset> # 4 bytes Load offset in GOT to r1
288 L 1,(1,12) # 4 bytes Load address from GOT to r1
289 BCR 15,1 # 2 bytes Jump to address
290 .word 0 # 2 bytes filler
291 RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
292 L 1,14(1) # 4 bytes Load offset in symbol table in r1
293 BRC 15,-x # 4 bytes Jump to start of PLT
294 .word 0,0,0 # 6 bytes filler
295 .long ? # 4 bytes offset into symbol table
296
297 Total = 32 bytes per PLT entry
298
299 The code for static build PLT entries looks like this:
300
301 PLT1: BASR 1,0 # 2 bytes
302 L 1,22(1) # 4 bytes Load address of GOT entry
303 L 1,0(0,1) # 4 bytes Load address from GOT in r1
304 BCR 15,1 # 2 bytes Jump to address
305 RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
306 L 1,14(1) # 4 bytes Load offset in symbol table in r1
307 BRC 15,-x # 4 bytes Jump to start of PLT
308 .word 0 # 2 bytes filler
309 .long ? # 4 bytes address of GOT entry
310 .long ? # 4 bytes offset into symbol table */
311
312 #define PLT_PIC_ENTRY_WORD0 0x0d105810
313 #define PLT_PIC_ENTRY_WORD1 0x10165811
314 #define PLT_PIC_ENTRY_WORD2 0xc00007f1
315 #define PLT_PIC_ENTRY_WORD3 0x0d105810
316 #define PLT_PIC_ENTRY_WORD4 0x100ea7f4
317
318 #define PLT_PIC12_ENTRY_WORD0 0x5810c000
319 #define PLT_PIC12_ENTRY_WORD1 0x07f10000
320 #define PLT_PIC12_ENTRY_WORD2 0x00000000
321 #define PLT_PIC12_ENTRY_WORD3 0x0d105810
322 #define PLT_PIC12_ENTRY_WORD4 0x100ea7f4
323
324 #define PLT_PIC16_ENTRY_WORD0 0xa7180000
325 #define PLT_PIC16_ENTRY_WORD1 0x5811c000
326 #define PLT_PIC16_ENTRY_WORD2 0x07f10000
327 #define PLT_PIC16_ENTRY_WORD3 0x0d105810
328 #define PLT_PIC16_ENTRY_WORD4 0x100ea7f4
329
330 #define PLT_ENTRY_WORD0 0x0d105810
331 #define PLT_ENTRY_WORD1 0x10165810
332 #define PLT_ENTRY_WORD2 0x100007f1
333 #define PLT_ENTRY_WORD3 0x0d105810
334 #define PLT_ENTRY_WORD4 0x100ea7f4
335
336 /* The first PLT entry pushes the offset into the symbol table
337 from R1 onto the stack at 8(15) and the loader object info
338 at 12(15), loads the loader address in R1 and jumps to it. */
339
340 /* The first entry in the PLT for PIC code:
341
342 PLT0:
343 ST 1,28(15) # R1 has offset into symbol table
344 L 1,4(12) # Get loader ino(object struct address)
345 ST 1,24(15) # Store address
346 L 1,8(12) # Entry address of loader in R1
347 BR 1 # Jump to loader
348
349 The first entry in the PLT for static code:
350
351 PLT0:
352 ST 1,28(15) # R1 has offset into symbol table
353 BASR 1,0
354 L 1,18(0,1) # Get address of GOT
355 MVC 24(4,15),4(1) # Move loader ino to stack
356 L 1,8(1) # Get address of loader
357 BR 1 # Jump to loader
358 .word 0 # filler
359 .long got # address of GOT */
360
361 #define PLT_PIC_FIRST_ENTRY_WORD0 0x5010f01c
362 #define PLT_PIC_FIRST_ENTRY_WORD1 0x5810c004
363 #define PLT_PIC_FIRST_ENTRY_WORD2 0x5010f018
364 #define PLT_PIC_FIRST_ENTRY_WORD3 0x5810c008
365 #define PLT_PIC_FIRST_ENTRY_WORD4 0x07f10000
366
367 #define PLT_FIRST_ENTRY_WORD0 0x5010f01c
368 #define PLT_FIRST_ENTRY_WORD1 0x0d105810
369 #define PLT_FIRST_ENTRY_WORD2 0x1012D203
370 #define PLT_FIRST_ENTRY_WORD3 0xf0181004
371 #define PLT_FIRST_ENTRY_WORD4 0x58101008
372 #define PLT_FIRST_ENTRY_WORD5 0x07f10000
373
374 /* The s390 linker needs to keep track of the number of relocs that it
375 decides to copy as dynamic relocs in check_relocs for each symbol.
376 This is so that it can later discard them if they are found to be
377 unnecessary. We store the information in a field extending the
378 regular ELF linker hash table. */
379
380 struct elf_s390_dyn_relocs
381 {
382 struct elf_s390_dyn_relocs *next;
383
384 /* The input section of the reloc. */
385 asection *sec;
386
387 /* Total number of relocs copied for the input section. */
388 bfd_size_type count;
389
390 /* Number of pc-relative relocs copied for the input section. */
391 bfd_size_type pc_count;
392 };
393
394 /* s390 ELF linker hash entry. */
395
396 struct elf_s390_link_hash_entry
397 {
398 struct elf_link_hash_entry elf;
399
400 /* Track dynamic relocs copied for this symbol. */
401 struct elf_s390_dyn_relocs *dyn_relocs;
402 };
403
404 /* s390 ELF linker hash table. */
405
406 struct elf_s390_link_hash_table
407 {
408 struct elf_link_hash_table elf;
409
410 /* Short-cuts to get to dynamic linker sections. */
411 asection *sgot;
412 asection *sgotplt;
413 asection *srelgot;
414 asection *splt;
415 asection *srelplt;
416 asection *sdynbss;
417 asection *srelbss;
418
419 /* Small local sym to section mapping cache. */
420 struct sym_sec_cache sym_sec;
421 };
422
423 /* Get the s390 ELF linker hash table from a link_info structure. */
424
425 #define elf_s390_hash_table(p) \
426 ((struct elf_s390_link_hash_table *) ((p)->hash))
427
428 /* Create an entry in an s390 ELF linker hash table. */
429
430 static struct bfd_hash_entry *
431 link_hash_newfunc (entry, table, string)
432 struct bfd_hash_entry *entry;
433 struct bfd_hash_table *table;
434 const char *string;
435 {
436 /* Allocate the structure if it has not already been allocated by a
437 subclass. */
438 if (entry == NULL)
439 {
440 entry = bfd_hash_allocate (table,
441 sizeof (struct elf_s390_link_hash_entry));
442 if (entry == NULL)
443 return entry;
444 }
445
446 /* Call the allocation method of the superclass. */
447 entry = _bfd_elf_link_hash_newfunc (entry, table, string);
448 if (entry != NULL)
449 {
450 struct elf_s390_link_hash_entry *eh;
451
452 eh = (struct elf_s390_link_hash_entry *) entry;
453 eh->dyn_relocs = NULL;
454 }
455
456 return entry;
457 }
458
459 /* Create an s390 ELF linker hash table. */
460
461 static struct bfd_link_hash_table *
462 elf_s390_link_hash_table_create (abfd)
463 bfd *abfd;
464 {
465 struct elf_s390_link_hash_table *ret;
466 bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
467
468 ret = (struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt);
469 if (ret == NULL)
470 return NULL;
471
472 if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
473 {
474 bfd_release (abfd, ret);
475 return NULL;
476 }
477
478 ret->sgot = NULL;
479 ret->sgotplt = NULL;
480 ret->srelgot = NULL;
481 ret->splt = NULL;
482 ret->srelplt = NULL;
483 ret->sdynbss = NULL;
484 ret->srelbss = NULL;
485 ret->sym_sec.abfd = NULL;
486
487 return &ret->elf.root;
488 }
489
490 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
491 shortcuts to them in our hash table. */
492
493 static boolean
494 create_got_section (dynobj, info)
495 bfd *dynobj;
496 struct bfd_link_info *info;
497 {
498 struct elf_s390_link_hash_table *htab;
499
500 if (! _bfd_elf_create_got_section (dynobj, info))
501 return false;
502
503 htab = elf_s390_hash_table (info);
504 htab->sgot = bfd_get_section_by_name (dynobj, ".got");
505 htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
506 if (!htab->sgot || !htab->sgotplt)
507 abort ();
508
509 htab->srelgot = bfd_make_section (dynobj, ".rela.got");
510 if (htab->srelgot == NULL
511 || ! bfd_set_section_flags (dynobj, htab->srelgot,
512 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
513 | SEC_IN_MEMORY | SEC_LINKER_CREATED
514 | SEC_READONLY))
515 || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
516 return false;
517 return true;
518 }
519
520 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
521 .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
522 hash table. */
523
524 static boolean
525 elf_s390_create_dynamic_sections (dynobj, info)
526 bfd *dynobj;
527 struct bfd_link_info *info;
528 {
529 struct elf_s390_link_hash_table *htab;
530
531 htab = elf_s390_hash_table (info);
532 if (!htab->sgot && !create_got_section (dynobj, info))
533 return false;
534
535 if (!_bfd_elf_create_dynamic_sections (dynobj, info))
536 return false;
537
538 htab->splt = bfd_get_section_by_name (dynobj, ".plt");
539 htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
540 htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
541 if (!info->shared)
542 htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
543
544 if (!htab->splt || !htab->srelplt || !htab->sdynbss
545 || (!info->shared && !htab->srelbss))
546 abort ();
547
548 return true;
549 }
550
551 /* Copy the extra info we tack onto an elf_link_hash_entry. */
552
553 static void
554 elf_s390_copy_indirect_symbol (dir, ind)
555 struct elf_link_hash_entry *dir, *ind;
556 {
557 struct elf_s390_link_hash_entry *edir, *eind;
558
559 edir = (struct elf_s390_link_hash_entry *) dir;
560 eind = (struct elf_s390_link_hash_entry *) ind;
561
562 if (eind->dyn_relocs != NULL)
563 {
564 if (edir->dyn_relocs != NULL)
565 {
566 struct elf_s390_dyn_relocs **pp;
567 struct elf_s390_dyn_relocs *p;
568
569 if (ind->root.type == bfd_link_hash_indirect)
570 abort ();
571
572 /* Add reloc counts against the weak sym to the strong sym
573 list. Merge any entries against the same section. */
574 for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
575 {
576 struct elf_s390_dyn_relocs *q;
577
578 for (q = edir->dyn_relocs; q != NULL; q = q->next)
579 if (q->sec == p->sec)
580 {
581 q->pc_count += p->pc_count;
582 q->count += p->count;
583 *pp = p->next;
584 break;
585 }
586 if (q == NULL)
587 pp = &p->next;
588 }
589 *pp = edir->dyn_relocs;
590 }
591
592 edir->dyn_relocs = eind->dyn_relocs;
593 eind->dyn_relocs = NULL;
594 }
595
596 _bfd_elf_link_hash_copy_indirect (dir, ind);
597 }
598
599 /* Look through the relocs for a section during the first phase, and
600 allocate space in the global offset table or procedure linkage
601 table. */
602
603 static boolean
604 elf_s390_check_relocs (abfd, info, sec, relocs)
605 bfd *abfd;
606 struct bfd_link_info *info;
607 asection *sec;
608 const Elf_Internal_Rela *relocs;
609 {
610 struct elf_s390_link_hash_table *htab;
611 Elf_Internal_Shdr *symtab_hdr;
612 struct elf_link_hash_entry **sym_hashes;
613 const Elf_Internal_Rela *rel;
614 const Elf_Internal_Rela *rel_end;
615 asection *sreloc;
616
617 if (info->relocateable)
618 return true;
619
620 htab = elf_s390_hash_table (info);
621 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
622 sym_hashes = elf_sym_hashes (abfd);
623
624 sreloc = NULL;
625
626 rel_end = relocs + sec->reloc_count;
627 for (rel = relocs; rel < rel_end; rel++)
628 {
629 unsigned long r_symndx;
630 struct elf_link_hash_entry *h;
631
632 r_symndx = ELF32_R_SYM (rel->r_info);
633
634 if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
635 {
636 (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
637 bfd_archive_filename (abfd),
638 r_symndx);
639 return false;
640 }
641
642 if (r_symndx < symtab_hdr->sh_info)
643 h = NULL;
644 else
645 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
646
647 switch (ELF32_R_TYPE (rel->r_info))
648 {
649 case R_390_GOT12:
650 case R_390_GOT16:
651 case R_390_GOT32:
652 /* This symbol requires a global offset table entry. */
653 if (h != NULL)
654 {
655 h->got.refcount += 1;
656 }
657 else
658 {
659 bfd_signed_vma *local_got_refcounts;
660
661 /* This is a global offset table entry for a local symbol. */
662 local_got_refcounts = elf_local_got_refcounts (abfd);
663 if (local_got_refcounts == NULL)
664 {
665 bfd_size_type size;
666
667 size = symtab_hdr->sh_info;
668 size *= sizeof (bfd_signed_vma);
669 local_got_refcounts = ((bfd_signed_vma *)
670 bfd_zalloc (abfd, size));
671 if (local_got_refcounts == NULL)
672 return false;
673 elf_local_got_refcounts (abfd) = local_got_refcounts;
674 }
675 local_got_refcounts[r_symndx] += 1;
676 }
677 /* Fall through */
678
679 case R_390_GOTOFF:
680 case R_390_GOTPC:
681 if (htab->sgot == NULL)
682 {
683 if (htab->elf.dynobj == NULL)
684 htab->elf.dynobj = abfd;
685 if (!create_got_section (htab->elf.dynobj, info))
686 return false;
687 }
688 break;
689
690 case R_390_PLT16DBL:
691 case R_390_PLT32:
692 /* This symbol requires a procedure linkage table entry. We
693 actually build the entry in adjust_dynamic_symbol,
694 because this might be a case of linking PIC code which is
695 never referenced by a dynamic object, in which case we
696 don't need to generate a procedure linkage table entry
697 after all. */
698
699 /* If this is a local symbol, we resolve it directly without
700 creating a procedure linkage table entry. */
701 if (h == NULL)
702 continue;
703
704 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
705 h->plt.refcount += 1;
706 break;
707
708 case R_390_8:
709 case R_390_16:
710 case R_390_32:
711 case R_390_PC16:
712 case R_390_PC16DBL:
713 case R_390_PC32:
714 if (h != NULL && !info->shared)
715 {
716 /* If this reloc is in a read-only section, we might
717 need a copy reloc. We can't check reliably at this
718 stage whether the section is read-only, as input
719 sections have not yet been mapped to output sections.
720 Tentatively set the flag for now, and correct in
721 adjust_dynamic_symbol. */
722 h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
723
724 /* We may need a .plt entry if the function this reloc
725 refers to is in a shared lib. */
726 h->plt.refcount += 1;
727 }
728
729 /* If we are creating a shared library, and this is a reloc
730 against a global symbol, or a non PC relative reloc
731 against a local symbol, then we need to copy the reloc
732 into the shared library. However, if we are linking with
733 -Bsymbolic, we do not need to copy a reloc against a
734 global symbol which is defined in an object we are
735 including in the link (i.e., DEF_REGULAR is set). At
736 this point we have not seen all the input files, so it is
737 possible that DEF_REGULAR is not set now but will be set
738 later (it is never cleared). In case of a weak definition,
739 DEF_REGULAR may be cleared later by a strong definition in
740 a shared library. We account for that possibility below by
741 storing information in the relocs_copied field of the hash
742 table entry. A similar situation occurs when creating
743 shared libraries and symbol visibility changes render the
744 symbol local.
745
746 If on the other hand, we are creating an executable, we
747 may need to keep relocations for symbols satisfied by a
748 dynamic library if we manage to avoid copy relocs for the
749 symbol. */
750 if ((info->shared
751 && (sec->flags & SEC_ALLOC) != 0
752 && ((ELF32_R_TYPE (rel->r_info) != R_390_PC16
753 && ELF32_R_TYPE (rel->r_info) != R_390_PC16DBL
754 && ELF32_R_TYPE (rel->r_info) != R_390_PC32)
755 || (h != NULL
756 && (! info->symbolic
757 || h->root.type == bfd_link_hash_defweak
758 || (h->elf_link_hash_flags
759 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
760 || (!info->shared
761 && (sec->flags & SEC_ALLOC) != 0
762 && h != NULL
763 && (h->root.type == bfd_link_hash_defweak
764 || (h->elf_link_hash_flags
765 & ELF_LINK_HASH_DEF_REGULAR) == 0)))
766 {
767 struct elf_s390_dyn_relocs *p;
768 struct elf_s390_dyn_relocs **head;
769
770 /* We must copy these reloc types into the output file.
771 Create a reloc section in dynobj and make room for
772 this reloc. */
773 if (sreloc == NULL)
774 {
775 const char *name;
776 bfd *dynobj;
777
778 name = (bfd_elf_string_from_elf_section
779 (abfd,
780 elf_elfheader (abfd)->e_shstrndx,
781 elf_section_data (sec)->rel_hdr.sh_name));
782 if (name == NULL)
783 return false;
784
785 if (strncmp (name, ".rela", 5) != 0
786 || strcmp (bfd_get_section_name (abfd, sec),
787 name + 5) != 0)
788 {
789 (*_bfd_error_handler)
790 (_("%s: bad relocation section name `%s\'"),
791 bfd_archive_filename (abfd), name);
792 }
793
794 if (htab->elf.dynobj == NULL)
795 htab->elf.dynobj = abfd;
796
797 dynobj = htab->elf.dynobj;
798 sreloc = bfd_get_section_by_name (dynobj, name);
799 if (sreloc == NULL)
800 {
801 flagword flags;
802
803 sreloc = bfd_make_section (dynobj, name);
804 flags = (SEC_HAS_CONTENTS | SEC_READONLY
805 | SEC_IN_MEMORY | SEC_LINKER_CREATED);
806 if ((sec->flags & SEC_ALLOC) != 0)
807 flags |= SEC_ALLOC | SEC_LOAD;
808 if (sreloc == NULL
809 || ! bfd_set_section_flags (dynobj, sreloc, flags)
810 || ! bfd_set_section_alignment (dynobj, sreloc, 2))
811 return false;
812 }
813 elf_section_data (sec)->sreloc = sreloc;
814 }
815
816 /* If this is a global symbol, we count the number of
817 relocations we need for this symbol. */
818 if (h != NULL)
819 {
820 head = &((struct elf_s390_link_hash_entry *) h)->dyn_relocs;
821 }
822 else
823 {
824 /* Track dynamic relocs needed for local syms too.
825 We really need local syms available to do this
826 easily. Oh well. */
827
828 asection *s;
829 s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
830 sec, r_symndx);
831 if (s == NULL)
832 return false;
833
834 head = ((struct elf_s390_dyn_relocs **)
835 &elf_section_data (s)->local_dynrel);
836 }
837
838 p = *head;
839 if (p == NULL || p->sec != sec)
840 {
841 bfd_size_type amt = sizeof *p;
842 p = ((struct elf_s390_dyn_relocs *)
843 bfd_alloc (htab->elf.dynobj, amt));
844 if (p == NULL)
845 return false;
846 p->next = *head;
847 *head = p;
848 p->sec = sec;
849 p->count = 0;
850 p->pc_count = 0;
851 }
852
853 p->count += 1;
854 if (ELF32_R_TYPE (rel->r_info) == R_390_PC16
855 || ELF32_R_TYPE (rel->r_info) == R_390_PC16DBL
856 || ELF32_R_TYPE (rel->r_info) == R_390_PC32)
857 p->pc_count += 1;
858 }
859 break;
860
861 /* This relocation describes the C++ object vtable hierarchy.
862 Reconstruct it for later use during GC. */
863 case R_390_GNU_VTINHERIT:
864 if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
865 return false;
866 break;
867
868 /* This relocation describes which C++ vtable entries are actually
869 used. Record for later use during GC. */
870 case R_390_GNU_VTENTRY:
871 if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
872 return false;
873 break;
874
875 default:
876 break;
877 }
878 }
879
880 return true;
881 }
882
883 /* Return the section that should be marked against GC for a given
884 relocation. */
885
886 static asection *
887 elf_s390_gc_mark_hook (abfd, info, rel, h, sym)
888 bfd *abfd;
889 struct bfd_link_info *info ATTRIBUTE_UNUSED;
890 Elf_Internal_Rela *rel;
891 struct elf_link_hash_entry *h;
892 Elf_Internal_Sym *sym;
893 {
894 if (h != NULL)
895 {
896 switch (ELF32_R_TYPE (rel->r_info))
897 {
898 case R_390_GNU_VTINHERIT:
899 case R_390_GNU_VTENTRY:
900 break;
901
902 default:
903 switch (h->root.type)
904 {
905 case bfd_link_hash_defined:
906 case bfd_link_hash_defweak:
907 return h->root.u.def.section;
908
909 case bfd_link_hash_common:
910 return h->root.u.c.p->section;
911
912 default:
913 break;
914 }
915 }
916 }
917 else
918 {
919 if (!(elf_bad_symtab (abfd)
920 && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
921 && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
922 && sym->st_shndx != SHN_COMMON))
923 {
924 return bfd_section_from_elf_index (abfd, sym->st_shndx);
925 }
926 }
927
928 return NULL;
929 }
930
931 /* Update the got entry reference counts for the section being removed. */
932
933 static boolean
934 elf_s390_gc_sweep_hook (abfd, info, sec, relocs)
935 bfd *abfd;
936 struct bfd_link_info *info;
937 asection *sec;
938 const Elf_Internal_Rela *relocs;
939 {
940 Elf_Internal_Shdr *symtab_hdr;
941 struct elf_link_hash_entry **sym_hashes;
942 bfd_signed_vma *local_got_refcounts;
943 const Elf_Internal_Rela *rel, *relend;
944 unsigned long r_symndx;
945 struct elf_link_hash_entry *h;
946
947 elf_section_data (sec)->local_dynrel = NULL;
948
949 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
950 sym_hashes = elf_sym_hashes (abfd);
951 local_got_refcounts = elf_local_got_refcounts (abfd);
952
953 relend = relocs + sec->reloc_count;
954 for (rel = relocs; rel < relend; rel++)
955 switch (ELF32_R_TYPE (rel->r_info))
956 {
957 case R_390_GOT12:
958 case R_390_GOT16:
959 case R_390_GOT32:
960 case R_390_GOTOFF:
961 case R_390_GOTPC:
962 r_symndx = ELF32_R_SYM (rel->r_info);
963 if (r_symndx >= symtab_hdr->sh_info)
964 {
965 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
966 if (h->got.refcount > 0)
967 h->got.refcount -= 1;
968 }
969 else if (local_got_refcounts != NULL)
970 {
971 if (local_got_refcounts[r_symndx] > 0)
972 local_got_refcounts[r_symndx] -= 1;
973 }
974 break;
975
976 case R_390_8:
977 case R_390_12:
978 case R_390_16:
979 case R_390_32:
980 case R_390_PC16:
981 case R_390_PC16DBL:
982 case R_390_PC32:
983 r_symndx = ELF32_R_SYM (rel->r_info);
984 if (r_symndx >= symtab_hdr->sh_info)
985 {
986 struct elf_s390_link_hash_entry *eh;
987 struct elf_s390_dyn_relocs **pp;
988 struct elf_s390_dyn_relocs *p;
989
990 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
991
992 if (!info->shared && h->plt.refcount > 0)
993 h->plt.refcount -= 1;
994
995 eh = (struct elf_s390_link_hash_entry *) h;
996
997 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
998 if (p->sec == sec)
999 {
1000 if (ELF32_R_TYPE (rel->r_info) == R_390_PC16
1001 || ELF32_R_TYPE (rel->r_info) == R_390_PC16DBL
1002 || ELF32_R_TYPE (rel->r_info) == R_390_PC32)
1003 p->pc_count -= 1;
1004 p->count -= 1;
1005 if (p->count == 0)
1006 *pp = p->next;
1007 break;
1008 }
1009 }
1010 break;
1011
1012 case R_390_PLT16DBL:
1013 case R_390_PLT32:
1014 r_symndx = ELF32_R_SYM (rel->r_info);
1015 if (r_symndx >= symtab_hdr->sh_info)
1016 {
1017 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1018 if (h->plt.refcount > 0)
1019 h->plt.refcount -= 1;
1020 }
1021 break;
1022
1023 default:
1024 break;
1025 }
1026
1027 return true;
1028 }
1029
1030 /* Adjust a symbol defined by a dynamic object and referenced by a
1031 regular object. The current definition is in some section of the
1032 dynamic object, but we're not including those sections. We have to
1033 change the definition to something the rest of the link can
1034 understand. */
1035
1036 static boolean
1037 elf_s390_adjust_dynamic_symbol (info, h)
1038 struct bfd_link_info *info;
1039 struct elf_link_hash_entry *h;
1040 {
1041 struct elf_s390_link_hash_table *htab;
1042 struct elf_s390_link_hash_entry * eh;
1043 struct elf_s390_dyn_relocs *p;
1044 asection *s;
1045 unsigned int power_of_two;
1046
1047 /* If this is a function, put it in the procedure linkage table. We
1048 will fill in the contents of the procedure linkage table later
1049 (although we could actually do it here). */
1050 if (h->type == STT_FUNC
1051 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
1052 {
1053 if (h->plt.refcount <= 0
1054 || (! info->shared
1055 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
1056 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0))
1057 {
1058 /* This case can occur if we saw a PLT32 reloc in an input
1059 file, but the symbol was never referred to by a dynamic
1060 object, or if all references were garbage collected. In
1061 such a case, we don't actually need to build a procedure
1062 linkage table, and we can just do a PC32 reloc instead. */
1063 h->plt.offset = (bfd_vma) -1;
1064 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1065 }
1066
1067 return true;
1068 }
1069 else
1070 /* It's possible that we incorrectly decided a .plt reloc was
1071 needed for an R_390_PC32 reloc to a non-function sym in
1072 check_relocs. We can't decide accurately between function and
1073 non-function syms in check-relocs; Objects loaded later in
1074 the link may change h->type. So fix it now. */
1075 h->plt.offset = (bfd_vma) -1;
1076
1077 /* If this is a weak symbol, and there is a real definition, the
1078 processor independent code will have arranged for us to see the
1079 real definition first, and we can just use the same value. */
1080 if (h->weakdef != NULL)
1081 {
1082 BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
1083 || h->weakdef->root.type == bfd_link_hash_defweak);
1084 h->root.u.def.section = h->weakdef->root.u.def.section;
1085 h->root.u.def.value = h->weakdef->root.u.def.value;
1086 return true;
1087 }
1088
1089 /* This is a reference to a symbol defined by a dynamic object which
1090 is not a function. */
1091
1092 /* If we are creating a shared library, we must presume that the
1093 only references to the symbol are via the global offset table.
1094 For such cases we need not do anything here; the relocations will
1095 be handled correctly by relocate_section. */
1096 if (info->shared)
1097 return true;
1098
1099 /* If there are no references to this symbol that do not use the
1100 GOT, we don't need to generate a copy reloc. */
1101 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
1102 return true;
1103
1104 /* If -z nocopyreloc was given, we won't generate them either. */
1105 if (info->nocopyreloc)
1106 {
1107 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
1108 return true;
1109 }
1110
1111 eh = (struct elf_s390_link_hash_entry *) h;
1112 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1113 {
1114 s = p->sec->output_section;
1115 if (s != NULL && (s->flags & SEC_READONLY) != 0)
1116 break;
1117 }
1118
1119 /* If we didn't find any dynamic relocs in read-only sections, then
1120 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1121 if (p == NULL)
1122 {
1123 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
1124 return true;
1125 }
1126
1127 /* We must allocate the symbol in our .dynbss section, which will
1128 become part of the .bss section of the executable. There will be
1129 an entry for this symbol in the .dynsym section. The dynamic
1130 object will contain position independent code, so all references
1131 from the dynamic object to this symbol will go through the global
1132 offset table. The dynamic linker will use the .dynsym entry to
1133 determine the address it must put in the global offset table, so
1134 both the dynamic object and the regular object will refer to the
1135 same memory location for the variable. */
1136
1137 htab = elf_s390_hash_table (info);
1138
1139 /* We must generate a R_390_COPY reloc to tell the dynamic linker to
1140 copy the initial value out of the dynamic object and into the
1141 runtime process image. */
1142 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
1143 {
1144 htab->srelbss->_raw_size += sizeof (Elf32_External_Rela);
1145 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
1146 }
1147
1148 /* We need to figure out the alignment required for this symbol. I
1149 have no idea how ELF linkers handle this. */
1150 power_of_two = bfd_log2 (h->size);
1151 if (power_of_two > 3)
1152 power_of_two = 3;
1153
1154 /* Apply the required alignment. */
1155 s = htab->sdynbss;
1156 s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two));
1157 if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
1158 {
1159 if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
1160 return false;
1161 }
1162
1163 /* Define the symbol as being at this point in the section. */
1164 h->root.u.def.section = s;
1165 h->root.u.def.value = s->_raw_size;
1166
1167 /* Increment the section size to make room for the symbol. */
1168 s->_raw_size += h->size;
1169
1170 return true;
1171 }
1172
1173 /* This is the condition under which elf_s390_finish_dynamic_symbol
1174 will be called from elflink.h. If elflink.h doesn't call our
1175 finish_dynamic_symbol routine, we'll need to do something about
1176 initializing any .plt and .got entries in elf_s390_relocate_section. */
1177 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
1178 ((DYN) \
1179 && ((INFO)->shared \
1180 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
1181 && ((H)->dynindx != -1 \
1182 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
1183
1184 /* Allocate space in .plt, .got and associated reloc sections for
1185 dynamic relocs. */
1186
1187 static boolean
1188 allocate_dynrelocs (h, inf)
1189 struct elf_link_hash_entry *h;
1190 PTR inf;
1191 {
1192 struct bfd_link_info *info;
1193 struct elf_s390_link_hash_table *htab;
1194 struct elf_s390_link_hash_entry *eh;
1195 struct elf_s390_dyn_relocs *p;
1196
1197 if (h->root.type == bfd_link_hash_indirect
1198 || h->root.type == bfd_link_hash_warning)
1199 return true;
1200
1201 info = (struct bfd_link_info *) inf;
1202 htab = elf_s390_hash_table (info);
1203
1204 if (htab->elf.dynamic_sections_created
1205 && h->plt.refcount > 0)
1206 {
1207 /* Make sure this symbol is output as a dynamic symbol.
1208 Undefined weak syms won't yet be marked as dynamic. */
1209 if (h->dynindx == -1
1210 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1211 {
1212 if (! bfd_elf32_link_record_dynamic_symbol (info, h))
1213 return false;
1214 }
1215
1216 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
1217 {
1218 asection *s = htab->splt;
1219
1220 /* If this is the first .plt entry, make room for the special
1221 first entry. */
1222 if (s->_raw_size == 0)
1223 s->_raw_size += PLT_FIRST_ENTRY_SIZE;
1224
1225 h->plt.offset = s->_raw_size;
1226
1227 /* If this symbol is not defined in a regular file, and we are
1228 not generating a shared library, then set the symbol to this
1229 location in the .plt. This is required to make function
1230 pointers compare as equal between the normal executable and
1231 the shared library. */
1232 if (! info->shared
1233 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1234 {
1235 h->root.u.def.section = s;
1236 h->root.u.def.value = h->plt.offset;
1237 }
1238
1239 /* Make room for this entry. */
1240 s->_raw_size += PLT_ENTRY_SIZE;
1241
1242 /* We also need to make an entry in the .got.plt section, which
1243 will be placed in the .got section by the linker script. */
1244 htab->sgotplt->_raw_size += GOT_ENTRY_SIZE;
1245
1246 /* We also need to make an entry in the .rela.plt section. */
1247 htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
1248 }
1249 else
1250 {
1251 h->plt.offset = (bfd_vma) -1;
1252 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1253 }
1254 }
1255 else
1256 {
1257 h->plt.offset = (bfd_vma) -1;
1258 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1259 }
1260
1261 if (h->got.refcount > 0)
1262 {
1263 asection *s;
1264 boolean dyn;
1265
1266 /* Make sure this symbol is output as a dynamic symbol.
1267 Undefined weak syms won't yet be marked as dynamic. */
1268 if (h->dynindx == -1
1269 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1270 {
1271 if (! bfd_elf32_link_record_dynamic_symbol (info, h))
1272 return false;
1273 }
1274
1275 s = htab->sgot;
1276 h->got.offset = s->_raw_size;
1277 s->_raw_size += GOT_ENTRY_SIZE;
1278 dyn = htab->elf.dynamic_sections_created;
1279 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
1280 htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
1281 }
1282 else
1283 h->got.offset = (bfd_vma) -1;
1284
1285 eh = (struct elf_s390_link_hash_entry *) h;
1286 if (eh->dyn_relocs == NULL)
1287 return true;
1288
1289 /* In the shared -Bsymbolic case, discard space allocated for
1290 dynamic pc-relative relocs against symbols which turn out to be
1291 defined in regular objects. For the normal shared case, discard
1292 space for pc-relative relocs that have become local due to symbol
1293 visibility changes. */
1294
1295 if (info->shared)
1296 {
1297 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
1298 && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
1299 || info->symbolic))
1300 {
1301 struct elf_s390_dyn_relocs **pp;
1302
1303 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
1304 {
1305 p->count -= p->pc_count;
1306 p->pc_count = 0;
1307 if (p->count == 0)
1308 *pp = p->next;
1309 else
1310 pp = &p->next;
1311 }
1312 }
1313 }
1314 else
1315 {
1316 /* For the non-shared case, discard space for relocs against
1317 symbols which turn out to need copy relocs or are not
1318 dynamic. */
1319
1320 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
1321 && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
1322 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1323 || (htab->elf.dynamic_sections_created
1324 && (h->root.type == bfd_link_hash_undefweak
1325 || h->root.type == bfd_link_hash_undefined))))
1326 {
1327 /* Make sure this symbol is output as a dynamic symbol.
1328 Undefined weak syms won't yet be marked as dynamic. */
1329 if (h->dynindx == -1
1330 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1331 {
1332 if (! bfd_elf32_link_record_dynamic_symbol (info, h))
1333 return false;
1334 }
1335
1336 /* If that succeeded, we know we'll be keeping all the
1337 relocs. */
1338 if (h->dynindx != -1)
1339 goto keep;
1340 }
1341
1342 eh->dyn_relocs = NULL;
1343
1344 keep: ;
1345 }
1346
1347 /* Finally, allocate space. */
1348 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1349 {
1350 asection *sreloc = elf_section_data (p->sec)->sreloc;
1351 sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela);
1352 }
1353
1354 return true;
1355 }
1356
1357 /* Find any dynamic relocs that apply to read-only sections. */
1358
1359 static boolean
1360 readonly_dynrelocs (h, inf)
1361 struct elf_link_hash_entry *h;
1362 PTR inf;
1363 {
1364 struct elf_s390_link_hash_entry *eh;
1365 struct elf_s390_dyn_relocs *p;
1366
1367 eh = (struct elf_s390_link_hash_entry *) h;
1368 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1369 {
1370 asection *s = p->sec->output_section;
1371
1372 if (s != NULL && (s->flags & SEC_READONLY) != 0)
1373 {
1374 struct bfd_link_info *info = (struct bfd_link_info *) inf;
1375
1376 info->flags |= DF_TEXTREL;
1377
1378 /* Not an error, just cut short the traversal. */
1379 return false;
1380 }
1381 }
1382 return true;
1383 }
1384
1385 /* Set the sizes of the dynamic sections. */
1386
1387 static boolean
1388 elf_s390_size_dynamic_sections (output_bfd, info)
1389 bfd *output_bfd ATTRIBUTE_UNUSED;
1390 struct bfd_link_info *info;
1391 {
1392 struct elf_s390_link_hash_table *htab;
1393 bfd *dynobj;
1394 asection *s;
1395 boolean relocs;
1396 bfd *ibfd;
1397
1398 htab = elf_s390_hash_table (info);
1399 dynobj = htab->elf.dynobj;
1400 if (dynobj == NULL)
1401 abort ();
1402
1403 if (htab->elf.dynamic_sections_created)
1404 {
1405 /* Set the contents of the .interp section to the interpreter. */
1406 if (! info->shared)
1407 {
1408 s = bfd_get_section_by_name (dynobj, ".interp");
1409 if (s == NULL)
1410 abort ();
1411 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
1412 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1413 }
1414 }
1415
1416 /* Set up .got offsets for local syms, and space for local dynamic
1417 relocs. */
1418 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
1419 {
1420 bfd_signed_vma *local_got;
1421 bfd_signed_vma *end_local_got;
1422 bfd_size_type locsymcount;
1423 Elf_Internal_Shdr *symtab_hdr;
1424 asection *srela;
1425
1426 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
1427 continue;
1428
1429 for (s = ibfd->sections; s != NULL; s = s->next)
1430 {
1431 struct elf_s390_dyn_relocs *p;
1432
1433 for (p = *((struct elf_s390_dyn_relocs **)
1434 &elf_section_data (s)->local_dynrel);
1435 p != NULL;
1436 p = p->next)
1437 {
1438 if (!bfd_is_abs_section (p->sec)
1439 && bfd_is_abs_section (p->sec->output_section))
1440 {
1441 /* Input section has been discarded, either because
1442 it is a copy of a linkonce section or due to
1443 linker script /DISCARD/, so we'll be discarding
1444 the relocs too. */
1445 }
1446 else
1447 {
1448 srela = elf_section_data (p->sec)->sreloc;
1449 srela->_raw_size += p->count * sizeof (Elf32_External_Rela);
1450 }
1451 }
1452 }
1453
1454 local_got = elf_local_got_refcounts (ibfd);
1455 if (!local_got)
1456 continue;
1457
1458 symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
1459 locsymcount = symtab_hdr->sh_info;
1460 end_local_got = local_got + locsymcount;
1461 s = htab->sgot;
1462 srela = htab->srelgot;
1463 for (; local_got < end_local_got; ++local_got)
1464 {
1465 if (*local_got > 0)
1466 {
1467 *local_got = s->_raw_size;
1468 s->_raw_size += GOT_ENTRY_SIZE;
1469 if (info->shared)
1470 srela->_raw_size += sizeof (Elf32_External_Rela);
1471 }
1472 else
1473 *local_got = (bfd_vma) -1;
1474 }
1475 }
1476
1477 /* Allocate global sym .plt and .got entries, and space for global
1478 sym dynamic relocs. */
1479 elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
1480
1481 /* We now have determined the sizes of the various dynamic sections.
1482 Allocate memory for them. */
1483 relocs = false;
1484 for (s = dynobj->sections; s != NULL; s = s->next)
1485 {
1486 if ((s->flags & SEC_LINKER_CREATED) == 0)
1487 continue;
1488
1489 if (s == htab->splt
1490 || s == htab->sgot
1491 || s == htab->sgotplt)
1492 {
1493 /* Strip this section if we don't need it; see the
1494 comment below. */
1495 }
1496 else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
1497 {
1498 if (s->_raw_size != 0 && s != htab->srelplt)
1499 relocs = true;
1500
1501 /* We use the reloc_count field as a counter if we need
1502 to copy relocs into the output file. */
1503 s->reloc_count = 0;
1504 }
1505 else
1506 {
1507 /* It's not one of our sections, so don't allocate space. */
1508 continue;
1509 }
1510
1511 if (s->_raw_size == 0)
1512 {
1513 /* If we don't need this section, strip it from the
1514 output file. This is to handle .rela.bss and
1515 .rela.plt. We must create it in
1516 create_dynamic_sections, because it must be created
1517 before the linker maps input sections to output
1518 sections. The linker does that before
1519 adjust_dynamic_symbol is called, and it is that
1520 function which decides whether anything needs to go
1521 into these sections. */
1522
1523 _bfd_strip_section_from_output (info, s);
1524 continue;
1525 }
1526
1527 /* Allocate memory for the section contents. We use bfd_zalloc
1528 here in case unused entries are not reclaimed before the
1529 section's contents are written out. This should not happen,
1530 but this way if it does, we get a R_390_NONE reloc instead
1531 of garbage. */
1532 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
1533 if (s->contents == NULL)
1534 return false;
1535 }
1536
1537 if (htab->elf.dynamic_sections_created)
1538 {
1539 /* Add some entries to the .dynamic section. We fill in the
1540 values later, in elf_s390_finish_dynamic_sections, but we
1541 must add the entries now so that we get the correct size for
1542 the .dynamic section. The DT_DEBUG entry is filled in by the
1543 dynamic linker and used by the debugger. */
1544 #define add_dynamic_entry(TAG, VAL) \
1545 bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
1546
1547 if (! info->shared)
1548 {
1549 if (!add_dynamic_entry (DT_DEBUG, 0))
1550 return false;
1551 }
1552
1553 if (htab->splt->_raw_size != 0)
1554 {
1555 if (!add_dynamic_entry (DT_PLTGOT, 0)
1556 || !add_dynamic_entry (DT_PLTRELSZ, 0)
1557 || !add_dynamic_entry (DT_PLTREL, DT_RELA)
1558 || !add_dynamic_entry (DT_JMPREL, 0))
1559 return false;
1560 }
1561
1562 if (relocs)
1563 {
1564 if (!add_dynamic_entry (DT_RELA, 0)
1565 || !add_dynamic_entry (DT_RELASZ, 0)
1566 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
1567 return false;
1568
1569 /* If any dynamic relocs apply to a read-only section,
1570 then we need a DT_TEXTREL entry. */
1571 elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
1572
1573 if ((info->flags & DF_TEXTREL) != 0)
1574 {
1575 if (!add_dynamic_entry (DT_TEXTREL, 0))
1576 return false;
1577 }
1578 }
1579 }
1580 #undef add_dynamic_entry
1581
1582 return true;
1583 }
1584
1585 /* Relocate a 390 ELF section. */
1586
1587 static boolean
1588 elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
1589 contents, relocs, local_syms, local_sections)
1590 bfd *output_bfd;
1591 struct bfd_link_info *info;
1592 bfd *input_bfd;
1593 asection *input_section;
1594 bfd_byte *contents;
1595 Elf_Internal_Rela *relocs;
1596 Elf_Internal_Sym *local_syms;
1597 asection **local_sections;
1598 {
1599 struct elf_s390_link_hash_table *htab;
1600 Elf_Internal_Shdr *symtab_hdr;
1601 struct elf_link_hash_entry **sym_hashes;
1602 bfd_vma *local_got_offsets;
1603 Elf_Internal_Rela *rel;
1604 Elf_Internal_Rela *relend;
1605
1606 htab = elf_s390_hash_table (info);
1607 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1608 sym_hashes = elf_sym_hashes (input_bfd);
1609 local_got_offsets = elf_local_got_offsets (input_bfd);
1610
1611 rel = relocs;
1612 relend = relocs + input_section->reloc_count;
1613 for (; rel < relend; rel++)
1614 {
1615 int r_type;
1616 reloc_howto_type *howto;
1617 unsigned long r_symndx;
1618 struct elf_link_hash_entry *h;
1619 Elf_Internal_Sym *sym;
1620 asection *sec;
1621 bfd_vma off;
1622 bfd_vma relocation;
1623 boolean unresolved_reloc;
1624 bfd_reloc_status_type r;
1625
1626 r_type = ELF32_R_TYPE (rel->r_info);
1627 if (r_type == (int) R_390_GNU_VTINHERIT
1628 || r_type == (int) R_390_GNU_VTENTRY)
1629 continue;
1630 if (r_type < 0 || r_type >= (int) R_390_max)
1631 {
1632 bfd_set_error (bfd_error_bad_value);
1633 return false;
1634 }
1635 howto = elf_howto_table + r_type;
1636
1637 r_symndx = ELF32_R_SYM (rel->r_info);
1638
1639 if (info->relocateable)
1640 {
1641 /* This is a relocateable link. We don't have to change
1642 anything, unless the reloc is against a section symbol,
1643 in which case we have to adjust according to where the
1644 section symbol winds up in the output section. */
1645 if (r_symndx < symtab_hdr->sh_info)
1646 {
1647 sym = local_syms + r_symndx;
1648 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
1649 {
1650 sec = local_sections[r_symndx];
1651 rel->r_addend += sec->output_offset + sym->st_value;
1652 }
1653 }
1654
1655 continue;
1656 }
1657
1658 /* This is a final link. */
1659 h = NULL;
1660 sym = NULL;
1661 sec = NULL;
1662 unresolved_reloc = false;
1663 if (r_symndx < symtab_hdr->sh_info)
1664 {
1665 sym = local_syms + r_symndx;
1666 sec = local_sections[r_symndx];
1667 relocation = (sec->output_section->vma
1668 + sec->output_offset
1669 + sym->st_value);
1670 }
1671 else
1672 {
1673 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1674 while (h->root.type == bfd_link_hash_indirect
1675 || h->root.type == bfd_link_hash_warning)
1676 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1677
1678 if (h->root.type == bfd_link_hash_defined
1679 || h->root.type == bfd_link_hash_defweak)
1680 {
1681 sec = h->root.u.def.section;
1682 if (r_type == R_390_GOTPC
1683 || ((r_type == R_390_PLT16DBL
1684 || r_type == R_390_PLT32)
1685 && htab->splt != NULL
1686 && h->plt.offset != (bfd_vma) -1)
1687 || ((r_type == R_390_GOT12
1688 || r_type == R_390_GOT16
1689 || r_type == R_390_GOT32)
1690 && elf_hash_table (info)->dynamic_sections_created
1691 && (! info->shared
1692 || (! info->symbolic && h->dynindx != -1)
1693 || (h->elf_link_hash_flags
1694 & ELF_LINK_HASH_DEF_REGULAR) == 0))
1695 || (info->shared
1696 && ((! info->symbolic && h->dynindx != -1)
1697 || (h->elf_link_hash_flags
1698 & ELF_LINK_HASH_DEF_REGULAR) == 0)
1699 && (r_type == R_390_8
1700 || r_type == R_390_16
1701 || r_type == R_390_32
1702 || r_type == R_390_PC16
1703 || r_type == R_390_PC16DBL
1704 || r_type == R_390_PC32)
1705 && ((input_section->flags & SEC_ALLOC) != 0
1706 /* DWARF will emit R_390_32 relocations in its
1707 sections against symbols defined externally
1708 in shared libraries. We can't do anything
1709 with them here. */
1710 || ((input_section->flags & SEC_DEBUGGING) != 0
1711 && (h->elf_link_hash_flags
1712 & ELF_LINK_HASH_DEF_DYNAMIC) != 0))))
1713 {
1714 /* In these cases, we don't need the relocation
1715 value. We check specially because in some
1716 obscure cases sec->output_section will be NULL. */
1717 relocation = 0;
1718 }
1719 else if (sec->output_section == NULL)
1720 {
1721 /* Set a flag that will be cleared later if we find a
1722 relocation value for this symbol. output_section
1723 is typically NULL for symbols satisfied by a shared
1724 library. */
1725 unresolved_reloc = true;
1726 relocation = 0;
1727 }
1728 else
1729 relocation = (h->root.u.def.value
1730 + sec->output_section->vma
1731 + sec->output_offset);
1732 }
1733 else if (h->root.type == bfd_link_hash_undefweak)
1734 relocation = 0;
1735 else if (info->shared
1736 && (!info->symbolic || info->allow_shlib_undefined)
1737 && !info->no_undefined
1738 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
1739 relocation = 0;
1740 else
1741 {
1742 if (! ((*info->callbacks->undefined_symbol)
1743 (info, h->root.root.string, input_bfd,
1744 input_section, rel->r_offset,
1745 (!info->shared || info->no_undefined
1746 || ELF_ST_VISIBILITY (h->other)))))
1747 return false;
1748 relocation = 0;
1749 }
1750 }
1751
1752 switch (r_type)
1753 {
1754 case R_390_GOT12:
1755 case R_390_GOT16:
1756 case R_390_GOT32:
1757 /* Relocation is to the entry for this symbol in the global
1758 offset table. */
1759 if (htab->sgot == NULL)
1760 abort ();
1761
1762 if (h != NULL)
1763 {
1764 boolean dyn;
1765
1766 off = h->got.offset;
1767 dyn = htab->elf.dynamic_sections_created;
1768 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
1769 || (info->shared
1770 && (info->symbolic
1771 || h->dynindx == -1
1772 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
1773 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
1774 {
1775 /* This is actually a static link, or it is a
1776 -Bsymbolic link and the symbol is defined
1777 locally, or the symbol was forced to be local
1778 because of a version file. We must initialize
1779 this entry in the global offset table. Since the
1780 offset must always be a multiple of 2, we use the
1781 least significant bit to record whether we have
1782 initialized it already.
1783
1784 When doing a dynamic link, we create a .rel.got
1785 relocation entry to initialize the value. This
1786 is done in the finish_dynamic_symbol routine. */
1787 if ((off & 1) != 0)
1788 off &= ~1;
1789 else
1790 {
1791 bfd_put_32 (output_bfd, relocation,
1792 htab->sgot->contents + off);
1793 h->got.offset |= 1;
1794 }
1795 }
1796 else
1797 unresolved_reloc = false;
1798 }
1799 else
1800 {
1801 if (local_got_offsets == NULL)
1802 abort ();
1803
1804 off = local_got_offsets[r_symndx];
1805
1806 /* The offset must always be a multiple of 4. We use
1807 the least significant bit to record whether we have
1808 already generated the necessary reloc. */
1809 if ((off & 1) != 0)
1810 off &= ~1;
1811 else
1812 {
1813 bfd_put_32 (output_bfd, relocation,
1814 htab->sgot->contents + off);
1815
1816 if (info->shared)
1817 {
1818 asection *srelgot;
1819 Elf_Internal_Rela outrel;
1820 Elf32_External_Rela *loc;
1821
1822 srelgot = htab->srelgot;
1823 if (srelgot == NULL)
1824 abort ();
1825
1826 outrel.r_offset = (htab->sgot->output_section->vma
1827 + htab->sgot->output_offset
1828 + off);
1829 outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
1830 outrel.r_addend = relocation;
1831 loc = (Elf32_External_Rela *) srelgot->contents;
1832 loc += srelgot->reloc_count++;
1833 bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
1834 }
1835
1836 local_got_offsets[r_symndx] |= 1;
1837 }
1838 }
1839
1840 if (off >= (bfd_vma) -2)
1841 abort ();
1842
1843 relocation = htab->sgot->output_offset + off;
1844 break;
1845
1846 case R_390_GOTOFF:
1847 /* Relocation is relative to the start of the global offset
1848 table. */
1849
1850 /* Note that sgot->output_offset is not involved in this
1851 calculation. We always want the start of .got. If we
1852 defined _GLOBAL_OFFSET_TABLE in a different way, as is
1853 permitted by the ABI, we might have to change this
1854 calculation. */
1855 relocation -= htab->sgot->output_section->vma;
1856 break;
1857
1858 case R_390_GOTPC:
1859 /* Use global offset table as symbol value. */
1860 relocation = htab->sgot->output_section->vma;
1861 unresolved_reloc = false;
1862 break;
1863
1864 case R_390_PLT16DBL:
1865 case R_390_PLT32:
1866 /* Relocation is to the entry for this symbol in the
1867 procedure linkage table. */
1868
1869 /* Resolve a PLT32 reloc against a local symbol directly,
1870 without using the procedure linkage table. */
1871 if (h == NULL)
1872 break;
1873
1874 if (h->plt.offset == (bfd_vma) -1
1875 || htab->splt == NULL)
1876 {
1877 /* We didn't make a PLT entry for this symbol. This
1878 happens when statically linking PIC code, or when
1879 using -Bsymbolic. */
1880 break;
1881 }
1882
1883 relocation = (htab->splt->output_section->vma
1884 + htab->splt->output_offset
1885 + h->plt.offset);
1886 unresolved_reloc = false;
1887 break;
1888
1889 case R_390_8:
1890 case R_390_16:
1891 case R_390_32:
1892 case R_390_PC16:
1893 case R_390_PC16DBL:
1894 case R_390_PC32:
1895 /* r_symndx will be zero only for relocs against symbols
1896 from removed linkonce sections, or sections discarded by
1897 a linker script. */
1898 if (r_symndx == 0
1899 || (input_section->flags & SEC_ALLOC) == 0)
1900 break;
1901
1902 if ((info->shared
1903 && ((r_type != R_390_PC16
1904 && r_type != R_390_PC16DBL
1905 && r_type != R_390_PC32)
1906 || (h != NULL
1907 && h->dynindx != -1
1908 && (! info->symbolic
1909 || (h->elf_link_hash_flags
1910 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
1911 || (!info->shared
1912 && h != NULL
1913 && h->dynindx != -1
1914 && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
1915 && (((h->elf_link_hash_flags
1916 & ELF_LINK_HASH_DEF_DYNAMIC) != 0
1917 && (h->elf_link_hash_flags
1918 & ELF_LINK_HASH_DEF_REGULAR) == 0)
1919 || h->root.type == bfd_link_hash_undefweak
1920 || h->root.type == bfd_link_hash_undefined)))
1921 {
1922 Elf_Internal_Rela outrel;
1923 boolean skip, relocate;
1924 asection *sreloc;
1925 Elf32_External_Rela *loc;
1926
1927 /* When generating a shared object, these relocations
1928 are copied into the output file to be resolved at run
1929 time. */
1930
1931 skip = false;
1932
1933 if (elf_section_data (input_section)->stab_info == NULL)
1934 outrel.r_offset = rel->r_offset;
1935 else
1936 {
1937 off = (_bfd_stab_section_offset
1938 (output_bfd, htab->elf.stab_info, input_section,
1939 &elf_section_data (input_section)->stab_info,
1940 rel->r_offset));
1941 if (off == (bfd_vma) -1)
1942 skip = true;
1943 outrel.r_offset = off;
1944 }
1945
1946 outrel.r_offset += (input_section->output_section->vma
1947 + input_section->output_offset);
1948
1949 if (skip)
1950 {
1951 memset (&outrel, 0, sizeof outrel);
1952 relocate = false;
1953 }
1954 else if (h != NULL
1955 && h->dynindx != -1
1956 && (r_type == R_390_PC16
1957 || r_type == R_390_PC16DBL
1958 || r_type == R_390_PC32
1959 || !info->shared
1960 || !info->symbolic
1961 || (h->elf_link_hash_flags
1962 & ELF_LINK_HASH_DEF_REGULAR) == 0))
1963 {
1964 relocate = false;
1965 outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
1966 outrel.r_addend = relocation + rel->r_addend;
1967 }
1968 else
1969 {
1970 /* This symbol is local, or marked to become local. */
1971 relocate = true;
1972 outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
1973 outrel.r_addend = relocation + rel->r_addend;
1974 }
1975
1976 sreloc = elf_section_data (input_section)->sreloc;
1977 if (sreloc == NULL)
1978 abort ();
1979
1980 loc = (Elf32_External_Rela *) sreloc->contents;
1981 loc += sreloc->reloc_count++;
1982 bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
1983
1984 /* If this reloc is against an external symbol, we do
1985 not want to fiddle with the addend. Otherwise, we
1986 need to include the symbol value so that it becomes
1987 an addend for the dynamic reloc. */
1988 if (! relocate)
1989 continue;
1990 }
1991 break;
1992
1993 default:
1994 break;
1995 }
1996
1997 if (unresolved_reloc
1998 && !(info->shared
1999 && (input_section->flags & SEC_DEBUGGING) != 0
2000 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
2001 (*_bfd_error_handler)
2002 (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
2003 bfd_archive_filename (input_bfd),
2004 bfd_get_section_name (input_bfd, input_section),
2005 (long) rel->r_offset,
2006 h->root.root.string);
2007
2008 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
2009 contents, rel->r_offset,
2010 relocation, rel->r_addend);
2011
2012 if (r != bfd_reloc_ok)
2013 {
2014 const char *name;
2015
2016 if (h != NULL)
2017 name = h->root.root.string;
2018 else
2019 {
2020 name = bfd_elf_string_from_elf_section (input_bfd,
2021 symtab_hdr->sh_link,
2022 sym->st_name);
2023 if (name == NULL)
2024 return false;
2025 if (*name == '\0')
2026 name = bfd_section_name (input_bfd, sec);
2027 }
2028
2029 if (r == bfd_reloc_overflow)
2030 {
2031
2032 if (! ((*info->callbacks->reloc_overflow)
2033 (info, name, howto->name, (bfd_vma) 0,
2034 input_bfd, input_section, rel->r_offset)))
2035 return false;
2036 }
2037 else
2038 {
2039 (*_bfd_error_handler)
2040 (_("%s(%s+0x%lx): reloc against `%s': error %d"),
2041 bfd_archive_filename (input_bfd),
2042 bfd_get_section_name (input_bfd, input_section),
2043 (long) rel->r_offset, name, (int) r);
2044 return false;
2045 }
2046 }
2047 }
2048
2049 return true;
2050 }
2051
2052 /* Finish up dynamic symbol handling. We set the contents of various
2053 dynamic sections here. */
2054
2055 static boolean
2056 elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
2057 bfd *output_bfd;
2058 struct bfd_link_info *info;
2059 struct elf_link_hash_entry *h;
2060 Elf_Internal_Sym *sym;
2061 {
2062 struct elf_s390_link_hash_table *htab;
2063
2064 htab = elf_s390_hash_table (info);
2065
2066 if (h->plt.offset != (bfd_vma) -1)
2067 {
2068 bfd_vma plt_index;
2069 bfd_vma got_offset;
2070 Elf_Internal_Rela rela;
2071 Elf32_External_Rela *loc;
2072 bfd_vma relative_offset;
2073
2074 /* This symbol has an entry in the procedure linkage table. Set
2075 it up. */
2076
2077 if (h->dynindx == -1
2078 || htab->splt == NULL
2079 || htab->sgotplt == NULL
2080 || htab->srelplt == NULL)
2081 abort ();
2082
2083 /* Calc. index no.
2084 Current offset - size first entry / entry size. */
2085 plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
2086
2087 /* Offset in GOT is PLT index plus GOT headers(3) times 4,
2088 addr & GOT addr. */
2089 got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
2090
2091 /* S390 uses halfwords for relative branch calc! */
2092 relative_offset = - ((PLT_FIRST_ENTRY_SIZE +
2093 (PLT_ENTRY_SIZE * plt_index) + 18) / 2);
2094 /* If offset is > 32768, branch to a previous branch
2095 390 can only handle +-64 K jumps. */
2096 if ( -32768 > (int) relative_offset )
2097 relative_offset =
2098 -(unsigned) (((65536 / PLT_ENTRY_SIZE - 1) * PLT_ENTRY_SIZE) / 2);
2099
2100 /* Fill in the entry in the procedure linkage table. */
2101 if (!info->shared)
2102 {
2103 bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD0,
2104 htab->splt->contents + h->plt.offset);
2105 bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD1,
2106 htab->splt->contents + h->plt.offset + 4);
2107 bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2,
2108 htab->splt->contents + h->plt.offset + 8);
2109 bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD3,
2110 htab->splt->contents + h->plt.offset + 12);
2111 bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD4,
2112 htab->splt->contents + h->plt.offset + 16);
2113 bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
2114 htab->splt->contents + h->plt.offset + 20);
2115 bfd_put_32 (output_bfd,
2116 (htab->sgotplt->output_section->vma
2117 + htab->sgotplt->output_offset
2118 + got_offset),
2119 htab->splt->contents + h->plt.offset + 24);
2120 }
2121 else if (got_offset < 4096)
2122 {
2123 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD0 + got_offset,
2124 htab->splt->contents + h->plt.offset);
2125 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD1,
2126 htab->splt->contents + h->plt.offset + 4);
2127 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD2,
2128 htab->splt->contents + h->plt.offset + 8);
2129 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD3,
2130 htab->splt->contents + h->plt.offset + 12);
2131 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD4,
2132 htab->splt->contents + h->plt.offset + 16);
2133 bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
2134 htab->splt->contents + h->plt.offset + 20);
2135 bfd_put_32 (output_bfd, (bfd_vma) 0,
2136 htab->splt->contents + h->plt.offset + 24);
2137 }
2138 else if (got_offset < 32768)
2139 {
2140 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD0 + got_offset,
2141 htab->splt->contents + h->plt.offset);
2142 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD1,
2143 htab->splt->contents + h->plt.offset + 4);
2144 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD2,
2145 htab->splt->contents + h->plt.offset + 8);
2146 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD3,
2147 htab->splt->contents + h->plt.offset + 12);
2148 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD4,
2149 htab->splt->contents + h->plt.offset + 16);
2150 bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
2151 htab->splt->contents + h->plt.offset + 20);
2152 bfd_put_32 (output_bfd, (bfd_vma) 0,
2153 htab->splt->contents + h->plt.offset + 24);
2154 }
2155 else
2156 {
2157 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD0,
2158 htab->splt->contents + h->plt.offset);
2159 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD1,
2160 htab->splt->contents + h->plt.offset + 4);
2161 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD2,
2162 htab->splt->contents + h->plt.offset + 8);
2163 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD3,
2164 htab->splt->contents + h->plt.offset + 12);
2165 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD4,
2166 htab->splt->contents + h->plt.offset + 16);
2167 bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
2168 htab->splt->contents + h->plt.offset + 20);
2169 bfd_put_32 (output_bfd, got_offset,
2170 htab->splt->contents + h->plt.offset + 24);
2171 }
2172 /* Insert offset into reloc. table here. */
2173 bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
2174 htab->splt->contents + h->plt.offset + 28);
2175
2176 /* Fill in the entry in the global offset table.
2177 Points to instruction after GOT offset. */
2178 bfd_put_32 (output_bfd,
2179 (htab->splt->output_section->vma
2180 + htab->splt->output_offset
2181 + h->plt.offset
2182 + 12),
2183 htab->sgotplt->contents + got_offset);
2184
2185 /* Fill in the entry in the .rela.plt section. */
2186 rela.r_offset = (htab->sgotplt->output_section->vma
2187 + htab->sgotplt->output_offset
2188 + got_offset);
2189 rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
2190 rela.r_addend = 0;
2191 loc = (Elf32_External_Rela *) htab->srelplt->contents + plt_index;
2192 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
2193
2194 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
2195 {
2196 /* Mark the symbol as undefined, rather than as defined in
2197 the .plt section. Leave the value alone. This is a clue
2198 for the dynamic linker, to make function pointer
2199 comparisons work between an application and shared
2200 library. */
2201 sym->st_shndx = SHN_UNDEF;
2202 }
2203 }
2204
2205 if (h->got.offset != (bfd_vma) -1)
2206 {
2207 Elf_Internal_Rela rela;
2208 Elf32_External_Rela *loc;
2209
2210 /* This symbol has an entry in the global offset table. Set it
2211 up. */
2212
2213 if (htab->sgot == NULL || htab->srelgot == NULL)
2214 abort ();
2215
2216 rela.r_offset = (htab->sgot->output_section->vma
2217 + htab->sgot->output_offset
2218 + (h->got.offset &~ (bfd_vma) 1));
2219
2220 /* If this is a static link, or it is a -Bsymbolic link and the
2221 symbol is defined locally or was forced to be local because
2222 of a version file, we just want to emit a RELATIVE reloc.
2223 The entry in the global offset table will already have been
2224 initialized in the relocate_section function. */
2225 if (info->shared
2226 && (info->symbolic
2227 || h->dynindx == -1
2228 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
2229 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
2230 {
2231 BFD_ASSERT((h->got.offset & 1) != 0);
2232 rela.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
2233 rela.r_addend = (h->root.u.def.value
2234 + h->root.u.def.section->output_section->vma
2235 + h->root.u.def.section->output_offset);
2236 }
2237 else
2238 {
2239 BFD_ASSERT((h->got.offset & 1) == 0);
2240 bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgot->contents + h->got.offset);
2241 rela.r_info = ELF32_R_INFO (h->dynindx, R_390_GLOB_DAT);
2242 rela.r_addend = 0;
2243 }
2244
2245 loc = (Elf32_External_Rela *) htab->srelgot->contents;
2246 loc += htab->srelgot->reloc_count++;
2247 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
2248 }
2249
2250 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
2251 {
2252 Elf_Internal_Rela rela;
2253 Elf32_External_Rela *loc;
2254
2255 /* This symbols needs a copy reloc. Set it up. */
2256
2257 if (h->dynindx == -1
2258 || (h->root.type != bfd_link_hash_defined
2259 && h->root.type != bfd_link_hash_defweak)
2260 || htab->srelbss == NULL)
2261 abort ();
2262
2263 rela.r_offset = (h->root.u.def.value
2264 + h->root.u.def.section->output_section->vma
2265 + h->root.u.def.section->output_offset);
2266 rela.r_info = ELF32_R_INFO (h->dynindx, R_390_COPY);
2267 rela.r_addend = 0;
2268 loc = (Elf32_External_Rela *) htab->srelbss->contents;
2269 loc += htab->srelbss->reloc_count++;
2270 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
2271 }
2272
2273 /* Mark some specially defined symbols as absolute. */
2274 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
2275 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
2276 || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
2277 sym->st_shndx = SHN_ABS;
2278
2279 return true;
2280 }
2281
2282 /* Used to decide how to sort relocs in an optimal manner for the
2283 dynamic linker, before writing them out. */
2284
2285 static enum elf_reloc_type_class
2286 elf_s390_reloc_type_class (rela)
2287 const Elf_Internal_Rela *rela;
2288 {
2289 switch ((int) ELF32_R_TYPE (rela->r_info))
2290 {
2291 case R_390_RELATIVE:
2292 return reloc_class_relative;
2293 case R_390_JMP_SLOT:
2294 return reloc_class_plt;
2295 case R_390_COPY:
2296 return reloc_class_copy;
2297 default:
2298 return reloc_class_normal;
2299 }
2300 }
2301
2302 /* Finish up the dynamic sections. */
2303
2304 static boolean
2305 elf_s390_finish_dynamic_sections (output_bfd, info)
2306 bfd *output_bfd;
2307 struct bfd_link_info *info;
2308 {
2309 struct elf_s390_link_hash_table *htab;
2310 bfd *dynobj;
2311 asection *sdyn;
2312
2313 htab = elf_s390_hash_table (info);
2314 dynobj = htab->elf.dynobj;
2315 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
2316
2317 if (htab->elf.dynamic_sections_created)
2318 {
2319 Elf32_External_Dyn *dyncon, *dynconend;
2320
2321 if (sdyn == NULL || htab->sgot == NULL)
2322 abort ();
2323
2324 dyncon = (Elf32_External_Dyn *) sdyn->contents;
2325 dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
2326 for (; dyncon < dynconend; dyncon++)
2327 {
2328 Elf_Internal_Dyn dyn;
2329 asection *s;
2330
2331 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
2332
2333 switch (dyn.d_tag)
2334 {
2335 default:
2336 continue;
2337
2338 case DT_PLTGOT:
2339 dyn.d_un.d_ptr = htab->sgot->output_section->vma;
2340 break;
2341
2342 case DT_JMPREL:
2343 dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
2344 break;
2345
2346 case DT_PLTRELSZ:
2347 s = htab->srelplt->output_section;
2348 if (s->_cooked_size != 0)
2349 dyn.d_un.d_val = s->_cooked_size;
2350 else
2351 dyn.d_un.d_val = s->_raw_size;
2352 break;
2353 }
2354
2355 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
2356 }
2357
2358 /* Fill in the special first entry in the procedure linkage table. */
2359 if (htab->splt && htab->splt->_raw_size > 0)
2360 {
2361 memset (htab->splt->contents, 0, PLT_FIRST_ENTRY_SIZE);
2362 if (info->shared)
2363 {
2364 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD0,
2365 htab->splt->contents );
2366 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD1,
2367 htab->splt->contents +4 );
2368 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD2,
2369 htab->splt->contents +8 );
2370 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD3,
2371 htab->splt->contents +12 );
2372 bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD4,
2373 htab->splt->contents +16 );
2374 }
2375 else
2376 {
2377 bfd_put_32 (output_bfd, (bfd_vma)PLT_FIRST_ENTRY_WORD0,
2378 htab->splt->contents );
2379 bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD1,
2380 htab->splt->contents +4 );
2381 bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD2,
2382 htab->splt->contents +8 );
2383 bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD3,
2384 htab->splt->contents +12 );
2385 bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD4,
2386 htab->splt->contents +16 );
2387 bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD5,
2388 htab->splt->contents +20 );
2389 bfd_put_32 (output_bfd,
2390 htab->sgotplt->output_section->vma
2391 + htab->sgotplt->output_offset,
2392 htab->splt->contents + 24);
2393 }
2394 elf_section_data (htab->splt->output_section)
2395 ->this_hdr.sh_entsize = 4;
2396 }
2397
2398 }
2399
2400 if (htab->sgotplt)
2401 {
2402 /* Fill in the first three entries in the global offset table. */
2403 if (htab->sgotplt->_raw_size > 0)
2404 {
2405 bfd_put_32 (output_bfd,
2406 (sdyn == NULL ? (bfd_vma) 0
2407 : sdyn->output_section->vma + sdyn->output_offset),
2408 htab->sgotplt->contents);
2409 /* One entry for shared object struct ptr. */
2410 bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 4);
2411 /* One entry for _dl_runtime_resolve. */
2412 bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 8);
2413 }
2414
2415 elf_section_data (htab->sgotplt->output_section)
2416 ->this_hdr.sh_entsize = 4;
2417 }
2418 return true;
2419 }
2420
2421 static boolean
2422 elf_s390_object_p (abfd)
2423 bfd *abfd;
2424 {
2425 return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_esa);
2426 }
2427
2428 #define TARGET_BIG_SYM bfd_elf32_s390_vec
2429 #define TARGET_BIG_NAME "elf32-s390"
2430 #define ELF_ARCH bfd_arch_s390
2431 #define ELF_MACHINE_CODE EM_S390
2432 #define ELF_MACHINE_ALT1 EM_S390_OLD
2433 #define ELF_MAXPAGESIZE 0x1000
2434
2435 #define elf_backend_can_gc_sections 1
2436 #define elf_backend_can_refcount 1
2437 #define elf_backend_want_got_plt 1
2438 #define elf_backend_plt_readonly 1
2439 #define elf_backend_want_plt_sym 0
2440 #define elf_backend_got_header_size 12
2441 #define elf_backend_plt_header_size PLT_ENTRY_SIZE
2442
2443 #define elf_info_to_howto elf_s390_info_to_howto
2444
2445 #define bfd_elf32_bfd_is_local_label_name elf_s390_is_local_label_name
2446 #define bfd_elf32_bfd_link_hash_table_create elf_s390_link_hash_table_create
2447 #define bfd_elf32_bfd_reloc_type_lookup elf_s390_reloc_type_lookup
2448
2449 #define elf_backend_adjust_dynamic_symbol elf_s390_adjust_dynamic_symbol
2450 #define elf_backend_check_relocs elf_s390_check_relocs
2451 #define elf_backend_copy_indirect_symbol elf_s390_copy_indirect_symbol
2452 #define elf_backend_create_dynamic_sections elf_s390_create_dynamic_sections
2453 #define elf_backend_finish_dynamic_sections elf_s390_finish_dynamic_sections
2454 #define elf_backend_finish_dynamic_symbol elf_s390_finish_dynamic_symbol
2455 #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
2456 #define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
2457 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
2458 #define elf_backend_relocate_section elf_s390_relocate_section
2459 #define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
2460 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
2461
2462 #define elf_backend_object_p elf_s390_object_p
2463
2464 #include "elf32-target.h"
This page took 0.080274 seconds and 4 git commands to generate.