Changeset View
Changeset View
Standalone View
Standalone View
lld/trunk/ELF/Relocations.h
//===- Relocations.h -------------------------------------------*- C++ -*-===// | //===- Relocations.h -------------------------------------------*- C++ -*-===// | ||||
// | // | ||||
// The LLVM Linker | // The LLVM Linker | ||||
// | // | ||||
// This file is distributed under the University of Illinois Open Source | // This file is distributed under the University of Illinois Open Source | ||||
// License. See LICENSE.TXT for details. | // License. See LICENSE.TXT for details. | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef LLD_ELF_RELOCATIONS_H | #ifndef LLD_ELF_RELOCATIONS_H | ||||
#define LLD_ELF_RELOCATIONS_H | #define LLD_ELF_RELOCATIONS_H | ||||
#include "lld/Core/LLVM.h" | #include "lld/Core/LLVM.h" | ||||
#include "llvm/ADT/DenseMap.h" | |||||
#include <map> | |||||
#include <vector> | |||||
namespace lld { | namespace lld { | ||||
namespace elf { | namespace elf { | ||||
class SymbolBody; | class SymbolBody; | ||||
class InputSection; | class InputSection; | ||||
class InputSectionBase; | class InputSectionBase; | ||||
class OutputSection; | class OutputSection; | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | struct Relocation { | ||||
uint32_t Type; | uint32_t Type; | ||||
uint64_t Offset; | uint64_t Offset; | ||||
int64_t Addend; | int64_t Addend; | ||||
SymbolBody *Sym; | SymbolBody *Sym; | ||||
}; | }; | ||||
template <class ELFT> void scanRelocations(InputSectionBase &); | template <class ELFT> void scanRelocations(InputSectionBase &); | ||||
template <class ELFT> | class ThunkSection; | ||||
class Thunk; | |||||
template <class ELFT> class ThunkCreator { | |||||
public: | |||||
// Return true if Thunks have been added to OutputSections | |||||
bool createThunks(ArrayRef<OutputSection *> OutputSections); | bool createThunks(ArrayRef<OutputSection *> OutputSections); | ||||
private: | |||||
void mergeThunks(OutputSection *OS, std::vector<ThunkSection *> &Thunks); | |||||
ThunkSection *getOSThunkSec(ThunkSection *&TS, OutputSection *OS); | |||||
ThunkSection *getISThunkSec(InputSection *IS, OutputSection *OS); | |||||
std::pair<Thunk *, bool> getThunk(SymbolBody &Body, uint32_t Type); | |||||
// Track Symbols that already have a Thunk | |||||
llvm::DenseMap<SymbolBody *, Thunk *> ThunkedSymbols; | |||||
// Track InputSections that have a ThunkSection placed in front | |||||
llvm::DenseMap<InputSection *, ThunkSection *> ThunkedSections; | |||||
// Track the ThunksSections that need to be inserted into an OutputSection | |||||
std::map<OutputSection *, std::vector<ThunkSection *>> ThunkSections; | |||||
}; | |||||
// Return a int64_t to make sure we get the sign extension out of the way as | // Return a int64_t to make sure we get the sign extension out of the way as | ||||
// early as possible. | // early as possible. | ||||
template <class ELFT> | template <class ELFT> | ||||
static inline int64_t getAddend(const typename ELFT::Rel &Rel) { | static inline int64_t getAddend(const typename ELFT::Rel &Rel) { | ||||
return 0; | return 0; | ||||
} | } | ||||
template <class ELFT> | template <class ELFT> | ||||
static inline int64_t getAddend(const typename ELFT::Rela &Rel) { | static inline int64_t getAddend(const typename ELFT::Rela &Rel) { | ||||
return Rel.r_addend; | return Rel.r_addend; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
#endif | #endif |