llvm.org GIT mirror llvm / 99eaef9
Header file for ELF relocations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36597 91177308-0d34-0410-b5e6-96231b3b80d8 Christopher Lamb 13 years ago
1 changed file(s) with 49 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //=== ELFRelocation.h - ELF Relocation Info ---------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by Christopher Lamb and is distributed under the
5 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the ELFRelocation class.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_CODEGEN_ELF_RELOCATION_H
14 #define LLVM_CODEGEN_ELF_RELOCATION_H
15
16 namespace llvm {
17
18 /// ELFRelocation - This class contains all the information necessary to
19 /// to generate any 32-bit or 64-bit ELF relocation entry.
20 class ELFRelocation {
21 uint64_t r_offset; // offset in the section of the object this applies to
22 uint32_t r_symidx; // symbol table index of the symbol to use
23 uint32_t r_type; // machine specific relocation type
24 int64_t r_add; // explicit relocation addend
25 bool r_rela; // if true then the addend is part of the entry
26 // otherwise the addend is at the location specified
27 // by r_offset
28 public:
29
30 uint64_t getInfo(bool is64Bit = false) const {
31 if (is64Bit)
32 return ((uint64_t)r_symidx << 32) + ((uint64_t)r_type & 0xFFFFFFFFL);
33 else
34 return (r_symidx << 8) + (r_type & 0xFFL);
35 }
36
37 uint64_t getOffset() const { return r_offset; }
38 uint64_t getAddress() const { return r_add; }
39
40 ELFRelocation(uint64_t off, uint32_t sym, uint32_t type,
41 bool rela = true, int64_t addend = 0) :
42 r_offset(off), r_symidx(sym), r_type(type),
43 r_add(addend), r_rela(rela) {}
44 };
45
46 } // end llvm namespace
47
48 #endif // LLVM_CODEGEN_ELF_RELOCATION_H