1 /* IBM S/390-specific support for 64-bit ELF
2 Copyright 2000, 2001 Free Software Foundation, Inc.
3 Contributed Martin Schwidefsky (schwidefsky@de.ibm.com).
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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
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
PARAMS ((bfd
*, const char *));
33 static struct bfd_hash_entry
*elf_s390_link_hash_newfunc
34 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
35 static struct bfd_link_hash_table
*elf_s390_link_hash_table_create
37 static boolean elf_s390_check_relocs
38 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
39 const Elf_Internal_Rela
*));
40 static asection
*elf_s390_gc_mark_hook
41 PARAMS ((bfd
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
42 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
43 static boolean elf_s390_gc_sweep_hook
44 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
45 const Elf_Internal_Rela
*));
46 static boolean elf_s390_adjust_dynamic_symbol
47 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
48 static boolean elf_s390_size_dynamic_sections
49 PARAMS ((bfd
*, struct bfd_link_info
*));
50 static boolean elf_s390_relocate_section
51 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
52 Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
53 static boolean elf_s390_finish_dynamic_symbol
54 PARAMS ((bfd
*, struct bfd_link_info
*, struct elf_link_hash_entry
*,
56 static boolean elf_s390_finish_dynamic_sections
57 PARAMS ((bfd
*, struct bfd_link_info
*));
58 static boolean elf_s390_object_p
PARAMS ((bfd
*));
59 static enum elf_reloc_type_class elf_s390_reloc_type_class
PARAMS ((int));
61 #define USE_RELA 1 /* We want RELA relocations, not REL. */
65 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
66 from smaller values. Start with zero, widen, *then* decrement. */
67 #define MINUS_ONE (((bfd_vma)0) - 1)
69 /* The relocation "howto" table. */
70 static reloc_howto_type elf_howto_table
[] =
72 HOWTO (R_390_NONE
, /* type */
74 0, /* size (0 = byte, 1 = short, 2 = long) */
76 false, /* pc_relative */
78 complain_overflow_dont
, /* complain_on_overflow */
79 bfd_elf_generic_reloc
, /* special_function */
80 "R_390_NONE", /* name */
81 false, /* partial_inplace */
84 false), /* pcrel_offset */
86 HOWTO(R_390_8
, 0, 0, 8, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_8", false, 0,0x000000ff, false),
87 HOWTO(R_390_12
, 0, 1, 12, false, 0, complain_overflow_dont
, bfd_elf_generic_reloc
, "R_390_12", false, 0,0x00000fff, false),
88 HOWTO(R_390_16
, 0, 1, 16, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_16", false, 0,0x0000ffff, false),
89 HOWTO(R_390_32
, 0, 2, 32, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_32", false, 0,0xffffffff, false),
90 HOWTO(R_390_PC32
, 0, 2, 32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PC32", false, 0,0xffffffff, true),
91 HOWTO(R_390_GOT12
, 0, 1, 12, false, 0, complain_overflow_dont
, bfd_elf_generic_reloc
, "R_390_GOT12", false, 0,0x00000fff, false),
92 HOWTO(R_390_GOT32
, 0, 2, 32, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GOT32", false, 0,0xffffffff, false),
93 HOWTO(R_390_PLT32
, 0, 2, 32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PLT32", false, 0,0xffffffff, true),
94 HOWTO(R_390_COPY
, 0, 4, 64, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_COPY", false, 0,MINUS_ONE
, false),
95 HOWTO(R_390_GLOB_DAT
, 0, 4, 64, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GLOB_DAT",false, 0,MINUS_ONE
, false),
96 HOWTO(R_390_JMP_SLOT
, 0, 4, 64, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_JMP_SLOT",false, 0,MINUS_ONE
, false),
97 HOWTO(R_390_RELATIVE
, 0, 4, 64, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_RELATIVE",false, 0,MINUS_ONE
, false),
98 HOWTO(R_390_GOTOFF
, 0, 4, 64, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GOTOFF", false, 0,MINUS_ONE
, false),
99 HOWTO(R_390_GOTPC
, 0, 4, 64, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GOTPC", false, 0,MINUS_ONE
, true),
100 HOWTO(R_390_GOT16
, 0, 1, 16, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GOT16", false, 0,0x0000ffff, false),
101 HOWTO(R_390_PC16
, 0, 1, 16, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PC16", false, 0,0x0000ffff, true),
102 HOWTO(R_390_PC16DBL
, 1, 1, 16, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PC16DBL", false, 0,0x0000ffff, true),
103 HOWTO(R_390_PLT16DBL
, 1, 1, 16, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PLT16DBL", false, 0,0x0000ffff, true),
104 HOWTO(R_390_PC32DBL
, 1, 2, 32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PC32DBL", false, 0,0xffffffff, true),
105 HOWTO(R_390_PLT32DBL
, 1, 2, 32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PLT32DBL", false, 0,0xffffffff, true),
106 HOWTO(R_390_GOTPCDBL
, 1, 2, 32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GOTPCDBL", false, 0,MINUS_ONE
, true),
107 HOWTO(R_390_64
, 0, 4, 64, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_64", false, 0,MINUS_ONE
, false),
108 HOWTO(R_390_PC64
, 0, 4, 64, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PC64", false, 0,MINUS_ONE
, true),
109 HOWTO(R_390_GOT64
, 0, 4, 64, false, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GOT64", false, 0,MINUS_ONE
, false),
110 HOWTO(R_390_PLT64
, 0, 4, 64, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_PLT64", false, 0,MINUS_ONE
, true),
111 HOWTO(R_390_GOTENT
, 1, 2, 32, true, 0, complain_overflow_bitfield
, bfd_elf_generic_reloc
, "R_390_GOTENT", false, 0,MINUS_ONE
, true),
114 /* GNU extension to record C++ vtable hierarchy. */
115 static reloc_howto_type elf64_s390_vtinherit_howto
=
116 HOWTO (R_390_GNU_VTINHERIT
, 0,4,0,false,0,complain_overflow_dont
, NULL
, "R_390_GNU_VTINHERIT", false,0, 0, false);
117 static reloc_howto_type elf64_s390_vtentry_howto
=
118 HOWTO (R_390_GNU_VTENTRY
, 0,4,0,false,0,complain_overflow_dont
, _bfd_elf_rel_vtable_reloc_fn
,"R_390_GNU_VTENTRY", false,0,0, false);
120 static reloc_howto_type
*
121 elf_s390_reloc_type_lookup (abfd
, code
)
122 bfd
*abfd ATTRIBUTE_UNUSED
;
123 bfd_reloc_code_real_type code
;
127 return &elf_howto_table
[(int) R_390_NONE
];
129 return &elf_howto_table
[(int) R_390_8
];
130 case BFD_RELOC_390_12
:
131 return &elf_howto_table
[(int) R_390_12
];
133 return &elf_howto_table
[(int) R_390_16
];
135 return &elf_howto_table
[(int) R_390_32
];
137 return &elf_howto_table
[(int) R_390_32
];
138 case BFD_RELOC_32_PCREL
:
139 return &elf_howto_table
[(int) R_390_PC32
];
140 case BFD_RELOC_390_GOT12
:
141 return &elf_howto_table
[(int) R_390_GOT12
];
142 case BFD_RELOC_32_GOT_PCREL
:
143 return &elf_howto_table
[(int) R_390_GOT32
];
144 case BFD_RELOC_390_PLT32
:
145 return &elf_howto_table
[(int) R_390_PLT32
];
146 case BFD_RELOC_390_COPY
:
147 return &elf_howto_table
[(int) R_390_COPY
];
148 case BFD_RELOC_390_GLOB_DAT
:
149 return &elf_howto_table
[(int) R_390_GLOB_DAT
];
150 case BFD_RELOC_390_JMP_SLOT
:
151 return &elf_howto_table
[(int) R_390_JMP_SLOT
];
152 case BFD_RELOC_390_RELATIVE
:
153 return &elf_howto_table
[(int) R_390_RELATIVE
];
154 case BFD_RELOC_32_GOTOFF
:
155 return &elf_howto_table
[(int) R_390_GOTOFF
];
156 case BFD_RELOC_390_GOTPC
:
157 return &elf_howto_table
[(int) R_390_GOTPC
];
158 case BFD_RELOC_390_GOT16
:
159 return &elf_howto_table
[(int) R_390_GOT16
];
160 case BFD_RELOC_16_PCREL
:
161 return &elf_howto_table
[(int) R_390_PC16
];
162 case BFD_RELOC_390_PC16DBL
:
163 return &elf_howto_table
[(int) R_390_PC16DBL
];
164 case BFD_RELOC_390_PLT16DBL
:
165 return &elf_howto_table
[(int) R_390_PLT16DBL
];
166 case BFD_RELOC_VTABLE_INHERIT
:
167 return &elf64_s390_vtinherit_howto
;
168 case BFD_RELOC_VTABLE_ENTRY
:
169 return &elf64_s390_vtentry_howto
;
170 case BFD_RELOC_390_PC32DBL
:
171 return &elf_howto_table
[(int) R_390_PC32DBL
];
172 case BFD_RELOC_390_PLT32DBL
:
173 return &elf_howto_table
[(int) R_390_PLT32DBL
];
174 case BFD_RELOC_390_GOTPCDBL
:
175 return &elf_howto_table
[(int) R_390_GOTPCDBL
];
177 return &elf_howto_table
[(int) R_390_64
];
178 case BFD_RELOC_64_PCREL
:
179 return &elf_howto_table
[(int) R_390_PC64
];
180 case BFD_RELOC_390_GOT64
:
181 return &elf_howto_table
[(int) R_390_GOT64
];
182 case BFD_RELOC_390_PLT64
:
183 return &elf_howto_table
[(int) R_390_PLT64
];
184 case BFD_RELOC_390_GOTENT
:
185 return &elf_howto_table
[(int) R_390_GOTENT
];
192 /* We need to use ELF64_R_TYPE so we have our own copy of this function,
193 and elf64-s390.c has its own copy. */
196 elf_s390_info_to_howto (abfd
, cache_ptr
, dst
)
197 bfd
*abfd ATTRIBUTE_UNUSED
;
199 Elf_Internal_Rela
*dst
;
201 switch (ELF64_R_TYPE(dst
->r_info
))
203 case R_390_GNU_VTINHERIT
:
204 cache_ptr
->howto
= &elf64_s390_vtinherit_howto
;
207 case R_390_GNU_VTENTRY
:
208 cache_ptr
->howto
= &elf64_s390_vtentry_howto
;
212 BFD_ASSERT (ELF64_R_TYPE(dst
->r_info
) < (unsigned int) R_390_max
);
213 cache_ptr
->howto
= &elf_howto_table
[ELF64_R_TYPE(dst
->r_info
)];
218 elf_s390_is_local_label_name (abfd
, name
)
222 if (name
[0] == '.' && (name
[1] == 'X' || name
[1] == 'L'))
225 return _bfd_elf_is_local_label_name (abfd
, name
);
228 /* Functions for the 390 ELF linker. */
230 /* The name of the dynamic interpreter. This is put in the .interp
233 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
235 /* The nop opcode we use. */
237 #define s390_NOP 0x07070707
240 /* The size in bytes of the first entry in the procedure linkage table. */
241 #define PLT_FIRST_ENTRY_SIZE 32
242 /* The size in bytes of an entry in the procedure linkage table. */
243 #define PLT_ENTRY_SIZE 32
245 #define GOT_ENTRY_SIZE 8
247 /* The first three entries in a procedure linkage table are reserved,
248 and the initial contents are unimportant (we zero them out).
249 Subsequent entries look like this. See the SVR4 ABI 386
250 supplement to see how this works. */
252 /* For the s390, simple addr offset can only be 0 - 4096.
253 To use the full 16777216 TB address space, several instructions
254 are needed to load an address in a register and execute
255 a branch( or just saving the address)
257 Furthermore, only r 0 and 1 are free to use!!! */
259 /* The first 3 words in the GOT are then reserved.
260 Word 0 is the address of the dynamic table.
261 Word 1 is a pointer to a structure describing the object
262 Word 2 is used to point to the loader entry address.
264 The code for PLT entries looks like this:
266 The GOT holds the address in the PLT to be executed.
267 The loader then gets:
268 24(15) = Pointer to the structure describing the object.
269 28(15) = Offset in symbol table
270 The loader must then find the module where the function is
271 and insert the address in the GOT.
273 PLT1: LARL 1,<fn>@GOTENT # 6 bytes Load address of GOT entry in r1
274 LG 1,0(1) # 6 bytes Load address from GOT in r1
275 BCR 15,1 # 2 bytes Jump to address
276 RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
277 LGF 1,12(1) # 6 bytes Load offset in symbl table in r1
278 BRCL 15,-x # 6 bytes Jump to start of PLT
279 .long ? # 4 bytes offset into symbol table
281 Total = 32 bytes per PLT entry
282 Fixup at offset 2: relative address to GOT entry
283 Fixup at offset 22: relative branch to PLT0
284 Fixup at offset 28: 32 bit offset into symbol table
286 A 32 bit offset into the symbol table is enough. It allows for symbol
287 tables up to a size of 2 gigabyte. A single dynamic object (the main
288 program, any shared library) is limited to 4GB in size and I want to see
289 the program that manages to have a symbol table of more than 2 GB with a
290 total size of at max 4 GB. */
292 #define PLT_ENTRY_WORD0 (bfd_vma) 0xc0100000
293 #define PLT_ENTRY_WORD1 (bfd_vma) 0x0000e310
294 #define PLT_ENTRY_WORD2 (bfd_vma) 0x10000004
295 #define PLT_ENTRY_WORD3 (bfd_vma) 0x07f10d10
296 #define PLT_ENTRY_WORD4 (bfd_vma) 0xe310100c
297 #define PLT_ENTRY_WORD5 (bfd_vma) 0x0014c0f4
298 #define PLT_ENTRY_WORD6 (bfd_vma) 0x00000000
299 #define PLT_ENTRY_WORD7 (bfd_vma) 0x00000000
301 /* The first PLT entry pushes the offset into the symbol table
302 from R1 onto the stack at 8(15) and the loader object info
303 at 12(15), loads the loader address in R1 and jumps to it. */
305 /* The first entry in the PLT:
308 STG 1,56(15) # r1 contains the offset into the symbol table
309 LARL 1,_GLOBAL_OFFSET_TABLE # load address of global offset table
310 MVC 48(8,15),8(1) # move loader ino (object struct address) to stack
311 LG 1,16(1) # get entry address of loader
312 BCR 15,1 # jump to loader
314 Fixup at offset 8: relative address to start of GOT. */
316 #define PLT_FIRST_ENTRY_WORD0 (bfd_vma) 0xe310f038
317 #define PLT_FIRST_ENTRY_WORD1 (bfd_vma) 0x0024c010
318 #define PLT_FIRST_ENTRY_WORD2 (bfd_vma) 0x00000000
319 #define PLT_FIRST_ENTRY_WORD3 (bfd_vma) 0xd207f030
320 #define PLT_FIRST_ENTRY_WORD4 (bfd_vma) 0x1008e310
321 #define PLT_FIRST_ENTRY_WORD5 (bfd_vma) 0x10100004
322 #define PLT_FIRST_ENTRY_WORD6 (bfd_vma) 0x07f10700
323 #define PLT_FIRST_ENTRY_WORD7 (bfd_vma) 0x07000700
325 /* The s390 linker needs to keep track of the number of relocs that it
326 decides to copy in check_relocs for each symbol. This is so that
327 it can discard PC relative relocs if it doesn't need them when
328 linking with -Bsymbolic. We store the information in a field
329 extending the regular ELF linker hash table. */
331 /* This structure keeps track of the number of PC relative relocs we
332 have copied for a given symbol. */
334 struct elf_s390_pcrel_relocs_copied
337 struct elf_s390_pcrel_relocs_copied
*next
;
338 /* A section in dynobj. */
340 /* Number of relocs copied in this section. */
344 /* s390 ELF linker hash entry. */
346 struct elf_s390_link_hash_entry
348 struct elf_link_hash_entry root
;
350 /* Number of PC relative relocs copied for this symbol. */
351 struct elf_s390_pcrel_relocs_copied
*pcrel_relocs_copied
;
354 /* s390 ELF linker hash table. */
356 struct elf_s390_link_hash_table
358 struct elf_link_hash_table root
;
361 /* Declare this now that the above structures are defined. */
363 static boolean elf_s390_discard_copies
364 PARAMS ((struct elf_s390_link_hash_entry
*, PTR
));
366 /* Traverse an s390 ELF linker hash table. */
368 #define elf_s390_link_hash_traverse(table, func, info) \
369 (elf_link_hash_traverse \
371 (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
374 /* Get the s390 ELF linker hash table from a link_info structure. */
376 #define elf_s390_hash_table(p) \
377 ((struct elf_s390_link_hash_table *) ((p)->hash))
379 /* Create an entry in an s390 ELF linker hash table. */
381 static struct bfd_hash_entry
*
382 elf_s390_link_hash_newfunc (entry
, table
, string
)
383 struct bfd_hash_entry
*entry
;
384 struct bfd_hash_table
*table
;
387 struct elf_s390_link_hash_entry
*ret
=
388 (struct elf_s390_link_hash_entry
*) entry
;
390 /* Allocate the structure if it has not already been allocated by a
392 if (ret
== (struct elf_s390_link_hash_entry
*) NULL
)
393 ret
= ((struct elf_s390_link_hash_entry
*)
394 bfd_hash_allocate (table
,
395 sizeof (struct elf_s390_link_hash_entry
)));
396 if (ret
== (struct elf_s390_link_hash_entry
*) NULL
)
397 return (struct bfd_hash_entry
*) ret
;
399 /* Call the allocation method of the superclass. */
400 ret
= ((struct elf_s390_link_hash_entry
*)
401 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
403 if (ret
!= (struct elf_s390_link_hash_entry
*) NULL
)
405 ret
->pcrel_relocs_copied
= NULL
;
408 return (struct bfd_hash_entry
*) ret
;
411 /* Create an s390 ELF linker hash table. */
413 static struct bfd_link_hash_table
*
414 elf_s390_link_hash_table_create (abfd
)
417 struct elf_s390_link_hash_table
*ret
;
418 bfd_size_type amt
= sizeof (struct elf_s390_link_hash_table
);
420 ret
= ((struct elf_s390_link_hash_table
*) bfd_alloc (abfd
, amt
));
421 if (ret
== (struct elf_s390_link_hash_table
*) NULL
)
424 if (! _bfd_elf_link_hash_table_init (&ret
->root
, abfd
,
425 elf_s390_link_hash_newfunc
))
427 bfd_release (abfd
, ret
);
431 return &ret
->root
.root
;
435 /* Look through the relocs for a section during the first phase, and
436 allocate space in the global offset table or procedure linkage
440 elf_s390_check_relocs (abfd
, info
, sec
, relocs
)
442 struct bfd_link_info
*info
;
444 const Elf_Internal_Rela
*relocs
;
447 Elf_Internal_Shdr
*symtab_hdr
;
448 struct elf_link_hash_entry
**sym_hashes
;
449 bfd_signed_vma
*local_got_refcounts
;
450 const Elf_Internal_Rela
*rel
;
451 const Elf_Internal_Rela
*rel_end
;
456 if (info
->relocateable
)
459 dynobj
= elf_hash_table (info
)->dynobj
;
460 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
461 sym_hashes
= elf_sym_hashes (abfd
);
462 local_got_refcounts
= elf_local_got_offsets (abfd
);
468 rel_end
= relocs
+ sec
->reloc_count
;
469 for (rel
= relocs
; rel
< rel_end
; rel
++)
471 unsigned long r_symndx
;
472 struct elf_link_hash_entry
*h
;
474 r_symndx
= ELF64_R_SYM (rel
->r_info
);
476 if (r_symndx
< symtab_hdr
->sh_info
)
479 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
481 /* Some relocs require a global offset table. */
484 switch (ELF64_R_TYPE (rel
->r_info
))
494 elf_hash_table (info
)->dynobj
= dynobj
= abfd
;
495 if (! _bfd_elf_create_got_section (dynobj
, info
))
505 switch (ELF64_R_TYPE (rel
->r_info
))
512 /* This symbol requires a global offset table entry. */
516 sgot
= bfd_get_section_by_name (dynobj
, ".got");
517 BFD_ASSERT (sgot
!= NULL
);
522 && (h
!= NULL
|| info
->shared
))
524 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
527 srelgot
= bfd_make_section (dynobj
, ".rela.got");
529 || ! bfd_set_section_flags (dynobj
, srelgot
,
536 || ! bfd_set_section_alignment (dynobj
, srelgot
, 2))
543 if (h
->got
.refcount
== -1)
547 /* Make sure this symbol is output as a dynamic symbol. */
548 if (h
->dynindx
== -1)
550 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
554 sgot
->_raw_size
+= 8;
555 srelgot
->_raw_size
+= sizeof (Elf64_External_Rela
);
558 h
->got
.refcount
+= 1;
562 /* This is a global offset table entry for a local symbol. */
563 if (local_got_refcounts
== NULL
)
567 size
= symtab_hdr
->sh_info
* sizeof (bfd_vma
);
568 local_got_refcounts
= ((bfd_signed_vma
*)
569 bfd_alloc (abfd
, size
));
570 if (local_got_refcounts
== NULL
)
572 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
573 memset (local_got_refcounts
, -1, (size_t) size
);
575 if (local_got_refcounts
[r_symndx
] == -1)
577 local_got_refcounts
[r_symndx
] = 1;
579 sgot
->_raw_size
+= 8;
582 /* If we are generating a shared object, we need to
583 output a R_390_RELATIVE reloc so that the dynamic
584 linker can adjust this GOT entry. */
585 srelgot
->_raw_size
+= sizeof (Elf64_External_Rela
);
589 local_got_refcounts
[r_symndx
] += 1;
598 /* This symbol requires a procedure linkage table entry. We
599 actually build the entry in adjust_dynamic_symbol,
600 because this might be a case of linking PIC code which is
601 never referenced by a dynamic object, in which case we
602 don't need to generate a procedure linkage table entry
605 /* If this is a local symbol, we resolve it directly without
606 creating a procedure linkage table entry. */
610 if (h
->plt
.refcount
== -1)
613 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
616 h
->plt
.refcount
+= 1;
629 h
->elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
631 /* If we are creating a shared library, and this is a reloc
632 against a global symbol, or a non PC relative reloc
633 against a local symbol, then we need to copy the reloc
634 into the shared library. However, if we are linking with
635 -Bsymbolic, we do not need to copy a reloc against a
636 global symbol which is defined in an object we are
637 including in the link (i.e., DEF_REGULAR is set). At
638 this point we have not seen all the input files, so it is
639 possible that DEF_REGULAR is not set now but will be set
640 later (it is never cleared). We account for that
641 possibility below by storing information in the
642 pcrel_relocs_copied field of the hash table entry. */
644 && (sec
->flags
& SEC_ALLOC
) != 0
645 && (ELF64_R_TYPE (rel
->r_info
) == R_390_8
646 || ELF64_R_TYPE (rel
->r_info
) == R_390_16
647 || ELF64_R_TYPE (rel
->r_info
) == R_390_32
648 || ELF64_R_TYPE (rel
->r_info
) == R_390_64
652 || (h
->elf_link_hash_flags
653 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
655 /* When creating a shared object, we must copy these
656 reloc types into the output file. We create a reloc
657 section in dynobj and make room for this reloc. */
662 name
= (bfd_elf_string_from_elf_section
664 elf_elfheader (abfd
)->e_shstrndx
,
665 elf_section_data (sec
)->rel_hdr
.sh_name
));
669 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
670 && strcmp (bfd_get_section_name (abfd
, sec
),
673 sreloc
= bfd_get_section_by_name (dynobj
, name
);
678 sreloc
= bfd_make_section (dynobj
, name
);
679 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
680 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
681 if ((sec
->flags
& SEC_ALLOC
) != 0)
682 flags
|= SEC_ALLOC
| SEC_LOAD
;
684 || ! bfd_set_section_flags (dynobj
, sreloc
, flags
)
685 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
688 if (sec
->flags
& SEC_READONLY
)
689 info
->flags
|= DF_TEXTREL
;
692 sreloc
->_raw_size
+= sizeof (Elf64_External_Rela
);
694 /* If we are linking with -Bsymbolic, and this is a
695 global symbol, we count the number of PC relative
696 relocations we have entered for this symbol, so that
697 we can discard them again if the symbol is later
698 defined by a regular object. Note that this function
699 is only called if we are using an elf64_s390 linker
700 hash table, which means that h is really a pointer to
701 an elf64_s390_link_hash_entry. */
703 && (ELF64_R_TYPE (rel
->r_info
) == R_390_PC16
||
704 ELF64_R_TYPE (rel
->r_info
) == R_390_PC16DBL
||
705 ELF64_R_TYPE (rel
->r_info
) == R_390_PC32
||
706 ELF64_R_TYPE (rel
->r_info
) == R_390_PC32DBL
||
707 ELF64_R_TYPE (rel
->r_info
) == R_390_PC64
))
709 struct elf_s390_link_hash_entry
*eh
;
710 struct elf_s390_pcrel_relocs_copied
*p
;
712 eh
= (struct elf_s390_link_hash_entry
*) h
;
714 for (p
= eh
->pcrel_relocs_copied
; p
!= NULL
; p
= p
->next
)
715 if (p
->section
== sreloc
)
720 p
= ((struct elf_s390_pcrel_relocs_copied
*)
721 bfd_alloc (dynobj
, (bfd_size_type
) sizeof *p
));
724 p
->next
= eh
->pcrel_relocs_copied
;
725 eh
->pcrel_relocs_copied
= p
;
736 /* This relocation describes the C++ object vtable hierarchy.
737 Reconstruct it for later use during GC. */
738 case R_390_GNU_VTINHERIT
:
739 if (!_bfd_elf64_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
743 /* This relocation describes which C++ vtable entries are actually
744 used. Record for later use during GC. */
745 case R_390_GNU_VTENTRY
:
746 if (!_bfd_elf64_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
758 /* Return the section that should be marked against GC for a given
762 elf_s390_gc_mark_hook (abfd
, info
, rel
, h
, sym
)
764 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
765 Elf_Internal_Rela
*rel
;
766 struct elf_link_hash_entry
*h
;
767 Elf_Internal_Sym
*sym
;
771 switch (ELF64_R_TYPE (rel
->r_info
))
773 case R_390_GNU_VTINHERIT
:
774 case R_390_GNU_VTENTRY
:
778 switch (h
->root
.type
)
780 case bfd_link_hash_defined
:
781 case bfd_link_hash_defweak
:
782 return h
->root
.u
.def
.section
;
784 case bfd_link_hash_common
:
785 return h
->root
.u
.c
.p
->section
;
794 if (!(elf_bad_symtab (abfd
)
795 && ELF_ST_BIND (sym
->st_info
) != STB_LOCAL
)
796 && ! ((sym
->st_shndx
<= 0 || sym
->st_shndx
>= SHN_LORESERVE
)
797 && sym
->st_shndx
!= SHN_COMMON
))
799 return bfd_section_from_elf_index (abfd
, sym
->st_shndx
);
806 /* Update the got entry reference counts for the section being removed. */
809 elf_s390_gc_sweep_hook (abfd
, info
, sec
, relocs
)
810 bfd
*abfd ATTRIBUTE_UNUSED
;
811 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
812 asection
*sec ATTRIBUTE_UNUSED
;
813 const Elf_Internal_Rela
*relocs ATTRIBUTE_UNUSED
;
815 Elf_Internal_Shdr
*symtab_hdr
;
816 struct elf_link_hash_entry
**sym_hashes
;
817 bfd_signed_vma
*local_got_refcounts
;
818 const Elf_Internal_Rela
*rel
, *relend
;
819 unsigned long r_symndx
;
820 struct elf_link_hash_entry
*h
;
825 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
826 sym_hashes
= elf_sym_hashes (abfd
);
827 local_got_refcounts
= elf_local_got_refcounts (abfd
);
829 dynobj
= elf_hash_table (info
)->dynobj
;
833 sgot
= bfd_get_section_by_name (dynobj
, ".got");
834 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
836 relend
= relocs
+ sec
->reloc_count
;
837 for (rel
= relocs
; rel
< relend
; rel
++)
838 switch (ELF64_R_TYPE (rel
->r_info
))
848 r_symndx
= ELF64_R_SYM (rel
->r_info
);
849 if (r_symndx
>= symtab_hdr
->sh_info
)
851 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
852 if (h
->got
.refcount
> 0)
854 h
->got
.refcount
-= 1;
855 if (h
->got
.refcount
== 0)
857 sgot
->_raw_size
-= 8;
858 srelgot
->_raw_size
-= sizeof (Elf64_External_Rela
);
862 else if (local_got_refcounts
!= NULL
)
864 if (local_got_refcounts
[r_symndx
] > 0)
866 local_got_refcounts
[r_symndx
] -= 1;
867 if (local_got_refcounts
[r_symndx
] == 0)
869 sgot
->_raw_size
-= 8;
871 srelgot
->_raw_size
-= sizeof (Elf64_External_Rela
);
881 r_symndx
= ELF64_R_SYM (rel
->r_info
);
882 if (r_symndx
>= symtab_hdr
->sh_info
)
884 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
885 if (h
->plt
.refcount
> 0)
886 h
->plt
.refcount
-= 1;
897 /* Adjust a symbol defined by a dynamic object and referenced by a
898 regular object. The current definition is in some section of the
899 dynamic object, but we're not including those sections. We have to
900 change the definition to something the rest of the link can
904 elf_s390_adjust_dynamic_symbol (info
, h
)
905 struct bfd_link_info
*info
;
906 struct elf_link_hash_entry
*h
;
910 unsigned int power_of_two
;
912 dynobj
= elf_hash_table (info
)->dynobj
;
914 /* Make sure we know what is going on here. */
915 BFD_ASSERT (dynobj
!= NULL
916 && ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
)
917 || h
->weakdef
!= NULL
918 || ((h
->elf_link_hash_flags
919 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
920 && (h
->elf_link_hash_flags
921 & ELF_LINK_HASH_REF_REGULAR
) != 0
922 && (h
->elf_link_hash_flags
923 & ELF_LINK_HASH_DEF_REGULAR
) == 0)));
925 /* If this is a function, put it in the procedure linkage table. We
926 will fill in the contents of the procedure linkage table later
927 (although we could actually do it here). */
928 if (h
->type
== STT_FUNC
929 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
932 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_DYNAMIC
) == 0
933 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_REF_DYNAMIC
) == 0)
934 || (info
->shared
&& h
->plt
.refcount
<= 0))
936 /* This case can occur if we saw a PLT32 reloc in an input
937 file, but the symbol was never referred to by a dynamic
938 object. In such a case, we don't actually need to build
939 a procedure linkage table, and we can just do a PC32
941 h
->plt
.offset
= (bfd_vma
) -1;
942 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
946 /* Make sure this symbol is output as a dynamic symbol. */
947 if (h
->dynindx
== -1)
949 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
953 s
= bfd_get_section_by_name (dynobj
, ".plt");
954 BFD_ASSERT (s
!= NULL
);
957 /* The first entry in .plt is reserved. */
958 if (s
->_raw_size
== 0)
959 s
->_raw_size
= PLT_FIRST_ENTRY_SIZE
;
961 /* If this symbol is not defined in a regular file, and we are
962 not generating a shared library, then set the symbol to this
963 location in the .plt. This is required to make function
964 pointers compare as equal between the normal executable and
965 the shared library. */
967 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
969 h
->root
.u
.def
.section
= s
;
970 h
->root
.u
.def
.value
= s
->_raw_size
;
973 h
->plt
.offset
= s
->_raw_size
;
975 /* Make room for this entry. */
976 s
->_raw_size
+= PLT_ENTRY_SIZE
;
978 /* We also need to make an entry in the .got.plt section, which
979 will be placed in the .got section by the linker script. */
980 s
= bfd_get_section_by_name (dynobj
, ".got.plt");
981 BFD_ASSERT (s
!= NULL
);
982 s
->_raw_size
+= GOT_ENTRY_SIZE
;
984 /* We also need to make an entry in the .rela.plt section. */
985 s
= bfd_get_section_by_name (dynobj
, ".rela.plt");
986 BFD_ASSERT (s
!= NULL
);
987 s
->_raw_size
+= sizeof (Elf64_External_Rela
);
992 /* If this is a weak symbol, and there is a real definition, the
993 processor independent code will have arranged for us to see the
994 real definition first, and we can just use the same value. */
995 if (h
->weakdef
!= NULL
)
997 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
998 || h
->weakdef
->root
.type
== bfd_link_hash_defweak
);
999 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
1000 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
1004 /* This is a reference to a symbol defined by a dynamic object which
1005 is not a function. */
1007 /* If we are creating a shared library, we must presume that the
1008 only references to the symbol are via the global offset table.
1009 For such cases we need not do anything here; the relocations will
1010 be handled correctly by relocate_section. */
1014 /* If there are no references to this symbol that do not use the
1015 GOT, we don't need to generate a copy reloc. */
1016 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0)
1019 /* We must allocate the symbol in our .dynbss section, which will
1020 become part of the .bss section of the executable. There will be
1021 an entry for this symbol in the .dynsym section. The dynamic
1022 object will contain position independent code, so all references
1023 from the dynamic object to this symbol will go through the global
1024 offset table. The dynamic linker will use the .dynsym entry to
1025 determine the address it must put in the global offset table, so
1026 both the dynamic object and the regular object will refer to the
1027 same memory location for the variable. */
1029 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
1030 BFD_ASSERT (s
!= NULL
);
1032 /* We must generate a R_390_COPY reloc to tell the dynamic linker
1033 to copy the initial value out of the dynamic object and into the
1034 runtime process image. We need to remember the offset into the
1035 .rel.bss section we are going to use. */
1036 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
1040 srel
= bfd_get_section_by_name (dynobj
, ".rela.bss");
1041 BFD_ASSERT (srel
!= NULL
);
1042 srel
->_raw_size
+= sizeof (Elf64_External_Rela
);
1043 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
1046 /* We need to figure out the alignment required for this symbol. I
1047 have no idea how ELF linkers handle this. */
1048 power_of_two
= bfd_log2 (h
->size
);
1049 if (power_of_two
> 3)
1052 /* Apply the required alignment. */
1053 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
1054 (bfd_size_type
) (1 << power_of_two
));
1055 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
1057 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
1061 /* Define the symbol as being at this point in the section. */
1062 h
->root
.u
.def
.section
= s
;
1063 h
->root
.u
.def
.value
= s
->_raw_size
;
1065 /* Increment the section size to make room for the symbol. */
1066 s
->_raw_size
+= h
->size
;
1071 /* Set the sizes of the dynamic sections. */
1074 elf_s390_size_dynamic_sections (output_bfd
, info
)
1075 bfd
*output_bfd ATTRIBUTE_UNUSED
;
1076 struct bfd_link_info
*info
;
1083 dynobj
= elf_hash_table (info
)->dynobj
;
1084 BFD_ASSERT (dynobj
!= NULL
);
1086 if (elf_hash_table (info
)->dynamic_sections_created
)
1088 /* Set the contents of the .interp section to the interpreter. */
1091 s
= bfd_get_section_by_name (dynobj
, ".interp");
1092 BFD_ASSERT (s
!= NULL
);
1093 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
1094 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
1099 /* We may have created entries in the .rela.got section.
1100 However, if we are not creating the dynamic sections, we will
1101 not actually use these entries. Reset the size of .rela.got,
1102 which will cause it to get stripped from the output file
1104 s
= bfd_get_section_by_name (dynobj
, ".rela.got");
1109 /* If this is a -Bsymbolic shared link, then we need to discard all
1110 PC relative relocs against symbols defined in a regular object.
1111 We allocated space for them in the check_relocs routine, but we
1112 will not fill them in in the relocate_section routine. */
1114 elf_s390_link_hash_traverse (elf_s390_hash_table (info
),
1115 elf_s390_discard_copies
,
1118 /* The check_relocs and adjust_dynamic_symbol entry points have
1119 determined the sizes of the various dynamic sections. Allocate
1123 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
1128 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
1131 /* It's OK to base decisions on the section name, because none
1132 of the dynobj section names depend upon the input files. */
1133 name
= bfd_get_section_name (dynobj
, s
);
1137 if (strcmp (name
, ".plt") == 0)
1139 if (s
->_raw_size
== 0)
1141 /* Strip this section if we don't need it; see the
1147 /* Remember whether there is a PLT. */
1151 else if (strncmp (name
, ".rela", 5) == 0)
1153 if (s
->_raw_size
== 0)
1155 /* If we don't need this section, strip it from the
1156 output file. This is to handle .rela.bss and
1157 .rel.plt. We must create it in
1158 create_dynamic_sections, because it must be created
1159 before the linker maps input sections to output
1160 sections. The linker does that before
1161 adjust_dynamic_symbol is called, and it is that
1162 function which decides whether anything needs to go
1163 into these sections. */
1168 /* Remember whether there are any reloc sections other
1170 if (strcmp (name
, ".rela.plt") != 0)
1173 /* We use the reloc_count field as a counter if we need
1174 to copy relocs into the output file. */
1178 else if (strncmp (name
, ".got", 4) != 0)
1180 /* It's not one of our sections, so don't allocate space. */
1186 _bfd_strip_section_from_output (info
, s
);
1190 /* Allocate memory for the section contents. */
1191 s
->contents
= (bfd_byte
*) bfd_alloc (dynobj
, s
->_raw_size
);
1192 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
1196 if (elf_hash_table (info
)->dynamic_sections_created
)
1198 /* Add some entries to the .dynamic section. We fill in the
1199 values later, in elf_s390_finish_dynamic_sections, but we
1200 must add the entries now so that we get the correct size for
1201 the .dynamic section. The DT_DEBUG entry is filled in by the
1202 dynamic linker and used by the debugger. */
1203 #define add_dynamic_entry(TAG, VAL) \
1204 bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
1208 if (!add_dynamic_entry (DT_DEBUG
, 0))
1214 if (!add_dynamic_entry (DT_PLTGOT
, 0)
1215 || !add_dynamic_entry (DT_PLTRELSZ
, 0)
1216 || !add_dynamic_entry (DT_PLTREL
, DT_RELA
)
1217 || !add_dynamic_entry (DT_JMPREL
, 0))
1223 if (!add_dynamic_entry (DT_RELA
, 0)
1224 || !add_dynamic_entry (DT_RELASZ
, 0)
1225 || !add_dynamic_entry (DT_RELAENT
, sizeof (Elf64_External_Rela
)))
1229 if ((info
->flags
& DF_TEXTREL
) != 0)
1231 if (!add_dynamic_entry (DT_TEXTREL
, 0))
1233 info
->flags
|= DF_TEXTREL
;
1236 #undef add_dynamic_entry
1241 /* This function is called via elf64_s390_link_hash_traverse if we are
1242 creating a shared object with -Bsymbolic. It discards the space
1243 allocated to copy PC relative relocs against symbols which are
1244 defined in regular objects. We allocated space for them in the
1245 check_relocs routine, but we won't fill them in in the
1246 relocate_section routine. */
1250 elf_s390_discard_copies (h
, inf
)
1251 struct elf_s390_link_hash_entry
*h
;
1254 struct elf_s390_pcrel_relocs_copied
*s
;
1255 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
1257 /* If a symbol has been forced local or we have found a regular
1258 definition for the symbolic link case, then we won't be needing
1260 if ((h
->root
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1261 && ((h
->root
.elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) != 0
1264 for (s
= h
->pcrel_relocs_copied
; s
!= NULL
; s
= s
->next
)
1265 s
->section
->_raw_size
-= s
->count
* sizeof (Elf64_External_Rela
);
1270 /* Relocate a 390 ELF section. */
1273 elf_s390_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1274 contents
, relocs
, local_syms
, local_sections
)
1276 struct bfd_link_info
*info
;
1278 asection
*input_section
;
1280 Elf_Internal_Rela
*relocs
;
1281 Elf_Internal_Sym
*local_syms
;
1282 asection
**local_sections
;
1285 Elf_Internal_Shdr
*symtab_hdr
;
1286 struct elf_link_hash_entry
**sym_hashes
;
1287 bfd_vma
*local_got_offsets
;
1291 Elf_Internal_Rela
*rel
;
1292 Elf_Internal_Rela
*relend
;
1294 dynobj
= elf_hash_table (info
)->dynobj
;
1295 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1296 sym_hashes
= elf_sym_hashes (input_bfd
);
1297 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1304 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1305 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1309 relend
= relocs
+ input_section
->reloc_count
;
1310 for (; rel
< relend
; rel
++)
1313 reloc_howto_type
*howto
;
1314 unsigned long r_symndx
;
1315 struct elf_link_hash_entry
*h
;
1316 Elf_Internal_Sym
*sym
;
1319 bfd_reloc_status_type r
;
1321 r_type
= ELF64_R_TYPE (rel
->r_info
);
1322 if (r_type
== R_390_GNU_VTINHERIT
1323 || r_type
== R_390_GNU_VTENTRY
)
1325 if (r_type
< 0 || r_type
>= (int) R_390_max
)
1327 bfd_set_error (bfd_error_bad_value
);
1330 howto
= elf_howto_table
+ r_type
;
1332 r_symndx
= ELF64_R_SYM (rel
->r_info
);
1334 if (info
->relocateable
)
1336 /* This is a relocateable link. We don't have to change
1337 anything, unless the reloc is against a section symbol,
1338 in which case we have to adjust according to where the
1339 section symbol winds up in the output section. */
1340 if (r_symndx
< symtab_hdr
->sh_info
)
1342 sym
= local_syms
+ r_symndx
;
1343 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1345 sec
= local_sections
[r_symndx
];
1346 rel
->r_addend
+= sec
->output_offset
+ sym
->st_value
;
1353 /* This is a final link. */
1357 if (r_symndx
< symtab_hdr
->sh_info
)
1359 sym
= local_syms
+ r_symndx
;
1360 sec
= local_sections
[r_symndx
];
1361 relocation
= (sec
->output_section
->vma
1362 + sec
->output_offset
1367 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1368 while (h
->root
.type
== bfd_link_hash_indirect
1369 || h
->root
.type
== bfd_link_hash_warning
)
1370 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1371 if (h
->root
.type
== bfd_link_hash_defined
1372 || h
->root
.type
== bfd_link_hash_defweak
)
1374 sec
= h
->root
.u
.def
.section
;
1375 if ((r_type
== R_390_GOTPC
1376 || r_type
== R_390_GOTPCDBL
)
1377 || ((r_type
== R_390_PLT16DBL
||
1378 r_type
== R_390_PLT32
||
1379 r_type
== R_390_PLT32DBL
||
1380 r_type
== R_390_PLT64
)
1382 && h
->plt
.offset
!= (bfd_vma
) -1)
1383 || ((r_type
== R_390_GOT12
||
1384 r_type
== R_390_GOT16
||
1385 r_type
== R_390_GOT32
||
1386 r_type
== R_390_GOT64
||
1387 r_type
== R_390_GOTENT
)
1388 && elf_hash_table (info
)->dynamic_sections_created
1390 || (! info
->symbolic
&& h
->dynindx
!= -1)
1391 || (h
->elf_link_hash_flags
1392 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1394 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1395 || (h
->elf_link_hash_flags
1396 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
1397 && ( r_type
== R_390_8
||
1398 r_type
== R_390_16
||
1399 r_type
== R_390_32
||
1400 r_type
== R_390_64
||
1401 r_type
== R_390_PC16
||
1402 r_type
== R_390_PC16DBL
||
1403 r_type
== R_390_PC32
||
1404 r_type
== R_390_PC32DBL
||
1405 r_type
== R_390_PC64
)
1406 && ((input_section
->flags
& SEC_ALLOC
) != 0
1407 /* DWARF will emit R_386_32 relocations in its
1408 sections against symbols defined externally
1409 in shared libraries. We can't do anything
1411 || ((input_section
->flags
& SEC_DEBUGGING
) != 0
1412 && (h
->elf_link_hash_flags
1413 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0))))
1415 /* In these cases, we don't need the relocation
1416 value. We check specially because in some
1417 obscure cases sec->output_section will be NULL. */
1420 else if (sec
->output_section
== NULL
)
1422 (*_bfd_error_handler
)
1423 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1424 bfd_archive_filename (input_bfd
), h
->root
.root
.string
,
1425 bfd_get_section_name (input_bfd
, input_section
));
1429 relocation
= (h
->root
.u
.def
.value
1430 + sec
->output_section
->vma
1431 + sec
->output_offset
);
1433 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1435 else if (info
->shared
1436 && (!info
->symbolic
|| info
->allow_shlib_undefined
)
1437 && !info
->no_undefined
1438 && ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
)
1442 if (! ((*info
->callbacks
->undefined_symbol
)
1443 (info
, h
->root
.root
.string
, input_bfd
,
1444 input_section
, rel
->r_offset
,
1445 (!info
->shared
|| info
->no_undefined
1446 || ELF_ST_VISIBILITY (h
->other
)))))
1459 /* Relocation is to the entry for this symbol in the global
1461 BFD_ASSERT (sgot
!= NULL
);
1467 off
= h
->got
.offset
;
1468 BFD_ASSERT (off
!= (bfd_vma
) -1);
1470 if (! elf_hash_table (info
)->dynamic_sections_created
1472 && (info
->symbolic
|| h
->dynindx
== -1)
1473 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1475 /* This is actually a static link, or it is a
1476 -Bsymbolic link and the symbol is defined
1477 locally, or the symbol was forced to be local
1478 because of a version file. We must initialize
1479 this entry in the global offset table. Since the
1480 offset must always be a multiple of 2, we use the
1481 least significant bit to record whether we have
1482 initialized it already.
1484 When doing a dynamic link, we create a .rel.got
1485 relocation entry to initialize the value. This
1486 is done in the finish_dynamic_symbol routine. */
1491 bfd_put_64 (output_bfd
, relocation
,
1492 sgot
->contents
+ off
);
1496 relocation
= sgot
->output_offset
+ off
;
1502 BFD_ASSERT (local_got_offsets
!= NULL
1503 && local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
1505 off
= local_got_offsets
[r_symndx
];
1507 /* The offset must always be a multiple of 8. We use
1508 the least significant bit to record whether we have
1509 already generated the necessary reloc. */
1514 bfd_put_64 (output_bfd
, relocation
, sgot
->contents
+ off
);
1519 Elf_Internal_Rela outrel
;
1521 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
1522 BFD_ASSERT (srelgot
!= NULL
);
1524 outrel
.r_offset
= (sgot
->output_section
->vma
1525 + sgot
->output_offset
1527 outrel
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
1528 outrel
.r_addend
= relocation
;
1529 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
,
1530 (((Elf64_External_Rela
*)
1532 + srelgot
->reloc_count
));
1533 ++srelgot
->reloc_count
;
1536 local_got_offsets
[r_symndx
] |= 1;
1539 relocation
= sgot
->output_offset
+ off
;
1543 * For @GOTENT the relocation is against the offset between
1544 * the instruction and the symbols entry in the GOT and not
1545 * between the start of the GOT and the symbols entry. We
1546 * add the vma of the GOT to get the correct value.
1548 if (r_type
== R_390_GOTENT
)
1549 relocation
+= sgot
->output_section
->vma
;
1554 /* Relocation is relative to the start of the global offset
1559 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1560 BFD_ASSERT (sgot
!= NULL
);
1563 /* Note that sgot->output_offset is not involved in this
1564 calculation. We always want the start of .got. If we
1565 defined _GLOBAL_OFFSET_TABLE in a different way, as is
1566 permitted by the ABI, we might have to change this
1568 relocation
-= sgot
->output_section
->vma
;
1573 case R_390_GOTPCDBL
:
1574 /* Use global offset table as symbol value. */
1578 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1579 BFD_ASSERT (sgot
!= NULL
);
1582 relocation
= sgot
->output_section
->vma
;
1586 case R_390_PLT16DBL
:
1588 case R_390_PLT32DBL
:
1590 /* Relocation is to the entry for this symbol in the
1591 procedure linkage table. */
1593 /* Resolve a PLT32 reloc against a local symbol directly,
1594 without using the procedure linkage table. */
1598 if (h
->plt
.offset
== (bfd_vma
) -1 || splt
== NULL
)
1600 /* We didn't make a PLT entry for this symbol. This
1601 happens when statically linking PIC code, or when
1602 using -Bsymbolic. */
1606 relocation
= (splt
->output_section
->vma
1607 + splt
->output_offset
1622 && (input_section
->flags
& SEC_ALLOC
) != 0
1623 && (r_type
== R_390_8
1624 || r_type
== R_390_16
1625 || r_type
== R_390_32
1626 || r_type
== R_390_64
1629 && (! info
->symbolic
1630 || (h
->elf_link_hash_flags
1631 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
1633 Elf_Internal_Rela outrel
;
1634 boolean skip
, relocate
;
1636 /* When generating a shared object, these relocations
1637 are copied into the output file to be resolved at run
1644 name
= (bfd_elf_string_from_elf_section
1646 elf_elfheader (input_bfd
)->e_shstrndx
,
1647 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1651 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1652 && strcmp (bfd_get_section_name (input_bfd
,
1656 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1657 BFD_ASSERT (sreloc
!= NULL
);
1662 if (elf_section_data (input_section
)->stab_info
== NULL
)
1663 outrel
.r_offset
= rel
->r_offset
;
1668 off
= (_bfd_stab_section_offset
1669 (output_bfd
, &elf_hash_table (info
)->stab_info
,
1671 &elf_section_data (input_section
)->stab_info
,
1673 if (off
== (bfd_vma
) -1)
1675 outrel
.r_offset
= off
;
1678 outrel
.r_offset
+= (input_section
->output_section
->vma
1679 + input_section
->output_offset
);
1683 memset (&outrel
, 0, sizeof outrel
);
1686 else if (r_type
== R_390_PC16
||
1687 r_type
== R_390_PC16DBL
||
1688 r_type
== R_390_PC32
||
1689 r_type
== R_390_PC32DBL
||
1690 r_type
== R_390_PC64
)
1692 BFD_ASSERT (h
!= NULL
&& h
->dynindx
!= -1);
1694 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, r_type
);
1695 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1699 /* h->dynindx may be -1 if this symbol was marked to
1702 || ((info
->symbolic
|| h
->dynindx
== -1)
1703 && (h
->elf_link_hash_flags
1704 & ELF_LINK_HASH_DEF_REGULAR
) != 0))
1707 outrel
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
1708 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1712 BFD_ASSERT (h
->dynindx
!= -1);
1714 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_64
);
1715 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1719 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
,
1720 (((Elf64_External_Rela
*)
1722 + sreloc
->reloc_count
));
1723 ++sreloc
->reloc_count
;
1725 /* If this reloc is against an external symbol, we do
1726 not want to fiddle with the addend. Otherwise, we
1727 need to include the symbol value so that it becomes
1728 an addend for the dynamic reloc. */
1739 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
1740 contents
, rel
->r_offset
,
1741 relocation
, rel
->r_addend
);
1743 if (r
!= bfd_reloc_ok
)
1748 case bfd_reloc_outofrange
:
1750 case bfd_reloc_overflow
:
1755 name
= h
->root
.root
.string
;
1758 name
= bfd_elf_string_from_elf_section (input_bfd
,
1759 symtab_hdr
->sh_link
,
1764 name
= bfd_section_name (input_bfd
, sec
);
1766 if (! ((*info
->callbacks
->reloc_overflow
)
1767 (info
, name
, howto
->name
, (bfd_vma
) 0,
1768 input_bfd
, input_section
, rel
->r_offset
)))
1779 /* Finish up dynamic symbol handling. We set the contents of various
1780 dynamic sections here. */
1783 elf_s390_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
1785 struct bfd_link_info
*info
;
1786 struct elf_link_hash_entry
*h
;
1787 Elf_Internal_Sym
*sym
;
1791 dynobj
= elf_hash_table (info
)->dynobj
;
1793 if (h
->plt
.offset
!= (bfd_vma
) -1)
1797 Elf_Internal_Rela rela
;
1802 /* This symbol has an entry in the procedure linkage table. Set
1805 BFD_ASSERT (h
->dynindx
!= -1);
1807 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1808 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
1809 srela
= bfd_get_section_by_name (dynobj
, ".rela.plt");
1810 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srela
!= NULL
);
1813 Current offset - size first entry / entry size. */
1814 plt_index
= (h
->plt
.offset
- PLT_FIRST_ENTRY_SIZE
) / PLT_ENTRY_SIZE
;
1816 /* Offset in GOT is PLT index plus GOT headers(3) times 8,
1818 got_offset
= (plt_index
+ 3) * GOT_ENTRY_SIZE
;
1820 /* Fill in the blueprint of a PLT. */
1821 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD0
,
1822 splt
->contents
+ h
->plt
.offset
);
1823 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD1
,
1824 splt
->contents
+ h
->plt
.offset
+ 4);
1825 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD2
,
1826 splt
->contents
+ h
->plt
.offset
+ 8);
1827 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD3
,
1828 splt
->contents
+ h
->plt
.offset
+ 12);
1829 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD4
,
1830 splt
->contents
+ h
->plt
.offset
+ 16);
1831 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD5
,
1832 splt
->contents
+ h
->plt
.offset
+ 20);
1833 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD6
,
1834 splt
->contents
+ h
->plt
.offset
+ 24);
1835 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD7
,
1836 splt
->contents
+ h
->plt
.offset
+ 28);
1837 /* Fixup the relative address to the GOT entry */
1838 bfd_put_32 (output_bfd
,
1839 (sgot
->output_section
->vma
+ sgot
->output_offset
+ got_offset
1840 - (splt
->output_section
->vma
+ h
->plt
.offset
))/2,
1841 splt
->contents
+ h
->plt
.offset
+ 2);
1842 /* Fixup the relative branch to PLT 0 */
1843 bfd_put_32 (output_bfd
, - (PLT_FIRST_ENTRY_SIZE
+
1844 (PLT_ENTRY_SIZE
* plt_index
) + 22)/2,
1845 splt
->contents
+ h
->plt
.offset
+ 24);
1846 /* Fixup offset into symbol table */
1847 bfd_put_32 (output_bfd
, plt_index
* sizeof (Elf64_External_Rela
),
1848 splt
->contents
+ h
->plt
.offset
+ 28);
1850 /* Fill in the entry in the .rela.plt section. */
1851 rela
.r_offset
= (sgot
->output_section
->vma
1852 + sgot
->output_offset
1854 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_JMP_SLOT
);
1856 bfd_elf64_swap_reloca_out (output_bfd
, &rela
,
1857 ((Elf64_External_Rela
*) srela
->contents
1860 /* Fill in the entry in the global offset table.
1861 Points to instruction after GOT offset. */
1862 bfd_put_64 (output_bfd
,
1863 (splt
->output_section
->vma
1864 + splt
->output_offset
1867 sgot
->contents
+ got_offset
);
1870 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
1872 /* Mark the symbol as undefined, rather than as defined in
1873 the .plt section. Leave the value alone. */
1874 sym
->st_shndx
= SHN_UNDEF
;
1878 if (h
->got
.offset
!= (bfd_vma
) -1)
1882 Elf_Internal_Rela rela
;
1884 /* This symbol has an entry in the global offset table. Set it
1887 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1888 srela
= bfd_get_section_by_name (dynobj
, ".rela.got");
1889 BFD_ASSERT (sgot
!= NULL
&& srela
!= NULL
);
1891 rela
.r_offset
= (sgot
->output_section
->vma
1892 + sgot
->output_offset
1893 + (h
->got
.offset
&~ (bfd_vma
) 1));
1895 /* If this is a static link, or it is a -Bsymbolic link and the
1896 symbol is defined locally or was forced to be local because
1897 of a version file, we just want to emit a RELATIVE reloc.
1898 The entry in the global offset table will already have been
1899 initialized in the relocate_section function. */
1900 if (! elf_hash_table (info
)->dynamic_sections_created
1902 && (info
->symbolic
|| h
->dynindx
== -1)
1903 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1905 rela
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
1906 rela
.r_addend
= (h
->root
.u
.def
.value
1907 + h
->root
.u
.def
.section
->output_section
->vma
1908 + h
->root
.u
.def
.section
->output_offset
);
1912 BFD_ASSERT((h
->got
.offset
& 1) == 0);
1913 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ h
->got
.offset
);
1914 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_GLOB_DAT
);
1918 bfd_elf64_swap_reloca_out (output_bfd
, &rela
,
1919 ((Elf64_External_Rela
*) srela
->contents
1920 + srela
->reloc_count
));
1921 ++srela
->reloc_count
;
1924 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
1927 Elf_Internal_Rela rela
;
1929 /* This symbols needs a copy reloc. Set it up. */
1931 BFD_ASSERT (h
->dynindx
!= -1
1932 && (h
->root
.type
== bfd_link_hash_defined
1933 || h
->root
.type
== bfd_link_hash_defweak
));
1936 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
1938 BFD_ASSERT (s
!= NULL
);
1940 rela
.r_offset
= (h
->root
.u
.def
.value
1941 + h
->root
.u
.def
.section
->output_section
->vma
1942 + h
->root
.u
.def
.section
->output_offset
);
1943 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_COPY
);
1945 bfd_elf64_swap_reloca_out (output_bfd
, &rela
,
1946 ((Elf64_External_Rela
*) s
->contents
1951 /* Mark some specially defined symbols as absolute. */
1952 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
1953 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0
1954 || strcmp (h
->root
.root
.string
, "_PROCEDURE_LINKAGE_TABLE_") == 0)
1955 sym
->st_shndx
= SHN_ABS
;
1960 /* Finish up the dynamic sections. */
1963 elf_s390_finish_dynamic_sections (output_bfd
, info
)
1965 struct bfd_link_info
*info
;
1971 dynobj
= elf_hash_table (info
)->dynobj
;
1973 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
1974 BFD_ASSERT (sgot
!= NULL
);
1975 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
1977 if (elf_hash_table (info
)->dynamic_sections_created
)
1980 Elf64_External_Dyn
*dyncon
, *dynconend
;
1982 BFD_ASSERT (sdyn
!= NULL
);
1984 dyncon
= (Elf64_External_Dyn
*) sdyn
->contents
;
1985 dynconend
= (Elf64_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
1986 for (; dyncon
< dynconend
; dyncon
++)
1988 Elf_Internal_Dyn dyn
;
1992 bfd_elf64_swap_dyn_in (dynobj
, dyncon
, &dyn
);
2005 s
= bfd_get_section_by_name(output_bfd
, name
);
2006 BFD_ASSERT (s
!= NULL
);
2007 dyn
.d_un
.d_ptr
= s
->vma
;
2008 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2012 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
2013 BFD_ASSERT (s
!= NULL
);
2014 if (s
->_cooked_size
!= 0)
2015 dyn
.d_un
.d_val
= s
->_cooked_size
;
2017 dyn
.d_un
.d_val
= s
->_raw_size
;
2018 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2022 /* The procedure linkage table relocs (DT_JMPREL) should
2023 not be included in the overall relocs (DT_RELA).
2024 Therefore, we override the DT_RELASZ entry here to
2025 make it not include the JMPREL relocs. Since the
2026 linker script arranges for .rela.plt to follow all
2027 other relocation sections, we don't have to worry
2028 about changing the DT_RELA entry. */
2029 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
2032 if (s
->_cooked_size
!= 0)
2033 dyn
.d_un
.d_val
-= s
->_cooked_size
;
2035 dyn
.d_un
.d_val
-= s
->_raw_size
;
2037 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2042 /* Fill in the special first entry in the procedure linkage table. */
2043 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2044 if (splt
&& splt
->_raw_size
> 0)
2046 /* fill in blueprint for plt 0 entry */
2047 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD0
,
2049 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD1
,
2050 splt
->contents
+4 );
2051 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD3
,
2052 splt
->contents
+12 );
2053 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD4
,
2054 splt
->contents
+16 );
2055 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD5
,
2056 splt
->contents
+20 );
2057 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD6
,
2058 splt
->contents
+ 24);
2059 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD7
,
2060 splt
->contents
+ 28 );
2061 /* Fixup relative address to start of GOT */
2062 bfd_put_32 (output_bfd
,
2063 (sgot
->output_section
->vma
+ sgot
->output_offset
2064 - splt
->output_section
->vma
- 6)/2,
2065 splt
->contents
+ 8);
2068 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
=
2072 /* Set the first entry in the global offset table to the address of
2073 the dynamic section. */
2074 if (sgot
->_raw_size
> 0)
2077 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
2079 bfd_put_64 (output_bfd
,
2080 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
2083 /* One entry for shared object struct ptr. */
2084 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
2085 /* One entry for _dl_runtime_resolve. */
2086 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 12);
2089 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 8;
2095 elf_s390_object_p (abfd
)
2098 return bfd_default_set_arch_mach (abfd
, bfd_arch_s390
, bfd_mach_s390_esame
);
2102 static enum elf_reloc_type_class
2103 elf_s390_reloc_type_class (type
)
2108 case R_390_RELATIVE
:
2109 return reloc_class_relative
;
2110 case R_390_JMP_SLOT
:
2111 return reloc_class_plt
;
2113 return reloc_class_copy
;
2115 return reloc_class_normal
;
2120 * Why was the hash table entry size definition changed from
2121 * ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
2122 * this is the only reason for the s390_elf64_size_info structure.
2125 const struct elf_size_info s390_elf64_size_info
=
2127 sizeof (Elf64_External_Ehdr
),
2128 sizeof (Elf64_External_Phdr
),
2129 sizeof (Elf64_External_Shdr
),
2130 sizeof (Elf64_External_Rel
),
2131 sizeof (Elf64_External_Rela
),
2132 sizeof (Elf64_External_Sym
),
2133 sizeof (Elf64_External_Dyn
),
2134 sizeof (Elf_External_Note
),
2135 8, /* hash-table entry size */
2136 1, /* internal relocations per external relocations */
2139 ELFCLASS64
, EV_CURRENT
,
2140 bfd_elf64_write_out_phdrs
,
2141 bfd_elf64_write_shdrs_and_ehdr
,
2142 bfd_elf64_write_relocs
,
2143 bfd_elf64_swap_symbol_out
,
2144 bfd_elf64_slurp_reloc_table
,
2145 bfd_elf64_slurp_symbol_table
,
2146 bfd_elf64_swap_dyn_in
,
2147 bfd_elf64_swap_dyn_out
,
2154 #define TARGET_BIG_SYM bfd_elf64_s390_vec
2155 #define TARGET_BIG_NAME "elf64-s390"
2156 #define ELF_ARCH bfd_arch_s390
2157 #define ELF_MACHINE_CODE EM_S390
2158 #define ELF_MACHINE_ALT1 EM_S390_OLD
2159 #define ELF_MAXPAGESIZE 0x1000
2161 #define elf_backend_size_info s390_elf64_size_info
2163 #define elf_backend_can_gc_sections 1
2164 #define elf_backend_want_got_plt 1
2165 #define elf_backend_plt_readonly 1
2166 #define elf_backend_want_plt_sym 0
2167 #define elf_backend_got_header_size 24
2168 #define elf_backend_plt_header_size PLT_ENTRY_SIZE
2170 #define elf_info_to_howto elf_s390_info_to_howto
2172 #define bfd_elf64_bfd_final_link _bfd_elf64_gc_common_final_link
2173 #define bfd_elf64_bfd_is_local_label_name elf_s390_is_local_label_name
2174 #define bfd_elf64_bfd_link_hash_table_create elf_s390_link_hash_table_create
2175 #define bfd_elf64_bfd_reloc_type_lookup elf_s390_reloc_type_lookup
2177 #define elf_backend_adjust_dynamic_symbol elf_s390_adjust_dynamic_symbol
2178 #define elf_backend_check_relocs elf_s390_check_relocs
2179 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
2180 #define elf_backend_finish_dynamic_sections elf_s390_finish_dynamic_sections
2181 #define elf_backend_finish_dynamic_symbol elf_s390_finish_dynamic_symbol
2182 #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
2183 #define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
2184 #define elf_backend_relocate_section elf_s390_relocate_section
2185 #define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
2186 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
2188 #define elf_backend_object_p elf_s390_object_p
2190 #include "elf64-target.h"