[lld] r248324 - Stub out ARM and PPC targets so that we can use a switch to create them.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 14:24:52 PDT 2015
Author: rafael
Date: Tue Sep 22 16:24:52 2015
New Revision: 248324
URL: http://llvm.org/viewvc/llvm-project?rev=248324&view=rev
Log:
Stub out ARM and PPC targets so that we can use a switch to create them.
Modified:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=248324&r1=248323&r2=248324&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Sep 22 16:24:52 2015
@@ -39,13 +39,24 @@ void SymbolTable::addFile(std::unique_pt
addELFFile(cast<ELFFileBase>(FileP));
}
+static TargetInfo *createTarget(uint16_t EMachine) {
+ switch (EMachine) {
+ case EM_PPC:
+ return new PPCTargetInfo();
+ case EM_ARM:
+ return new ARMTargetInfo();
+ case EM_PPC64:
+ return new PPC64TargetInfo();
+ case EM_X86_64:
+ return new X86_64TargetInfo();
+ case EM_386:
+ return new X86TargetInfo();
+ }
+ error("Unknown target machine");
+}
+
template <class ELFT> void SymbolTable::init(uint16_t EMachine) {
- if (EMachine == EM_PPC64)
- Target.reset(new PPC64TargetInfo());
- else if (EMachine == EM_X86_64)
- Target.reset(new X86_64TargetInfo());
- else
- Target.reset(new X86TargetInfo());
+ Target.reset(createTarget(EMachine));
if (Config->Shared)
return;
EntrySym = new (Alloc) Undefined<ELFT>("_start", Undefined<ELFT>::Synthetic);
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=248324&r1=248323&r2=248324&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Sep 22 16:24:52 2015
@@ -180,5 +180,25 @@ void PPC64TargetInfo::relocateOne(uint8_
break;
}
}
+
+PPCTargetInfo::PPCTargetInfo() {
+ // PCRelReloc = FIXME
+}
+void PPCTargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
+ uint64_t PltEntryAddr) const {}
+bool PPCTargetInfo::relocNeedsGot(uint32_t Type) const { return false; }
+bool PPCTargetInfo::relocNeedsPlt(uint32_t Type) const { return false; }
+void PPCTargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
+ uint64_t BaseAddr, uint64_t SymVA) const {}
+
+ARMTargetInfo::ARMTargetInfo() {
+ // PCRelReloc = FIXME
+}
+void ARMTargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
+ uint64_t PltEntryAddr) const {}
+bool ARMTargetInfo::relocNeedsGot(uint32_t Type) const { return false; }
+bool ARMTargetInfo::relocNeedsPlt(uint32_t Type) const { return false; }
+void ARMTargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
+ uint64_t BaseAddr, uint64_t SymVA) const {}
}
}
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=248324&r1=248323&r2=248324&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Tue Sep 22 16:24:52 2015
@@ -65,6 +65,28 @@ public:
uint64_t BaseAddr, uint64_t SymVA) const override;
};
+class PPCTargetInfo final : public TargetInfo {
+public:
+ PPCTargetInfo();
+ void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
+ uint64_t PltEntryAddr) const override;
+ bool relocNeedsGot(uint32_t Type) const override;
+ bool relocNeedsPlt(uint32_t Type) const override;
+ void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
+ uint64_t BaseAddr, uint64_t SymVA) const override;
+};
+
+class ARMTargetInfo final : public TargetInfo {
+public:
+ ARMTargetInfo();
+ void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
+ uint64_t PltEntryAddr) const override;
+ bool relocNeedsGot(uint32_t Type) const override;
+ bool relocNeedsPlt(uint32_t Type) const override;
+ void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
+ uint64_t BaseAddr, uint64_t SymVA) const override;
+};
+
extern std::unique_ptr<TargetInfo> Target;
}
}
More information about the llvm-commits
mailing list