diff options
| author | Pete Cooper <peter_cooper@apple.com> | 2016-01-15 02:24:12 +0000 |
|---|---|---|
| committer | Pete Cooper <peter_cooper@apple.com> | 2016-01-15 02:24:12 +0000 |
| commit | 835594e62702024a86a9884cad4721d78bab4593 (patch) | |
| tree | 963352ff0241d2aa08c2c4331f5603cdbbf52566 /llvm | |
| parent | b825bf32b7738f8ba4e2701a49c1cd2906654e66 (diff) | |
| download | bcm5719-llvm-835594e62702024a86a9884cad4721d78bab4593.tar.gz bcm5719-llvm-835594e62702024a86a9884cad4721d78bab4593.zip | |
Delete MCRelocationInfo::createExprForRelocation.
This method has no callers.
Also remove X86ELFRelocationInfo.cpp and X86MachORelocationInfo.cpp
which only existed to provide an implementation of that method.
Ok'd by Rafael and Jim.
llvm-svn: 257859
Diffstat (limited to 'llvm')
7 files changed, 0 insertions, 281 deletions
diff --git a/llvm/include/llvm/MC/MCRelocationInfo.h b/llvm/include/llvm/MC/MCRelocationInfo.h index 40e0217b8d8..02ff1921b07 100644 --- a/llvm/include/llvm/MC/MCRelocationInfo.h +++ b/llvm/include/llvm/MC/MCRelocationInfo.h @@ -38,10 +38,6 @@ public: MCRelocationInfo(MCContext &Ctx); virtual ~MCRelocationInfo(); - /// \brief Create an MCExpr for the relocation \p Rel. - /// \returns If possible, an MCExpr corresponding to Rel, else 0. - virtual const MCExpr *createExprForRelocation(object::RelocationRef Rel); - /// \brief Create an MCExpr for the target-specific \p VariantKind. /// The VariantKinds are defined in llvm-c/Disassembler.h. /// Used by MCExternalSymbolizer. diff --git a/llvm/lib/MC/MCDisassembler/MCRelocationInfo.cpp b/llvm/lib/MC/MCDisassembler/MCRelocationInfo.cpp index 43005e7c740..08158e7f737 100644 --- a/llvm/lib/MC/MCDisassembler/MCRelocationInfo.cpp +++ b/llvm/lib/MC/MCDisassembler/MCRelocationInfo.cpp @@ -22,11 +22,6 @@ MCRelocationInfo::~MCRelocationInfo() { } const MCExpr * -MCRelocationInfo::createExprForRelocation(object::RelocationRef Rel) { - return nullptr; -} - -const MCExpr * MCRelocationInfo::createExprForCAPIVariantKind(const MCExpr *SubExpr, unsigned VariantKind) { if (VariantKind != LLVMDisassembler_VariantKind_None) diff --git a/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt index 129c28d804e..33df9ec7dcd 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt @@ -7,6 +7,4 @@ add_llvm_library(LLVMX86Desc X86ELFObjectWriter.cpp X86WinCOFFStreamer.cpp X86WinCOFFObjectWriter.cpp - X86MachORelocationInfo.cpp - X86ELFRelocationInfo.cpp ) diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp deleted file mode 100644 index ddb764facdb..00000000000 --- a/llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//===-- X86ELFRelocationInfo.cpp ----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "MCTargetDesc/X86MCTargetDesc.h" -#include "llvm/MC/MCContext.h" -#include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCInst.h" -#include "llvm/MC/MCRelocationInfo.h" -#include "llvm/MC/MCSymbol.h" -#include "llvm/Object/ELFObjectFile.h" -#include "llvm/Support/ELF.h" - -using namespace llvm; -using namespace object; -using namespace ELF; - -namespace { -class X86_64ELFRelocationInfo : public MCRelocationInfo { -public: - X86_64ELFRelocationInfo(MCContext &Ctx) : MCRelocationInfo(Ctx) {} - - const MCExpr *createExprForRelocation(RelocationRef Rel) override { - uint64_t RelType = Rel.getType(); - elf_symbol_iterator SymI = Rel.getSymbol(); - - ErrorOr<StringRef> SymNameOrErr = SymI->getName(); - if (std::error_code EC = SymNameOrErr.getError()) - report_fatal_error(EC.message()); - StringRef SymName = *SymNameOrErr; - - ErrorOr<uint64_t> SymAddr = SymI->getAddress(); - if (std::error_code EC = SymAddr.getError()) - report_fatal_error(EC.message()); - uint64_t SymSize = SymI->getSize(); - int64_t Addend = *ELFRelocationRef(Rel).getAddend(); - - MCSymbol *Sym = Ctx.getOrCreateSymbol(SymName); - // FIXME: check that the value is actually the same. - if (!Sym->isVariable()) - Sym->setVariableValue(MCConstantExpr::create(*SymAddr, Ctx)); - - const MCExpr *Expr = nullptr; - // If hasAddend is true, then we need to add Addend (r_addend) to Expr. - bool hasAddend = false; - - // The AMD64 SysV ABI says: - // A: the addend used to compute the value of the relocatable field. - // B: the base address at which a shared object has been loaded into memory - // during execution. Generally, a shared object is built with a 0 base - // virtual address, but the execution address will be different. - // G: the offset into the global offset table at which the relocation - // entry's symbol will reside during execution. - // GOT: the address of the global offset table. - // L: the place (section offset or address) of the Procedure Linkage Table - // entry for a symbol. - // P: the place (section offset or address) of the storage unit being - // relocated (computed using r_offset). - // S: the value of the symbol whose index resides in the relocation entry. - // Z: the size of the symbol whose index resides in the relocation entry. - - switch(RelType) { - case R_X86_64_NONE: - case R_X86_64_COPY: - // none - break; - case R_X86_64_64: - case R_X86_64_16: - case R_X86_64_8: - // S + A - case R_X86_64_32: - case R_X86_64_32S: - // S + A (We don't care about the result not fitting in 32 bits.) - case R_X86_64_PC32: - case R_X86_64_PC16: - case R_X86_64_PC8: - case R_X86_64_PC64: - // S + A - P (P/pcrel is implicit) - hasAddend = true; - Expr = MCSymbolRefExpr::create(Sym, Ctx); - break; - case R_X86_64_GOT32: - case R_X86_64_GOT64: - case R_X86_64_GOTPC32: - case R_X86_64_GOTPC64: - case R_X86_64_GOTPLT64: - // G + A - hasAddend = true; - Expr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, Ctx); - break; - case R_X86_64_PLT32: - // L + A - P -> S@PLT + A - hasAddend = true; - Expr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_PLT, Ctx); - break; - case R_X86_64_GLOB_DAT: - case R_X86_64_JUMP_SLOT: - // S - Expr = MCSymbolRefExpr::create(Sym, Ctx); - break; - case R_X86_64_GOTPCREL: - case R_X86_64_GOTPCREL64: - // G + GOT + A - P -> S@GOTPCREL + A - hasAddend = true; - Expr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Ctx); - break; - case R_X86_64_GOTOFF64: - // S + A - GOT - Expr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTOFF, Ctx); - break; - case R_X86_64_PLTOFF64: - // L + A - GOT - break; - case R_X86_64_SIZE32: - case R_X86_64_SIZE64: - // Z + A - Expr = MCConstantExpr::create(SymSize, Ctx); - break; - default: - Expr = MCSymbolRefExpr::create(Sym, Ctx); - break; - } - if (Expr && hasAddend && Addend != 0) - Expr = MCBinaryExpr::createAdd(Expr, - MCConstantExpr::create(Addend, Ctx), - Ctx); - return Expr; - } -}; -} // End unnamed namespace - -/// createX86ELFRelocationInfo - Construct an X86 Mach-O RelocationInfo. -MCRelocationInfo *llvm::createX86_64ELFRelocationInfo(MCContext &Ctx) { - // We only handle x86-64 for now. - return new X86_64ELFRelocationInfo(Ctx); -} diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index 53a6550acdd..25a377c5acc 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -215,10 +215,6 @@ static MCInstPrinter *createX86MCInstPrinter(const Triple &T, static MCRelocationInfo *createX86MCRelocationInfo(const Triple &TheTriple, MCContext &Ctx) { - if (TheTriple.isOSBinFormatMachO() && TheTriple.getArch() == Triple::x86_64) - return createX86_64MachORelocationInfo(Ctx); - else if (TheTriple.isOSBinFormatELF()) - return createX86_64ELFRelocationInfo(Ctx); // Default to the stock relocation info. return llvm::createMCRelocationInfo(TheTriple, Ctx); } diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h index 2d2836ff07c..a5fc8380139 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h @@ -93,12 +93,6 @@ MCObjectWriter *createX86ELFObjectWriter(raw_pwrite_stream &OS, bool IsELF64, MCObjectWriter *createX86WinCOFFObjectWriter(raw_pwrite_stream &OS, bool Is64Bit); -/// Construct X86-64 Mach-O relocation info. -MCRelocationInfo *createX86_64MachORelocationInfo(MCContext &Ctx); - -/// Construct X86-64 ELF relocation info. -MCRelocationInfo *createX86_64ELFRelocationInfo(MCContext &Ctx); - /// Returns the sub or super register of a specific X86 register. /// e.g. getX86SubSuperRegister(X86::EAX, 16) returns X86::AX. /// Aborts on error. diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp deleted file mode 100644 index 9bfe999424f..00000000000 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//===-- X86MachORelocationInfo.cpp ----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "MCTargetDesc/X86MCTargetDesc.h" -#include "llvm/MC/MCContext.h" -#include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCInst.h" -#include "llvm/MC/MCRelocationInfo.h" -#include "llvm/MC/MCSymbol.h" -#include "llvm/Object/MachO.h" - -using namespace llvm; -using namespace object; -using namespace MachO; - -namespace { -class X86_64MachORelocationInfo : public MCRelocationInfo { -public: - X86_64MachORelocationInfo(MCContext &Ctx) : MCRelocationInfo(Ctx) {} - - const MCExpr *createExprForRelocation(RelocationRef Rel) override { - const MachOObjectFile *Obj = cast<MachOObjectFile>(Rel.getObject()); - - uint64_t RelType = Rel.getType(); - symbol_iterator SymI = Rel.getSymbol(); - - ErrorOr<StringRef> SymNameOrErr = SymI->getName(); - if (std::error_code EC = SymNameOrErr.getError()) - report_fatal_error(EC.message()); - StringRef SymName = *SymNameOrErr; - uint64_t SymAddr = SymI->getValue(); - - any_relocation_info RE = Obj->getRelocation(Rel.getRawDataRefImpl()); - bool isPCRel = Obj->getAnyRelocationPCRel(RE); - - MCSymbol *Sym = Ctx.getOrCreateSymbol(SymName); - // FIXME: check that the value is actually the same. - if (!Sym->isVariable()) - Sym->setVariableValue(MCConstantExpr::create(SymAddr, Ctx)); - const MCExpr *Expr = nullptr; - - switch(RelType) { - case X86_64_RELOC_TLV: - Expr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_TLVP, Ctx); - break; - case X86_64_RELOC_SIGNED_4: - Expr = MCBinaryExpr::createAdd(MCSymbolRefExpr::create(Sym, Ctx), - MCConstantExpr::create(4, Ctx), - Ctx); - break; - case X86_64_RELOC_SIGNED_2: - Expr = MCBinaryExpr::createAdd(MCSymbolRefExpr::create(Sym, Ctx), - MCConstantExpr::create(2, Ctx), - Ctx); - break; - case X86_64_RELOC_SIGNED_1: - Expr = MCBinaryExpr::createAdd(MCSymbolRefExpr::create(Sym, Ctx), - MCConstantExpr::create(1, Ctx), - Ctx); - break; - case X86_64_RELOC_GOT_LOAD: - Expr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Ctx); - break; - case X86_64_RELOC_GOT: - Expr = MCSymbolRefExpr::create(Sym, isPCRel ? - MCSymbolRefExpr::VK_GOTPCREL : - MCSymbolRefExpr::VK_GOT, - Ctx); - break; - case X86_64_RELOC_SUBTRACTOR: - { - Rel.moveNext(); - any_relocation_info RENext = - Obj->getRelocation(Rel.getRawDataRefImpl()); - - // X86_64_SUBTRACTOR must be followed by a relocation of type - // X86_64_RELOC_UNSIGNED. - // NOTE: Scattered relocations don't exist on x86_64. - unsigned RType = Obj->getAnyRelocationType(RENext); - if (RType != X86_64_RELOC_UNSIGNED) - report_fatal_error("Expected X86_64_RELOC_UNSIGNED after " - "X86_64_RELOC_SUBTRACTOR."); - - const MCExpr *LHS = MCSymbolRefExpr::create(Sym, Ctx); - - symbol_iterator RSymI = Rel.getSymbol(); - uint64_t RSymAddr = RSymI->getValue(); - ErrorOr<StringRef> RSymName = RSymI->getName(); - if (std::error_code EC = RSymName.getError()) - report_fatal_error(EC.message()); - - MCSymbol *RSym = Ctx.getOrCreateSymbol(*RSymName); - if (!RSym->isVariable()) - RSym->setVariableValue(MCConstantExpr::create(RSymAddr, Ctx)); - - const MCExpr *RHS = MCSymbolRefExpr::create(RSym, Ctx); - - Expr = MCBinaryExpr::createSub(LHS, RHS, Ctx); - break; - } - default: - Expr = MCSymbolRefExpr::create(Sym, Ctx); - break; - } - return Expr; - } -}; -} // End unnamed namespace - -/// createX86_64MachORelocationInfo - Construct an X86-64 Mach-O RelocationInfo. -MCRelocationInfo *llvm::createX86_64MachORelocationInfo(MCContext &Ctx) { - return new X86_64MachORelocationInfo(Ctx); -} |

