Deleted Added
full compact
elf32-i386.c (77302) elf32-i386.c (78832)
1/* Intel 80386/80486-specific support for 32-bit ELF
1/* Intel 80386/80486-specific support for 32-bit ELF
2 Copyright 1993, 94, 95, 96, 97, 98, 99, 2000
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
3 Free Software Foundation, Inc.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21/* $FreeBSD: head/contrib/binutils/bfd/elf32-i386.c 77302 2001-05-28 05:52:12Z obrien $ */
21/* $FreeBSD: head/contrib/binutils/bfd/elf32-i386.c 78832 2001-06-26 17:15:34Z obrien $ */
22
23#include "bfd.h"
24#include "sysdep.h"
25#include "bfdlink.h"
26#include "libbfd.h"
27#include "elf-bfd.h"
28
29static reloc_howto_type *elf_i386_reloc_type_lookup

--- 472 unchanged lines hidden (view full) ---

502 rel_end = relocs + sec->reloc_count;
503 for (rel = relocs; rel < rel_end; rel++)
504 {
505 unsigned long r_symndx;
506 struct elf_link_hash_entry *h;
507
508 r_symndx = ELF32_R_SYM (rel->r_info);
509
22
23#include "bfd.h"
24#include "sysdep.h"
25#include "bfdlink.h"
26#include "libbfd.h"
27#include "elf-bfd.h"
28
29static reloc_howto_type *elf_i386_reloc_type_lookup

--- 472 unchanged lines hidden (view full) ---

502 rel_end = relocs + sec->reloc_count;
503 for (rel = relocs; rel < rel_end; rel++)
504 {
505 unsigned long r_symndx;
506 struct elf_link_hash_entry *h;
507
508 r_symndx = ELF32_R_SYM (rel->r_info);
509
510 if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
511 {
512 if (abfd->my_archive)
513 (*_bfd_error_handler) (_("%s(%s): bad symbol index: %d"),
514 bfd_get_filename (abfd->my_archive),
515 bfd_get_filename (abfd),
516 r_symndx);
517 else
518 (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
519 bfd_get_filename (abfd),
520 r_symndx);
521 return false;
522 }
523
510 if (r_symndx < symtab_hdr->sh_info)
511 h = NULL;
512 else
513 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
514
515 /* Some relocs require a global offset table. */
516 if (dynobj == NULL)
517 {

--- 169 unchanged lines hidden (view full) ---

687 (*_bfd_error_handler) (_("%s(%s): bad relocation section name `%s\'"),
688 bfd_get_filename (abfd->my_archive),
689 bfd_get_filename (abfd),
690 name);
691 else
692 (*_bfd_error_handler) (_("%s: bad relocation section name `%s\'"),
693 bfd_get_filename (abfd),
694 name);
524 if (r_symndx < symtab_hdr->sh_info)
525 h = NULL;
526 else
527 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
528
529 /* Some relocs require a global offset table. */
530 if (dynobj == NULL)
531 {

--- 169 unchanged lines hidden (view full) ---

701 (*_bfd_error_handler) (_("%s(%s): bad relocation section name `%s\'"),
702 bfd_get_filename (abfd->my_archive),
703 bfd_get_filename (abfd),
704 name);
705 else
706 (*_bfd_error_handler) (_("%s: bad relocation section name `%s\'"),
707 bfd_get_filename (abfd),
708 name);
695 }
709 }
696
697 sreloc = bfd_get_section_by_name (dynobj, name);
698 if (sreloc == NULL)
699 {
700 flagword flags;
701
702 sreloc = bfd_make_section (dynobj, name);
703 flags = (SEC_HAS_CONTENTS | SEC_READONLY

--- 115 unchanged lines hidden (view full) ---

819 return NULL;
820}
821
822/* Update the got entry reference counts for the section being removed. */
823
824static boolean
825elf_i386_gc_sweep_hook (abfd, info, sec, relocs)
826 bfd *abfd;
710
711 sreloc = bfd_get_section_by_name (dynobj, name);
712 if (sreloc == NULL)
713 {
714 flagword flags;
715
716 sreloc = bfd_make_section (dynobj, name);
717 flags = (SEC_HAS_CONTENTS | SEC_READONLY

--- 115 unchanged lines hidden (view full) ---

833 return NULL;
834}
835
836/* Update the got entry reference counts for the section being removed. */
837
838static boolean
839elf_i386_gc_sweep_hook (abfd, info, sec, relocs)
840 bfd *abfd;
827 struct bfd_link_info *info ATTRIBUTE_UNUSED;
841 struct bfd_link_info *info;
828 asection *sec;
829 const Elf_Internal_Rela *relocs;
830{
831 Elf_Internal_Shdr *symtab_hdr;
832 struct elf_link_hash_entry **sym_hashes;
833 bfd_signed_vma *local_got_refcounts;
834 const Elf_Internal_Rela *rel, *relend;
835 unsigned long r_symndx;

--- 1231 unchanged lines hidden (view full) ---

2067 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
2068 }
2069
2070 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
2071
2072 return true;
2073}
2074
842 asection *sec;
843 const Elf_Internal_Rela *relocs;
844{
845 Elf_Internal_Shdr *symtab_hdr;
846 struct elf_link_hash_entry **sym_hashes;
847 bfd_signed_vma *local_got_refcounts;
848 const Elf_Internal_Rela *rel, *relend;
849 unsigned long r_symndx;

--- 1231 unchanged lines hidden (view full) ---

2081 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
2082 }
2083
2084 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
2085
2086 return true;
2087}
2088
2089/* Set the correct type for an x86 ELF section. We do this by the
2090 section name, which is a hack, but ought to work. */
2091
2092static boolean
2093elf_i386_fake_sections (abfd, hdr, sec)
2094 bfd *abfd ATTRIBUTE_UNUSED;
2095 Elf32_Internal_Shdr *hdr;
2096 asection *sec;
2097{
2098 register const char *name;
2099
2100 name = bfd_get_section_name (abfd, sec);
2101
2102 if (strcmp (name, ".reloc") == 0)
2103 /*
2104 * This is an ugly, but unfortunately necessary hack that is
2105 * needed when producing EFI binaries on x86. It tells
2106 * elf.c:elf_fake_sections() not to consider ".reloc" as a section
2107 * containing ELF relocation info. We need this hack in order to
2108 * be able to generate ELF binaries that can be translated into
2109 * EFI applications (which are essentially COFF objects). Those
2110 * files contain a COFF ".reloc" section inside an ELFNN object,
2111 * which would normally cause BFD to segfault because it would
2112 * attempt to interpret this section as containing relocation
2113 * entries for section "oc". With this hack enabled, ".reloc"
2114 * will be treated as a normal data section, which will avoid the
2115 * segfault. However, you won't be able to create an ELFNN binary
2116 * with a section named "oc" that needs relocations, but that's
2117 * the kind of ugly side-effects you get when detecting section
2118 * types based on their names... In practice, this limitation is
2119 * unlikely to bite.
2120 */
2121 hdr->sh_type = SHT_PROGBITS;
2122
2123 return true;
2124}
2125
2126
2075#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
2076#define TARGET_LITTLE_NAME "elf32-i386"
2077#define ELF_ARCH bfd_arch_i386
2078#define ELF_MACHINE_CODE EM_386
2079#define ELF_MAXPAGESIZE 0x1000
2080
2081#define elf_backend_can_gc_sections 1
2082#define elf_backend_want_got_plt 1

--- 14 unchanged lines hidden (view full) ---

2097#define elf_backend_check_relocs elf_i386_check_relocs
2098#define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
2099#define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections
2100#define elf_backend_finish_dynamic_symbol elf_i386_finish_dynamic_symbol
2101#define elf_backend_gc_mark_hook elf_i386_gc_mark_hook
2102#define elf_backend_gc_sweep_hook elf_i386_gc_sweep_hook
2103#define elf_backend_relocate_section elf_i386_relocate_section
2104#define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections
2127#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
2128#define TARGET_LITTLE_NAME "elf32-i386"
2129#define ELF_ARCH bfd_arch_i386
2130#define ELF_MACHINE_CODE EM_386
2131#define ELF_MAXPAGESIZE 0x1000
2132
2133#define elf_backend_can_gc_sections 1
2134#define elf_backend_want_got_plt 1

--- 14 unchanged lines hidden (view full) ---

2149#define elf_backend_check_relocs elf_i386_check_relocs
2150#define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
2151#define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections
2152#define elf_backend_finish_dynamic_symbol elf_i386_finish_dynamic_symbol
2153#define elf_backend_gc_mark_hook elf_i386_gc_mark_hook
2154#define elf_backend_gc_sweep_hook elf_i386_gc_sweep_hook
2155#define elf_backend_relocate_section elf_i386_relocate_section
2156#define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections
2157#define elf_backend_fake_sections elf_i386_fake_sections
2105
2106#include "elf32-target.h"
2158
2159#include "elf32-target.h"