mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
We don't need a null terminator for the output file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128098 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c1dbd5d9c3
commit
11d1803770
@ -64,10 +64,12 @@ public:
|
||||
/// specified, this means that the client knows that the file exists and that
|
||||
/// it has the specified size.
|
||||
static error_code getFile(StringRef Filename, OwningPtr<MemoryBuffer> &result,
|
||||
int64_t FileSize = -1);
|
||||
int64_t FileSize = -1,
|
||||
bool RequiresNullTerminator = true);
|
||||
static error_code getFile(const char *Filename,
|
||||
OwningPtr<MemoryBuffer> &result,
|
||||
int64_t FileSize = -1);
|
||||
int64_t FileSize = -1,
|
||||
bool RequiresNullTerminator = true);
|
||||
|
||||
/// getOpenFile - Given an already-open file descriptor, read the file and
|
||||
/// return a MemoryBuffer.
|
||||
|
@ -196,15 +196,18 @@ public:
|
||||
|
||||
error_code MemoryBuffer::getFile(StringRef Filename,
|
||||
OwningPtr<MemoryBuffer> &result,
|
||||
int64_t FileSize) {
|
||||
int64_t FileSize,
|
||||
bool RequiresNullTerminator) {
|
||||
// Ensure the path is null terminated.
|
||||
SmallString<256> PathBuf(Filename.begin(), Filename.end());
|
||||
return MemoryBuffer::getFile(PathBuf.c_str(), result, FileSize);
|
||||
return MemoryBuffer::getFile(PathBuf.c_str(), result, FileSize,
|
||||
RequiresNullTerminator);
|
||||
}
|
||||
|
||||
error_code MemoryBuffer::getFile(const char *Filename,
|
||||
OwningPtr<MemoryBuffer> &result,
|
||||
int64_t FileSize) {
|
||||
int64_t FileSize,
|
||||
bool RequiresNullTerminator) {
|
||||
int OpenFlags = O_RDONLY;
|
||||
#ifdef O_BINARY
|
||||
OpenFlags |= O_BINARY; // Open input file in binary mode on win32.
|
||||
@ -213,7 +216,8 @@ error_code MemoryBuffer::getFile(const char *Filename,
|
||||
if (FD == -1) {
|
||||
return error_code(errno, posix_category());
|
||||
}
|
||||
error_code ret = getOpenFile(FD, Filename, result, FileSize);
|
||||
error_code ret = getOpenFile(FD, Filename, result, FileSize, FileSize,
|
||||
0, RequiresNullTerminator);
|
||||
close(FD);
|
||||
return ret;
|
||||
}
|
||||
|
@ -209,8 +209,11 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg)
|
||||
|
||||
// read .o file into memory buffer
|
||||
OwningPtr<MemoryBuffer> BuffPtr;
|
||||
if (error_code ec = MemoryBuffer::getFile(uniqueObjStr.c_str(),BuffPtr))
|
||||
if (error_code ec = MemoryBuffer::getFile(uniqueObjStr.c_str(), BuffPtr,
|
||||
-1, false)) {
|
||||
errMsg = ec.message();
|
||||
return NULL;
|
||||
}
|
||||
_nativeObjectFile = BuffPtr.take();
|
||||
|
||||
// remove temp files
|
||||
|
Loading…
x
Reference in New Issue
Block a user