* elfcode.h (map_program_segments): Restore check of file_size !=
[deliverable/binutils-gdb.git] / bfd / elf32-i386.c
1 /* Intel 80386/80486-specific support for 32-bit ELF
2 Copyright 1993 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
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.
10
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.
15
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. */
19
20 /*
21 * This file contains changes from the Open Software Foundation.
22 */
23
24 #include "bfd.h"
25 #include "sysdep.h"
26 #include "libbfd.h"
27 #include "libelf.h"
28
29 #define USE_REL 1 /* 386 uses REL relocations instead of RELA */
30
31 enum reloc_type
32 {
33 R_386_NONE = 0,
34 R_386_32, R_386_PC32,
35 R_386_GOT32, R_386_PLT32,
36 R_386_COPY,
37 R_386_GLOB_DAT, R_386_JUMP_SLOT,
38 R_386_RELATIVE,
39 R_386_GOTOFF, R_386_GOTPC,
40 R_386_max
41 };
42
43 #if 0
44 static CONST char *CONST reloc_type_names[] =
45 {
46 "R_386_NONE",
47 "R_386_32", "R_386_PC32",
48 "R_386_GOT32", "R_386_PLT32",
49 "R_386_COPY",
50 "R_386_GLOB_DAT", "R_386_JUMP_SLOT",
51 "R_386_RELATIVE",
52 "R_386_GOTOFF", "R_386_GOTPC",
53 };
54 #endif
55
56
57 static reloc_howto_type elf_howto_table[]=
58 {
59 HOWTO(R_386_NONE, 0,0, 0,false,0, complain_overflow_dont, 0,"R_386_NONE", false,0x00000000,0x00000000,false),
60 HOWTO(R_386_32, 0,2,32,false,0, complain_overflow_bitfield, 0,"R_386_32", false,0xffffffff,0xffffffff,false),
61 HOWTO(R_386_PC32, 0,2,32,true, 0, complain_overflow_signed, 0,"R_386_PC32", false,0xffffffff,0xffffffff,false),
62 HOWTO(R_386_GOT32, 0,2,32,false,0, complain_overflow_bitfield, 0,"R_386_GOT32",false,0xffffffff,0xffffffff,false)
63 };
64
65 #ifdef DEBUG_GEN_RELOC
66 #define TRACE(str) fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
67 #else
68 #define TRACE(str)
69 #endif
70
71 static CONST struct reloc_howto_struct *
72 DEFUN (elf_i386_reloc_type_lookup, (abfd, code),
73 bfd *abfd AND
74 bfd_reloc_code_real_type code)
75 {
76 switch (code)
77 {
78 case BFD_RELOC_NONE:
79 TRACE ("BFD_RELOC_NONE");
80 return &elf_howto_table[ (int)R_386_NONE ];
81
82 case BFD_RELOC_32:
83 TRACE ("BFD_RELOC_32");
84 return &elf_howto_table[ (int)R_386_32 ];
85
86 case BFD_RELOC_32_PCREL:
87 TRACE ("BFD_RELOC_PC32");
88 return &elf_howto_table[ (int)R_386_PC32 ];
89
90 default:
91 abort ();
92 }
93
94 TRACE ("Unknown");
95 return 0;
96 }
97
98 static void
99 DEFUN(elf_i386_info_to_howto, (abfd, cache_ptr, dst),
100 bfd *abfd AND
101 arelent *cache_ptr AND
102 Elf32_Internal_Rela *dst)
103 {
104 BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < R_386_GOT32);
105
106 cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
107 }
108
109 static void
110 DEFUN(elf_i386_info_to_howto_rel, (abfd, cache_ptr, dst),
111 bfd *abfd AND
112 arelent *cache_ptr AND
113 Elf32_Internal_Rel *dst)
114 {
115 BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < R_386_GOT32);
116
117 cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
118 }
119
120 #define TARGET_LITTLE_SYM bfd_elf32_i386_vec
121 #define TARGET_LITTLE_NAME "elf32-i386"
122 #define ELF_ARCH bfd_arch_i386
123 #define elf_info_to_howto elf_i386_info_to_howto
124 #define elf_info_to_howto_rel elf_i386_info_to_howto_rel
125 #define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
126
127 #include "elf32-target.h"
This page took 0.03201 seconds and 4 git commands to generate.