aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Object/ObjectFile.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-20 14:16:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-20 14:16:56 +0000
commit2cab237b5dbfe1b3e9c7aa7a3c02d2b98fcf7462 (patch)
tree524fe828571f81358bba62fdb6d04c6e5e96a2a4 /contrib/llvm/lib/Object/ObjectFile.cpp
parent6c7828a2807ea5e50c79ca42dbedf2b589ce63b2 (diff)
parent044eb2f6afba375a914ac9d8024f8f5142bb912e (diff)
Notes
Diffstat (limited to 'contrib/llvm/lib/Object/ObjectFile.cpp')
-rw-r--r--contrib/llvm/lib/Object/ObjectFile.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/contrib/llvm/lib/Object/ObjectFile.cpp b/contrib/llvm/lib/Object/ObjectFile.cpp
index 8377dd0d73fa..652a2b2497ef 100644
--- a/contrib/llvm/lib/Object/ObjectFile.cpp
+++ b/contrib/llvm/lib/Object/ObjectFile.cpp
@@ -75,10 +75,37 @@ bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const {
return false;
}
+bool ObjectFile::isSectionStripped(DataRefImpl Sec) const { return false; }
+
section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const {
return section_iterator(SectionRef(Sec, this));
}
+Triple ObjectFile::makeTriple() const {
+ Triple TheTriple;
+ auto Arch = getArch();
+ TheTriple.setArch(Triple::ArchType(Arch));
+
+ // For ARM targets, try to use the build attributes to build determine
+ // the build target. Target features are also added, but later during
+ // disassembly.
+ if (Arch == Triple::arm || Arch == Triple::armeb)
+ setARMSubArch(TheTriple);
+
+ // TheTriple defaults to ELF, and COFF doesn't have an environment:
+ // the best we can do here is indicate that it is mach-o.
+ if (isMachO())
+ TheTriple.setObjectFormat(Triple::MachO);
+
+ if (isCOFF()) {
+ const auto COFFObj = dyn_cast<COFFObjectFile>(this);
+ if (COFFObj->getArch() == Triple::thumb)
+ TheTriple.setTriple("thumbv7-windows");
+ }
+
+ return TheTriple;
+}
+
Expected<std::unique_ptr<ObjectFile>>
ObjectFile::createObjectFile(MemoryBufferRef Object, file_magic Type) {
StringRef Data = Object.getBuffer();
@@ -98,7 +125,7 @@ ObjectFile::createObjectFile(MemoryBufferRef Object, file_magic Type) {
case file_magic::elf_executable:
case file_magic::elf_shared_object:
case file_magic::elf_core:
- return errorOrToExpected(createELFObjectFile(Object));
+ return createELFObjectFile(Object);
case file_magic::macho_object:
case file_magic::macho_executable:
case file_magic::macho_fixed_virtual_memory_shared_lib:
@@ -114,7 +141,7 @@ ObjectFile::createObjectFile(MemoryBufferRef Object, file_magic Type) {
case file_magic::coff_object:
case file_magic::coff_import_library:
case file_magic::pecoff_executable:
- return errorOrToExpected(createCOFFObjectFile(Object));
+ return createCOFFObjectFile(Object);
case file_magic::wasm_object:
return createWasmObjectFile(Object);
}