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. */
25 #define USE_REL 1 /* 386 uses REL relocations instead of RELA */
44 static CONST char *CONST reloc_type_names[] =
60 static reloc_howto_type elf_howto_table[]=
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),
75 #ifdef DEBUG_GEN_RELOC
76 #define TRACE(str) fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
81 static CONST struct reloc_howto_struct *
82 DEFUN (elf_i386_reloc_type_lookup, (abfd, code),
84 bfd_reloc_code_real_type code)
89 TRACE ("BFD_RELOC_NONE");
90 return &elf_howto_table[ (int)R_386_NONE ];
93 TRACE ("BFD_RELOC_32");
94 return &elf_howto_table[ (int)R_386_32 ];
96 case BFD_RELOC_32_PCREL:
97 TRACE ("BFD_RELOC_PC32");
98 return &elf_howto_table[ (int)R_386_PC32 ];
100 case BFD_RELOC_386_GOT32:
101 TRACE ("BFD_RELOC_386_GOT32");
102 return &elf_howto_table[ (int)R_386_GOT32 ];
104 case BFD_RELOC_386_PLT32:
105 TRACE ("BFD_RELOC_386_PLT32");
106 return &elf_howto_table[ (int)R_386_PLT32 ];
108 case BFD_RELOC_386_COPY:
109 TRACE ("BFD_RELOC_386_COPY");
110 return &elf_howto_table[ (int)R_386_COPY ];
112 case BFD_RELOC_386_GLOB_DAT:
113 TRACE ("BFD_RELOC_386_GLOB_DAT");
114 return &elf_howto_table[ (int)R_386_GLOB_DAT ];
116 case BFD_RELOC_386_JUMP_SLOT:
117 TRACE ("BFD_RELOC_386_JUMP_SLOT");
118 return &elf_howto_table[ (int)R_386_JUMP_SLOT ];
120 case BFD_RELOC_386_RELATIVE:
121 TRACE ("BFD_RELOC_386_RELATIVE");
122 return &elf_howto_table[ (int)R_386_RELATIVE ];
124 case BFD_RELOC_386_GOTOFF:
125 TRACE ("BFD_RELOC_386_GOTOFF");
126 return &elf_howto_table[ (int)R_386_GOTOFF ];
128 case BFD_RELOC_386_GOTPC:
129 TRACE ("BFD_RELOC_386_GOTPC");
130 return &elf_howto_table[ (int)R_386_GOTPC ];
141 DEFUN(elf_i386_info_to_howto, (abfd, cache_ptr, dst),
143 arelent *cache_ptr AND
144 Elf32_Internal_Rela *dst)
146 BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
148 cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
152 DEFUN(elf_i386_info_to_howto_rel, (abfd, cache_ptr, dst),
154 arelent *cache_ptr AND
155 Elf32_Internal_Rel *dst)
157 BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
159 cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
162 #define TARGET_LITTLE_SYM bfd_elf32_i386_vec
163 #define TARGET_LITTLE_NAME "elf32-i386"
164 #define ELF_ARCH bfd_arch_i386
165 #define ELF_MACHINE_CODE EM_386
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
169 #define ELF_MAXPAGESIZE 0x1000
171 #include "elf32-target.h"