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