LLVM API Documentation
00001 //=== ELFRelocation.h - ELF Relocation Info ---------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the ELFRelocation class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CODEGEN_ELF_RELOCATION_H 00015 #define LLVM_CODEGEN_ELF_RELOCATION_H 00016 00017 #include "llvm/Support/DataTypes.h" 00018 00019 namespace llvm { 00020 00021 /// ELFRelocation - This class contains all the information necessary to 00022 /// to generate any 32-bit or 64-bit ELF relocation entry. 00023 class ELFRelocation { 00024 uint64_t r_offset; // offset in the section of the object this applies to 00025 uint32_t r_symidx; // symbol table index of the symbol to use 00026 uint32_t r_type; // machine specific relocation type 00027 int64_t r_add; // explicit relocation addend 00028 bool r_rela; // if true then the addend is part of the entry 00029 // otherwise the addend is at the location specified 00030 // by r_offset 00031 public: 00032 00033 uint64_t getInfo(bool is64Bit = false) const { 00034 if (is64Bit) 00035 return ((uint64_t)r_symidx << 32) + ((uint64_t)r_type & 0xFFFFFFFFL); 00036 else 00037 return (r_symidx << 8) + (r_type & 0xFFL); 00038 } 00039 00040 uint64_t getOffset() const { return r_offset; } 00041 uint64_t getAddress() const { return r_add; } 00042 00043 ELFRelocation(uint64_t off, uint32_t sym, uint32_t type, 00044 bool rela = true, int64_t addend = 0) : 00045 r_offset(off), r_symidx(sym), r_type(type), 00046 r_add(addend), r_rela(rela) {} 00047 }; 00048 00049 } // end llvm namespace 00050 00051 #endif // LLVM_CODEGEN_ELF_RELOCATION_H