7829440bf49ecb21f2d8529919a67843e45df371
1 // reloc.h -- relocate input files for gold -*- C++ -*-
13 class General_options
;
15 class Read_relocs_data
;
20 // A class to read the relocations for an object file, and then queue
21 // up a task to see if they require any GOT/PLT/COPY relocations in
24 class Read_relocs
: public Task
27 // SYMTAB_LOCK is used to lock the symbol table. BLOCKER should be
28 // unblocked when the Scan_relocs task completes.
29 Read_relocs(const General_options
& options
, Symbol_table
* symtab
,
30 Layout
* layout
, Relobj
* object
, Task_token
* symtab_lock
,
32 : options_(options
), symtab_(symtab
), layout_(layout
), object_(object
),
33 symtab_lock_(symtab_lock
), blocker_(blocker
)
36 // The standard Task methods.
39 is_runnable(Workqueue
*);
48 const General_options
& options_
;
49 Symbol_table
* symtab_
;
52 Task_token
* symtab_lock_
;
56 // Scan the relocations for an object to see if they require any
57 // GOT/PLT/COPY relocations.
59 class Scan_relocs
: public Task
62 // SYMTAB_LOCK is used to lock the symbol table. BLOCKER should be
63 // unblocked when the task completes.
64 Scan_relocs(const General_options
& options
, Symbol_table
* symtab
,
65 Layout
* layout
, Relobj
* object
, Read_relocs_data
* rd
,
66 Task_token
* symtab_lock
, Task_token
* blocker
)
67 : options_(options
), symtab_(symtab
), layout_(layout
), object_(object
),
68 rd_(rd
), symtab_lock_(symtab_lock
), blocker_(blocker
)
71 // The standard Task methods.
74 is_runnable(Workqueue
*);
83 class Scan_relocs_locker
;
85 const General_options
& options_
;
86 Symbol_table
* symtab_
;
89 Read_relocs_data
* rd_
;
90 Task_token
* symtab_lock_
;
94 // A class to perform all the relocations for an object file.
96 class Relocate_task
: public Task
99 Relocate_task(const General_options
& options
, const Symbol_table
* symtab
,
100 const Layout
* layout
, Relobj
* object
, Output_file
* of
,
101 Task_token
* final_blocker
)
102 : options_(options
), symtab_(symtab
), layout_(layout
), object_(object
),
103 of_(of
), final_blocker_(final_blocker
)
106 // The standard Task methods.
109 is_runnable(Workqueue
*);
118 class Relocate_locker
;
120 const General_options
& options_
;
121 const Symbol_table
* symtab_
;
122 const Layout
* layout_
;
125 Task_token
* final_blocker_
;
128 // Standard relocation routines which are used on many targets. Here
129 // SIZE and BIG_ENDIAN refer to the target, not the relocation type.
131 template<int size
, bool big_endian
>
132 class Relocate_functions
135 // Do a simple relocation with the addend in the section contents.
136 // VALSIZE is the size of the value.
137 template<int valsize
>
139 rel(unsigned char* view
,
140 typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype value
)
142 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
143 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
144 Valtype x
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
145 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, x
+ value
);
148 // Do a simple PC relative relocation with the addend in the section
149 // contents. VALSIZE is the size of the value.
150 template<int valsize
>
152 pcrel(unsigned char* view
,
153 typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype value
,
154 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
156 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
157 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
158 Valtype x
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
159 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, x
+ value
- address
);
162 typedef Relocate_functions
<size
, big_endian
> This
;
165 // Do a simple 8-bit REL relocation with the addend in the object
168 rel8(unsigned char* view
, unsigned char value
)
170 This::template rel
<8>(view
, value
);
173 // Do a simple 8-bit PC relative relocation with the addend in the
176 pcrel8(unsigned char* view
, unsigned char value
,
177 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
179 This::template pcrel
<8>(view
, value
, address
);
182 // Do a simple 16-bit REL relocation with the addend in the object
185 rel16(unsigned char* view
, elfcpp::Elf_Half value
)
187 This::template rel
<16>(view
, value
);
190 // Do a simple 32-bit PC relative REL relocation with the addend in
191 // the object file data.
193 pcrel16(unsigned char* view
, elfcpp::Elf_Word value
,
194 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
196 This::template pcrel
<16>(view
, value
, address
);
199 // Do a simple 32-bit REL relocation with the addend in the section
202 rel32(unsigned char* view
, elfcpp::Elf_Word value
)
204 This::template rel
<32>(view
, value
);
207 // Do a simple 32-bit PC relative REL relocation with the addend in
208 // the section contents.
210 pcrel32(unsigned char* view
, elfcpp::Elf_Word value
,
211 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
213 This::template pcrel
<32>(view
, value
, address
);
216 // Do a simple 64-bit REL relocation with the addend in the section
219 rel64(unsigned char* view
, elfcpp::Elf_Xword value
)
221 This::template rel
<64>(view
, value
);
224 // Do a simple 64-bit PC relative REL relocation with the addend in
225 // the section contents.
227 pcrel64(unsigned char* view
, elfcpp::Elf_Xword value
,
228 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
230 This::template pcrel
<64>(view
, value
, address
);
233 // Return whether we need a COPY reloc for a reloc against GSYM,
234 // which is being applied to section SHNDX in OBJECT.
236 need_copy_reloc(const General_options
*, Relobj
* object
, unsigned int shndx
,
240 } // End namespace gold.
242 #endif // !defined(GOLD_RELOC_H)
This page took 0.034158 seconds and 4 git commands to generate.