]>
Commit | Line | Data |
---|---|---|
e4b6b3e7 ILT |
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 | ||
e4b6b3e7 ILT |
20 | #include "bfd.h" |
21 | #include "sysdep.h" | |
22 | #include "libbfd.h" | |
23 | #include "libelf.h" | |
24 | ||
25 | #define USE_REL 1 /* 386 uses REL relocations instead of RELA */ | |
26 | ||
27 | enum reloc_type | |
28 | { | |
29 | R_386_NONE = 0, | |
68241b2b ILT |
30 | R_386_32, |
31 | R_386_PC32, | |
32 | R_386_GOT32, | |
33 | R_386_PLT32, | |
e4b6b3e7 | 34 | R_386_COPY, |
68241b2b ILT |
35 | R_386_GLOB_DAT, |
36 | R_386_JUMP_SLOT, | |
e4b6b3e7 | 37 | R_386_RELATIVE, |
68241b2b ILT |
38 | R_386_GOTOFF, |
39 | R_386_GOTPC, | |
e4b6b3e7 ILT |
40 | R_386_max |
41 | }; | |
42 | ||
43 | #if 0 | |
44 | static CONST char *CONST reloc_type_names[] = | |
45 | { | |
46 | "R_386_NONE", | |
68241b2b ILT |
47 | "R_386_32", |
48 | "R_386_PC32", | |
49 | "R_386_GOT32", | |
50 | "R_386_PLT32", | |
e4b6b3e7 | 51 | "R_386_COPY", |
68241b2b ILT |
52 | "R_386_GLOB_DAT", |
53 | "R_386_JUMP_SLOT", | |
e4b6b3e7 | 54 | "R_386_RELATIVE", |
68241b2b ILT |
55 | "R_386_GOTOFF", |
56 | "R_386_GOTPC", | |
e4b6b3e7 ILT |
57 | }; |
58 | #endif | |
59 | ||
e4b6b3e7 ILT |
60 | static reloc_howto_type elf_howto_table[]= |
61 | { | |
68241b2b ILT |
62 | HOWTO(R_386_NONE, 0,0, 0,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_NONE", true,0x00000000,0x00000000,false), |
63 | HOWTO(R_386_32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_32", true,0xffffffff,0xffffffff,false), | |
64 | HOWTO(R_386_PC32, 0,2,32,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC32", true,0xffffffff,0xffffffff,true), | |
65 | HOWTO(R_386_GOT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOT32", true,0xffffffff,0xffffffff,false), | |
66 | HOWTO(R_386_PLT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PLT32", true,0xffffffff,0xffffffff,false), | |
67 | HOWTO(R_386_COPY, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_COPY", true,0xffffffff,0xffffffff,false), | |
68 | 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), | |
69 | 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), | |
70 | HOWTO(R_386_RELATIVE, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_RELATIVE", true,0xffffffff,0xffffffff,false), | |
71 | HOWTO(R_386_GOTOFF, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTOFF", true,0xffffffff,0xffffffff,false), | |
72 | HOWTO(R_386_GOTPC, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTPC", true,0xffffffff,0xffffffff,false), | |
e4b6b3e7 ILT |
73 | }; |
74 | ||
75 | #ifdef DEBUG_GEN_RELOC | |
76 | #define TRACE(str) fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str) | |
77 | #else | |
78 | #define TRACE(str) | |
79 | #endif | |
80 | ||
81 | static CONST struct reloc_howto_struct * | |
82 | DEFUN (elf_i386_reloc_type_lookup, (abfd, code), | |
83 | bfd *abfd AND | |
84 | bfd_reloc_code_real_type code) | |
85 | { | |
86 | switch (code) | |
87 | { | |
88 | case BFD_RELOC_NONE: | |
89 | TRACE ("BFD_RELOC_NONE"); | |
90 | return &elf_howto_table[ (int)R_386_NONE ]; | |
91 | ||
92 | case BFD_RELOC_32: | |
93 | TRACE ("BFD_RELOC_32"); | |
94 | return &elf_howto_table[ (int)R_386_32 ]; | |
95 | ||
96 | case BFD_RELOC_32_PCREL: | |
97 | TRACE ("BFD_RELOC_PC32"); | |
98 | return &elf_howto_table[ (int)R_386_PC32 ]; | |
99 | ||
68241b2b ILT |
100 | case BFD_RELOC_386_GOT32: |
101 | TRACE ("BFD_RELOC_386_GOT32"); | |
102 | return &elf_howto_table[ (int)R_386_GOT32 ]; | |
103 | ||
104 | case BFD_RELOC_386_PLT32: | |
105 | TRACE ("BFD_RELOC_386_PLT32"); | |
106 | return &elf_howto_table[ (int)R_386_PLT32 ]; | |
107 | ||
108 | case BFD_RELOC_386_COPY: | |
109 | TRACE ("BFD_RELOC_386_COPY"); | |
110 | return &elf_howto_table[ (int)R_386_COPY ]; | |
111 | ||
112 | case BFD_RELOC_386_GLOB_DAT: | |
113 | TRACE ("BFD_RELOC_386_GLOB_DAT"); | |
114 | return &elf_howto_table[ (int)R_386_GLOB_DAT ]; | |
115 | ||
116 | case BFD_RELOC_386_JUMP_SLOT: | |
117 | TRACE ("BFD_RELOC_386_JUMP_SLOT"); | |
118 | return &elf_howto_table[ (int)R_386_JUMP_SLOT ]; | |
119 | ||
120 | case BFD_RELOC_386_RELATIVE: | |
121 | TRACE ("BFD_RELOC_386_RELATIVE"); | |
122 | return &elf_howto_table[ (int)R_386_RELATIVE ]; | |
123 | ||
124 | case BFD_RELOC_386_GOTOFF: | |
125 | TRACE ("BFD_RELOC_386_GOTOFF"); | |
126 | return &elf_howto_table[ (int)R_386_GOTOFF ]; | |
127 | ||
128 | case BFD_RELOC_386_GOTPC: | |
129 | TRACE ("BFD_RELOC_386_GOTPC"); | |
130 | return &elf_howto_table[ (int)R_386_GOTPC ]; | |
131 | ||
e4b6b3e7 | 132 | default: |
68241b2b | 133 | break; |
e4b6b3e7 ILT |
134 | } |
135 | ||
136 | TRACE ("Unknown"); | |
137 | return 0; | |
138 | } | |
139 | ||
140 | static void | |
141 | DEFUN(elf_i386_info_to_howto, (abfd, cache_ptr, dst), | |
142 | bfd *abfd AND | |
143 | arelent *cache_ptr AND | |
144 | Elf32_Internal_Rela *dst) | |
145 | { | |
68241b2b | 146 | BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max); |
e4b6b3e7 ILT |
147 | |
148 | cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)]; | |
149 | } | |
150 | ||
151 | static void | |
152 | DEFUN(elf_i386_info_to_howto_rel, (abfd, cache_ptr, dst), | |
153 | bfd *abfd AND | |
154 | arelent *cache_ptr AND | |
155 | Elf32_Internal_Rel *dst) | |
156 | { | |
68241b2b | 157 | BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max); |
e4b6b3e7 ILT |
158 | |
159 | cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)]; | |
160 | } | |
161 | ||
162 | #define TARGET_LITTLE_SYM bfd_elf32_i386_vec | |
163 | #define TARGET_LITTLE_NAME "elf32-i386" | |
164 | #define ELF_ARCH bfd_arch_i386 | |
68241b2b | 165 | #define ELF_MACHINE_CODE EM_386 |
e4b6b3e7 ILT |
166 | #define elf_info_to_howto elf_i386_info_to_howto |
167 | #define elf_info_to_howto_rel elf_i386_info_to_howto_rel | |
168 | #define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup | |
68241b2b | 169 | #define ELF_MAXPAGESIZE 0x1000 |
e4b6b3e7 ILT |
170 | |
171 | #include "elf32-target.h" |