diff options
| author | 2018-04-06 14:26:03 +0000 | |
|---|---|---|
| committer | 2018-04-06 14:26:03 +0000 | |
| commit | bdabc2f19ffb9e20600dad6e8a300842a7bda50e (patch) | |
| tree | c50e7b2e5449b074651bb82a58517a8ebc4a8cf7 /gnu/llvm/lib/Object/ObjectFile.cpp | |
| parent | Print a 'p' flag for file descriptors that were opened after pledge(2). (diff) | |
| download | wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.tar.xz wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.zip | |
Import LLVM 6.0.1 release including clang, lld and lldb.
"where is the kaboom?" deraadt@
Diffstat (limited to 'gnu/llvm/lib/Object/ObjectFile.cpp')
| -rw-r--r-- | gnu/llvm/lib/Object/ObjectFile.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/gnu/llvm/lib/Object/ObjectFile.cpp b/gnu/llvm/lib/Object/ObjectFile.cpp index 8377dd0d73f..652a2b2497e 100644 --- a/gnu/llvm/lib/Object/ObjectFile.cpp +++ b/gnu/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); } |
