Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Elf.h
Go to the documentation of this file.
1#ifndef HALIDE_ELF_H
2#define HALIDE_ELF_H
3
4#include <algorithm>
5#include <cstdint>
6#include <iterator>
7#include <list>
8#include <memory>
9#include <string>
10#include <utility>
11#include <vector>
12
13 namespace Halide {
14 namespace Internal {
15 namespace Elf {
16
17// This ELF parser mostly deserializes the object into a graph
18// structure in memory. It replaces indices into tables (sections,
19// symbols, etc.) with a weakly referenced graph of pointers. The
20// Object datastructure owns all of the objects. This namespace exists
21// because it is very difficult to use LLVM's object parser to modify
22// an object (it's fine for parsing only). This was built using
23// http://www.skyfree.org/linux/references/ELF_Format.pdf as a reference
24// for the ELF structs and constants.
25
26 class Object;
27 class Symbol;
28 class Section;
29 class Relocation;
30
31// Helpful wrapper to allow range-based for loops.
32 template<typename T>
33 class iterator_range {
34 T b, e;
35
36 public:
37 iterator_range(T b, T e)
38 : b(b), e(e) {
39 }
40
41 T begin() const {
42 return b;
43 }
44 T end() const {
45 return e;
46 }
47};
48
49/** Describes a symbol */
50 class Symbol {
51 public:
52 enum Binding : uint8_t {
53 STB_LOCAL = 0,
54 STB_GLOBAL = 1,
55 STB_WEAK = 2,
56 STB_LOPROC = 13,
57 STB_HIPROC = 15,
58 };
59
60 enum Type : uint8_t {
61 STT_NOTYPE = 0,
62 STT_OBJECT = 1,
63 STT_FUNC = 2,
64 STT_SECTION = 3,
65 STT_FILE = 4,
66 STT_LOPROC = 13,
67 STT_HIPROC = 15,
68 };
69
70 enum Visibility : uint8_t {
71 STV_DEFAULT = 0,
72 STV_INTERNAL = 1,
73 STV_HIDDEN = 2,
74 STV_PROTECTED = 3,
75 };
76
77 private:
78 std::string name;
79 const Section *definition = nullptr;
80 uint64_t offset = 0;
81 uint32_t size = 0;
82 Binding binding = STB_LOCAL;
83 Type type = STT_NOTYPE;
84 Visibility visibility = STV_DEFAULT;
85
86 public:
87 Symbol() = default;
88 Symbol(const std::string &name)
89 : name(name) {
90 }
91
92 /** Accesses the name of this symbol. */
93 ///@{
94 Symbol &set_name(const std::string &name) {
95 this->name = name;
96 return *this;
97 }
98 const std::string &get_name() const {
99 return name;
100 }
101 ///@}
102
103 /** Accesses the type of this symbol. */
104 ///@{
105 Symbol &set_type(Type type) {
106 this->type = type;
107 return *this;
108 }
109 Type get_type() const {
110 return type;
111 }
112 ///@}
113
114 /** Accesses the properties that describe the definition of this symbol. */
115 ///@{
116 Symbol &define(const Section *section, uint64_t offset, uint32_t size) {
117 this->definition = section;
118 this->offset = offset;
119 this->size = size;
120 return *this;
121 }
122 bool is_defined() const {
123 return definition != nullptr;
124 }
125 const Section *get_section() const {
126 return definition;
127 }
128 uint64_t get_offset() const {
129 return offset;
130 }
131 uint32_t get_size() const {
132 return size;
133 }
134 ///@}
135
136 /** Access the binding and visibility of this symbol. See the ELF
137 * spec for more information about these properties. */
138 ///@{
139 Symbol &set_binding(Binding binding) {
140 this->binding = binding;
141 return *this;
142 }
143 Symbol &set_visibility(Visibility visibility) {
144 this->visibility = visibility;
145 return *this;
146 }
147 Binding get_binding() const {
148 return binding;
149 }
150 Visibility get_visibility() const {
151 return visibility;
152 }
153 ///@}
154};
155
156/** Describes a relocation to be applied to an offset of a section in
157 * an Object. */
158 class Relocation {
159 uint32_t type = 0;
160 uint64_t offset = 0;
161 int64_t addend = 0;
162 const Symbol *symbol = nullptr;
163
164 public:
165 Relocation() = default;
166 Relocation(uint32_t type, uint64_t offset, int64_t addend, const Symbol *symbol)
167 : type(type), offset(offset), addend(addend), symbol(symbol) {
168 }
169
170 /** The type of relocation to be applied. The meaning of this
171 * value depends on the machine of the object. */
172 ///@{
173 Relocation &set_type(uint32_t type) {
174 this->type = type;
175 return *this;
176 }
177 uint32_t get_type() const {
178 return type;
179 }
180 ///@}
181
182 /** Where to apply the relocation. This is relative to the section
183 * the relocation belongs to. */
184 ///@{
185 Relocation &set_offset(uint64_t offset) {
186 this->offset = offset;
187 return *this;
188 }
189 uint64_t get_offset() const {
190 return offset;
191 }
192 ///@}
193
194 /** The value to replace with the relocation is the address of the symbol plus the addend. */
195 ///@{
196 Relocation &set_symbol(const Symbol *symbol) {
197 this->symbol = symbol;
198 return *this;
199 }
200 Relocation &set_addend(int64_t addend) {
201 this->addend = addend;
202 return *this;
203 }
204 const Symbol *get_symbol() const {
205 return symbol;
206 }
207 int64_t get_addend() const {
208 return addend;
209 }
210 ///@}
211};
212
213/** Describes a section of an object file. */
214 class Section {
215 public:
216 enum Type : uint32_t {
217 SHT_NULL = 0,
218 SHT_PROGBITS = 1,
219 SHT_SYMTAB = 2,
220 SHT_STRTAB = 3,
221 SHT_RELA = 4,
222 SHT_HASH = 5,
223 SHT_DYNAMIC = 6,
224 SHT_NOTE = 7,
225 SHT_NOBITS = 8,
226 SHT_REL = 9,
227 SHT_SHLIB = 10,
228 SHT_DYNSYM = 11,
229 SHT_LOPROC = 0x70000000u,
230 SHT_HIPROC = 0x7fffffffu,
231 SHT_LOUSER = 0x80000000u,
232 SHT_HIUSER = 0xffffffffu,
233 };
234
235 enum Flag : uint32_t {
236 SHF_WRITE = 0x1,
237 SHF_ALLOC = 0x2,
238 SHF_EXECINSTR = 0x4,
239 SHF_MASKPROC = 0xf0000000u,
240 };
241
242 typedef std::vector<Relocation> RelocationList;
243 typedef RelocationList::iterator relocation_iterator;
244 typedef RelocationList::const_iterator const_relocation_iterator;
245
246 typedef std::vector<char>::iterator contents_iterator;
247 typedef std::vector<char>::const_iterator const_contents_iterator;
248
249 private:
250 std::string name;
251 Type type = SHT_NULL;
252 uint32_t flags = 0;
253 std::vector<char> contents;
254 // Sections may have a size larger than the contents.
255 uint64_t size = 0;
256 uint64_t alignment = 1;
257 RelocationList relocs;
258
259 public:
260 Section() = default;
261 Section(const std::string &name, Type type)
262 : name(name), type(type) {
263 }
264
265 Section &set_name(const std::string &name) {
266 this->name = name;
267 return *this;
268 }
269 const std::string &get_name() const {
270 return name;
271 }
272
273 Section &set_type(Type type) {
274 this->type = type;
275 return *this;
276 }
277 Type get_type() const {
278 return type;
279 }
280
281 Section &set_flag(Flag flag) {
282 this->flags |= flag;
283 return *this;
284 }
285 Section &remove_flag(Flag flag) {
286 this->flags &= ~flag;
287 return *this;
288 }
289 Section &set_flags(uint32_t flags) {
290 this->flags = flags;
291 return *this;
292 }
293 uint32_t get_flags() const {
294 return flags;
295 }
296 bool is_alloc() const {
297 return (flags & SHF_ALLOC) != 0;
298 }
299 bool is_writable() const {
300 return (flags & SHF_WRITE) != 0;
301 }
302
303 /** Get or set the size of the section. The size may be larger
304 * than the content. */
305 ///@{
306 Section &set_size(uint64_t size) {
307 this->size = size;
308 return *this;
309 }
310 uint64_t get_size() const {
311 return std::max((uint64_t)size, (uint64_t)contents.size());
312 }
313 ///@}
314
315 Section &set_alignment(uint64_t alignment) {
316 this->alignment = alignment;
317 return *this;
318 }
319 uint64_t get_alignment() const {
320 return alignment;
321 }
322
323 Section &set_contents(std::vector<char> contents) {
324 this->contents = std::move(contents);
325 return *this;
326 }
327 template<typename It>
328 Section &set_contents(It begin, It end) {
329 this->contents.assign(begin, end);
330 return *this;
331 }
332 template<typename It>
333 Section &append_contents(It begin, It end) {
334 this->contents.insert(this->contents.end(), begin, end);
335 return *this;
336 }
337 template<typename It>
338 Section &prepend_contents(It begin, It end) {
339 typedef typename std::iterator_traits<It>::value_type T;
340 uint64_t size_bytes = std::distance(begin, end) * sizeof(T);
341 this->contents.insert(this->contents.begin(), begin, end);
342
343 // When we add data to the start of the section, we need to fix up
344 // the offsets of the relocations linked to this section.
345 for (Relocation &r : relocations()) {
346 r.set_offset(r.get_offset() + size_bytes);
347 }
348
349 return *this;
350 }
351 /** Set, append or prepend an object to the contents, assuming T is a
352 * trivially copyable datatype. */
353 template<typename T>
354 Section &set_contents(const std::vector<T> &contents) {
355 this->contents.assign((const char *)contents.data(), (const char *)(contents.data() + contents.size()));
356 return *this;
357 }
358 template<typename T>
359 Section &append_contents(const T &x) {
360 return append_contents((const char *)&x, (const char *)(&x + 1));
361 }
362 template<typename T>
363 Section &prepend_contents(const T &x) {
364 return prepend_contents((const char *)&x, (const char *)(&x + 1));
365 }
366 const std::vector<char> &get_contents() const {
367 return contents;
368 }
369 contents_iterator contents_begin() {
370 return contents.begin();
371 }
372 contents_iterator contents_end() {
373 return contents.end();
374 }
375 const_contents_iterator contents_begin() const {
376 return contents.begin();
377 }
378 const_contents_iterator contents_end() const {
379 return contents.end();
380 }
381 const char *contents_data() const {
382 return contents.data();
383 }
384 size_t contents_size() const {
385 return contents.size();
386 }
387 bool contents_empty() const {
388 return contents.empty();
389 }
390
391 Section &set_relocations(std::vector<Relocation> relocs) {
392 this->relocs = std::move(relocs);
393 return *this;
394 }
395 template<typename It>
396 Section &set_relocations(It begin, It end) {
397 this->relocs.assign(begin, end);
398 return *this;
399 }
400 void add_relocation(const Relocation &reloc) {
401 relocs.push_back(reloc);
402 }
403 relocation_iterator relocations_begin() {
404 return relocs.begin();
405 }
406 relocation_iterator relocations_end() {
407 return relocs.end();
408 }
409 iterator_range<relocation_iterator> relocations() {
410 return {relocs.begin(), relocs.end()};
411 }
412 const_relocation_iterator relocations_begin() const {
413 return relocs.begin();
414 }
415 const_relocation_iterator relocations_end() const {
416 return relocs.end();
417 }
418 iterator_range<const_relocation_iterator> relocations() const {
419 return {relocs.begin(), relocs.end()};
420 }
421 size_t relocations_size() const {
422 return relocs.size();
423 }
424};
425
426/** Base class for a target architecture to implement the target
427 * specific aspects of linking. */
428 class Linker {
429 public:
430 virtual ~Linker() = default;
431
432 virtual uint16_t get_machine() = 0;
433 virtual uint32_t get_flags() = 0;
434 virtual uint32_t get_version() = 0;
435 virtual void append_dynamic(Section &dynamic) = 0;
436
437 /** Add or get an entry to the global offset table (GOT) with a
438 * relocation pointing to sym. */
439 virtual uint64_t get_got_entry(Section &got, const Symbol &sym) = 0;
440
441 /** Check to see if this relocation should go through the PLT. */
442 virtual bool needs_plt_entry(const Relocation &reloc) = 0;
443
444 /** Add a PLT entry for a symbol sym defined externally. Returns a
445 * symbol representing the PLT entry. */
446 virtual Symbol add_plt_entry(const Symbol &sym, Section &plt, Section &got,
447 const Symbol &got_sym) = 0;
448
449 /** Perform a relocation. This function may opt to not apply the
450 * relocation, and return a new relocation to be performed at
451 * runtime. This requires that the section to apply the relocation
452 * to is writable at runtime. */
453 virtual Relocation relocate(uint64_t fixup_offset, char *fixup_addr, uint64_t type,
454 const Symbol *sym, uint64_t sym_offset, int64_t addend,
455 Section &got) = 0;
456};
457
458/** Holds all of the relevant sections and symbols for an object. */
459 class Object {
460 public:
461 enum Type : uint16_t {
462 ET_NONE = 0,
463 ET_REL = 1,
464 ET_EXEC = 2,
465 ET_DYN = 3,
466 ET_CORE = 4,
467 ET_LOPROC = 0xff00u,
468 ET_HIPROC = 0xffffu,
469 };
470
471 // We use lists for sections and symbols to avoid iterator
472 // invalidation when we modify the containers.
473 typedef std::list<Section> SectionList;
474 typedef typename SectionList::iterator section_iterator;
475 typedef typename SectionList::const_iterator const_section_iterator;
476
477 typedef std::list<Symbol> SymbolList;
478 typedef typename SymbolList::iterator symbol_iterator;
479 typedef typename SymbolList::const_iterator const_symbol_iterator;
480
481 private:
482 SectionList secs;
483 SymbolList syms;
484
485 Type type = ET_NONE;
486 uint16_t machine = 0;
487 uint32_t version = 0;
488 uint64_t entry = 0;
489 uint32_t flags = 0;
490
491 Object(const Object &);
492 void operator=(const Object &);
493
494 public:
495 Object() = default;
496
497 Type get_type() const {
498 return type;
499 }
500 uint16_t get_machine() const {
501 return machine;
502 }
503 uint32_t get_version() const {
504 return version;
505 }
506 uint64_t get_entry() const {
507 return entry;
508 }
509 uint32_t get_flags() const {
510 return flags;
511 }
512
513 Object &set_type(Type type) {
514 this->type = type;
515 return *this;
516 }
517 Object &set_machine(uint16_t machine) {
518 this->machine = machine;
519 return *this;
520 }
521 Object &set_version(uint32_t version) {
522 this->version = version;
523 return *this;
524 }
525 Object &set_entry(uint64_t entry) {
526 this->entry = entry;
527 return *this;
528 }
529 Object &set_flags(uint32_t flags) {
530 this->flags = flags;
531 return *this;
532 }
533
534 /** Parse an object in memory to an Object. */
535 static std::unique_ptr<Object> parse_object(const char *data, size_t size);
536
537 /** Write a shared object in memory. */
538 std::vector<char> write_shared_object(Linker *linker, const std::vector<std::string> &depedencies = {},
539 const std::string &soname = "");
540
541 section_iterator sections_begin() {
542 return secs.begin();
543 }
544 section_iterator sections_end() {
545 return secs.end();
546 }
547 iterator_range<section_iterator> sections() {
548 return {secs.begin(), secs.end()};
549 }
550 const_section_iterator sections_begin() const {
551 return secs.begin();
552 }
553 const_section_iterator sections_end() const {
554 return secs.end();
555 }
556 iterator_range<const_section_iterator> sections() const {
557 return {secs.begin(), secs.end()};
558 }
559 size_t sections_size() const {
560 return secs.size();
561 }
562 section_iterator find_section(const std::string &name);
563
564 section_iterator add_section(const std::string &name, Section::Type type);
565 section_iterator add_relocation_section(const Section &for_section);
566 section_iterator erase_section(section_iterator i) {
567 return secs.erase(i);
568 }
569
570 section_iterator merge_sections(const std::vector<section_iterator> &sections);
571 section_iterator merge_text_sections();
572
573 symbol_iterator symbols_begin() {
574 return syms.begin();
575 }
576 symbol_iterator symbols_end() {
577 return syms.end();
578 }
579 iterator_range<symbol_iterator> symbols() {
580 return {syms.begin(), syms.end()};
581 }
582 const_symbol_iterator symbols_begin() const {
583 return syms.begin();
584 }
585 const_symbol_iterator symbols_end() const {
586 return syms.end();
587 }
588 iterator_range<const_symbol_iterator> symbols() const {
589 return {syms.begin(), syms.end()};
590 }
591 size_t symbols_size() const {
592 return syms.size();
593 }
594 symbol_iterator find_symbol(const std::string &name);
595 const_symbol_iterator find_symbol(const std::string &name) const;
596
597 symbol_iterator add_symbol(const std::string &name);
598};
599
600} // namespace Elf
601} // namespace Internal
602} // namespace Halide
603
604#endif
Halide::Internal::Elf::Linker
Base class for a target architecture to implement the target specific aspects of linking.
Definition Elf.h:428
Halide::Internal::Elf::Linker::add_plt_entry
virtual Symbol add_plt_entry(const Symbol &sym, Section &plt, Section &got, const Symbol &got_sym)=0
Add a PLT entry for a symbol sym defined externally.
Halide::Internal::Elf::Linker::append_dynamic
virtual void append_dynamic(Section &dynamic)=0
Halide::Internal::Elf::Linker::needs_plt_entry
virtual bool needs_plt_entry(const Relocation &reloc)=0
Check to see if this relocation should go through the PLT.
Halide::Internal::Elf::Linker::get_flags
virtual uint32_t get_flags()=0
Halide::Internal::Elf::Linker::~Linker
virtual ~Linker()=default
Halide::Internal::Elf::Linker::get_version
virtual uint32_t get_version()=0
Halide::Internal::Elf::Linker::get_got_entry
virtual uint64_t get_got_entry(Section &got, const Symbol &sym)=0
Add or get an entry to the global offset table (GOT) with a relocation pointing to sym.
Halide::Internal::Elf::Linker::get_machine
virtual uint16_t get_machine()=0
Halide::Internal::Elf::Linker::relocate
virtual Relocation relocate(uint64_t fixup_offset, char *fixup_addr, uint64_t type, const Symbol *sym, uint64_t sym_offset, int64_t addend, Section &got)=0
Perform a relocation.
Halide::Internal::Elf::Object
Holds all of the relevant sections and symbols for an object.
Definition Elf.h:459
Halide::Internal::Elf::Object::get_machine
uint16_t get_machine() const
Definition Elf.h:500
Halide::Internal::Elf::Object::symbols_end
symbol_iterator symbols_end()
Definition Elf.h:576
Halide::Internal::Elf::Object::Type
Type
Definition Elf.h:461
Halide::Internal::Elf::Object::ET_CORE
@ ET_CORE
Definition Elf.h:466
Halide::Internal::Elf::Object::ET_NONE
@ ET_NONE
Definition Elf.h:462
Halide::Internal::Elf::Object::ET_REL
@ ET_REL
Definition Elf.h:463
Halide::Internal::Elf::Object::ET_DYN
@ ET_DYN
Definition Elf.h:465
Halide::Internal::Elf::Object::ET_EXEC
@ ET_EXEC
Definition Elf.h:464
Halide::Internal::Elf::Object::ET_HIPROC
@ ET_HIPROC
Definition Elf.h:468
Halide::Internal::Elf::Object::ET_LOPROC
@ ET_LOPROC
Definition Elf.h:467
Halide::Internal::Elf::Object::erase_section
section_iterator erase_section(section_iterator i)
Definition Elf.h:566
Halide::Internal::Elf::Object::set_type
Object & set_type(Type type)
Definition Elf.h:513
Halide::Internal::Elf::Object::find_symbol
symbol_iterator find_symbol(const std::string &name)
Halide::Internal::Elf::Object::set_flags
Object & set_flags(uint32_t flags)
Definition Elf.h:529
Halide::Internal::Elf::Object::sections_begin
const_section_iterator sections_begin() const
Definition Elf.h:550
Halide::Internal::Elf::Object::sections_end
section_iterator sections_end()
Definition Elf.h:544
Halide::Internal::Elf::Object::parse_object
static std::unique_ptr< Object > parse_object(const char *data, size_t size)
Parse an object in memory to an Object.
Halide::Internal::Elf::Object::const_symbol_iterator
SymbolList::const_iterator const_symbol_iterator
Definition Elf.h:479
Halide::Internal::Elf::Object::sections
iterator_range< const_section_iterator > sections() const
Definition Elf.h:556
Halide::Internal::Elf::Object::set_entry
Object & set_entry(uint64_t entry)
Definition Elf.h:525
Halide::Internal::Elf::Object::find_section
section_iterator find_section(const std::string &name)
Halide::Internal::Elf::Object::write_shared_object
std::vector< char > write_shared_object(Linker *linker, const std::vector< std::string > &depedencies={}, const std::string &soname="")
Write a shared object in memory.
Halide::Internal::Elf::Object::sections
iterator_range< section_iterator > sections()
Definition Elf.h:547
Halide::Internal::Elf::Object::symbols
iterator_range< symbol_iterator > symbols()
Definition Elf.h:579
Halide::Internal::Elf::Object::add_section
section_iterator add_section(const std::string &name, Section::Type type)
Halide::Internal::Elf::Object::get_flags
uint32_t get_flags() const
Definition Elf.h:509
Halide::Internal::Elf::Object::set_machine
Object & set_machine(uint16_t machine)
Definition Elf.h:517
Halide::Internal::Elf::Object::symbol_iterator
SymbolList::iterator symbol_iterator
Definition Elf.h:478
Halide::Internal::Elf::Object::get_type
Type get_type() const
Definition Elf.h:497
Halide::Internal::Elf::Object::Object
Object()=default
Halide::Internal::Elf::Object::find_symbol
const_symbol_iterator find_symbol(const std::string &name) const
Halide::Internal::Elf::Object::sections_end
const_section_iterator sections_end() const
Definition Elf.h:553
Halide::Internal::Elf::Object::const_section_iterator
SectionList::const_iterator const_section_iterator
Definition Elf.h:475
Halide::Internal::Elf::Object::symbols_begin
const_symbol_iterator symbols_begin() const
Definition Elf.h:582
Halide::Internal::Elf::Object::set_version
Object & set_version(uint32_t version)
Definition Elf.h:521
Halide::Internal::Elf::Object::add_relocation_section
section_iterator add_relocation_section(const Section &for_section)
Halide::Internal::Elf::Object::symbols_size
size_t symbols_size() const
Definition Elf.h:591
Halide::Internal::Elf::Object::merge_text_sections
section_iterator merge_text_sections()
Halide::Internal::Elf::Object::get_entry
uint64_t get_entry() const
Definition Elf.h:506
Halide::Internal::Elf::Object::merge_sections
section_iterator merge_sections(const std::vector< section_iterator > &sections)
Halide::Internal::Elf::Object::symbols_end
const_symbol_iterator symbols_end() const
Definition Elf.h:585
Halide::Internal::Elf::Object::SymbolList
std::list< Symbol > SymbolList
Definition Elf.h:477
Halide::Internal::Elf::Object::add_symbol
symbol_iterator add_symbol(const std::string &name)
Halide::Internal::Elf::Object::symbols_begin
symbol_iterator symbols_begin()
Definition Elf.h:573
Halide::Internal::Elf::Object::sections_size
size_t sections_size() const
Definition Elf.h:559
Halide::Internal::Elf::Object::get_version
uint32_t get_version() const
Definition Elf.h:503
Halide::Internal::Elf::Object::sections_begin
section_iterator sections_begin()
Definition Elf.h:541
Halide::Internal::Elf::Object::section_iterator
SectionList::iterator section_iterator
Definition Elf.h:474
Halide::Internal::Elf::Object::symbols
iterator_range< const_symbol_iterator > symbols() const
Definition Elf.h:588
Halide::Internal::Elf::Object::SectionList
std::list< Section > SectionList
Definition Elf.h:473
Halide::Internal::Elf::Relocation
Describes a relocation to be applied to an offset of a section in an Object.
Definition Elf.h:158
Halide::Internal::Elf::Relocation::get_addend
int64_t get_addend() const
The value to replace with the relocation is the address of the symbol plus the addend.
Definition Elf.h:207
Halide::Internal::Elf::Relocation::Relocation
Relocation(uint32_t type, uint64_t offset, int64_t addend, const Symbol *symbol)
Definition Elf.h:166
Halide::Internal::Elf::Relocation::Relocation
Relocation()=default
Halide::Internal::Elf::Relocation::set_symbol
Relocation & set_symbol(const Symbol *symbol)
The value to replace with the relocation is the address of the symbol plus the addend.
Definition Elf.h:196
Halide::Internal::Elf::Relocation::set_type
Relocation & set_type(uint32_t type)
The type of relocation to be applied.
Definition Elf.h:173
Halide::Internal::Elf::Relocation::set_addend
Relocation & set_addend(int64_t addend)
The value to replace with the relocation is the address of the symbol plus the addend.
Definition Elf.h:200
Halide::Internal::Elf::Relocation::get_offset
uint64_t get_offset() const
Where to apply the relocation.
Definition Elf.h:189
Halide::Internal::Elf::Relocation::set_offset
Relocation & set_offset(uint64_t offset)
Where to apply the relocation.
Definition Elf.h:185
Halide::Internal::Elf::Relocation::get_symbol
const Symbol * get_symbol() const
The value to replace with the relocation is the address of the symbol plus the addend.
Definition Elf.h:204
Halide::Internal::Elf::Relocation::get_type
uint32_t get_type() const
The type of relocation to be applied.
Definition Elf.h:177
Halide::Internal::Elf::Section
Describes a section of an object file.
Definition Elf.h:214
Halide::Internal::Elf::Section::Flag
Flag
Definition Elf.h:235
Halide::Internal::Elf::Section::SHF_MASKPROC
@ SHF_MASKPROC
Definition Elf.h:239
Halide::Internal::Elf::Section::SHF_EXECINSTR
@ SHF_EXECINSTR
Definition Elf.h:238
Halide::Internal::Elf::Section::SHF_WRITE
@ SHF_WRITE
Definition Elf.h:236
Halide::Internal::Elf::Section::SHF_ALLOC
@ SHF_ALLOC
Definition Elf.h:237
Halide::Internal::Elf::Section::contents_empty
bool contents_empty() const
Definition Elf.h:387
Halide::Internal::Elf::Section::prepend_contents
Section & prepend_contents(It begin, It end)
Definition Elf.h:338
Halide::Internal::Elf::Section::relocations_size
size_t relocations_size() const
Definition Elf.h:421
Halide::Internal::Elf::Section::append_contents
Section & append_contents(It begin, It end)
Definition Elf.h:333
Halide::Internal::Elf::Section::get_alignment
uint64_t get_alignment() const
Definition Elf.h:319
Halide::Internal::Elf::Section::Section
Section()=default
Halide::Internal::Elf::Section::contents_size
size_t contents_size() const
Definition Elf.h:384
Halide::Internal::Elf::Section::set_contents
Section & set_contents(const std::vector< T > &contents)
Set, append or prepend an object to the contents, assuming T is a trivially copyable datatype.
Definition Elf.h:354
Halide::Internal::Elf::Section::relocations_end
relocation_iterator relocations_end()
Definition Elf.h:406
Halide::Internal::Elf::Section::get_flags
uint32_t get_flags() const
Definition Elf.h:293
Halide::Internal::Elf::Section::set_relocations
Section & set_relocations(std::vector< Relocation > relocs)
Definition Elf.h:391
Halide::Internal::Elf::Section::set_contents
Section & set_contents(std::vector< char > contents)
Definition Elf.h:323
Halide::Internal::Elf::Section::get_size
uint64_t get_size() const
Get or set the size of the section.
Definition Elf.h:310
Halide::Internal::Elf::Section::set_flags
Section & set_flags(uint32_t flags)
Definition Elf.h:289
Halide::Internal::Elf::Section::contents_iterator
std::vector< char >::iterator contents_iterator
Definition Elf.h:246
Halide::Internal::Elf::Section::relocations_begin
relocation_iterator relocations_begin()
Definition Elf.h:403
Halide::Internal::Elf::Section::add_relocation
void add_relocation(const Relocation &reloc)
Definition Elf.h:400
Halide::Internal::Elf::Section::get_contents
const std::vector< char > & get_contents() const
Definition Elf.h:366
Halide::Internal::Elf::Section::relocation_iterator
RelocationList::iterator relocation_iterator
Definition Elf.h:243
Halide::Internal::Elf::Section::const_relocation_iterator
RelocationList::const_iterator const_relocation_iterator
Definition Elf.h:244
Halide::Internal::Elf::Section::set_contents
Section & set_contents(It begin, It end)
Definition Elf.h:328
Halide::Internal::Elf::Section::contents_begin
const_contents_iterator contents_begin() const
Definition Elf.h:375
Halide::Internal::Elf::Section::set_size
Section & set_size(uint64_t size)
Get or set the size of the section.
Definition Elf.h:306
Halide::Internal::Elf::Section::contents_begin
contents_iterator contents_begin()
Definition Elf.h:369
Halide::Internal::Elf::Section::get_name
const std::string & get_name() const
Definition Elf.h:269
Halide::Internal::Elf::Section::contents_end
contents_iterator contents_end()
Definition Elf.h:372
Halide::Internal::Elf::Section::relocations_begin
const_relocation_iterator relocations_begin() const
Definition Elf.h:412
Halide::Internal::Elf::Section::relocations
iterator_range< relocation_iterator > relocations()
Definition Elf.h:409
Halide::Internal::Elf::Section::set_type
Section & set_type(Type type)
Definition Elf.h:273
Halide::Internal::Elf::Section::const_contents_iterator
std::vector< char >::const_iterator const_contents_iterator
Definition Elf.h:247
Halide::Internal::Elf::Section::remove_flag
Section & remove_flag(Flag flag)
Definition Elf.h:285
Halide::Internal::Elf::Section::append_contents
Section & append_contents(const T &x)
Definition Elf.h:359
Halide::Internal::Elf::Section::Section
Section(const std::string &name, Type type)
Definition Elf.h:261
Halide::Internal::Elf::Section::set_flag
Section & set_flag(Flag flag)
Definition Elf.h:281
Halide::Internal::Elf::Section::set_name
Section & set_name(const std::string &name)
Definition Elf.h:265
Halide::Internal::Elf::Section::get_type
Type get_type() const
Definition Elf.h:277
Halide::Internal::Elf::Section::RelocationList
std::vector< Relocation > RelocationList
Definition Elf.h:242
Halide::Internal::Elf::Section::is_writable
bool is_writable() const
Definition Elf.h:299
Halide::Internal::Elf::Section::is_alloc
bool is_alloc() const
Definition Elf.h:296
Halide::Internal::Elf::Section::prepend_contents
Section & prepend_contents(const T &x)
Definition Elf.h:363
Halide::Internal::Elf::Section::contents_end
const_contents_iterator contents_end() const
Definition Elf.h:378
Halide::Internal::Elf::Section::set_relocations
Section & set_relocations(It begin, It end)
Definition Elf.h:396
Halide::Internal::Elf::Section::relocations_end
const_relocation_iterator relocations_end() const
Definition Elf.h:415
Halide::Internal::Elf::Section::relocations
iterator_range< const_relocation_iterator > relocations() const
Definition Elf.h:418
Halide::Internal::Elf::Section::contents_data
const char * contents_data() const
Definition Elf.h:381
Halide::Internal::Elf::Section::Type
Type
Definition Elf.h:216
Halide::Internal::Elf::Section::SHT_NULL
@ SHT_NULL
Definition Elf.h:217
Halide::Internal::Elf::Section::SHT_STRTAB
@ SHT_STRTAB
Definition Elf.h:220
Halide::Internal::Elf::Section::SHT_NOTE
@ SHT_NOTE
Definition Elf.h:224
Halide::Internal::Elf::Section::SHT_SHLIB
@ SHT_SHLIB
Definition Elf.h:227
Halide::Internal::Elf::Section::SHT_DYNAMIC
@ SHT_DYNAMIC
Definition Elf.h:223
Halide::Internal::Elf::Section::SHT_HIUSER
@ SHT_HIUSER
Definition Elf.h:232
Halide::Internal::Elf::Section::SHT_NOBITS
@ SHT_NOBITS
Definition Elf.h:225
Halide::Internal::Elf::Section::SHT_LOPROC
@ SHT_LOPROC
Definition Elf.h:229
Halide::Internal::Elf::Section::SHT_PROGBITS
@ SHT_PROGBITS
Definition Elf.h:218
Halide::Internal::Elf::Section::SHT_SYMTAB
@ SHT_SYMTAB
Definition Elf.h:219
Halide::Internal::Elf::Section::SHT_REL
@ SHT_REL
Definition Elf.h:226
Halide::Internal::Elf::Section::SHT_HASH
@ SHT_HASH
Definition Elf.h:222
Halide::Internal::Elf::Section::SHT_RELA
@ SHT_RELA
Definition Elf.h:221
Halide::Internal::Elf::Section::SHT_LOUSER
@ SHT_LOUSER
Definition Elf.h:231
Halide::Internal::Elf::Section::SHT_HIPROC
@ SHT_HIPROC
Definition Elf.h:230
Halide::Internal::Elf::Section::SHT_DYNSYM
@ SHT_DYNSYM
Definition Elf.h:228
Halide::Internal::Elf::Section::set_alignment
Section & set_alignment(uint64_t alignment)
Definition Elf.h:315
Halide::Internal::Elf::Symbol
Describes a symbol.
Definition Elf.h:50
Halide::Internal::Elf::Symbol::Symbol
Symbol(const std::string &name)
Definition Elf.h:88
Halide::Internal::Elf::Symbol::get_offset
uint64_t get_offset() const
Accesses the properties that describe the definition of this symbol.
Definition Elf.h:128
Halide::Internal::Elf::Symbol::Symbol
Symbol()=default
Halide::Internal::Elf::Symbol::get_section
const Section * get_section() const
Accesses the properties that describe the definition of this symbol.
Definition Elf.h:125
Halide::Internal::Elf::Symbol::get_visibility
Visibility get_visibility() const
Access the binding and visibility of this symbol.
Definition Elf.h:150
Halide::Internal::Elf::Symbol::get_type
Type get_type() const
Accesses the type of this symbol.
Definition Elf.h:109
Halide::Internal::Elf::Symbol::set_visibility
Symbol & set_visibility(Visibility visibility)
Access the binding and visibility of this symbol.
Definition Elf.h:143
Halide::Internal::Elf::Symbol::Visibility
Visibility
Definition Elf.h:70
Halide::Internal::Elf::Symbol::STV_HIDDEN
@ STV_HIDDEN
Definition Elf.h:73
Halide::Internal::Elf::Symbol::STV_INTERNAL
@ STV_INTERNAL
Definition Elf.h:72
Halide::Internal::Elf::Symbol::STV_DEFAULT
@ STV_DEFAULT
Definition Elf.h:71
Halide::Internal::Elf::Symbol::STV_PROTECTED
@ STV_PROTECTED
Definition Elf.h:74
Halide::Internal::Elf::Symbol::define
Symbol & define(const Section *section, uint64_t offset, uint32_t size)
Accesses the properties that describe the definition of this symbol.
Definition Elf.h:116
Halide::Internal::Elf::Symbol::set_type
Symbol & set_type(Type type)
Accesses the type of this symbol.
Definition Elf.h:105
Halide::Internal::Elf::Symbol::is_defined
bool is_defined() const
Accesses the properties that describe the definition of this symbol.
Definition Elf.h:122
Halide::Internal::Elf::Symbol::set_name
Symbol & set_name(const std::string &name)
Accesses the name of this symbol.
Definition Elf.h:94
Halide::Internal::Elf::Symbol::Binding
Binding
Definition Elf.h:52
Halide::Internal::Elf::Symbol::STB_LOPROC
@ STB_LOPROC
Definition Elf.h:56
Halide::Internal::Elf::Symbol::STB_LOCAL
@ STB_LOCAL
Definition Elf.h:53
Halide::Internal::Elf::Symbol::STB_HIPROC
@ STB_HIPROC
Definition Elf.h:57
Halide::Internal::Elf::Symbol::STB_GLOBAL
@ STB_GLOBAL
Definition Elf.h:54
Halide::Internal::Elf::Symbol::STB_WEAK
@ STB_WEAK
Definition Elf.h:55
Halide::Internal::Elf::Symbol::set_binding
Symbol & set_binding(Binding binding)
Access the binding and visibility of this symbol.
Definition Elf.h:139
Halide::Internal::Elf::Symbol::get_name
const std::string & get_name() const
Accesses the name of this symbol.
Definition Elf.h:98
Halide::Internal::Elf::Symbol::Type
Type
Definition Elf.h:60
Halide::Internal::Elf::Symbol::STT_SECTION
@ STT_SECTION
Definition Elf.h:64
Halide::Internal::Elf::Symbol::STT_HIPROC
@ STT_HIPROC
Definition Elf.h:67
Halide::Internal::Elf::Symbol::STT_OBJECT
@ STT_OBJECT
Definition Elf.h:62
Halide::Internal::Elf::Symbol::STT_NOTYPE
@ STT_NOTYPE
Definition Elf.h:61
Halide::Internal::Elf::Symbol::STT_LOPROC
@ STT_LOPROC
Definition Elf.h:66
Halide::Internal::Elf::Symbol::STT_FUNC
@ STT_FUNC
Definition Elf.h:63
Halide::Internal::Elf::Symbol::STT_FILE
@ STT_FILE
Definition Elf.h:65
Halide::Internal::Elf::Symbol::get_size
uint32_t get_size() const
Accesses the properties that describe the definition of this symbol.
Definition Elf.h:131
Halide::Internal::Elf::Symbol::get_binding
Binding get_binding() const
Access the binding and visibility of this symbol.
Definition Elf.h:147
Halide::Internal::Elf::iterator_range
Definition Elf.h:33
Halide::Internal::Elf::iterator_range::begin
T begin() const
Definition Elf.h:41
Halide::Internal::Elf::iterator_range::iterator_range
iterator_range(T b, T e)
Definition Elf.h:37
Halide::Internal::Elf::iterator_range::end
T end() const
Definition Elf.h:44
Halide::Internal::begin
auto begin(reverse_adaptor< T > i)
Definition Util.h:478
Halide::Internal::end
auto end(reverse_adaptor< T > i)
Definition Util.h:483
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::cast
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
uint64_t
unsigned __INT64_TYPE__ uint64_t
Definition runtime_internal.h:23
int64_t
signed __INT64_TYPE__ int64_t
Definition runtime_internal.h:22
uint8_t
unsigned __INT8_TYPE__ uint8_t
Definition runtime_internal.h:29
uint16_t
unsigned __INT16_TYPE__ uint16_t
Definition runtime_internal.h:27
uint32_t
unsigned __INT32_TYPE__ uint32_t
Definition runtime_internal.h:25
Halide::Type
Types in the halide type system.
Definition Type.h:281