aboutsummaryrefslogtreecommitdiff
path: root/ELF/Target.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:52:45 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:52:45 +0000
commitd2bd9e70b16db88a7808ee2280b0a107afbfdd3b (patch)
tree12612d2c593445b297ac656911c9db7cf9065bdd /ELF/Target.cpp
parentf1e1c239e31b467e17f1648b1f524fc9ab5b431a (diff)
Notes
Diffstat (limited to 'ELF/Target.cpp')
-rw-r--r--ELF/Target.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/ELF/Target.cpp b/ELF/Target.cpp
index d07478a5178c..024e0cfec27b 100644
--- a/ELF/Target.cpp
+++ b/ELF/Target.cpp
@@ -34,19 +34,19 @@
using namespace llvm;
using namespace llvm::object;
using namespace llvm::ELF;
-using namespace lld;
-using namespace lld::elf;
-const TargetInfo *elf::target;
-
-std::string lld::toString(RelType type) {
+namespace lld {
+std::string toString(elf::RelType type) {
StringRef s = getELFRelocationTypeName(elf::config->emachine, type);
if (s == "Unknown")
return ("Unknown (" + Twine(type) + ")").str();
return s;
}
-TargetInfo *elf::getTarget() {
+namespace elf {
+const TargetInfo *target;
+
+TargetInfo *getTarget() {
switch (config->emachine) {
case EM_386:
case EM_IAMCU:
@@ -91,6 +91,9 @@ TargetInfo *elf::getTarget() {
}
template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *loc) {
+ if (!Out::bufferStart)
+ return {};
+
for (InputSectionBase *d : inputSections) {
auto *isec = cast<InputSection>(d);
if (!isec->getParent())
@@ -103,7 +106,7 @@ template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *loc) {
return {};
}
-ErrorPlace elf::getErrorPlace(const uint8_t *loc) {
+ErrorPlace getErrorPlace(const uint8_t *loc) {
switch (config->ekind) {
case ELF32LEKind:
return getErrPlace<ELF32LE>(loc);
@@ -179,3 +182,6 @@ uint64_t TargetInfo::getImageBase() const {
return *config->imageBase;
return config->isPic ? 0 : defaultImageBase;
}
+
+} // namespace elf
+} // namespace lld