[lld] r234573 - [ARM] Add skeleton for dynamic relocation pass
Denis Protivensky
dprotivensky at accesssoftek.com
Fri Apr 10 00:42:09 PDT 2015
Author: denis-protivensky
Date: Fri Apr 10 02:42:08 2015
New Revision: 234573
URL: http://llvm.org/viewvc/llvm-project?rev=234573&view=rev
Log:
[ARM] Add skeleton for dynamic relocation pass
Modified:
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp?rev=234573&r1=234572&r2=234573&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp Fri Apr 10 02:42:08 2015
@@ -526,6 +526,14 @@ protected:
return g;
}
+ std::error_code handleGOT(const Reference &ref) {
+ if (isa<UndefinedAtom>(ref.target()))
+ const_cast<Reference &>(ref).setTarget(getNullGOT());
+ else if (const auto *da = dyn_cast<DefinedAtom>(ref.target()))
+ const_cast<Reference &>(ref).setTarget(getGOT(da));
+ return std::error_code();
+ }
+
public:
ARMRelocationPass(const ELFLinkingContext &ctx) : _file(ctx), _ctx(ctx) {}
@@ -710,13 +718,38 @@ public:
const GOTAtom *getTLSTPOFF32(const DefinedAtom *da) {
return getGOTTLSEntry<R_ARM_TLS_LE32>(da);
}
+};
+
+/// This implements the dynamic relocation model. GOT and PLT entries are
+/// created for references that cannot be directly resolved.
+class ARMDynamicRelocationPass final
+ : public ARMRelocationPass<ARMDynamicRelocationPass> {
+public:
+ ARMDynamicRelocationPass(const elf::ARMLinkingContext &ctx)
+ : ARMRelocationPass(ctx) {}
+
+ /// \brief Get the veneer for ARM B/BL instructions.
+ const VeneerAtom *getVeneer_ARM_B_BL(const DefinedAtom *da,
+ StringRef secName) {
+ llvm_unreachable("Handle ARM veneer");
+ }
+
+ /// \brief Get the veneer for Thumb B/BL instructions.
+ const VeneerAtom *getVeneer_THM_B_BL(const DefinedAtom *da,
+ StringRef secName) {
+ llvm_unreachable("Handle Thumb veneer");
+ }
+
+ /// \brief Create a GOT entry for R_ARM_TLS_TPOFF32 reloc.
+ const GOTAtom *getTLSTPOFF32(const DefinedAtom *da) {
+ llvm_unreachable("Handle TLS TPOFF32");
+ }
std::error_code handleGOT(const Reference &ref) {
- if (isa<UndefinedAtom>(ref.target()))
- const_cast<Reference &>(ref).setTarget(getNullGOT());
- else if (const auto *da = dyn_cast<DefinedAtom>(ref.target()))
- const_cast<Reference &>(ref).setTarget(getGOT(da));
- return std::error_code();
+ if (const auto sla = dyn_cast<const SharedLibraryAtom>(ref.target())) {
+ llvm_unreachable("Handle shared GOT entries");
+ }
+ return ARMRelocationPass::handleGOT(ref);
}
};
@@ -727,7 +760,7 @@ lld::elf::createARMRelocationPass(const
switch (ctx.getOutputELFType()) {
case llvm::ELF::ET_EXEC:
if (ctx.isDynamic())
- llvm_unreachable("Unhandled output file type");
+ return llvm::make_unique<ARMDynamicRelocationPass>(ctx);
return llvm::make_unique<ARMStaticRelocationPass>(ctx);
default:
llvm_unreachable("Unhandled output file type");
More information about the llvm-commits
mailing list