summaryrefslogtreecommitdiff
path: root/llvm/lib/Object
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-12-25 22:30:44 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-12-25 22:30:44 +0000
commit77fc4c146f0870ffb09c1afb823ccbe742c5e6ff (patch)
tree5c0eb39553003b9c75a901af6bc4ddabd6f2f28c /llvm/lib/Object
parentf65dcba83ce5035ab88a85fe17628b447eb56e1b (diff)
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/ArchiveWriter.cpp2
-rw-r--r--llvm/lib/Object/ELF.cpp2
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp46
-rw-r--r--llvm/lib/Object/MachOUniversalWriter.cpp1
4 files changed, 49 insertions, 2 deletions
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp
index ce997464caa7..da8bcec7f3d4 100644
--- a/llvm/lib/Object/ArchiveWriter.cpp
+++ b/llvm/lib/Object/ArchiveWriter.cpp
@@ -696,7 +696,7 @@ writeArchiveToBuffer(ArrayRef<NewArchiveMember> NewMembers, bool WriteSymtab,
return std::move(E);
return std::make_unique<SmallVectorMemoryBuffer>(
- std::move(ArchiveBufferVector));
+ std::move(ArchiveBufferVector), /*RequiresNullTerminator=*/false);
}
} // namespace llvm
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index 84181ae5e501..6e56da1a31f3 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -210,6 +210,8 @@ uint32_t llvm::object::getELFRelativeRelocationType(uint32_t Machine) {
return ELF::R_SPARC_RELATIVE;
case ELF::EM_CSKY:
return ELF::R_CKCORE_RELATIVE;
+ case ELF::EM_VE:
+ return ELF::R_VE_RELATIVE;
case ELF::EM_AMDGPU:
break;
case ELF::EM_BPF:
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 7501661591f0..42e257516f4e 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -26,12 +26,15 @@
#include "llvm/Object/SymbolicFile.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -4719,3 +4722,46 @@ StringRef MachOObjectFile::mapDebugSectionName(StringRef Name) const {
.Case("debug_str_offs", "debug_str_offsets")
.Default(Name);
}
+
+Expected<std::vector<std::string>>
+MachOObjectFile::findDsymObjectMembers(StringRef Path) {
+ SmallString<256> BundlePath(Path);
+ // Normalize input path. This is necessary to accept `bundle.dSYM/`.
+ sys::path::remove_dots(BundlePath);
+ if (!sys::fs::is_directory(BundlePath) ||
+ sys::path::extension(BundlePath) != ".dSYM")
+ return std::vector<std::string>();
+ sys::path::append(BundlePath, "Contents", "Resources", "DWARF");
+ bool IsDir;
+ auto EC = sys::fs::is_directory(BundlePath, IsDir);
+ if (EC == errc::no_such_file_or_directory || (!EC && !IsDir))
+ return createStringError(
+ EC, "%s: expected directory 'Contents/Resources/DWARF' in dSYM bundle",
+ Path.str().c_str());
+ if (EC)
+ return createFileError(BundlePath, errorCodeToError(EC));
+
+ std::vector<std::string> ObjectPaths;
+ for (sys::fs::directory_iterator Dir(BundlePath, EC), DirEnd;
+ Dir != DirEnd && !EC; Dir.increment(EC)) {
+ StringRef ObjectPath = Dir->path();
+ sys::fs::file_status Status;
+ if (auto EC = sys::fs::status(ObjectPath, Status))
+ return createFileError(ObjectPath, errorCodeToError(EC));
+ switch (Status.type()) {
+ case sys::fs::file_type::regular_file:
+ case sys::fs::file_type::symlink_file:
+ case sys::fs::file_type::type_unknown:
+ ObjectPaths.push_back(ObjectPath.str());
+ break;
+ default: /*ignore*/;
+ }
+ }
+ if (EC)
+ return createFileError(BundlePath, errorCodeToError(EC));
+ if (ObjectPaths.empty())
+ return createStringError(std::error_code(),
+ "%s: no objects found in dSYM bundle",
+ Path.str().c_str());
+ return ObjectPaths;
+}
diff --git a/llvm/lib/Object/MachOUniversalWriter.cpp b/llvm/lib/Object/MachOUniversalWriter.cpp
index 9673c97a10f0..ae1ff09a4f8f 100644
--- a/llvm/lib/Object/MachOUniversalWriter.cpp
+++ b/llvm/lib/Object/MachOUniversalWriter.cpp
@@ -19,7 +19,6 @@
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
-#include "llvm/Support/SmallVectorMemoryBuffer.h"
using namespace llvm;
using namespace object;