1 /* i370-specific support for 32-bit ELF
2 Copyright 1994, 95, 96, 97, 98, 2000 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
4 Hacked by Linas Vepstas for i370 linas@linas.org
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 /* This file is based on a preliminary PowerPC ELF ABI.
23 But its been hacked on for the IBM 360/370 architectures.
24 Basically, the 31bit relocation works, and just about everything
25 else is a wild card. In particular, don't expect shared libs or
26 dynamic loading to work ... its never been tested ...
36 #define USE_RELA /* we want RELA relocations, not REL */
38 /* i370 relocations */
39 /* Note that there is really just one relocation that we currently
40 * support (and only one that we seem to need, at the moment), and
41 * that is the 31-bit address relocation. Note that the 370/390
42 * only supports a 31-bit (2GB) address space.
62 static reloc_howto_type
*i370_elf_howto_table
[ (int)R_I370_max
];
64 static reloc_howto_type i370_elf_howto_raw
[] =
66 /* This reloc does nothing. */
67 HOWTO (R_I370_NONE
, /* type */
69 2, /* size (0 = byte, 1 = short, 2 = long) */
71 false, /* pc_relative */
73 complain_overflow_bitfield
, /* complain_on_overflow */
74 bfd_elf_generic_reloc
, /* special_function */
75 "R_I370_NONE", /* name */
76 false, /* partial_inplace */
79 false), /* pcrel_offset */
81 /* A standard 31 bit relocation. */
82 HOWTO (R_I370_ADDR31
, /* type */
84 2, /* size (0 = byte, 1 = short, 2 = long) */
86 false, /* pc_relative */
88 complain_overflow_bitfield
, /* complain_on_overflow */
89 bfd_elf_generic_reloc
, /* special_function */
90 "R_I370_ADDR31", /* name */
91 false, /* partial_inplace */
93 0x7fffffff, /* dst_mask */
94 false), /* pcrel_offset */
96 /* A standard 32 bit relocation. */
97 HOWTO (R_I370_ADDR32
, /* type */
99 2, /* size (0 = byte, 1 = short, 2 = long) */
101 false, /* pc_relative */
103 complain_overflow_bitfield
, /* complain_on_overflow */
104 bfd_elf_generic_reloc
, /* special_function */
105 "R_I370_ADDR32", /* name */
106 false, /* partial_inplace */
108 0xffffffff, /* dst_mask */
109 false), /* pcrel_offset */
111 /* A standard 16 bit relocation. */
112 HOWTO (R_I370_ADDR16
, /* type */
114 1, /* size (0 = byte, 1 = short, 2 = long) */
116 false, /* pc_relative */
118 complain_overflow_bitfield
, /* complain_on_overflow */
119 bfd_elf_generic_reloc
, /* special_function */
120 "R_I370_ADDR16", /* name */
121 false, /* partial_inplace */
123 0xffff, /* dst_mask */
124 false), /* pcrel_offset */
126 /* 31-bit PC relative */
127 HOWTO (R_I370_REL31
, /* type */
129 2, /* size (0 = byte, 1 = short, 2 = long) */
131 true, /* pc_relative */
133 complain_overflow_bitfield
, /* complain_on_overflow */
134 bfd_elf_generic_reloc
, /* special_function */
135 "R_I370_REL31", /* name */
136 false, /* partial_inplace */
138 0x7fffffff, /* dst_mask */
139 true), /* pcrel_offset */
141 /* 32-bit PC relative */
142 HOWTO (R_I370_REL32
, /* type */
144 2, /* size (0 = byte, 1 = short, 2 = long) */
146 true, /* pc_relative */
148 complain_overflow_bitfield
, /* complain_on_overflow */
149 bfd_elf_generic_reloc
, /* special_function */
150 "R_I370_REL32", /* name */
151 false, /* partial_inplace */
153 0xffffffff, /* dst_mask */
154 true), /* pcrel_offset */
156 /* A standard 12 bit relocation. */
157 HOWTO (R_I370_ADDR12
, /* type */
159 1, /* size (0 = byte, 1 = short, 2 = long) */
161 false, /* pc_relative */
163 complain_overflow_bitfield
, /* complain_on_overflow */
164 bfd_elf_generic_reloc
, /* special_function */
165 "R_I370_ADDR12", /* name */
166 false, /* partial_inplace */
168 0xfff, /* dst_mask */
169 false), /* pcrel_offset */
171 /* 12-bit PC relative */
172 HOWTO (R_I370_REL12
, /* type */
174 1, /* size (0 = byte, 1 = short, 2 = long) */
176 true, /* pc_relative */
178 complain_overflow_bitfield
, /* complain_on_overflow */
179 bfd_elf_generic_reloc
, /* special_function */
180 "R_I370_REL12", /* name */
181 false, /* partial_inplace */
183 0xfff, /* dst_mask */
184 true), /* pcrel_offset */
186 /* A standard 8 bit relocation. */
187 HOWTO (R_I370_ADDR8
, /* type */
189 0, /* size (0 = byte, 1 = short, 2 = long) */
191 false, /* pc_relative */
193 complain_overflow_bitfield
, /* complain_on_overflow */
194 bfd_elf_generic_reloc
, /* special_function */
195 "R_I370_ADDR8", /* name */
196 false, /* partial_inplace */
199 false), /* pcrel_offset */
201 /* 8-bit PC relative */
202 HOWTO (R_I370_REL8
, /* type */
204 0, /* size (0 = byte, 1 = short, 2 = long) */
206 true, /* pc_relative */
208 complain_overflow_bitfield
, /* complain_on_overflow */
209 bfd_elf_generic_reloc
, /* special_function */
210 "R_I370_REL8", /* name */
211 false, /* partial_inplace */
214 true), /* pcrel_offset */
216 /* This is used only by the dynamic linker. The symbol should exist
217 both in the object being run and in some shared library. The
218 dynamic linker copies the data addressed by the symbol from the
219 shared library into the object, because the object being
220 run has to have the data at some particular address. */
221 HOWTO (R_I370_COPY
, /* type */
223 2, /* size (0 = byte, 1 = short, 2 = long) */
225 false, /* pc_relative */
227 complain_overflow_bitfield
, /* complain_on_overflow */
228 bfd_elf_generic_reloc
, /* special_function */
229 "R_I370_COPY", /* name */
230 false, /* partial_inplace */
233 false), /* pcrel_offset */
235 /* Used only by the dynamic linker. When the object is run, this
236 longword is set to the load address of the object, plus the
238 HOWTO (R_I370_RELATIVE
, /* type */
240 2, /* size (0 = byte, 1 = short, 2 = long) */
242 false, /* pc_relative */
244 complain_overflow_bitfield
, /* complain_on_overflow */
245 bfd_elf_generic_reloc
, /* special_function */
246 "R_I370_RELATIVE", /* name */
247 false, /* partial_inplace */
249 0xffffffff, /* dst_mask */
250 false), /* pcrel_offset */
254 static void i370_elf_howto_init
PARAMS ((void));
255 static void i370_elf_info_to_howto
PARAMS ((bfd
*abfd
, arelent
*cache_ptr
,
256 Elf32_Internal_Rela
*dst
));
257 static boolean i370_elf_set_private_flags
PARAMS ((bfd
*, flagword
));
259 /* Initialize the i370_elf_howto_table, so that linear accesses can be done. */
262 i370_elf_howto_init ()
264 unsigned int i
, type
;
266 for (i
= 0; i
< sizeof (i370_elf_howto_raw
) / sizeof (i370_elf_howto_raw
[0]); i
++)
268 type
= i370_elf_howto_raw
[i
].type
;
269 BFD_ASSERT (type
< sizeof (i370_elf_howto_table
) / sizeof (i370_elf_howto_table
[0]));
270 i370_elf_howto_table
[type
] = &i370_elf_howto_raw
[i
];
274 static reloc_howto_type
*
275 i370_elf_reloc_type_lookup (abfd
, code
)
276 bfd
*abfd ATTRIBUTE_UNUSED
;
277 bfd_reloc_code_real_type code
;
279 enum i370_reloc_type i370_reloc
= R_I370_NONE
;
281 if (!i370_elf_howto_table
[ R_I370_ADDR31
]) /* Initialize howto table if needed */
282 i370_elf_howto_init ();
287 return (reloc_howto_type
*)NULL
;
289 case BFD_RELOC_NONE
: i370_reloc
= R_I370_NONE
; break;
290 case BFD_RELOC_32
: i370_reloc
= R_I370_ADDR31
; break;
291 case BFD_RELOC_16
: i370_reloc
= R_I370_ADDR16
; break;
292 case BFD_RELOC_32_PCREL
: i370_reloc
= R_I370_REL31
; break;
293 case BFD_RELOC_CTOR
: i370_reloc
= R_I370_ADDR31
; break;
294 case BFD_RELOC_I370_D12
: i370_reloc
= R_I370_ADDR12
; break;
297 return i370_elf_howto_table
[ (int)i370_reloc
];
300 static boolean i370_elf_copy_private_bfd_data
PARAMS ((bfd
*, bfd
*));
301 static boolean i370_elf_merge_private_bfd_data
PARAMS ((bfd
*, bfd
*));
303 static boolean i370_elf_relocate_section
PARAMS ((bfd
*,
304 struct bfd_link_info
*info
,
308 Elf_Internal_Rela
*relocs
,
309 Elf_Internal_Sym
*local_syms
,
312 static boolean i370_elf_create_dynamic_sections
PARAMS ((bfd
*,
313 struct bfd_link_info
*));
315 static boolean i370_elf_section_from_shdr
PARAMS ((bfd
*,
316 Elf32_Internal_Shdr
*,
318 static boolean i370_elf_fake_sections
PARAMS ((bfd
*,
319 Elf32_Internal_Shdr
*,
322 static elf_linker_section_t
*i370_elf_create_linker_section
324 struct bfd_link_info
*info
,
325 enum elf_linker_section_enum
));
327 static boolean i370_elf_check_relocs
PARAMS ((bfd
*,
328 struct bfd_link_info
*,
330 const Elf_Internal_Rela
*));
332 static boolean i370_elf_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info
*,
333 struct elf_link_hash_entry
*));
335 static boolean i370_elf_adjust_dynindx
PARAMS ((struct elf_link_hash_entry
*, PTR
));
337 static boolean i370_elf_size_dynamic_sections
PARAMS ((bfd
*, struct bfd_link_info
*));
339 static boolean i370_elf_finish_dynamic_sections
PARAMS ((bfd
*, struct bfd_link_info
*));
341 /* The name of the dynamic interpreter. This is put in the .interp
344 #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so"
346 /* Set the howto pointer for an i370 ELF reloc. */
349 i370_elf_info_to_howto (abfd
, cache_ptr
, dst
)
350 bfd
*abfd ATTRIBUTE_UNUSED
;
352 Elf32_Internal_Rela
*dst
;
354 if (!i370_elf_howto_table
[ R_I370_ADDR31
]) /* Initialize howto table */
355 i370_elf_howto_init ();
357 BFD_ASSERT (ELF32_R_TYPE (dst
->r_info
) < (unsigned int) R_I370_max
);
358 cache_ptr
->howto
= i370_elf_howto_table
[ELF32_R_TYPE (dst
->r_info
)];
361 /* hack alert -- the following several routines look generic to me ...
362 * why are we bothering with them ???
364 /* Function to set whether a module needs the -mrelocatable bit set. */
366 i370_elf_set_private_flags (abfd
, flags
)
370 BFD_ASSERT (!elf_flags_init (abfd
)
371 || elf_elfheader (abfd
)->e_flags
== flags
);
373 elf_elfheader (abfd
)->e_flags
= flags
;
374 elf_flags_init (abfd
) = true;
378 /* Copy backend specific data from one object module to another */
380 i370_elf_copy_private_bfd_data (ibfd
, obfd
)
384 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
385 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
388 BFD_ASSERT (!elf_flags_init (obfd
)
389 || elf_elfheader (obfd
)->e_flags
== elf_elfheader (ibfd
)->e_flags
);
391 elf_elfheader (obfd
)->e_flags
= elf_elfheader (ibfd
)->e_flags
;
392 elf_flags_init (obfd
) = true;
396 /* Merge backend specific data from an object file to the output
397 object file when linking */
399 i370_elf_merge_private_bfd_data (ibfd
, obfd
)
406 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
407 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
410 new_flags
= elf_elfheader (ibfd
)->e_flags
;
411 old_flags
= elf_elfheader (obfd
)->e_flags
;
412 if (!elf_flags_init (obfd
)) /* First call, no flags set */
414 elf_flags_init (obfd
) = true;
415 elf_elfheader (obfd
)->e_flags
= new_flags
;
418 else if (new_flags
== old_flags
) /* Compatible flags are ok */
421 else /* Incompatible flags */
423 (*_bfd_error_handler
)
424 ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
425 bfd_get_filename (ibfd
), (long)new_flags
, (long)old_flags
);
427 bfd_set_error (bfd_error_bad_value
);
434 /* Handle an i370 specific section when reading an object file. This
435 is called when elfcode.h finds a section with an unknown type. */
436 /* XXX hack alert bogus This routine is mostly all junk and almost
437 * certainly does the wrong thing. Its here simply because it does
438 * just enough to allow glibc-2.1 ld.so to compile & link.
442 i370_elf_section_from_shdr (abfd
, hdr
, name
)
444 Elf32_Internal_Shdr
*hdr
;
450 if (! _bfd_elf_make_section_from_shdr (abfd
, hdr
, name
))
453 newsect
= hdr
->bfd_section
;
454 flags
= bfd_get_section_flags (abfd
, newsect
);
455 if (hdr
->sh_flags
& SHF_EXCLUDE
)
456 flags
|= SEC_EXCLUDE
;
458 if (hdr
->sh_type
== SHT_ORDERED
)
459 flags
|= SEC_SORT_ENTRIES
;
461 bfd_set_section_flags (abfd
, newsect
, flags
);
465 /* Set up any other section flags and such that may be necessary. */
466 /* XXX hack alert bogus This routine is mostly all junk and almost
467 * certainly does the wrong thing. Its here simply because it does
468 * just enough to allow glibc-2.1 ld.so to compile & link.
472 i370_elf_fake_sections (abfd
, shdr
, asect
)
473 bfd
*abfd ATTRIBUTE_UNUSED
;
474 Elf32_Internal_Shdr
*shdr
;
477 if ((asect
->flags
& SEC_EXCLUDE
) != 0)
478 shdr
->sh_flags
|= SHF_EXCLUDE
;
480 if ((asect
->flags
& SEC_SORT_ENTRIES
) != 0)
481 shdr
->sh_type
= SHT_ORDERED
;
487 /* Create a special linker section */
488 /* XXX hack alert bogus This routine is mostly all junk and almost
489 * certainly does the wrong thing. Its here simply because it does
490 * just enough to allow glibc-2.1 ld.so to compile & link.
493 static elf_linker_section_t
*
494 i370_elf_create_linker_section (abfd
, info
, which
)
496 struct bfd_link_info
*info
;
497 enum elf_linker_section_enum which
;
499 bfd
*dynobj
= elf_hash_table (info
)->dynobj
;
500 elf_linker_section_t
*lsect
;
502 /* Record the first bfd section that needs the special section */
504 dynobj
= elf_hash_table (info
)->dynobj
= abfd
;
506 /* If this is the first time, create the section */
507 lsect
= elf_linker_section (dynobj
, which
);
510 elf_linker_section_t defaults
;
511 static elf_linker_section_t zero_section
;
513 defaults
= zero_section
;
514 defaults
.which
= which
;
515 defaults
.hole_written_p
= false;
516 defaults
.alignment
= 2;
518 /* Both of these sections are (technically) created by the user
519 putting data in them, so they shouldn't be marked
522 The linker creates them so it has somewhere to attach their
523 respective symbols. In fact, if they were empty it would
524 be OK to leave the symbol set to 0 (or any random number), because
525 the appropriate register should never be used. */
526 defaults
.flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
532 (*_bfd_error_handler
) ("%s: Unknown special linker type %d",
533 bfd_get_filename (abfd
),
536 bfd_set_error (bfd_error_bad_value
);
537 return (elf_linker_section_t
*)0;
539 case LINKER_SECTION_SDATA
: /* .sdata/.sbss section */
540 defaults
.name
= ".sdata";
541 defaults
.rel_name
= ".rela.sdata";
542 defaults
.bss_name
= ".sbss";
543 defaults
.sym_name
= "_SDA_BASE_";
544 defaults
.sym_offset
= 32768;
547 case LINKER_SECTION_SDATA2
: /* .sdata2/.sbss2 section */
548 defaults
.name
= ".sdata2";
549 defaults
.rel_name
= ".rela.sdata2";
550 defaults
.bss_name
= ".sbss2";
551 defaults
.sym_name
= "_SDA2_BASE_";
552 defaults
.sym_offset
= 32768;
553 defaults
.flags
|= SEC_READONLY
;
557 lsect
= _bfd_elf_create_linker_section (abfd
, info
, which
, &defaults
);
564 /* We have to create .dynsbss and .rela.sbss here so that they get mapped
565 to output sections (just like _bfd_elf_create_dynamic_sections has
566 to create .dynbss and .rela.bss). */
567 /* XXX hack alert bogus This routine is mostly all junk and almost
568 * certainly does the wrong thing. Its here simply because it does
569 * just enough to allow glibc-2.1 ld.so to compile & link.
573 i370_elf_create_dynamic_sections (abfd
, info
)
575 struct bfd_link_info
*info
;
577 register asection
*s
;
580 if (!_bfd_elf_create_dynamic_sections(abfd
, info
))
583 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
584 | SEC_LINKER_CREATED
);
586 s
= bfd_make_section (abfd
, ".dynsbss");
588 || ! bfd_set_section_flags (abfd
, s
, SEC_ALLOC
))
593 s
= bfd_make_section (abfd
, ".rela.sbss");
595 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
596 || ! bfd_set_section_alignment (abfd
, s
, 2))
600 /* xxx beats me, seem to need a rela.text ... */
601 s
= bfd_make_section (abfd
, ".rela.text");
603 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
604 || ! bfd_set_section_alignment (abfd
, s
, 2))
609 /* Adjust a symbol defined by a dynamic object and referenced by a
610 regular object. The current definition is in some section of the
611 dynamic object, but we're not including those sections. We have to
612 change the definition to something the rest of the link can
614 /* XXX hack alert bogus This routine is mostly all junk and almost
615 * certainly does the wrong thing. Its here simply because it does
616 * just enough to allow glibc-2.1 ld.so to compile & link.
620 i370_elf_adjust_dynamic_symbol (info
, h
)
621 struct bfd_link_info
*info
;
622 struct elf_link_hash_entry
*h
;
624 bfd
*dynobj
= elf_hash_table (info
)->dynobj
;
626 unsigned int power_of_two
;
629 fprintf (stderr
, "i370_elf_adjust_dynamic_symbol called for %s\n",
630 h
->root
.root
.string
);
633 /* Make sure we know what is going on here. */
634 BFD_ASSERT (dynobj
!= NULL
635 && ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
)
636 || h
->weakdef
!= NULL
637 || ((h
->elf_link_hash_flags
638 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
639 && (h
->elf_link_hash_flags
640 & ELF_LINK_HASH_REF_REGULAR
) != 0
641 && (h
->elf_link_hash_flags
642 & ELF_LINK_HASH_DEF_REGULAR
) == 0)));
644 s
= bfd_get_section_by_name (dynobj
, ".rela.text");
645 BFD_ASSERT (s
!= NULL
);
646 s
->_raw_size
+= sizeof (Elf32_External_Rela
);
648 /* If this is a weak symbol, and there is a real definition, the
649 processor independent code will have arranged for us to see the
650 real definition first, and we can just use the same value. */
651 if (h
->weakdef
!= NULL
)
653 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
654 || h
->weakdef
->root
.type
== bfd_link_hash_defweak
);
655 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
656 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
660 /* This is a reference to a symbol defined by a dynamic object which
661 is not a function. */
663 /* If we are creating a shared library, we must presume that the
664 only references to the symbol are via the global offset table.
665 For such cases we need not do anything here; the relocations will
666 be handled correctly by relocate_section. */
670 /* We must allocate the symbol in our .dynbss section, which will
671 become part of the .bss section of the executable. There will be
672 an entry for this symbol in the .dynsym section. The dynamic
673 object will contain position independent code, so all references
674 from the dynamic object to this symbol will go through the global
675 offset table. The dynamic linker will use the .dynsym entry to
676 determine the address it must put in the global offset table, so
677 both the dynamic object and the regular object will refer to the
678 same memory location for the variable.
680 Of course, if the symbol is sufficiently small, we must instead
681 allocate it in .sbss. FIXME: It would be better to do this if and
682 only if there were actually SDAREL relocs for that symbol. */
684 if (h
->size
<= elf_gp_size (dynobj
))
685 s
= bfd_get_section_by_name (dynobj
, ".dynsbss");
687 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
688 BFD_ASSERT (s
!= NULL
);
690 /* We must generate a R_I370_COPY reloc to tell the dynamic linker to
691 copy the initial value out of the dynamic object and into the
692 runtime process image. We need to remember the offset into the
693 .rela.bss section we are going to use. */
694 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
698 if (h
->size
<= elf_gp_size (dynobj
))
699 srel
= bfd_get_section_by_name (dynobj
, ".rela.sbss");
701 srel
= bfd_get_section_by_name (dynobj
, ".rela.bss");
702 BFD_ASSERT (srel
!= NULL
);
703 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
704 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
707 /* We need to figure out the alignment required for this symbol. I
708 have no idea how ELF linkers handle this. */
709 power_of_two
= bfd_log2 (h
->size
);
710 if (power_of_two
> 4)
713 /* Apply the required alignment. */
714 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
715 (bfd_size_type
) (1 << power_of_two
));
716 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
718 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
722 /* Define the symbol as being at this point in the section. */
723 h
->root
.u
.def
.section
= s
;
724 h
->root
.u
.def
.value
= s
->_raw_size
;
726 /* Increment the section size to make room for the symbol. */
727 s
->_raw_size
+= h
->size
;
732 /* Increment the index of a dynamic symbol by a given amount. Called
733 via elf_link_hash_traverse. */
734 /* XXX hack alert bogus This routine is mostly all junk and almost
735 * certainly does the wrong thing. Its here simply because it does
736 * just enough to allow glibc-2.1 ld.so to compile & link.
740 i370_elf_adjust_dynindx (h
, cparg
)
741 struct elf_link_hash_entry
*h
;
744 int *cp
= (int *) cparg
;
748 "i370_elf_adjust_dynindx called, h->dynindx = %d, *cp = %d\n",
752 if (h
->dynindx
!= -1)
758 /* Set the sizes of the dynamic sections. */
759 /* XXX hack alert bogus This routine is mostly all junk and almost
760 * certainly does the wrong thing. Its here simply because it does
761 * just enough to allow glibc-2.1 ld.so to compile & link.
765 i370_elf_size_dynamic_sections (output_bfd
, info
)
767 struct bfd_link_info
*info
;
776 fprintf (stderr
, "i370_elf_size_dynamic_sections called\n");
779 dynobj
= elf_hash_table (info
)->dynobj
;
780 BFD_ASSERT (dynobj
!= NULL
);
782 if (elf_hash_table (info
)->dynamic_sections_created
)
784 /* Set the contents of the .interp section to the interpreter. */
787 s
= bfd_get_section_by_name (dynobj
, ".interp");
788 BFD_ASSERT (s
!= NULL
);
789 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
790 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
795 /* We may have created entries in the .rela.got, .rela.sdata, and
796 .rela.sdata2 sections. However, if we are not creating the
797 dynamic sections, we will not actually use these entries. Reset
798 the size of .rela.got, et al, which will cause it to get
799 stripped from the output file below. */
800 static char *rela_sections
[] = { ".rela.got", ".rela.sdata",
801 ".rela.sdata2", ".rela.sbss",
805 for (p
= rela_sections
; *p
!= (char *)0; p
++)
807 s
= bfd_get_section_by_name (dynobj
, *p
);
813 /* The check_relocs and adjust_dynamic_symbol entry points have
814 determined the sizes of the various dynamic sections. Allocate
819 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
824 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
827 /* It's OK to base decisions on the section name, because none
828 of the dynobj section names depend upon the input files. */
829 name
= bfd_get_section_name (dynobj
, s
);
832 if (strcmp (name
, ".plt") == 0)
834 if (s
->_raw_size
== 0)
836 /* Strip this section if we don't need it; see the
842 /* Remember whether there is a PLT. */
846 else if (strncmp (name
, ".rela", 5) == 0)
848 if (s
->_raw_size
== 0)
850 /* If we don't need this section, strip it from the
851 output file. This is mostly to handle .rela.bss and
852 .rela.plt. We must create both sections in
853 create_dynamic_sections, because they must be created
854 before the linker maps input sections to output
855 sections. The linker does that before
856 adjust_dynamic_symbol is called, and it is that
857 function which decides whether anything needs to go
858 into these sections. */
866 /* Remember whether there are any relocation sections. */
869 /* If this relocation section applies to a read only
870 section, then we probably need a DT_TEXTREL entry. */
871 outname
= bfd_get_section_name (output_bfd
,
873 target
= bfd_get_section_by_name (output_bfd
, outname
+ 5);
875 && (target
->flags
& SEC_READONLY
) != 0
876 && (target
->flags
& SEC_ALLOC
) != 0)
879 /* We use the reloc_count field as a counter if we need
880 to copy relocs into the output file. */
884 else if (strcmp (name
, ".got") != 0
885 && strcmp (name
, ".sdata") != 0
886 && strcmp (name
, ".sdata2") != 0)
888 /* It's not one of our sections, so don't allocate space. */
896 for (spp
= &s
->output_section
->owner
->sections
;
897 *spp
!= s
->output_section
;
900 *spp
= s
->output_section
->next
;
901 --s
->output_section
->owner
->section_count
;
905 /* Allocate memory for the section contents. */
906 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->_raw_size
);
907 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
911 if (elf_hash_table (info
)->dynamic_sections_created
)
913 /* Add some entries to the .dynamic section. We fill in the
914 values later, in i370_elf_finish_dynamic_sections, but we
915 must add the entries now so that we get the correct size for
916 the .dynamic section. The DT_DEBUG entry is filled in by the
917 dynamic linker and used by the debugger. */
920 if (! bfd_elf32_add_dynamic_entry (info
, DT_DEBUG
, 0))
926 if (! bfd_elf32_add_dynamic_entry (info
, DT_PLTGOT
, 0)
927 || ! bfd_elf32_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
928 || ! bfd_elf32_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
929 || ! bfd_elf32_add_dynamic_entry (info
, DT_JMPREL
, 0))
935 if (! bfd_elf32_add_dynamic_entry (info
, DT_RELA
, 0)
936 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELASZ
, 0)
937 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELAENT
,
938 sizeof (Elf32_External_Rela
)))
944 if (! bfd_elf32_add_dynamic_entry (info
, DT_TEXTREL
, 0))
946 info
->flags
|= DF_TEXTREL
;
950 /* If we are generating a shared library, we generate a section
951 symbol for each output section. These are local symbols, which
952 means that they must come first in the dynamic symbol table.
953 That means we must increment the dynamic symbol index of every
954 other dynamic symbol.
956 FIXME: We assume that there will never be relocations to
957 locations in linker-created sections that do not have
958 externally-visible names. Instead, we should work out precisely
959 which sections relocations are targetted at. */
964 for (c
= 0, s
= output_bfd
->sections
; s
!= NULL
; s
= s
->next
)
966 if ((s
->flags
& SEC_LINKER_CREATED
) != 0
967 || (s
->flags
& SEC_ALLOC
) == 0)
969 elf_section_data (s
)->dynindx
= -1;
973 /* These symbols will have no names, so we don't need to
974 fiddle with dynstr_index. */
976 elf_section_data (s
)->dynindx
= c
+ 1;
981 elf_link_hash_traverse (elf_hash_table (info
),
982 i370_elf_adjust_dynindx
,
984 elf_hash_table (info
)->dynsymcount
+= c
;
990 /* Look through the relocs for a section during the first phase, and
991 allocate space in the global offset table or procedure linkage
993 /* XXX hack alert bogus This routine is mostly all junk and almost
994 * certainly does the wrong thing. Its here simply because it does
995 * just enough to allow glibc-2.1 ld.so to compile & link.
999 i370_elf_check_relocs (abfd
, info
, sec
, relocs
)
1001 struct bfd_link_info
*info
;
1003 const Elf_Internal_Rela
*relocs
;
1006 Elf_Internal_Shdr
*symtab_hdr
;
1007 struct elf_link_hash_entry
**sym_hashes
;
1008 const Elf_Internal_Rela
*rel
;
1009 const Elf_Internal_Rela
*rel_end
;
1010 bfd_vma
*local_got_offsets
;
1013 if (info
->relocateable
)
1017 fprintf (stderr
, "i370_elf_check_relocs called for section %s in %s\n",
1018 bfd_get_section_name (abfd
, sec
),
1019 bfd_get_filename (abfd
));
1022 dynobj
= elf_hash_table (info
)->dynobj
;
1023 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1024 sym_hashes
= elf_sym_hashes (abfd
);
1025 local_got_offsets
= elf_local_got_offsets (abfd
);
1029 rel_end
= relocs
+ sec
->reloc_count
;
1030 for (rel
= relocs
; rel
< rel_end
; rel
++)
1032 unsigned long r_symndx
;
1033 struct elf_link_hash_entry
*h
;
1035 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1036 if (r_symndx
< symtab_hdr
->sh_info
)
1039 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1045 "i370_elf_check_relocs needs to create relocation for %s\n",
1046 (h
&& h
->root
.root
.string
)
1047 ? h
->root
.root
.string
: "<unknown>");
1053 name
= (bfd_elf_string_from_elf_section
1055 elf_elfheader (abfd
)->e_shstrndx
,
1056 elf_section_data (sec
)->rel_hdr
.sh_name
));
1060 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1061 && strcmp (bfd_get_section_name (abfd
, sec
), name
+ 5) == 0);
1063 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1068 sreloc
= bfd_make_section (dynobj
, name
);
1069 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
1070 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
1071 if ((sec
->flags
& SEC_ALLOC
) != 0)
1072 flags
|= SEC_ALLOC
| SEC_LOAD
;
1074 || ! bfd_set_section_flags (dynobj
, sreloc
, flags
)
1075 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
1080 sreloc
->_raw_size
+= sizeof (Elf32_External_Rela
);
1082 /* FIXME: We should here do what the m68k and i386
1083 backends do: if the reloc is pc-relative, record it
1084 in case it turns out that the reloc is unnecessary
1085 because the symbol is forced local by versioning or
1086 we are linking with -Bdynamic. Fortunately this
1087 case is not frequent. */
1094 /* Finish up the dynamic sections. */
1095 /* XXX hack alert bogus This routine is mostly all junk and almost
1096 * certainly does the wrong thing. Its here simply because it does
1097 * just enough to allow glibc-2.1 ld.so to compile & link.
1101 i370_elf_finish_dynamic_sections (output_bfd
, info
)
1103 struct bfd_link_info
*info
;
1106 bfd
*dynobj
= elf_hash_table (info
)->dynobj
;
1107 asection
*sgot
= bfd_get_section_by_name (dynobj
, ".got");
1110 fprintf (stderr
, "i370_elf_finish_dynamic_sections called\n");
1113 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
1115 if (elf_hash_table (info
)->dynamic_sections_created
)
1118 Elf32_External_Dyn
*dyncon
, *dynconend
;
1120 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1121 BFD_ASSERT (splt
!= NULL
&& sdyn
!= NULL
);
1123 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
1124 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
1125 for (; dyncon
< dynconend
; dyncon
++)
1127 Elf_Internal_Dyn dyn
;
1131 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
1135 case DT_PLTGOT
: name
= ".plt"; size
= false; break;
1136 case DT_PLTRELSZ
: name
= ".rela.plt"; size
= true; break;
1137 case DT_JMPREL
: name
= ".rela.plt"; size
= false; break;
1138 default: name
= NULL
; size
= false; break;
1145 s
= bfd_get_section_by_name (output_bfd
, name
);
1151 dyn
.d_un
.d_ptr
= s
->vma
;
1154 if (s
->_cooked_size
!= 0)
1155 dyn
.d_un
.d_val
= s
->_cooked_size
;
1157 dyn
.d_un
.d_val
= s
->_raw_size
;
1160 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
1165 /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can
1166 easily find the address of the _GLOBAL_OFFSET_TABLE_. */
1167 /* XXX this is clearly very wrong for the 370 arch */
1170 unsigned char *contents
= sgot
->contents
;
1171 bfd_put_32 (output_bfd
, 0x4e800021 /* blrl */, contents
);
1174 bfd_put_32 (output_bfd
, (bfd_vma
) 0, contents
+4);
1176 bfd_put_32 (output_bfd
,
1177 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
1180 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 4;
1187 Elf_Internal_Sym sym
;
1190 /* Set up the section symbols for the output sections. */
1192 sdynsym
= bfd_get_section_by_name (dynobj
, ".dynsym");
1193 BFD_ASSERT (sdynsym
!= NULL
);
1197 sym
.st_info
= ELF_ST_INFO (STB_LOCAL
, STT_SECTION
);
1200 for (s
= output_bfd
->sections
; s
!= NULL
; s
= s
->next
)
1204 sym
.st_value
= s
->vma
;
1206 indx
= elf_section_data (s
)->this_idx
;
1207 dindx
= elf_section_data (s
)->dynindx
;
1210 BFD_ASSERT(indx
> 0);
1211 BFD_ASSERT(dindx
> 0);
1213 if (dindx
> maxdindx
)
1216 sym
.st_shndx
= indx
;
1218 bfd_elf32_swap_symbol_out (output_bfd
, &sym
,
1219 (PTR
) (((Elf32_External_Sym
*)
1225 /* Set the sh_info field of the output .dynsym section to the
1226 index of the first global symbol. */
1227 elf_section_data (sdynsym
->output_section
)->this_hdr
.sh_info
=
1234 /* The RELOCATE_SECTION function is called by the ELF backend linker
1235 to handle the relocations for a section.
1237 The relocs are always passed as Rela structures; if the section
1238 actually uses Rel structures, the r_addend field will always be
1241 This function is responsible for adjust the section contents as
1242 necessary, and (if using Rela relocs and generating a
1243 relocateable output file) adjusting the reloc addend as
1246 This function does not have to worry about setting the reloc
1247 address or the reloc symbol index.
1249 LOCAL_SYMS is a pointer to the swapped in local symbols.
1251 LOCAL_SECTIONS is an array giving the section in the input file
1252 corresponding to the st_shndx field of each local symbol.
1254 The global hash table entry for the global symbols can be found
1255 via elf_sym_hashes (input_bfd).
1257 When generating relocateable output, this function must handle
1258 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
1259 going to be the section symbol corresponding to the output
1260 section, which means that the addend must be adjusted
1264 i370_elf_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1265 contents
, relocs
, local_syms
, local_sections
)
1267 struct bfd_link_info
*info
;
1269 asection
*input_section
;
1271 Elf_Internal_Rela
*relocs
;
1272 Elf_Internal_Sym
*local_syms
;
1273 asection
**local_sections
;
1275 Elf_Internal_Shdr
*symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1276 struct elf_link_hash_entry
**sym_hashes
= elf_sym_hashes (input_bfd
);
1277 bfd
*dynobj
= elf_hash_table (info
)->dynobj
;
1278 Elf_Internal_Rela
*rel
= relocs
;
1279 Elf_Internal_Rela
*relend
= relocs
+ input_section
->reloc_count
;
1280 asection
*sreloc
= NULL
;
1281 bfd_vma
*local_got_offsets
;
1285 fprintf (stderr
, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n",
1286 bfd_get_filename (input_bfd
),
1287 bfd_section_name(input_bfd
, input_section
),
1288 (long)input_section
->reloc_count
,
1289 (info
->relocateable
) ? " (relocatable)" : "");
1292 if (!i370_elf_howto_table
[ R_I370_ADDR31
]) /* Initialize howto table if needed */
1293 i370_elf_howto_init ();
1295 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1297 for (; rel
< relend
; rel
++)
1299 enum i370_reloc_type r_type
= (enum i370_reloc_type
)ELF32_R_TYPE (rel
->r_info
);
1300 bfd_vma offset
= rel
->r_offset
;
1301 bfd_vma addend
= rel
->r_addend
;
1302 bfd_reloc_status_type r
= bfd_reloc_other
;
1303 Elf_Internal_Sym
*sym
= (Elf_Internal_Sym
*)0;
1304 asection
*sec
= (asection
*)0;
1305 struct elf_link_hash_entry
*h
= (struct elf_link_hash_entry
*)0;
1306 const char *sym_name
= (const char *)0;
1307 reloc_howto_type
*howto
;
1308 unsigned long r_symndx
;
1311 /* Unknown relocation handling */
1312 if ((unsigned)r_type
>= (unsigned)R_I370_max
1313 || !i370_elf_howto_table
[(int)r_type
])
1315 (*_bfd_error_handler
) ("%s: unknown relocation type %d",
1316 bfd_get_filename (input_bfd
),
1319 bfd_set_error (bfd_error_bad_value
);
1324 howto
= i370_elf_howto_table
[(int)r_type
];
1325 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1327 if (info
->relocateable
)
1329 /* This is a relocateable link. We don't have to change
1330 anything, unless the reloc is against a section symbol,
1331 in which case we have to adjust according to where the
1332 section symbol winds up in the output section. */
1333 if (r_symndx
< symtab_hdr
->sh_info
)
1335 sym
= local_syms
+ r_symndx
;
1336 if ((unsigned)ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1338 sec
= local_sections
[r_symndx
];
1339 addend
= rel
->r_addend
+= sec
->output_offset
+ sym
->st_value
;
1344 fprintf (stderr
, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
1354 /* This is a final link. */
1355 if (r_symndx
< symtab_hdr
->sh_info
)
1357 sym
= local_syms
+ r_symndx
;
1358 sec
= local_sections
[r_symndx
];
1359 sym_name
= "<local symbol>";
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 sym_name
= h
->root
.root
.string
;
1372 if (h
->root
.type
== bfd_link_hash_defined
1373 || h
->root
.type
== bfd_link_hash_defweak
)
1375 sec
= h
->root
.u
.def
.section
;
1377 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1378 || (h
->elf_link_hash_flags
1379 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
1380 && (input_section
->flags
& SEC_ALLOC
) != 0
1381 && (r_type
== R_I370_ADDR31
1382 || r_type
== R_I370_COPY
1383 || r_type
== R_I370_ADDR16
1384 || r_type
== R_I370_RELATIVE
))
1386 /* In these cases, we don't need the relocation
1387 value. We check specially because in some
1388 obscure cases sec->output_section will be NULL. */
1392 relocation
= (h
->root
.u
.def
.value
1393 + sec
->output_section
->vma
1394 + sec
->output_offset
);
1396 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1398 else if (info
->shared
1399 && ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
)
1403 (*info
->callbacks
->undefined_symbol
) (info
,
1404 h
->root
.root
.string
,
1414 switch ((int)r_type
)
1417 (*_bfd_error_handler
) ("%s: unknown relocation type %d for symbol %s",
1418 bfd_get_filename (input_bfd
),
1419 (int)r_type
, sym_name
);
1421 bfd_set_error (bfd_error_bad_value
);
1425 /* Relocations that may need to be propagated if this is a shared
1427 case (int)R_I370_REL31
:
1428 /* If these relocations are not to a named symbol, they can be
1429 handled right here, no need to bother the dynamic linker. */
1431 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
1435 /* Relocations that always need to be propagated if this is a shared
1437 case (int)R_I370_NONE
:
1438 case (int)R_I370_ADDR31
:
1439 case (int)R_I370_ADDR16
:
1442 Elf_Internal_Rela outrel
;
1447 "i370_elf_relocate_section needs to create relocation for %s\n",
1448 (h
&& h
->root
.root
.string
) ? h
->root
.root
.string
: "<unknown>");
1451 /* When generating a shared object, these relocations
1452 are copied into the output file to be resolved at run
1459 name
= (bfd_elf_string_from_elf_section
1461 elf_elfheader (input_bfd
)->e_shstrndx
,
1462 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1466 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1467 && strcmp (bfd_get_section_name (input_bfd
,
1471 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1472 BFD_ASSERT (sreloc
!= NULL
);
1477 if (elf_section_data (input_section
)->stab_info
== NULL
)
1478 outrel
.r_offset
= rel
->r_offset
;
1483 off
= (_bfd_stab_section_offset
1484 (output_bfd
, &elf_hash_table (info
)->stab_info
,
1486 &elf_section_data (input_section
)->stab_info
,
1488 if (off
== (bfd_vma
) -1)
1490 outrel
.r_offset
= off
;
1493 outrel
.r_offset
+= (input_section
->output_section
->vma
1494 + input_section
->output_offset
);
1497 memset (&outrel
, 0, sizeof outrel
);
1498 /* h->dynindx may be -1 if this symbol was marked to
1501 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1502 || (h
->elf_link_hash_flags
1503 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1505 BFD_ASSERT (h
->dynindx
!= -1);
1506 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, r_type
);
1507 outrel
.r_addend
= rel
->r_addend
;
1511 if (r_type
== R_I370_ADDR31
)
1513 outrel
.r_info
= ELF32_R_INFO (0, R_I370_RELATIVE
);
1514 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1521 sec
= local_sections
[r_symndx
];
1524 BFD_ASSERT (h
->root
.type
== bfd_link_hash_defined
1526 == bfd_link_hash_defweak
));
1527 sec
= h
->root
.u
.def
.section
;
1529 if (sec
!= NULL
&& bfd_is_abs_section (sec
))
1531 else if (sec
== NULL
|| sec
->owner
== NULL
)
1533 bfd_set_error (bfd_error_bad_value
);
1540 osec
= sec
->output_section
;
1541 indx
= elf_section_data (osec
)->dynindx
;
1542 BFD_ASSERT(indx
> 0);
1546 printf ("indx=%d section=%s flags=%08x name=%s\n",
1547 indx
, osec
->name
, osec
->flags
,
1548 h
->root
.root
.string
);
1553 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
1554 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1558 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
1559 (((Elf32_External_Rela
*)
1561 + sreloc
->reloc_count
));
1562 ++sreloc
->reloc_count
;
1564 /* This reloc will be computed at runtime, so there's no
1565 need to do anything now, unless this is a RELATIVE
1566 reloc in an unallocated section. */
1568 || (input_section
->flags
& SEC_ALLOC
) != 0
1569 || ELF32_R_TYPE (outrel
.r_info
) != R_I370_RELATIVE
)
1574 case (int)R_I370_COPY
:
1575 case (int)R_I370_RELATIVE
:
1576 (*_bfd_error_handler
) ("%s: Relocation %s is not yet supported for symbol %s.",
1577 bfd_get_filename (input_bfd
),
1578 i370_elf_howto_table
[ (int)r_type
]->name
,
1581 bfd_set_error (bfd_error_invalid_operation
);
1587 fprintf (stderr
, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n",
1596 r
= _bfd_final_link_relocate (howto
,
1604 if (r
!= bfd_reloc_ok
)
1612 case bfd_reloc_overflow
:
1617 name
= h
->root
.root
.string
;
1620 name
= bfd_elf_string_from_elf_section (input_bfd
,
1621 symtab_hdr
->sh_link
,
1627 name
= bfd_section_name (input_bfd
, sec
);
1630 (*info
->callbacks
->reloc_overflow
) (info
,
1645 fprintf (stderr
, "\n");
1652 i370_elf_post_process_headers (abfd
, link_info
)
1654 struct bfd_link_info
* link_info ATTRIBUTE_UNUSED
;
1656 Elf_Internal_Ehdr
* i_ehdrp
; /* Elf file header, internal form */
1658 i_ehdrp
= elf_elfheader (abfd
);
1659 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_LINUX
;
1662 #define TARGET_BIG_SYM bfd_elf32_i370_vec
1663 #define TARGET_BIG_NAME "elf32-i370"
1664 #define ELF_ARCH bfd_arch_i370
1665 #define ELF_MACHINE_CODE EM_S370
1667 #define ELF_MACHINE_ALT1 EM_I370_OLD
1669 #define ELF_MAXPAGESIZE 0x1000
1670 #define elf_info_to_howto i370_elf_info_to_howto
1672 #define elf_backend_plt_not_loaded 1
1673 #define elf_backend_got_symbol_offset 4
1675 #define bfd_elf32_bfd_reloc_type_lookup i370_elf_reloc_type_lookup
1676 #define bfd_elf32_bfd_set_private_flags i370_elf_set_private_flags
1677 #define bfd_elf32_bfd_copy_private_bfd_data i370_elf_copy_private_bfd_data
1678 #define bfd_elf32_bfd_merge_private_bfd_data i370_elf_merge_private_bfd_data
1679 #define elf_backend_relocate_section i370_elf_relocate_section
1681 /* dynamic loader support is mostly broken; just enough here to be able to
1682 * link glibc's ld.so without errors.
1684 #define elf_backend_create_dynamic_sections i370_elf_create_dynamic_sections
1685 #define elf_backend_size_dynamic_sections i370_elf_size_dynamic_sections
1686 #define elf_backend_finish_dynamic_sections i370_elf_finish_dynamic_sections
1687 #define elf_backend_fake_sections i370_elf_fake_sections
1688 #define elf_backend_section_from_shdr i370_elf_section_from_shdr
1689 #define elf_backend_adjust_dynamic_symbol i370_elf_adjust_dynamic_symbol
1690 #define elf_backend_check_relocs i370_elf_check_relocs
1693 #define elf_backend_add_symbol_hook i370_elf_add_symbol_hook
1694 #define elf_backend_finish_dynamic_symbol i370_elf_finish_dynamic_symbol
1695 #define elf_backend_additional_program_headers i370_elf_additional_program_headers
1696 #define elf_backend_modify_segment_map i370_elf_modify_segment_map
1699 #define elf_backend_post_process_headers i370_elf_post_process_headers
1706 /* we need to define these at least as no-ops to link glibc ld.so */
1708 #define elf_backend_add_symbol_hook \
1709 (boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \
1710 const Elf_Internal_Sym *, const char **, flagword *, \
1711 asection **, bfd_vma *))) i370_noop
1712 #define elf_backend_finish_dynamic_symbol \
1713 (boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \
1714 struct elf_link_hash_entry *, \
1715 Elf_Internal_Sym *))) i370_noop
1716 #define elf_backend_additional_program_headers \
1717 (int (*) PARAMS ((bfd *))) i370_noop
1718 #define elf_backend_modify_segment_map \
1719 (boolean (*) PARAMS ((bfd *))) i370_noop
1721 #include "elf32-target.h"