LLVM
3.7.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
work
release_test
rc4
llvm.src
lib
Object
SymbolicFile.cpp
Go to the documentation of this file.
1
//===- SymbolicFile.cpp - Interface that only provides symbols --*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file defines a file format independent SymbolicFile class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "
llvm/Object/IRObjectFile.h
"
15
#include "
llvm/Object/ObjectFile.h
"
16
#include "
llvm/Object/SymbolicFile.h
"
17
#include "
llvm/Support/MemoryBuffer.h
"
18
19
using namespace
llvm;
20
using namespace
object;
21
22
SymbolicFile::SymbolicFile
(
unsigned
int
Type
,
MemoryBufferRef
Source
)
23
:
Binary
(Type, Source) {}
24
25
SymbolicFile::~SymbolicFile
() {}
26
27
ErrorOr<std::unique_ptr<SymbolicFile>
>
SymbolicFile::createSymbolicFile
(
28
MemoryBufferRef
Object,
sys::fs::file_magic
Type
,
LLVMContext
*Context) {
29
StringRef
Data
= Object.
getBuffer
();
30
if
(Type ==
sys::fs::file_magic::unknown
)
31
Type =
sys::fs::identify_magic
(Data);
32
33
switch
(Type) {
34
case
sys::fs::file_magic::bitcode
:
35
if
(Context)
36
return
IRObjectFile::create
(Object, *Context);
37
// Fallthrough
38
case
sys::fs::file_magic::unknown
:
39
case
sys::fs::file_magic::archive
:
40
case
sys::fs::file_magic::macho_universal_binary
:
41
case
sys::fs::file_magic::windows_resource
:
42
return
object_error::invalid_file_type
;
43
case
sys::fs::file_magic::elf
:
44
case
sys::fs::file_magic::elf_executable
:
45
case
sys::fs::file_magic::elf_shared_object
:
46
case
sys::fs::file_magic::elf_core
:
47
case
sys::fs::file_magic::macho_executable
:
48
case
sys::fs::file_magic::macho_fixed_virtual_memory_shared_lib
:
49
case
sys::fs::file_magic::macho_core
:
50
case
sys::fs::file_magic::macho_preload_executable
:
51
case
sys::fs::file_magic::macho_dynamically_linked_shared_lib
:
52
case
sys::fs::file_magic::macho_dynamic_linker
:
53
case
sys::fs::file_magic::macho_bundle
:
54
case
sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub
:
55
case
sys::fs::file_magic::macho_dsym_companion
:
56
case
sys::fs::file_magic::macho_kext_bundle
:
57
case
sys::fs::file_magic::coff_import_library
:
58
case
sys::fs::file_magic::pecoff_executable
:
59
return
ObjectFile::createObjectFile
(Object, Type);
60
case
sys::fs::file_magic::elf_relocatable
:
61
case
sys::fs::file_magic::macho_object
:
62
case
sys::fs::file_magic::coff_object
: {
63
ErrorOr<std::unique_ptr<ObjectFile>
> Obj =
64
ObjectFile::createObjectFile
(Object, Type);
65
if
(!Obj || !Context)
66
return
std::move(Obj);
67
68
ErrorOr<MemoryBufferRef>
BCData =
69
IRObjectFile::findBitcodeInObject
(*Obj->
get
());
70
if
(!BCData)
71
return
std::move(Obj);
72
73
return
IRObjectFile::create
(
74
MemoryBufferRef
(BCData->getBuffer(), Object.
getBufferIdentifier
()),
75
*Context);
76
}
77
}
78
llvm_unreachable
(
"Unexpected Binary File Type"
);
79
}
SymbolicFile.h
llvm::ErrorOr
Represents either an error or a value T.
Definition:
ErrorOr.h:82
llvm::Sched::Source
Definition:
TargetLowering.h:69
llvm::sys::fs::file_magic::macho_bundle
Mach-O Bundle file.
Definition:
FileSystem.h:241
llvm::sys::fs::file_magic::bitcode
Bitcode file.
Definition:
FileSystem.h:227
llvm::sys::fs::file_magic::macho_dynamically_linked_shared_lib
Mach-O dynlinked shared lib.
Definition:
FileSystem.h:239
llvm::sys::fs::file_magic::elf_relocatable
ELF Relocatable object file.
Definition:
FileSystem.h:230
llvm::object::SymbolicFile::createSymbolicFile
static ErrorOr< std::unique_ptr< SymbolicFile > > createSymbolicFile(MemoryBufferRef Object, sys::fs::file_magic Type, LLVMContext *Context)
Definition:
SymbolicFile.cpp:27
IRObjectFile.h
ObjectFile.h
llvm::object::SymbolicFile::SymbolicFile
SymbolicFile(unsigned int Type, MemoryBufferRef Source)
Definition:
SymbolicFile.cpp:22
llvm::sys::fs::file_magic::elf
ELF Unknown type.
Definition:
FileSystem.h:229
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:
ErrorHandling.h:98
llvm::object::Binary
Definition:
Binary.h:29
llvm::sys::fs::file_magic::coff_object
COFF object file.
Definition:
FileSystem.h:246
llvm::sys::fs::file_magic::pecoff_executable
PECOFF executable file.
Definition:
FileSystem.h:248
llvm::object::IRObjectFile::create
static ErrorOr< std::unique_ptr< IRObjectFile > > create(MemoryBufferRef Object, LLVMContext &Context)
Definition:
IRObjectFile.cpp:296
llvm::sys::fs::file_magic::macho_universal_binary
Mach-O universal binary.
Definition:
FileSystem.h:245
llvm::sys::fs::file_magic::macho_executable
Mach-O Executable.
Definition:
FileSystem.h:235
llvm::sys::fs::file_magic::elf_shared_object
ELF dynamically linked shared lib.
Definition:
FileSystem.h:232
llvm::sys::fs::file_magic::macho_core
Mach-O Core File.
Definition:
FileSystem.h:237
llvm::sys::fs::file_magic::windows_resource
Windows compiled resource file (.rc)
Definition:
FileSystem.h:249
llvm::object::object_error::invalid_file_type
llvm::sys::fs::file_magic::archive
ar style archive file
Definition:
FileSystem.h:228
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed...
Definition:
Type.h:45
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:
LLVMContext.h:41
llvm::sys::fs::file_magic::coff_import_library
COFF import library.
Definition:
FileSystem.h:247
llvm::sys::fs::file_magic::macho_preload_executable
Mach-O Preloaded Executable.
Definition:
FileSystem.h:238
llvm::sys::fs::identify_magic
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
Definition:
Path.cpp:900
llvm::sys::fs::file_magic::macho_fixed_virtual_memory_shared_lib
Mach-O Shared Lib, FVM.
Definition:
FileSystem.h:236
llvm::sys::fs::file_magic::macho_object
Mach-O Object file.
Definition:
FileSystem.h:234
llvm::MemoryBufferRef::getBuffer
StringRef getBuffer() const
Definition:
MemoryBuffer.h:157
llvm::object::Binary::Data
MemoryBufferRef Data
Definition:
Binary.h:37
llvm::sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub
Mach-O Shared lib stub.
Definition:
FileSystem.h:242
llvm::MemoryBufferRef
Definition:
MemoryBuffer.h:148
llvm::sys::fs::file_magic
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
Definition:
FileSystem.h:224
llvm::sys::fs::file_magic::elf_core
ELF core image.
Definition:
FileSystem.h:233
llvm::sys::fs::file_magic::macho_dsym_companion
Mach-O dSYM companion file.
Definition:
FileSystem.h:243
llvm::sys::fs::file_magic::elf_executable
ELF Executable image.
Definition:
FileSystem.h:231
llvm::sys::fs::file_magic::macho_dynamic_linker
The Mach-O dynamic linker.
Definition:
FileSystem.h:240
MemoryBuffer.h
llvm::object::IRObjectFile::findBitcodeInObject
static ErrorOr< MemoryBufferRef > findBitcodeInObject(const ObjectFile &Obj)
Finds and returns bitcode embedded in the given object file, or an error code if not found...
Definition:
IRObjectFile.cpp:260
llvm::MemoryBufferRef::getBufferIdentifier
StringRef getBufferIdentifier() const
Definition:
MemoryBuffer.h:159
llvm::object::ObjectFile::createObjectFile
static ErrorOr< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Create ObjectFile from path.
Definition:
ObjectFile.cpp:102
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:40
llvm::object::SymbolicFile::~SymbolicFile
~SymbolicFile() override
Definition:
SymbolicFile.cpp:25
llvm::sys::fs::file_magic::unknown
Unrecognized file.
Definition:
FileSystem.h:226
llvm::ErrorOr::get
reference get()
Definition:
ErrorOr.h:175
llvm::sys::fs::file_magic::macho_kext_bundle
Mach-O kext bundle file.
Definition:
FileSystem.h:244
Generated on Mon Aug 31 2015 11:10:30 for LLVM by
1.8.6