2016-05-25 04:24:43 +08:00
|
|
|
//===- Relocations.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_RELOCATIONS_H
|
|
|
|
#define LLD_ELF_RELOCATIONS_H
|
|
|
|
|
|
|
|
#include "lld/Core/LLVM.h"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace elf {
|
|
|
|
class SymbolBody;
|
2016-09-08 04:37:34 +08:00
|
|
|
class InputSectionData;
|
2016-05-25 04:24:43 +08:00
|
|
|
template <class ELFT> class InputSection;
|
|
|
|
template <class ELFT> class InputSectionBase;
|
|
|
|
|
2016-10-21 12:52:11 +08:00
|
|
|
// List of target-independent relocation types. Relocations read
|
|
|
|
// from files are converted to these types so that the main code
|
|
|
|
// doesn't have to know about architecture-specific details.
|
2016-05-25 04:24:43 +08:00
|
|
|
enum RelExpr {
|
|
|
|
R_ABS,
|
|
|
|
R_GOT,
|
|
|
|
R_GOTONLY_PC,
|
2016-09-01 07:24:11 +08:00
|
|
|
R_GOTONLY_PC_FROM_END,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_GOTREL,
|
2016-09-01 07:24:11 +08:00
|
|
|
R_GOTREL_FROM_END,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_GOT_FROM_END,
|
|
|
|
R_GOT_OFF,
|
|
|
|
R_GOT_PAGE_PC,
|
|
|
|
R_GOT_PC,
|
|
|
|
R_HINT,
|
|
|
|
R_MIPS_GOT_LOCAL_PAGE,
|
2016-06-20 05:39:37 +08:00
|
|
|
R_MIPS_GOT_OFF,
|
2016-10-21 15:22:30 +08:00
|
|
|
R_MIPS_GOT_OFF32,
|
2016-06-23 23:26:31 +08:00
|
|
|
R_MIPS_TLSGD,
|
|
|
|
R_MIPS_TLSLD,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_NEG_TLS,
|
|
|
|
R_PAGE_PC,
|
|
|
|
R_PC,
|
|
|
|
R_PLT,
|
|
|
|
R_PLT_PC,
|
2016-06-05 03:11:14 +08:00
|
|
|
R_PLT_PAGE_PC,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_PPC_OPD,
|
|
|
|
R_PPC_PLT_OPD,
|
|
|
|
R_PPC_TOC,
|
2016-05-25 22:31:37 +08:00
|
|
|
R_RELAX_GOT_PC,
|
[ELF] - Implemented support for test/binop relaxations from latest ABI.
Patch implements next relaxation from latest ABI:
"Convert memory operand of test and binop into immediate operand, where binop is one of adc, add, and, cmp, or,
sbb, sub, xor instructions, when position-independent code is disabled."
It is described in System V Application Binary Interface AMD64 Architecture Processor
Supplement Draft Version 0.99.8 (https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r249.pdf,
B.2 "B.2 Optimize GOTPCRELX Relocations").
Differential revision: http://reviews.llvm.org/D20793
llvm-svn: 271405
2016-06-02 00:45:30 +08:00
|
|
|
R_RELAX_GOT_PC_NOPIC,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_RELAX_TLS_GD_TO_IE,
|
2016-06-05 07:22:34 +08:00
|
|
|
R_RELAX_TLS_GD_TO_IE_END,
|
2016-06-05 07:33:31 +08:00
|
|
|
R_RELAX_TLS_GD_TO_IE_ABS,
|
|
|
|
R_RELAX_TLS_GD_TO_IE_PAGE_PC,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_RELAX_TLS_GD_TO_LE,
|
2016-06-05 07:22:34 +08:00
|
|
|
R_RELAX_TLS_GD_TO_LE_NEG,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_RELAX_TLS_IE_TO_LE,
|
|
|
|
R_RELAX_TLS_LD_TO_LE,
|
|
|
|
R_SIZE,
|
2016-07-09 00:10:27 +08:00
|
|
|
R_THUNK_ABS,
|
|
|
|
R_THUNK_PC,
|
|
|
|
R_THUNK_PLT_PC,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_TLS,
|
2016-06-03 03:49:53 +08:00
|
|
|
R_TLSDESC,
|
|
|
|
R_TLSDESC_PAGE,
|
2016-10-20 17:59:26 +08:00
|
|
|
R_TLSDESC_CALL,
|
2016-05-25 04:24:43 +08:00
|
|
|
R_TLSGD,
|
|
|
|
R_TLSGD_PC,
|
|
|
|
R_TLSLD,
|
2016-10-21 12:52:11 +08:00
|
|
|
R_TLSLD_PC,
|
2016-05-25 04:24:43 +08:00
|
|
|
};
|
|
|
|
|
2016-10-21 12:52:11 +08:00
|
|
|
// Architecture-neutral representation of relocation.
|
2016-09-08 04:37:34 +08:00
|
|
|
struct Relocation {
|
2016-05-25 04:24:43 +08:00
|
|
|
RelExpr Expr;
|
|
|
|
uint32_t Type;
|
|
|
|
uint64_t Offset;
|
|
|
|
uint64_t Addend;
|
|
|
|
SymbolBody *Sym;
|
|
|
|
};
|
|
|
|
|
2016-11-10 22:53:24 +08:00
|
|
|
template <class ELFT> void scanRelocations(InputSectionBase<ELFT> &);
|
2016-07-02 16:50:03 +08:00
|
|
|
|
2016-11-10 22:53:24 +08:00
|
|
|
template <class ELFT> void createThunks(InputSectionBase<ELFT> &);
|
2016-07-21 01:58:07 +08:00
|
|
|
|
2016-11-09 00:26:32 +08:00
|
|
|
template <class ELFT>
|
2016-11-09 04:30:19 +08:00
|
|
|
std::string getLocation(InputSectionBase<ELFT> &S, typename ELFT::uint Offset);
|
2016-11-09 00:26:32 +08:00
|
|
|
|
2016-07-02 16:50:03 +08:00
|
|
|
template <class ELFT>
|
|
|
|
static inline typename ELFT::uint getAddend(const typename ELFT::Rel &Rel) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ELFT>
|
|
|
|
static inline typename ELFT::uint getAddend(const typename ELFT::Rela &Rel) {
|
|
|
|
return Rel.r_addend;
|
|
|
|
}
|
2016-05-25 04:24:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|