1 /* Intel 80386/80486-specific support for 32-bit ELF
2 Copyright 1993 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 static CONST
struct reloc_howto_struct
*elf_i386_reloc_type_lookup
27 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
28 static void elf_i386_info_to_howto
29 PARAMS ((bfd
*, arelent
*, Elf32_Internal_Rela
*));
30 static void elf_i386_info_to_howto_rel
31 PARAMS ((bfd
*, arelent
*, Elf32_Internal_Rel
*));
32 static boolean elf_i386_create_dynamic_sections
33 PARAMS ((bfd
*, struct bfd_link_info
*));
34 static boolean elf_i386_create_got_section
35 PARAMS ((bfd
*, struct bfd_link_info
*));
36 static boolean elf_i386_check_relocs
37 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
38 const Elf_Internal_Rela
*));
39 static boolean elf_i386_adjust_dynamic_symbol
40 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
41 static boolean elf_i386_size_dynamic_sections
42 PARAMS ((bfd
*, struct bfd_link_info
*));
43 static boolean elf_i386_relocate_section
44 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
45 Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
46 static boolean elf_i386_finish_dynamic_symbol
47 PARAMS ((bfd
*, struct bfd_link_info
*, struct elf_link_hash_entry
*,
49 static boolean elf_i386_finish_dynamic_sections
50 PARAMS ((bfd
*, struct bfd_link_info
*));
52 #define USE_REL 1 /* 386 uses REL relocations instead of RELA */
71 static CONST
char *CONST reloc_type_names
[] =
87 static reloc_howto_type elf_howto_table
[]=
89 HOWTO(R_386_NONE
, 0,0, 0,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_NONE", true,0x00000000,0x00000000,false),
90 HOWTO(R_386_32
, 0,2,32,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_32", true,0xffffffff,0xffffffff,false),
91 HOWTO(R_386_PC32
, 0,2,32,true, 0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_PC32", true,0xffffffff,0xffffffff,true),
92 HOWTO(R_386_GOT32
, 0,2,32,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_GOT32", true,0xffffffff,0xffffffff,false),
93 HOWTO(R_386_PLT32
, 0,2,32,true,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_PLT32", true,0xffffffff,0xffffffff,true),
94 HOWTO(R_386_COPY
, 0,2,32,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_COPY", true,0xffffffff,0xffffffff,false),
95 HOWTO(R_386_GLOB_DAT
, 0,2,32,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_GLOB_DAT", true,0xffffffff,0xffffffff,false),
96 HOWTO(R_386_JUMP_SLOT
, 0,2,32,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_JUMP_SLOT",true,0xffffffff,0xffffffff,false),
97 HOWTO(R_386_RELATIVE
, 0,2,32,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_RELATIVE", true,0xffffffff,0xffffffff,false),
98 HOWTO(R_386_GOTOFF
, 0,2,32,false,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_GOTOFF", true,0xffffffff,0xffffffff,false),
99 HOWTO(R_386_GOTPC
, 0,2,32,true,0,complain_overflow_bitfield
, bfd_elf_generic_reloc
,"R_386_GOTPC", true,0xffffffff,0xffffffff,true),
102 #ifdef DEBUG_GEN_RELOC
103 #define TRACE(str) fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
108 static CONST
struct reloc_howto_struct
*
109 elf_i386_reloc_type_lookup (abfd
, code
)
111 bfd_reloc_code_real_type code
;
116 TRACE ("BFD_RELOC_NONE");
117 return &elf_howto_table
[ (int)R_386_NONE
];
120 TRACE ("BFD_RELOC_32");
121 return &elf_howto_table
[ (int)R_386_32
];
123 case BFD_RELOC_32_PCREL
:
124 TRACE ("BFD_RELOC_PC32");
125 return &elf_howto_table
[ (int)R_386_PC32
];
127 case BFD_RELOC_386_GOT32
:
128 TRACE ("BFD_RELOC_386_GOT32");
129 return &elf_howto_table
[ (int)R_386_GOT32
];
131 case BFD_RELOC_386_PLT32
:
132 TRACE ("BFD_RELOC_386_PLT32");
133 return &elf_howto_table
[ (int)R_386_PLT32
];
135 case BFD_RELOC_386_COPY
:
136 TRACE ("BFD_RELOC_386_COPY");
137 return &elf_howto_table
[ (int)R_386_COPY
];
139 case BFD_RELOC_386_GLOB_DAT
:
140 TRACE ("BFD_RELOC_386_GLOB_DAT");
141 return &elf_howto_table
[ (int)R_386_GLOB_DAT
];
143 case BFD_RELOC_386_JUMP_SLOT
:
144 TRACE ("BFD_RELOC_386_JUMP_SLOT");
145 return &elf_howto_table
[ (int)R_386_JUMP_SLOT
];
147 case BFD_RELOC_386_RELATIVE
:
148 TRACE ("BFD_RELOC_386_RELATIVE");
149 return &elf_howto_table
[ (int)R_386_RELATIVE
];
151 case BFD_RELOC_386_GOTOFF
:
152 TRACE ("BFD_RELOC_386_GOTOFF");
153 return &elf_howto_table
[ (int)R_386_GOTOFF
];
155 case BFD_RELOC_386_GOTPC
:
156 TRACE ("BFD_RELOC_386_GOTPC");
157 return &elf_howto_table
[ (int)R_386_GOTPC
];
168 elf_i386_info_to_howto (abfd
, cache_ptr
, dst
)
171 Elf32_Internal_Rela
*dst
;
173 BFD_ASSERT (ELF32_R_TYPE(dst
->r_info
) < (unsigned int) R_386_max
);
175 cache_ptr
->howto
= &elf_howto_table
[ELF32_R_TYPE(dst
->r_info
)];
179 elf_i386_info_to_howto_rel (abfd
, cache_ptr
, dst
)
182 Elf32_Internal_Rel
*dst
;
184 BFD_ASSERT (ELF32_R_TYPE(dst
->r_info
) < (unsigned int) R_386_max
);
186 cache_ptr
->howto
= &elf_howto_table
[ELF32_R_TYPE(dst
->r_info
)];
189 /* Functions for the i386 ELF linker. */
191 /* The name of the dynamic interpreter. This is put in the .interp
194 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
196 /* The size in bytes of an entry in the procedure linkage table. */
198 #define PLT_ENTRY_SIZE 16
200 /* The first entry in an absolute procedure linkage table looks like
201 this. See the SVR4 ABI i386 supplement to see how this works. */
203 static const bfd_byte elf_i386_plt0_entry
[PLT_ENTRY_SIZE
] =
205 0xff, 0x35, /* pushl contents of address */
206 0, 0, 0, 0, /* replaced with address of .got + 4. */
207 0xff, 0x25, /* jmp indirect */
208 0, 0, 0, 0, /* replaced with address of .got + 8. */
209 0, 0, 0, 0 /* pad out to 16 bytes. */
212 /* Subsequent entries in an absolute procedure linkage table look like
215 static const bfd_byte elf_i386_plt_entry
[PLT_ENTRY_SIZE
] =
217 0xff, 0x25, /* jmp indirect */
218 0, 0, 0, 0, /* replaced with address of this symbol in .got. */
219 0x68, /* pushl immediate */
220 0, 0, 0, 0, /* replaced with offset into relocation table. */
221 0xe9, /* jmp relative */
222 0, 0, 0, 0 /* replaced with offset to start of .plt. */
225 /* The first entry in a PIC procedure linkage table look like this. */
227 static const bfd_byte elf_i386_pic_plt0_entry
[PLT_ENTRY_SIZE
] =
229 0xff, 0xb3, 4, 0, 0, 0, /* pushl 4(%ebx) */
230 0xff, 0xa3, 8, 0, 0, 0, /* jmp *8(%ebx) */
231 0, 0, 0, 0 /* pad out to 16 bytes. */
234 /* Subsequent entries in a PIC procedure linkage table look like this. */
236 static const bfd_byte elf_i386_pic_plt_entry
[PLT_ENTRY_SIZE
] =
238 0xff, 0xa3, /* jmp *offset(%ebx) */
239 0, 0, 0, 0, /* replaced with offset of this symbol in .got. */
240 0x68, /* pushl immediate */
241 0, 0, 0, 0, /* replaced with offset into relocation table. */
242 0xe9, /* jmp relative */
243 0, 0, 0, 0 /* replaced with offset to start of .plt. */
246 /* Create dynamic sections when linking against a dynamic object. */
249 elf_i386_create_dynamic_sections (abfd
, info
)
251 struct bfd_link_info
*info
;
254 register asection
*s
;
256 /* We need to create .plt, .rel.plt, .got, .got.plt, .dynbss, and
257 .rel.bss sections. */
259 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
;
261 s
= bfd_make_section (abfd
, ".plt");
263 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
| SEC_CODE
)
264 || ! bfd_set_section_alignment (abfd
, s
, 2))
267 s
= bfd_make_section (abfd
, ".rel.plt");
269 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
270 || ! bfd_set_section_alignment (abfd
, s
, 2))
273 if (! elf_i386_create_got_section (abfd
, info
))
276 /* The .dynbss section is a place to put symbols which are defined
277 by dynamic objects, are referenced by regular objects, and are
278 not functions. We must allocate space for them in the process
279 image and use a R_386_COPY reloc to tell the dynamic linker to
280 initialize them at run time. The linker script puts the .dynbss
281 section into the .bss section of the final image. */
282 s
= bfd_make_section (abfd
, ".dynbss");
284 || ! bfd_set_section_flags (abfd
, s
, SEC_ALLOC
))
287 /* The .rel.bss section holds copy relocs. This section is not
288 normally needed. We need to create it here, though, so that the
289 linker will map it to an output section. We can't just create it
290 only if we need it, because we will not know whether we need it
291 until we have seen all the input files, and the first time the
292 main linker code calls BFD after examining all the input files
293 (size_dynamic_sections) the input sections have already been
294 mapped to the output sections. If the section turns out not to
295 be needed, we can discard it later. We will never need this
296 section when generating a shared object, since they do not use
300 s
= bfd_make_section (abfd
, ".rel.bss");
302 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
303 || ! bfd_set_section_alignment (abfd
, s
, 2))
310 /* Create the .got section to hold the global offset table, and the
311 .got.plt section to hold procedure linkage table GOT entries. The
312 linker script will put .got.plt into the output .got section. */
315 elf_i386_create_got_section (abfd
, info
)
317 struct bfd_link_info
*info
;
320 register asection
*s
;
321 struct elf_link_hash_entry
*h
;
323 /* This function may be called more than once. */
324 if (bfd_get_section_by_name (abfd
, ".got") != NULL
)
327 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
;
329 s
= bfd_make_section (abfd
, ".got");
331 || ! bfd_set_section_flags (abfd
, s
, flags
)
332 || ! bfd_set_section_alignment (abfd
, s
, 2))
335 s
= bfd_make_section (abfd
, ".got.plt");
337 || ! bfd_set_section_flags (abfd
, s
, flags
)
338 || ! bfd_set_section_alignment (abfd
, s
, 2))
341 /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the
342 .got.plt section, which will be placed at the start of the output
343 .got section. We don't do this in the linker script because we
344 don't want to define the symbol if we are not creating a global
347 if (! (_bfd_generic_link_add_one_symbol
348 (info
, abfd
, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL
, s
, (bfd_vma
) 0,
349 (const char *) NULL
, false, get_elf_backend_data (abfd
)->collect
,
350 (struct bfd_link_hash_entry
**) &h
)))
352 h
->elf_link_hash_flags
|= ELF_LINK_HASH_DEF_REGULAR
;
353 h
->type
= STT_OBJECT
;
356 && ! bfd_elf32_link_record_dynamic_symbol (info
, h
))
359 /* The first three global offset table entries are reserved. */
360 s
->_raw_size
+= 3 * 4;
365 /* Look through the relocs for a section during the first phase, and
366 allocate space in the global offset table or procedure linkage
370 elf_i386_check_relocs (abfd
, info
, sec
, relocs
)
372 struct bfd_link_info
*info
;
374 const Elf_Internal_Rela
*relocs
;
377 Elf_Internal_Shdr
*symtab_hdr
;
378 struct elf_link_hash_entry
**sym_hashes
;
379 bfd_vma
*local_got_offsets
;
380 const Elf_Internal_Rela
*rel
;
381 const Elf_Internal_Rela
*rel_end
;
386 if (info
->relocateable
)
389 dynobj
= elf_hash_table (info
)->dynobj
;
390 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
391 sym_hashes
= elf_sym_hashes (abfd
);
392 local_got_offsets
= elf_local_got_offsets (abfd
);
398 rel_end
= relocs
+ sec
->reloc_count
;
399 for (rel
= relocs
; rel
< rel_end
; rel
++)
402 struct elf_link_hash_entry
*h
;
404 r_symndx
= ELF32_R_SYM (rel
->r_info
);
406 if (r_symndx
< symtab_hdr
->sh_info
)
409 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
411 /* Some relocs require a global offset table. */
414 switch (ELF32_R_TYPE (rel
->r_info
))
419 elf_hash_table (info
)->dynobj
= dynobj
= abfd
;
420 if (! elf_i386_create_got_section (dynobj
, info
))
429 switch (ELF32_R_TYPE (rel
->r_info
))
432 /* This symbol requires a global offset table entry. */
436 sgot
= bfd_get_section_by_name (dynobj
, ".got");
437 BFD_ASSERT (sgot
!= NULL
);
441 && (h
!= NULL
|| info
->shared
))
443 srelgot
= bfd_get_section_by_name (dynobj
, ".rel.got");
446 srelgot
= bfd_make_section (dynobj
, ".rel.got");
448 || ! bfd_set_section_flags (dynobj
, srelgot
,
454 || ! bfd_set_section_alignment (dynobj
, srelgot
, 2))
461 if (h
->got_offset
!= (bfd_vma
) -1)
463 /* We have already allocated space in the .got. */
466 h
->got_offset
= sgot
->_raw_size
;
468 /* Make sure this symbol is output as a dynamic symbol. */
469 if (h
->dynindx
== -1)
471 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
475 srelgot
->_raw_size
+= sizeof (Elf32_External_Rel
);
479 /* This is a global offset table entry for a local
481 if (local_got_offsets
== NULL
)
486 size
= symtab_hdr
->sh_info
* sizeof (bfd_vma
);
487 local_got_offsets
= (bfd_vma
*) bfd_alloc (abfd
, size
);
488 if (local_got_offsets
== NULL
)
490 bfd_set_error (bfd_error_no_memory
);
493 elf_local_got_offsets (abfd
) = local_got_offsets
;
494 for (i
= 0; i
< symtab_hdr
->sh_info
; i
++)
495 local_got_offsets
[i
] = (bfd_vma
) -1;
497 if (local_got_offsets
[r_symndx
] != (bfd_vma
) -1)
499 /* We have already allocated space in the .got. */
502 local_got_offsets
[r_symndx
] = sgot
->_raw_size
;
506 /* If we are generating a shared object, we need to
507 output a R_386_RELATIVE reloc so that the dynamic
508 linker can adjust this GOT entry. */
509 srelgot
->_raw_size
+= sizeof (Elf32_External_Rel
);
513 sgot
->_raw_size
+= 4;
518 /* This symbol requires a procedure linkage table entry. We
519 actually build the entry in adjust_dynamic_symbol,
520 because this might be a case of linking PIC code without
521 linking in any dynamic objects, in which case we don't
522 need to generate a procedure linkage table after all. */
524 /* If this is a local symbol, we resolve it directly without
525 creating a procedure linkage table entry. */
529 /* Make sure this symbol is output as a dynamic symbol. */
530 if (h
->dynindx
== -1)
532 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
536 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
543 && (sec
->flags
& SEC_ALLOC
) != 0)
545 /* When creating a shared object, we must copy these
546 reloc types into the output file. We create a reloc
547 section in dynobj and make room for this reloc. */
552 name
= (elf_string_from_elf_section
554 elf_elfheader (abfd
)->e_shstrndx
,
555 elf_section_data (sec
)->rel_hdr
.sh_name
));
559 BFD_ASSERT (strncmp (name
, ".rel", 4) == 0
560 && strcmp (bfd_get_section_name (abfd
, sec
),
563 sreloc
= bfd_get_section_by_name (dynobj
, name
);
566 sreloc
= bfd_make_section (dynobj
, name
);
568 || ! bfd_set_section_flags (dynobj
, sreloc
,
574 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
579 sreloc
->_raw_size
+= sizeof (Elf32_External_Rel
);
592 /* Adjust a symbol defined by a dynamic object and referenced by a
593 regular object. The current definition is in some section of the
594 dynamic object, but we're not including those sections. We have to
595 change the definition to something the rest of the link can
599 elf_i386_adjust_dynamic_symbol (info
, h
)
600 struct bfd_link_info
*info
;
601 struct elf_link_hash_entry
*h
;
605 unsigned int power_of_two
;
607 dynobj
= elf_hash_table (info
)->dynobj
;
609 /* Make sure we know what is going on here. */
610 BFD_ASSERT (dynobj
!= NULL
611 && ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
)
612 || ((h
->elf_link_hash_flags
613 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
614 && (h
->elf_link_hash_flags
615 & ELF_LINK_HASH_REF_REGULAR
) != 0
616 && (h
->elf_link_hash_flags
617 & ELF_LINK_HASH_DEF_REGULAR
) == 0
618 && (elf_elfheader (h
->root
.u
.def
.section
->owner
)->e_type
620 && h
->root
.type
== bfd_link_hash_defined
621 && (bfd_get_flavour (h
->root
.u
.def
.section
->owner
)
622 == bfd_target_elf_flavour
)
623 && h
->root
.u
.def
.section
->output_section
== NULL
)));
625 /* If this is a function, put it in the procedure linkage table. We
626 will fill in the contents of the procedure linkage table later,
627 when we know the address of the .got section. */
628 if (h
->type
== STT_FUNC
629 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
631 if (! elf_hash_table (info
)->dynamic_sections_created
)
633 /* This case can occur if we saw a PLT32 reloc in an input
634 file, but none of the input files were dynamic objects.
635 In such a case, we don't actually need to build a
636 procedure linkage table, and we can just do a PC32 reloc
638 BFD_ASSERT ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0);
642 s
= bfd_get_section_by_name (dynobj
, ".plt");
643 BFD_ASSERT (s
!= NULL
);
645 /* If this is the first .plt entry, make room for the special
647 if (s
->_raw_size
== 0)
648 s
->_raw_size
+= PLT_ENTRY_SIZE
;
650 /* If this symbol is not defined in a regular file, and we are
651 not generating a shared library, then set the symbol to this
652 location in the .plt. This is required to make function
653 pointers compare as equal between the normal executable and
654 the shared library. */
656 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
658 h
->root
.u
.def
.section
= s
;
659 h
->root
.u
.def
.value
= s
->_raw_size
;
662 h
->plt_offset
= s
->_raw_size
;
664 /* Make room for this entry. */
665 s
->_raw_size
+= PLT_ENTRY_SIZE
;
667 /* We also need to make an entry in the .got.plt section, which
668 will be placed in the .got section by the linker script. */
670 s
= bfd_get_section_by_name (dynobj
, ".got.plt");
671 BFD_ASSERT (s
!= NULL
);
674 /* We also need to make an entry in the .rel.plt section. */
676 s
= bfd_get_section_by_name (dynobj
, ".rel.plt");
677 BFD_ASSERT (s
!= NULL
);
678 s
->_raw_size
+= sizeof (Elf32_External_Rel
);
683 /* If this is a weak symbol, and there is a real definition, the
684 processor independent code will have arranged for us to see the
685 real definition first, and we can just use the same value. */
686 if (h
->weakdef
!= NULL
)
688 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
);
689 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
690 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
694 /* This is a reference to a symbol defined by a dynamic object which
695 is not a function. */
697 /* If we are creating a shared library, we must presume that the
698 only references to the symbol are via the global offset table.
699 For such cases we need not do anything here; the relocations will
700 be handled correctly by relocate_section. */
704 /* We must allocate the symbol in our .dynbss section, which will
705 become part of the .bss section of the executable. There will be
706 an entry for this symbol in the .dynsym section. The dynamic
707 object will contain position independent code, so all references
708 from the dynamic object to this symbol will go through the global
709 offset table. The dynamic linker will use the .dynsym entry to
710 determine the address it must put in the global offset table, so
711 both the dynamic object and the regular object will refer to the
712 same memory location for the variable. */
714 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
715 BFD_ASSERT (s
!= NULL
);
717 /* If the symbol is currently defined in the .bss section of the
718 dynamic object, then it is OK to simply initialize it to zero.
719 If the symbol is in some other section, we must generate a
720 R_386_COPY reloc to tell the dynamic linker to copy the initial
721 value out of the dynamic object and into the runtime process
722 image. We need to remember the offset into the .rel.bss section
723 we are going to use. */
724 if ((h
->root
.u
.def
.section
->flags
& SEC_LOAD
) != 0)
728 srel
= bfd_get_section_by_name (dynobj
, ".rel.bss");
729 BFD_ASSERT (srel
!= NULL
);
730 srel
->_raw_size
+= sizeof (Elf32_External_Rel
);
731 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
734 /* We need to figure out the alignment required for this symbol. I
735 have no idea how ELF linkers handle this. */
736 power_of_two
= bfd_log2 (h
->size
);
737 if (power_of_two
> 3)
740 /* Apply the required alignment. */
741 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
742 (bfd_size_type
) (1 << power_of_two
));
743 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
745 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
749 /* Define the symbol as being at this point in the section. */
750 h
->root
.u
.def
.section
= s
;
751 h
->root
.u
.def
.value
= s
->_raw_size
;
753 /* Increment the section size to make room for the symbol. */
754 s
->_raw_size
+= h
->size
;
759 /* Set the sizes of the dynamic sections. */
762 elf_i386_size_dynamic_sections (output_bfd
, info
)
764 struct bfd_link_info
*info
;
772 dynobj
= elf_hash_table (info
)->dynobj
;
773 BFD_ASSERT (dynobj
!= NULL
);
775 if (elf_hash_table (info
)->dynamic_sections_created
)
777 /* Set the contents of the .interp section to the interpreter. */
780 s
= bfd_get_section_by_name (dynobj
, ".interp");
781 BFD_ASSERT (s
!= NULL
);
782 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
783 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
788 /* We may have created entries in the .rel.got section.
789 However, if we are not creating the dynamic sections, we will
790 not actually use these entries. Reset the size of .rel.got,
791 which will cause it to get stripped from the output file
793 s
= bfd_get_section_by_name (dynobj
, ".rel.got");
798 /* The check_relocs and adjust_dynamic_symbol entry points have
799 determined the sizes of the various dynamic sections. Allocate
804 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
809 if ((s
->flags
& SEC_IN_MEMORY
) == 0)
812 /* It's OK to base decisions on the section name, because none
813 of the dynobj section names depend upon the input files. */
814 name
= bfd_get_section_name (dynobj
, s
);
818 if (strcmp (name
, ".plt") == 0)
820 if (s
->_raw_size
== 0)
822 /* Strip this section if we don't need it; see the
828 /* Remember whether there is a PLT. */
832 else if (strncmp (name
, ".rel", 4) == 0)
834 if (s
->_raw_size
== 0)
836 /* If we don't need this section, strip it from the
837 output file. This is mostly to handle .rel.bss and
838 .rel.plt. We must create both sections in
839 create_dynamic_sections, because they must be created
840 before the linker maps input sections to output
841 sections. The linker does that before
842 adjust_dynamic_symbol is called, and it is that
843 function which decides whether anything needs to go
844 into these sections. */
851 /* Remember whether there are any reloc sections other
853 if (strcmp (name
, ".rel.plt") != 0)
856 /* If this relocation section applies to a read only
857 section, then we probably need a DT_TEXTREL entry. */
858 target
= bfd_get_section_by_name (output_bfd
, name
+ 4);
860 && (target
->flags
& SEC_READONLY
) != 0)
863 /* We use the reloc_count field as a counter if we need
864 to copy relocs into the output file. */
868 else if (strncmp (name
, ".got", 4) != 0)
870 /* It's not one of our sections, so don't allocate space. */
878 for (spp
= &s
->output_section
->owner
->sections
;
879 *spp
!= s
->output_section
;
882 *spp
= s
->output_section
->next
;
883 --s
->output_section
->owner
->section_count
;
888 /* Allocate memory for the section contents. */
889 s
->contents
= (bfd_byte
*) bfd_alloc (dynobj
, s
->_raw_size
);
890 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
892 bfd_set_error (bfd_error_no_memory
);
897 if (elf_hash_table (info
)->dynamic_sections_created
)
899 /* Add some entries to the .dynamic section. We fill in the
900 values later, in elf_i386_finish_dynamic_sections, but we
901 must add the entries now so that we get the correct size for
902 the .dynamic section. The DT_DEBUG entry is filled in by the
903 dynamic linker and used by the debugger. */
906 if (! bfd_elf32_add_dynamic_entry (info
, DT_DEBUG
, 0))
912 if (! bfd_elf32_add_dynamic_entry (info
, DT_PLTGOT
, 0)
913 || ! bfd_elf32_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
914 || ! bfd_elf32_add_dynamic_entry (info
, DT_PLTREL
, DT_REL
)
915 || ! bfd_elf32_add_dynamic_entry (info
, DT_JMPREL
, 0))
921 if (! bfd_elf32_add_dynamic_entry (info
, DT_REL
, 0)
922 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELSZ
, 0)
923 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELENT
,
924 sizeof (Elf32_External_Rel
)))
930 if (! bfd_elf32_add_dynamic_entry (info
, DT_TEXTREL
, 0))
938 /* Relocate an i386 ELF section. */
941 elf_i386_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
942 contents
, relocs
, local_syms
, local_sections
)
944 struct bfd_link_info
*info
;
946 asection
*input_section
;
948 Elf_Internal_Rela
*relocs
;
949 Elf_Internal_Sym
*local_syms
;
950 asection
**local_sections
;
953 Elf_Internal_Shdr
*symtab_hdr
;
954 struct elf_link_hash_entry
**sym_hashes
;
955 bfd_vma
*local_got_offsets
;
959 Elf_Internal_Rela
*rel
;
960 Elf_Internal_Rela
*relend
;
962 dynobj
= elf_hash_table (info
)->dynobj
;
963 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
964 sym_hashes
= elf_sym_hashes (input_bfd
);
965 local_got_offsets
= elf_local_got_offsets (input_bfd
);
972 relend
= relocs
+ input_section
->reloc_count
;
973 for (; rel
< relend
; rel
++)
976 reloc_howto_type
*howto
;
978 struct elf_link_hash_entry
*h
;
979 Elf_Internal_Sym
*sym
;
982 bfd_reloc_status_type r
;
984 r_type
= ELF32_R_TYPE (rel
->r_info
);
985 if (r_type
< 0 || r_type
>= (int) R_386_max
)
987 bfd_set_error (bfd_error_bad_value
);
990 howto
= elf_howto_table
+ r_type
;
992 r_symndx
= ELF32_R_SYM (rel
->r_info
);
994 if (info
->relocateable
)
996 /* This is a relocateable link. We don't have to change
997 anything, unless the reloc is against a section symbol,
998 in which case we have to adjust according to where the
999 section symbol winds up in the output section. */
1000 if (r_symndx
< symtab_hdr
->sh_info
)
1002 sym
= local_syms
+ r_symndx
;
1003 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1007 sec
= local_sections
[r_symndx
];
1008 val
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
1009 val
+= sec
->output_offset
+ sym
->st_value
;
1010 bfd_put_32 (input_bfd
, val
, contents
+ rel
->r_offset
);
1017 /* This is a final link. */
1021 if (r_symndx
< symtab_hdr
->sh_info
)
1023 sym
= local_syms
+ r_symndx
;
1024 sec
= local_sections
[r_symndx
];
1025 relocation
= (sec
->output_section
->vma
1026 + sec
->output_offset
1031 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1032 if (h
->root
.type
== bfd_link_hash_defined
)
1034 sec
= h
->root
.u
.def
.section
;
1035 if (r_type
== R_386_GOTPC
1036 || (r_type
== R_386_PLT32
1037 && h
->plt_offset
!= (bfd_vma
) -1)
1038 || (r_type
== R_386_GOT32
1039 && elf_hash_table (info
)->dynamic_sections_created
)
1041 && (r_type
== R_386_32
1042 || r_type
== R_386_PC32
)
1043 && (input_section
->flags
& SEC_ALLOC
) != 0))
1045 /* In these cases, we don't need the relocation
1046 value. We check specially because in some
1047 obscure cases sec->output_section will be NULL. */
1051 relocation
= (h
->root
.u
.def
.value
1052 + sec
->output_section
->vma
1053 + sec
->output_offset
);
1055 else if (h
->root
.type
== bfd_link_hash_weak
)
1057 else if (info
->shared
)
1061 if (! ((*info
->callbacks
->undefined_symbol
)
1062 (info
, h
->root
.root
.string
, input_bfd
,
1063 input_section
, rel
->r_offset
)))
1072 /* Relocation is to the entry for this symbol in the global
1076 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1077 BFD_ASSERT (sgot
!= NULL
);
1084 off
= h
->got_offset
;
1085 BFD_ASSERT (off
!= (bfd_vma
) -1);
1087 if (! elf_hash_table (info
)->dynamic_sections_created
)
1089 /* This is actually a static link. We must
1090 initialize this entry in the global offset table.
1091 Since the offset must always be a multiple of 4,
1092 we use the least significant bit to record
1093 whether we have initialized it already.
1095 When doing a dynamic link, we create a .rel.got
1096 relocation entry to initialize the value. This
1097 is done in the finish_dynamic_symbol routine. */
1102 bfd_put_32 (output_bfd
, relocation
,
1103 sgot
->contents
+ off
);
1108 relocation
= sgot
->output_offset
+ off
;
1114 BFD_ASSERT (local_got_offsets
!= NULL
1115 && local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
1117 off
= local_got_offsets
[r_symndx
];
1119 /* The offset must always be a multiple of 4. We use
1120 the least significant bit to record whether we have
1121 already generated the necessary reloc. */
1126 bfd_put_32 (output_bfd
, relocation
, sgot
->contents
+ off
);
1131 Elf_Internal_Rel outrel
;
1133 srelgot
= bfd_get_section_by_name (dynobj
, ".rel.got");
1134 BFD_ASSERT (srelgot
!= NULL
);
1136 outrel
.r_offset
= (sgot
->output_section
->vma
1137 + sgot
->output_offset
1139 outrel
.r_info
= ELF32_R_INFO (0, R_386_RELATIVE
);
1140 bfd_elf32_swap_reloc_out (output_bfd
, &outrel
,
1141 (((Elf32_External_Rel
*)
1143 + srelgot
->reloc_count
));
1144 ++srelgot
->reloc_count
;
1147 local_got_offsets
[r_symndx
] |= 1;
1150 relocation
= sgot
->output_offset
+ off
;
1156 /* Relocation is relative to the start of the global offset
1161 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1162 BFD_ASSERT (sgot
!= NULL
);
1165 /* Note that sgot->output_offset is not involved in this
1166 calculation. We always want the start of .got. If we
1167 defined _GLOBAL_OFFSET_TABLE in a different way, as is
1168 permitted by the ABI, we might have to change this
1170 relocation
-= sgot
->output_section
->vma
;
1175 /* Use global offset table as symbol value. */
1179 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1180 BFD_ASSERT (sgot
!= NULL
);
1183 relocation
= sgot
->output_section
->vma
;
1188 /* Relocation is to the entry for this symbol in the
1189 procedure linkage table. */
1191 /* Resolve a PLT32 reloc again a local symbol directly,
1192 without using the procedure linkage table. */
1196 if (h
->plt_offset
== (bfd_vma
) -1)
1198 /* We didn't make a PLT entry for this symbol. This
1199 happens when statically linking PIC code. */
1205 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1206 BFD_ASSERT (splt
!= NULL
);
1209 relocation
= (splt
->output_section
->vma
1210 + splt
->output_offset
1218 && (input_section
->flags
& SEC_ALLOC
) != 0)
1220 Elf_Internal_Rel outrel
;
1222 /* When generating a shared object, these relocations
1223 are copied into the output file to be resolved at run
1230 name
= (elf_string_from_elf_section
1232 elf_elfheader (input_bfd
)->e_shstrndx
,
1233 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1237 BFD_ASSERT (strncmp (name
, ".rel", 4) == 0
1238 && strcmp (bfd_get_section_name (input_bfd
,
1242 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1243 BFD_ASSERT (sreloc
!= NULL
);
1246 outrel
.r_offset
= (rel
->r_offset
1247 + input_section
->output_section
->vma
1248 + input_section
->output_offset
);
1249 if (r_type
== R_386_PC32
)
1251 BFD_ASSERT (h
!= NULL
&& h
->dynindx
!= -1);
1252 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_386_PC32
);
1257 outrel
.r_info
= ELF32_R_INFO (0, R_386_RELATIVE
);
1260 BFD_ASSERT (h
->dynindx
!= (bfd_vma
) -1);
1261 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_386_32
);
1265 bfd_elf32_swap_reloc_out (output_bfd
, &outrel
,
1266 (((Elf32_External_Rel
*)
1268 + sreloc
->reloc_count
));
1269 ++sreloc
->reloc_count
;
1271 /* If this reloc is against an external symbol, we do
1272 not want to fiddle with the addend. Otherwise, we
1273 need to include the symbol value so that it becomes
1274 an addend for the dynamic reloc. */
1285 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
1286 contents
, rel
->r_offset
,
1287 relocation
, (bfd_vma
) 0);
1289 if (r
!= bfd_reloc_ok
)
1294 case bfd_reloc_outofrange
:
1296 case bfd_reloc_overflow
:
1301 name
= h
->root
.root
.string
;
1304 name
= elf_string_from_elf_section (input_bfd
,
1305 symtab_hdr
->sh_link
,
1310 name
= bfd_section_name (input_bfd
, sec
);
1312 if (! ((*info
->callbacks
->reloc_overflow
)
1313 (info
, name
, howto
->name
, (bfd_vma
) 0,
1314 input_bfd
, input_section
, rel
->r_offset
)))
1325 /* Finish up dynamic symbol handling. We set the contents of various
1326 dynamic sections here. */
1329 elf_i386_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
1331 struct bfd_link_info
*info
;
1332 struct elf_link_hash_entry
*h
;
1333 Elf_Internal_Sym
*sym
;
1337 dynobj
= elf_hash_table (info
)->dynobj
;
1339 if (h
->plt_offset
!= (bfd_vma
) -1)
1346 Elf_Internal_Rel rel
;
1348 /* This symbol has an entry in the procedure linkage table. Set
1351 BFD_ASSERT (h
->dynindx
!= -1);
1353 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1354 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
1355 srel
= bfd_get_section_by_name (dynobj
, ".rel.plt");
1356 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
1358 /* Get the index in the procedure linkage table which
1359 corresponds to this symbol. This is the index of this symbol
1360 in all the symbols for which we are making plt entries. The
1361 first entry in the procedure linkage table is reserved. */
1362 plt_index
= h
->plt_offset
/ PLT_ENTRY_SIZE
- 1;
1364 /* Get the offset into the .got table of the entry that
1365 corresponds to this function. Each .got entry is 4 bytes.
1366 The first three are reserved. */
1367 got_offset
= (plt_index
+ 3) * 4;
1369 /* Fill in the entry in the procedure linkage table. */
1372 memcpy (splt
->contents
+ h
->plt_offset
, elf_i386_plt_entry
,
1374 bfd_put_32 (output_bfd
,
1375 (sgot
->output_section
->vma
1376 + sgot
->output_offset
1378 splt
->contents
+ h
->plt_offset
+ 2);
1382 memcpy (splt
->contents
+ h
->plt_offset
, elf_i386_pic_plt_entry
,
1384 bfd_put_32 (output_bfd
, got_offset
,
1385 splt
->contents
+ h
->plt_offset
+ 2);
1388 bfd_put_32 (output_bfd
, plt_index
* sizeof (Elf32_External_Rel
),
1389 splt
->contents
+ h
->plt_offset
+ 7);
1390 bfd_put_32 (output_bfd
, - (h
->plt_offset
+ PLT_ENTRY_SIZE
),
1391 splt
->contents
+ h
->plt_offset
+ 12);
1393 /* Fill in the entry in the global offset table. */
1394 bfd_put_32 (output_bfd
,
1395 (splt
->output_section
->vma
1396 + splt
->output_offset
1399 sgot
->contents
+ got_offset
);
1401 /* Fill in the entry in the .rel.plt section. */
1402 rel
.r_offset
= (sgot
->output_section
->vma
1403 + sgot
->output_offset
1405 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_386_JUMP_SLOT
);
1406 bfd_elf32_swap_reloc_out (output_bfd
, &rel
,
1407 ((Elf32_External_Rel
*) srel
->contents
1410 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
1412 /* Mark the symbol as undefined, rather than as defined in
1413 the .plt section. Leave the value alone. */
1414 sym
->st_shndx
= SHN_UNDEF
;
1418 if (h
->got_offset
!= (bfd_vma
) -1)
1422 Elf_Internal_Rel rel
;
1424 /* This symbol has an entry in the global offset table. Set it
1427 BFD_ASSERT (h
->dynindx
!= -1);
1429 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1430 srel
= bfd_get_section_by_name (dynobj
, ".rel.got");
1431 BFD_ASSERT (sgot
!= NULL
&& srel
!= NULL
);
1433 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ h
->got_offset
);
1435 rel
.r_offset
= (sgot
->output_section
->vma
1436 + sgot
->output_offset
1438 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_386_GLOB_DAT
);
1439 bfd_elf32_swap_reloc_out (output_bfd
, &rel
,
1440 ((Elf32_External_Rel
*) srel
->contents
1441 + srel
->reloc_count
));
1442 ++srel
->reloc_count
;
1445 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
1448 Elf_Internal_Rel rel
;
1450 /* This symbol needs a copy reloc. Set it up. */
1452 BFD_ASSERT (h
->dynindx
!= -1
1453 && h
->root
.type
== bfd_link_hash_defined
);
1455 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
1457 BFD_ASSERT (s
!= NULL
);
1459 rel
.r_offset
= (h
->root
.u
.def
.value
1460 + h
->root
.u
.def
.section
->output_section
->vma
1461 + h
->root
.u
.def
.section
->output_offset
);
1462 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_386_COPY
);
1463 bfd_elf32_swap_reloc_out (output_bfd
, &rel
,
1464 ((Elf32_External_Rel
*) s
->contents
1469 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
1470 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
1471 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
1472 sym
->st_shndx
= SHN_ABS
;
1477 /* Finish up the dynamic sections. */
1480 elf_i386_finish_dynamic_sections (output_bfd
, info
)
1482 struct bfd_link_info
*info
;
1488 dynobj
= elf_hash_table (info
)->dynobj
;
1490 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
1491 BFD_ASSERT (sgot
!= NULL
);
1492 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
1494 if (elf_hash_table (info
)->dynamic_sections_created
)
1497 Elf32_External_Dyn
*dyncon
, *dynconend
;
1499 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1500 BFD_ASSERT (splt
!= NULL
&& sdyn
!= NULL
);
1502 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
1503 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
1504 for (; dyncon
< dynconend
; dyncon
++)
1506 Elf_Internal_Dyn dyn
;
1510 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
1523 s
= bfd_get_section_by_name (output_bfd
, name
);
1524 BFD_ASSERT (s
!= NULL
);
1525 dyn
.d_un
.d_ptr
= s
->vma
;
1526 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
1530 s
= bfd_get_section_by_name (output_bfd
, ".rel.plt");
1531 BFD_ASSERT (s
!= NULL
);
1532 if (s
->_cooked_size
!= 0)
1533 dyn
.d_un
.d_val
= s
->_cooked_size
;
1535 dyn
.d_un
.d_val
= s
->_raw_size
;
1536 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
1540 /* My reading of the SVR4 ABI indicates that the
1541 procedure linkage table relocs (DT_JMPREL) should be
1542 included in the overall relocs (DT_REL). This is
1543 what Solaris does. However, UnixWare can not handle
1544 that case. Therefore, we override the DT_RELSZ entry
1545 here to make it not include the JMPREL relocs. Since
1546 the linker script arranges for .rel.plt to follow all
1547 other relocation sections, we don't have to worry
1548 about changing the DT_REL entry. */
1549 s
= bfd_get_section_by_name (output_bfd
, ".rel.plt");
1552 if (s
->_cooked_size
!= 0)
1553 dyn
.d_un
.d_val
-= s
->_cooked_size
;
1555 dyn
.d_un
.d_val
-= s
->_raw_size
;
1557 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
1562 /* Fill in the first entry in the procedure linkage table. */
1563 if (splt
->_raw_size
> 0)
1566 memcpy (splt
->contents
, elf_i386_pic_plt0_entry
, PLT_ENTRY_SIZE
);
1569 memcpy (splt
->contents
, elf_i386_plt0_entry
, PLT_ENTRY_SIZE
);
1570 bfd_put_32 (output_bfd
,
1571 sgot
->output_section
->vma
+ sgot
->output_offset
+ 4,
1572 splt
->contents
+ 2);
1573 bfd_put_32 (output_bfd
,
1574 sgot
->output_section
->vma
+ sgot
->output_offset
+ 8,
1575 splt
->contents
+ 8);
1579 /* UnixWare sets the entsize of .plt to 4, although that doesn't
1580 really seem like the right value. */
1581 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
= 4;
1584 /* Fill in the first three entries in the global offset table. */
1585 if (sgot
->_raw_size
> 0)
1588 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
1590 bfd_put_32 (output_bfd
,
1591 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
1593 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 4);
1594 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
1597 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 4;
1602 #define TARGET_LITTLE_SYM bfd_elf32_i386_vec
1603 #define TARGET_LITTLE_NAME "elf32-i386"
1604 #define ELF_ARCH bfd_arch_i386
1605 #define ELF_MACHINE_CODE EM_386
1606 #define elf_info_to_howto elf_i386_info_to_howto
1607 #define elf_info_to_howto_rel elf_i386_info_to_howto_rel
1608 #define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
1609 #define ELF_MAXPAGESIZE 0x1000
1610 #define elf_backend_create_dynamic_sections \
1611 elf_i386_create_dynamic_sections
1612 #define elf_backend_check_relocs elf_i386_check_relocs
1613 #define elf_backend_adjust_dynamic_symbol \
1614 elf_i386_adjust_dynamic_symbol
1615 #define elf_backend_size_dynamic_sections \
1616 elf_i386_size_dynamic_sections
1617 #define elf_backend_relocate_section elf_i386_relocate_section
1618 #define elf_backend_finish_dynamic_symbol \
1619 elf_i386_finish_dynamic_symbol
1620 #define elf_backend_finish_dynamic_sections \
1621 elf_i386_finish_dynamic_sections
1623 #include "elf32-target.h"