aboutsummaryrefslogtreecommitdiff
path: root/ELF/Target.h
diff options
context:
space:
mode:
Diffstat (limited to 'ELF/Target.h')
-rw-r--r--ELF/Target.h47
1 files changed, 43 insertions, 4 deletions
diff --git a/ELF/Target.h b/ELF/Target.h
index f4f366219d86..79b03f876d0d 100644
--- a/ELF/Target.h
+++ b/ELF/Target.h
@@ -10,13 +10,13 @@
#ifndef LLD_ELF_TARGET_H
#define LLD_ELF_TARGET_H
+#include "Error.h"
#include "InputSection.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/Object/ELF.h"
-#include <memory>
-
namespace lld {
+std::string toString(uint32_t RelType);
+
namespace elf {
class InputFile;
class SymbolBody;
@@ -102,14 +102,53 @@ public:
virtual void relaxTlsLdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;
};
+TargetInfo *createAArch64TargetInfo();
+TargetInfo *createAMDGPUTargetInfo();
+TargetInfo *createARMTargetInfo();
+TargetInfo *createAVRTargetInfo();
+TargetInfo *createPPC64TargetInfo();
+TargetInfo *createPPCTargetInfo();
+TargetInfo *createX32TargetInfo();
+TargetInfo *createX86TargetInfo();
+TargetInfo *createX86_64TargetInfo();
+template <class ELFT> TargetInfo *createMipsTargetInfo();
+
+std::string getErrorLocation(const uint8_t *Loc);
+
uint64_t getPPC64TocBase();
uint64_t getAArch64Page(uint64_t Expr);
extern TargetInfo *Target;
TargetInfo *createTarget();
+
+template <unsigned N>
+static void checkInt(uint8_t *Loc, int64_t V, uint32_t Type) {
+ if (!llvm::isInt<N>(V))
+ error(getErrorLocation(Loc) + "relocation " + lld::toString(Type) +
+ " out of range");
}
-std::string toString(uint32_t RelType);
+template <unsigned N>
+static void checkUInt(uint8_t *Loc, uint64_t V, uint32_t Type) {
+ if (!llvm::isUInt<N>(V))
+ error(getErrorLocation(Loc) + "relocation " + lld::toString(Type) +
+ " out of range");
+}
+
+template <unsigned N>
+static void checkIntUInt(uint8_t *Loc, uint64_t V, uint32_t Type) {
+ if (!llvm::isInt<N>(V) && !llvm::isUInt<N>(V))
+ error(getErrorLocation(Loc) + "relocation " + lld::toString(Type) +
+ " out of range");
+}
+
+template <unsigned N>
+static void checkAlignment(uint8_t *Loc, uint64_t V, uint32_t Type) {
+ if ((V & (N - 1)) != 0)
+ error(getErrorLocation(Loc) + "improper alignment for relocation " +
+ lld::toString(Type));
+}
+} // namespace elf
}
#endif