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 0xc0100000
293 #define PLT_ENTRY_WORD1 0x0000e310
294 #define PLT_ENTRY_WORD2 0x10000004
295 #define PLT_ENTRY_WORD3 0x07f10d10
296 #define PLT_ENTRY_WORD4 0xe310100c
297 #define PLT_ENTRY_WORD5 0x0014c0f4
298 #define PLT_ENTRY_WORD6 0x00000000
299 #define PLT_ENTRY_WORD7 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 0xe310f038
317 #define PLT_FIRST_ENTRY_WORD1 0x0024c010
318 #define PLT_FIRST_ENTRY_WORD2 0x00000000
319 #define PLT_FIRST_ENTRY_WORD3 0xd207f030
320 #define PLT_FIRST_ENTRY_WORD4 0x1008e310
321 #define PLT_FIRST_ENTRY_WORD5 0x10100004
322 #define PLT_FIRST_ENTRY_WORD6 0x07f10700
323 #define PLT_FIRST_ENTRY_WORD7 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
;
419 ret
= ((struct elf_s390_link_hash_table
*)
420 bfd_alloc (abfd
, sizeof (struct elf_s390_link_hash_table
)));
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
);
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
, 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. */
1205 if (! bfd_elf64_add_dynamic_entry (info
, DT_DEBUG
, 0))
1211 if (! bfd_elf64_add_dynamic_entry (info
, DT_PLTGOT
, 0)
1212 || ! bfd_elf64_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
1213 || ! bfd_elf64_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
1214 || ! bfd_elf64_add_dynamic_entry (info
, DT_JMPREL
, 0))
1220 if (! bfd_elf64_add_dynamic_entry (info
, DT_RELA
, 0)
1221 || ! bfd_elf64_add_dynamic_entry (info
, DT_RELASZ
, 0)
1222 || ! bfd_elf64_add_dynamic_entry (info
, DT_RELAENT
,
1223 sizeof (Elf64_External_Rela
)))
1227 if ((info
->flags
& DF_TEXTREL
) != 0)
1229 if (! bfd_elf64_add_dynamic_entry (info
, DT_TEXTREL
, 0))
1231 info
->flags
|= DF_TEXTREL
;
1238 /* This function is called via elf64_s390_link_hash_traverse if we are
1239 creating a shared object with -Bsymbolic. It discards the space
1240 allocated to copy PC relative relocs against symbols which are
1241 defined in regular objects. We allocated space for them in the
1242 check_relocs routine, but we won't fill them in in the
1243 relocate_section routine. */
1247 elf_s390_discard_copies (h
, inf
)
1248 struct elf_s390_link_hash_entry
*h
;
1251 struct elf_s390_pcrel_relocs_copied
*s
;
1252 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
1254 /* If a symbol has been forced local or we have found a regular
1255 definition for the symbolic link case, then we won't be needing
1257 if ((h
->root
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1258 && ((h
->root
.elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) != 0
1261 for (s
= h
->pcrel_relocs_copied
; s
!= NULL
; s
= s
->next
)
1262 s
->section
->_raw_size
-= s
->count
* sizeof (Elf64_External_Rela
);
1267 /* Relocate a 390 ELF section. */
1270 elf_s390_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1271 contents
, relocs
, local_syms
, local_sections
)
1273 struct bfd_link_info
*info
;
1275 asection
*input_section
;
1277 Elf_Internal_Rela
*relocs
;
1278 Elf_Internal_Sym
*local_syms
;
1279 asection
**local_sections
;
1282 Elf_Internal_Shdr
*symtab_hdr
;
1283 struct elf_link_hash_entry
**sym_hashes
;
1284 bfd_vma
*local_got_offsets
;
1288 Elf_Internal_Rela
*rel
;
1289 Elf_Internal_Rela
*relend
;
1291 dynobj
= elf_hash_table (info
)->dynobj
;
1292 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1293 sym_hashes
= elf_sym_hashes (input_bfd
);
1294 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1301 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1302 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1306 relend
= relocs
+ input_section
->reloc_count
;
1307 for (; rel
< relend
; rel
++)
1310 reloc_howto_type
*howto
;
1311 unsigned long r_symndx
;
1312 struct elf_link_hash_entry
*h
;
1313 Elf_Internal_Sym
*sym
;
1316 bfd_reloc_status_type r
;
1318 r_type
= ELF64_R_TYPE (rel
->r_info
);
1319 if (r_type
== R_390_GNU_VTINHERIT
1320 || r_type
== R_390_GNU_VTENTRY
)
1322 if (r_type
< 0 || r_type
>= (int) R_390_max
)
1324 bfd_set_error (bfd_error_bad_value
);
1327 howto
= elf_howto_table
+ r_type
;
1329 r_symndx
= ELF64_R_SYM (rel
->r_info
);
1331 if (info
->relocateable
)
1333 /* This is a relocateable link. We don't have to change
1334 anything, unless the reloc is against a section symbol,
1335 in which case we have to adjust according to where the
1336 section symbol winds up in the output section. */
1337 if (r_symndx
< symtab_hdr
->sh_info
)
1339 sym
= local_syms
+ r_symndx
;
1340 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1342 sec
= local_sections
[r_symndx
];
1343 rel
->r_addend
+= sec
->output_offset
+ sym
->st_value
;
1350 /* This is a final link. */
1354 if (r_symndx
< symtab_hdr
->sh_info
)
1356 sym
= local_syms
+ r_symndx
;
1357 sec
= local_sections
[r_symndx
];
1358 relocation
= (sec
->output_section
->vma
1359 + sec
->output_offset
1364 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1365 while (h
->root
.type
== bfd_link_hash_indirect
1366 || h
->root
.type
== bfd_link_hash_warning
)
1367 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1368 if (h
->root
.type
== bfd_link_hash_defined
1369 || h
->root
.type
== bfd_link_hash_defweak
)
1371 sec
= h
->root
.u
.def
.section
;
1372 if ((r_type
== R_390_GOTPC
1373 || r_type
== R_390_GOTPCDBL
)
1374 || ((r_type
== R_390_PLT16DBL
||
1375 r_type
== R_390_PLT32
||
1376 r_type
== R_390_PLT32DBL
||
1377 r_type
== R_390_PLT64
)
1379 && h
->plt
.offset
!= (bfd_vma
) -1)
1380 || ((r_type
== R_390_GOT12
||
1381 r_type
== R_390_GOT16
||
1382 r_type
== R_390_GOT32
||
1383 r_type
== R_390_GOT64
||
1384 r_type
== R_390_GOTENT
)
1385 && elf_hash_table (info
)->dynamic_sections_created
1387 || (! info
->symbolic
&& h
->dynindx
!= -1)
1388 || (h
->elf_link_hash_flags
1389 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1391 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1392 || (h
->elf_link_hash_flags
1393 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
1394 && ( r_type
== R_390_8
||
1395 r_type
== R_390_16
||
1396 r_type
== R_390_32
||
1397 r_type
== R_390_64
||
1398 r_type
== R_390_PC16
||
1399 r_type
== R_390_PC16DBL
||
1400 r_type
== R_390_PC32
||
1401 r_type
== R_390_PC32DBL
||
1402 r_type
== R_390_PC64
)
1403 && ((input_section
->flags
& SEC_ALLOC
) != 0
1404 /* DWARF will emit R_386_32 relocations in its
1405 sections against symbols defined externally
1406 in shared libraries. We can't do anything
1408 || ((input_section
->flags
& SEC_DEBUGGING
) != 0
1409 && (h
->elf_link_hash_flags
1410 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0))))
1412 /* In these cases, we don't need the relocation
1413 value. We check specially because in some
1414 obscure cases sec->output_section will be NULL. */
1417 else if (sec
->output_section
== NULL
)
1419 (*_bfd_error_handler
)
1420 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1421 bfd_get_filename (input_bfd
), h
->root
.root
.string
,
1422 bfd_get_section_name (input_bfd
, input_section
));
1426 relocation
= (h
->root
.u
.def
.value
1427 + sec
->output_section
->vma
1428 + sec
->output_offset
);
1430 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1432 else if (info
->shared
&& !info
->symbolic
1433 && !info
->no_undefined
1434 && ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
)
1438 if (! ((*info
->callbacks
->undefined_symbol
)
1439 (info
, h
->root
.root
.string
, input_bfd
,
1440 input_section
, rel
->r_offset
,
1441 (!info
->shared
|| info
->no_undefined
1442 || ELF_ST_VISIBILITY (h
->other
)))))
1455 /* Relocation is to the entry for this symbol in the global
1457 BFD_ASSERT (sgot
!= NULL
);
1463 off
= h
->got
.offset
;
1464 BFD_ASSERT (off
!= (bfd_vma
) -1);
1466 if (! elf_hash_table (info
)->dynamic_sections_created
1468 && (info
->symbolic
|| h
->dynindx
== -1)
1469 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1471 /* This is actually a static link, or it is a
1472 -Bsymbolic link and the symbol is defined
1473 locally, or the symbol was forced to be local
1474 because of a version file. We must initialize
1475 this entry in the global offset table. Since the
1476 offset must always be a multiple of 2, we use the
1477 least significant bit to record whether we have
1478 initialized it already.
1480 When doing a dynamic link, we create a .rel.got
1481 relocation entry to initialize the value. This
1482 is done in the finish_dynamic_symbol routine. */
1487 bfd_put_64 (output_bfd
, relocation
,
1488 sgot
->contents
+ off
);
1492 relocation
= sgot
->output_offset
+ off
;
1498 BFD_ASSERT (local_got_offsets
!= NULL
1499 && local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
1501 off
= local_got_offsets
[r_symndx
];
1503 /* The offset must always be a multiple of 8. We use
1504 the least significant bit to record whether we have
1505 already generated the necessary reloc. */
1510 bfd_put_64 (output_bfd
, relocation
, sgot
->contents
+ off
);
1515 Elf_Internal_Rela outrel
;
1517 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
1518 BFD_ASSERT (srelgot
!= NULL
);
1520 outrel
.r_offset
= (sgot
->output_section
->vma
1521 + sgot
->output_offset
1523 outrel
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
1524 outrel
.r_addend
= relocation
;
1525 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
,
1526 (((Elf64_External_Rela
*)
1528 + srelgot
->reloc_count
));
1529 ++srelgot
->reloc_count
;
1532 local_got_offsets
[r_symndx
] |= 1;
1535 relocation
= sgot
->output_offset
+ off
;
1539 * For @GOTENT the relocation is against the offset between
1540 * the instruction and the symbols entry in the GOT and not
1541 * between the start of the GOT and the symbols entry. We
1542 * add the vma of the GOT to get the correct value.
1544 if (r_type
== R_390_GOTENT
)
1545 relocation
+= sgot
->output_section
->vma
;
1550 /* Relocation is relative to the start of the global offset
1555 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1556 BFD_ASSERT (sgot
!= NULL
);
1559 /* Note that sgot->output_offset is not involved in this
1560 calculation. We always want the start of .got. If we
1561 defined _GLOBAL_OFFSET_TABLE in a different way, as is
1562 permitted by the ABI, we might have to change this
1564 relocation
-= sgot
->output_section
->vma
;
1569 case R_390_GOTPCDBL
:
1570 /* Use global offset table as symbol value. */
1574 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1575 BFD_ASSERT (sgot
!= NULL
);
1578 relocation
= sgot
->output_section
->vma
;
1582 case R_390_PLT16DBL
:
1584 case R_390_PLT32DBL
:
1586 /* Relocation is to the entry for this symbol in the
1587 procedure linkage table. */
1589 /* Resolve a PLT32 reloc against a local symbol directly,
1590 without using the procedure linkage table. */
1594 if (h
->plt
.offset
== (bfd_vma
) -1 || splt
== NULL
)
1596 /* We didn't make a PLT entry for this symbol. This
1597 happens when statically linking PIC code, or when
1598 using -Bsymbolic. */
1602 relocation
= (splt
->output_section
->vma
1603 + splt
->output_offset
1618 && (input_section
->flags
& SEC_ALLOC
) != 0
1619 && (r_type
== R_390_8
1620 || r_type
== R_390_16
1621 || r_type
== R_390_32
1622 || r_type
== R_390_64
1625 && (! info
->symbolic
1626 || (h
->elf_link_hash_flags
1627 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
1629 Elf_Internal_Rela outrel
;
1630 boolean skip
, relocate
;
1632 /* When generating a shared object, these relocations
1633 are copied into the output file to be resolved at run
1640 name
= (bfd_elf_string_from_elf_section
1642 elf_elfheader (input_bfd
)->e_shstrndx
,
1643 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1647 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1648 && strcmp (bfd_get_section_name (input_bfd
,
1652 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1653 BFD_ASSERT (sreloc
!= NULL
);
1658 if (elf_section_data (input_section
)->stab_info
== NULL
)
1659 outrel
.r_offset
= rel
->r_offset
;
1664 off
= (_bfd_stab_section_offset
1665 (output_bfd
, &elf_hash_table (info
)->stab_info
,
1667 &elf_section_data (input_section
)->stab_info
,
1669 if (off
== (bfd_vma
) -1)
1671 outrel
.r_offset
= off
;
1674 outrel
.r_offset
+= (input_section
->output_section
->vma
1675 + input_section
->output_offset
);
1679 memset (&outrel
, 0, sizeof outrel
);
1682 else if (r_type
== R_390_PC16
||
1683 r_type
== R_390_PC16DBL
||
1684 r_type
== R_390_PC32
||
1685 r_type
== R_390_PC32DBL
||
1686 r_type
== R_390_PC64
)
1688 BFD_ASSERT (h
!= NULL
&& h
->dynindx
!= -1);
1690 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, r_type
);
1691 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1695 /* h->dynindx may be -1 if this symbol was marked to
1698 || ((info
->symbolic
|| h
->dynindx
== -1)
1699 && (h
->elf_link_hash_flags
1700 & ELF_LINK_HASH_DEF_REGULAR
) != 0))
1703 outrel
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
1704 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1708 BFD_ASSERT (h
->dynindx
!= -1);
1710 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_64
);
1711 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1715 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
,
1716 (((Elf64_External_Rela
*)
1718 + sreloc
->reloc_count
));
1719 ++sreloc
->reloc_count
;
1721 /* If this reloc is against an external symbol, we do
1722 not want to fiddle with the addend. Otherwise, we
1723 need to include the symbol value so that it becomes
1724 an addend for the dynamic reloc. */
1735 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
1736 contents
, rel
->r_offset
,
1737 relocation
, rel
->r_addend
);
1739 if (r
!= bfd_reloc_ok
)
1744 case bfd_reloc_outofrange
:
1746 case bfd_reloc_overflow
:
1751 name
= h
->root
.root
.string
;
1754 name
= bfd_elf_string_from_elf_section (input_bfd
,
1755 symtab_hdr
->sh_link
,
1760 name
= bfd_section_name (input_bfd
, sec
);
1762 if (! ((*info
->callbacks
->reloc_overflow
)
1763 (info
, name
, howto
->name
, (bfd_vma
) 0,
1764 input_bfd
, input_section
, rel
->r_offset
)))
1775 /* Finish up dynamic symbol handling. We set the contents of various
1776 dynamic sections here. */
1779 elf_s390_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
1781 struct bfd_link_info
*info
;
1782 struct elf_link_hash_entry
*h
;
1783 Elf_Internal_Sym
*sym
;
1787 dynobj
= elf_hash_table (info
)->dynobj
;
1789 if (h
->plt
.offset
!= (bfd_vma
) -1)
1793 Elf_Internal_Rela rela
;
1798 /* This symbol has an entry in the procedure linkage table. Set
1801 BFD_ASSERT (h
->dynindx
!= -1);
1803 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1804 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
1805 srela
= bfd_get_section_by_name (dynobj
, ".rela.plt");
1806 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srela
!= NULL
);
1809 Current offset - size first entry / entry size. */
1810 plt_index
= (h
->plt
.offset
- PLT_FIRST_ENTRY_SIZE
) / PLT_ENTRY_SIZE
;
1812 /* Offset in GOT is PLT index plus GOT headers(3) times 8,
1814 got_offset
= (plt_index
+ 3) * GOT_ENTRY_SIZE
;
1816 /* Fill in the blueprint of a PLT. */
1817 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD0
,
1818 splt
->contents
+ h
->plt
.offset
);
1819 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD1
,
1820 splt
->contents
+ h
->plt
.offset
+ 4);
1821 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD2
,
1822 splt
->contents
+ h
->plt
.offset
+ 8);
1823 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD3
,
1824 splt
->contents
+ h
->plt
.offset
+ 12);
1825 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD4
,
1826 splt
->contents
+ h
->plt
.offset
+ 16);
1827 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD5
,
1828 splt
->contents
+ h
->plt
.offset
+ 20);
1829 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD6
,
1830 splt
->contents
+ h
->plt
.offset
+ 24);
1831 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD7
,
1832 splt
->contents
+ h
->plt
.offset
+ 28);
1833 /* Fixup the relative address to the GOT entry */
1834 bfd_put_32 (output_bfd
,
1835 (sgot
->output_section
->vma
+ sgot
->output_offset
+ got_offset
1836 - (splt
->output_section
->vma
+ h
->plt
.offset
))/2,
1837 splt
->contents
+ h
->plt
.offset
+ 2);
1838 /* Fixup the relative branch to PLT 0 */
1839 bfd_put_32 (output_bfd
, - (PLT_FIRST_ENTRY_SIZE
+
1840 (PLT_ENTRY_SIZE
* plt_index
) + 22)/2,
1841 splt
->contents
+ h
->plt
.offset
+ 24);
1842 /* Fixup offset into symbol table */
1843 bfd_put_32 (output_bfd
, plt_index
* sizeof (Elf64_External_Rela
),
1844 splt
->contents
+ h
->plt
.offset
+ 28);
1846 /* Fill in the entry in the .rela.plt section. */
1847 rela
.r_offset
= (sgot
->output_section
->vma
1848 + sgot
->output_offset
1850 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_JMP_SLOT
);
1852 bfd_elf64_swap_reloca_out (output_bfd
, &rela
,
1853 ((Elf64_External_Rela
*) srela
->contents
1856 /* Fill in the entry in the global offset table.
1857 Points to instruction after GOT offset. */
1858 bfd_put_64 (output_bfd
,
1859 (splt
->output_section
->vma
1860 + splt
->output_offset
1863 sgot
->contents
+ got_offset
);
1866 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
1868 /* Mark the symbol as undefined, rather than as defined in
1869 the .plt section. Leave the value alone. */
1870 sym
->st_shndx
= SHN_UNDEF
;
1874 if (h
->got
.offset
!= (bfd_vma
) -1)
1878 Elf_Internal_Rela rela
;
1880 /* This symbol has an entry in the global offset table. Set it
1883 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1884 srela
= bfd_get_section_by_name (dynobj
, ".rela.got");
1885 BFD_ASSERT (sgot
!= NULL
&& srela
!= NULL
);
1887 rela
.r_offset
= (sgot
->output_section
->vma
1888 + sgot
->output_offset
1889 + (h
->got
.offset
&~ 1));
1891 /* If this is a static link, or it is a -Bsymbolic link and the
1892 symbol is defined locally or was forced to be local because
1893 of a version file, we just want to emit a RELATIVE reloc.
1894 The entry in the global offset table will already have been
1895 initialized in the relocate_section function. */
1896 if (! elf_hash_table (info
)->dynamic_sections_created
1898 && (info
->symbolic
|| h
->dynindx
== -1)
1899 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1901 rela
.r_info
= ELF64_R_INFO (0, R_390_RELATIVE
);
1902 rela
.r_addend
= (h
->root
.u
.def
.value
1903 + h
->root
.u
.def
.section
->output_section
->vma
1904 + h
->root
.u
.def
.section
->output_offset
);
1908 BFD_ASSERT((h
->got
.offset
& 1) == 0);
1909 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ h
->got
.offset
);
1910 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_GLOB_DAT
);
1914 bfd_elf64_swap_reloca_out (output_bfd
, &rela
,
1915 ((Elf64_External_Rela
*) srela
->contents
1916 + srela
->reloc_count
));
1917 ++srela
->reloc_count
;
1920 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
1923 Elf_Internal_Rela rela
;
1925 /* This symbols needs a copy reloc. Set it up. */
1927 BFD_ASSERT (h
->dynindx
!= -1
1928 && (h
->root
.type
== bfd_link_hash_defined
1929 || h
->root
.type
== bfd_link_hash_defweak
));
1932 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
1934 BFD_ASSERT (s
!= NULL
);
1936 rela
.r_offset
= (h
->root
.u
.def
.value
1937 + h
->root
.u
.def
.section
->output_section
->vma
1938 + h
->root
.u
.def
.section
->output_offset
);
1939 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_390_COPY
);
1941 bfd_elf64_swap_reloca_out (output_bfd
, &rela
,
1942 ((Elf64_External_Rela
*) s
->contents
1947 /* Mark some specially defined symbols as absolute. */
1948 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
1949 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0
1950 || strcmp (h
->root
.root
.string
, "_PROCEDURE_LINKAGE_TABLE_") == 0)
1951 sym
->st_shndx
= SHN_ABS
;
1956 /* Finish up the dynamic sections. */
1959 elf_s390_finish_dynamic_sections (output_bfd
, info
)
1961 struct bfd_link_info
*info
;
1967 dynobj
= elf_hash_table (info
)->dynobj
;
1969 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
1970 BFD_ASSERT (sgot
!= NULL
);
1971 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
1973 if (elf_hash_table (info
)->dynamic_sections_created
)
1976 Elf64_External_Dyn
*dyncon
, *dynconend
;
1978 BFD_ASSERT (sdyn
!= NULL
);
1980 dyncon
= (Elf64_External_Dyn
*) sdyn
->contents
;
1981 dynconend
= (Elf64_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
1982 for (; dyncon
< dynconend
; dyncon
++)
1984 Elf_Internal_Dyn dyn
;
1988 bfd_elf64_swap_dyn_in (dynobj
, dyncon
, &dyn
);
2001 s
= bfd_get_section_by_name(output_bfd
, name
);
2002 BFD_ASSERT (s
!= NULL
);
2003 dyn
.d_un
.d_ptr
= s
->vma
;
2004 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2008 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
2009 BFD_ASSERT (s
!= NULL
);
2010 if (s
->_cooked_size
!= 0)
2011 dyn
.d_un
.d_val
= s
->_cooked_size
;
2013 dyn
.d_un
.d_val
= s
->_raw_size
;
2014 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2018 /* The procedure linkage table relocs (DT_JMPREL) should
2019 not be included in the overall relocs (DT_RELA).
2020 Therefore, we override the DT_RELASZ entry here to
2021 make it not include the JMPREL relocs. Since the
2022 linker script arranges for .rela.plt to follow all
2023 other relocation sections, we don't have to worry
2024 about changing the DT_RELA entry. */
2025 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
2028 if (s
->_cooked_size
!= 0)
2029 dyn
.d_un
.d_val
-= s
->_cooked_size
;
2031 dyn
.d_un
.d_val
-= s
->_raw_size
;
2033 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2038 /* Fill in the special first entry in the procedure linkage table. */
2039 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2040 if (splt
&& splt
->_raw_size
> 0)
2042 /* fill in blueprint for plt 0 entry */
2043 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD0
,
2045 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD1
,
2046 splt
->contents
+4 );
2047 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD3
,
2048 splt
->contents
+12 );
2049 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD4
,
2050 splt
->contents
+16 );
2051 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD5
,
2052 splt
->contents
+20 );
2053 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD6
,
2054 splt
->contents
+ 24);
2055 bfd_put_32 (output_bfd
, PLT_FIRST_ENTRY_WORD7
,
2056 splt
->contents
+ 28 );
2057 /* Fixup relative address to start of GOT */
2058 bfd_put_32 (output_bfd
,
2059 (sgot
->output_section
->vma
+ sgot
->output_offset
2060 - splt
->output_section
->vma
- 6)/2,
2061 splt
->contents
+ 8);
2064 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
=
2068 /* Set the first entry in the global offset table to the address of
2069 the dynamic section. */
2070 if (sgot
->_raw_size
> 0)
2073 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
2075 bfd_put_64 (output_bfd
,
2076 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
2079 /* One entry for shared object struct ptr. */
2080 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
2081 /* One entry for _dl_runtime_resolve. */
2082 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 12);
2085 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 8;
2091 elf_s390_object_p (abfd
)
2094 return bfd_default_set_arch_mach (abfd
, bfd_arch_s390
, bfd_mach_s390_esame
);
2098 static enum elf_reloc_type_class
2099 elf_s390_reloc_type_class (type
)
2104 case R_390_RELATIVE
:
2105 return reloc_class_relative
;
2106 case R_390_JMP_SLOT
:
2107 return reloc_class_plt
;
2109 return reloc_class_copy
;
2111 return reloc_class_normal
;
2116 * Why was the hash table entry size definition changed from
2117 * ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
2118 * this is the only reason for the s390_elf64_size_info structure.
2121 const struct elf_size_info s390_elf64_size_info
=
2123 sizeof (Elf64_External_Ehdr
),
2124 sizeof (Elf64_External_Phdr
),
2125 sizeof (Elf64_External_Shdr
),
2126 sizeof (Elf64_External_Rel
),
2127 sizeof (Elf64_External_Rela
),
2128 sizeof (Elf64_External_Sym
),
2129 sizeof (Elf64_External_Dyn
),
2130 sizeof (Elf_External_Note
),
2131 8, /* hash-table entry size */
2132 1, /* internal relocations per external relocations */
2135 ELFCLASS64
, EV_CURRENT
,
2136 bfd_elf64_write_out_phdrs
,
2137 bfd_elf64_write_shdrs_and_ehdr
,
2138 bfd_elf64_write_relocs
,
2139 bfd_elf64_swap_symbol_out
,
2140 bfd_elf64_slurp_reloc_table
,
2141 bfd_elf64_slurp_symbol_table
,
2142 bfd_elf64_swap_dyn_in
,
2143 bfd_elf64_swap_dyn_out
,
2150 #define TARGET_BIG_SYM bfd_elf64_s390_vec
2151 #define TARGET_BIG_NAME "elf64-s390"
2152 #define ELF_ARCH bfd_arch_s390
2153 #define ELF_MACHINE_CODE EM_S390
2154 #define ELF_MACHINE_ALT1 EM_S390_OLD
2155 #define ELF_MAXPAGESIZE 0x1000
2157 #define elf_backend_size_info s390_elf64_size_info
2159 #define elf_backend_can_gc_sections 1
2160 #define elf_backend_want_got_plt 1
2161 #define elf_backend_plt_readonly 1
2162 #define elf_backend_want_plt_sym 0
2163 #define elf_backend_got_header_size 24
2164 #define elf_backend_plt_header_size PLT_ENTRY_SIZE
2166 #define elf_info_to_howto elf_s390_info_to_howto
2168 #define bfd_elf64_bfd_final_link _bfd_elf64_gc_common_final_link
2169 #define bfd_elf64_bfd_is_local_label_name elf_s390_is_local_label_name
2170 #define bfd_elf64_bfd_link_hash_table_create elf_s390_link_hash_table_create
2171 #define bfd_elf64_bfd_reloc_type_lookup elf_s390_reloc_type_lookup
2173 #define elf_backend_adjust_dynamic_symbol elf_s390_adjust_dynamic_symbol
2174 #define elf_backend_check_relocs elf_s390_check_relocs
2175 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
2176 #define elf_backend_finish_dynamic_sections elf_s390_finish_dynamic_sections
2177 #define elf_backend_finish_dynamic_symbol elf_s390_finish_dynamic_symbol
2178 #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
2179 #define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
2180 #define elf_backend_relocate_section elf_s390_relocate_section
2181 #define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
2182 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
2184 #define elf_backend_object_p elf_s390_object_p
2186 #include "elf64-target.h"