Add support in the LTO library for loading an object from the middle

of an file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127781 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2011-03-17 00:36:11 +00:00
parent d02c8b6cc1
commit f21b1058a1
6 changed files with 45 additions and 42 deletions

View File

@@ -95,10 +95,19 @@ LTOModule *LTOModule::makeLTOModule(const char *path,
}
LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
off_t size,
size_t size,
std::string &errMsg) {
return makeLTOModule(fd, path, size, size, 0, errMsg);
}
LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
size_t file_size,
size_t map_size,
off_t offset,
std::string &errMsg) {
OwningPtr<MemoryBuffer> buffer;
if (error_code ec = MemoryBuffer::getOpenFile(fd, path, buffer, size)) {
if (error_code ec = MemoryBuffer::getOpenFile(fd, path, buffer, file_size,
map_size, offset, false)) {
errMsg = ec.message();
return NULL;
}

View File

@@ -52,7 +52,12 @@ struct LTOModule {
static LTOModule* makeLTOModule(const char* path,
std::string& errMsg);
static LTOModule* makeLTOModule(int fd, const char *path,
off_t size,
size_t size,
std::string& errMsg);
static LTOModule* makeLTOModule(int fd, const char *path,
size_t file_size,
size_t map_size,
off_t offset,
std::string& errMsg);
static LTOModule* makeLTOModule(const void* mem, size_t length,
std::string& errMsg);

View File

@@ -95,11 +95,24 @@ lto_module_t lto_module_create(const char* path)
// loads an object file from disk
// returns NULL on error (check lto_get_error_message() for details)
//
lto_module_t lto_module_create_from_fd(int fd, const char *path, off_t size)
lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size)
{
return LTOModule::makeLTOModule(fd, path, size, sLastErrorString);
}
//
// loads an object file from disk
// returns NULL on error (check lto_get_error_message() for details)
//
lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
size_t file_size,
size_t map_size,
off_t offset)
{
return LTOModule::makeLTOModule(fd, path, file_size, map_size,
offset, sLastErrorString);
}
//
// loads an object file from memory
// returns NULL on error (check lto_get_error_message() for details)

View File

@@ -2,6 +2,7 @@ lto_get_error_message
lto_get_version
lto_module_create
lto_module_create_from_fd
lto_module_create_from_fd_at_offset
lto_module_create_from_memory
lto_module_get_num_symbols
lto_module_get_symbol_attribute