1 // i386.cc -- i386 target support for gold.
8 #include "target-reloc.h"
9 #include "target-select.h"
16 // The i386 target class.
18 class Target_i386
: public Sized_target
<32, false>
22 : Sized_target
<32, false>(&i386_info
)
26 relocate_section(const Symbol_table
* symtab
,
27 Sized_object
<32, false>*,
32 const elfcpp::Elf_types
<32>::Elf_Addr
*,
35 elfcpp::Elf_types
<32>::Elf_Addr
,
38 // The class which implements relocation.
42 operator()(Sized_object
<32, false>*, const elfcpp::Rel
<32, false>&,
43 unsigned int r_type
, Sized_symbol
<32>*,
44 elfcpp::Elf_types
<32>::Elf_Addr
,
45 unsigned char*, elfcpp::Elf_types
<32>::Elf_Addr
);
50 static const Target::Target_info i386_info
;
53 const Target::Target_info
Target_i386::i386_info
=
56 false, // is_big_endian
57 elfcpp::EM_386
, // machine_code
58 false, // has_make_symbol
59 false, // has_resolve,
60 0x08048000, // text_segment_address,
61 0x1000, // abi_pagesize
62 0x1000 // common_pagesize
65 // Perform a relocation.
68 Target_i386::Relocate::operator()(Sized_object
<32, false>* object
,
69 const elfcpp::Rel
<32, false>&,
72 elfcpp::Elf_types
<32>::Elf_Addr value
,
74 elfcpp::Elf_types
<32>::Elf_Addr address
)
78 case elfcpp::R_386_NONE
:
81 case elfcpp::R_386_32
:
83 elfcpp::Elf_Word
* wv
= reinterpret_cast<elfcpp::Elf_Word
*>(view
);
84 unsigned int x
= elfcpp::read_elf_word
<false>(wv
);
85 elfcpp::write_elf_word
<false>(wv
, x
+ value
);
89 case elfcpp::R_386_PC32
:
91 elfcpp::Elf_Word
* wv
= reinterpret_cast<elfcpp::Elf_Word
*>(view
);
92 unsigned int x
= elfcpp::read_elf_word
<false>(wv
);
93 elfcpp::write_elf_word
<false>(wv
, x
+ value
- address
);
98 fprintf(stderr
, _("%s: %s: unsupported reloc %u\n"),
99 program_name
, object
->name().c_str(), r_type
);
104 // Relocate section data.
107 Target_i386::relocate_section(const Symbol_table
* symtab
,
108 Sized_object
<32, false>* object
,
109 unsigned int sh_type
,
110 const unsigned char* prelocs
,
112 unsigned int local_count
,
113 const elfcpp::Elf_types
<32>::Elf_Addr
* values
,
114 Symbol
** global_syms
,
116 elfcpp::Elf_types
<32>::Elf_Addr address
,
119 if (sh_type
== elfcpp::SHT_RELA
)
121 fprintf(stderr
, _("%s: %s: unsupported RELA reloc section\n"),
122 program_name
, object
->name().c_str());
126 gold::relocate_section
<32, false, elfcpp::SHT_REL
, Target_i386::Relocate
>(
141 Target_i386 target_i386
;
143 // The selector for i386 object files.
145 class Target_selector_i386
: public Target_selector
148 Target_selector_i386()
149 : Target_selector(elfcpp::EM_386
, 32, false)
153 recognize(int machine
, int osabi
, int abiversion
) const;
156 // Recognize an i386 object file when we already know that the machine
160 Target_selector_i386::recognize(int, int, int) const
165 Target_selector_i386 target_selector_i386
;
167 } // End anonymous namespace.