mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Don't write into MemoryBuffers.
llvm-svn: 101783
This commit is contained in:
parent
e2e1b9063a
commit
96b4f6c003
@ -107,7 +107,7 @@ class ArchiveMember : public ilist_node<ArchiveMember> {
|
|||||||
/// into memory, the return value will be null.
|
/// into memory, the return value will be null.
|
||||||
/// @returns a pointer to the member's data.
|
/// @returns a pointer to the member's data.
|
||||||
/// @brief Get the data content of the archive member
|
/// @brief Get the data content of the archive member
|
||||||
const void* getData() const { return data; }
|
const char* getData() const { return data; }
|
||||||
|
|
||||||
/// This method determines if the member is a regular compressed file.
|
/// This method determines if the member is a regular compressed file.
|
||||||
/// @returns true iff the archive member is a compressed regular file.
|
/// @returns true iff the archive member is a compressed regular file.
|
||||||
@ -172,7 +172,7 @@ class ArchiveMember : public ilist_node<ArchiveMember> {
|
|||||||
sys::PathWithStatus path; ///< Path of file containing the member
|
sys::PathWithStatus path; ///< Path of file containing the member
|
||||||
sys::FileStatus info; ///< Status info (size,mode,date)
|
sys::FileStatus info; ///< Status info (size,mode,date)
|
||||||
unsigned flags; ///< Flags about the archive member
|
unsigned flags; ///< Flags about the archive member
|
||||||
const void* data; ///< Data for the member
|
const char* data; ///< Data for the member
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Constructors
|
/// @name Constructors
|
||||||
|
@ -233,15 +233,14 @@ bool llvm::GetBitcodeSymbols(const sys::Path& fName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Module*
|
Module*
|
||||||
llvm::GetBitcodeSymbols(const unsigned char *BufPtr, unsigned Length,
|
llvm::GetBitcodeSymbols(const char *BufPtr, unsigned Length,
|
||||||
const std::string& ModuleID,
|
const std::string& ModuleID,
|
||||||
LLVMContext& Context,
|
LLVMContext& Context,
|
||||||
std::vector<std::string>& symbols,
|
std::vector<std::string>& symbols,
|
||||||
std::string* ErrMsg) {
|
std::string* ErrMsg) {
|
||||||
// Get the module.
|
// Get the module.
|
||||||
std::auto_ptr<MemoryBuffer> Buffer(
|
std::auto_ptr<MemoryBuffer> Buffer(
|
||||||
MemoryBuffer::getNewMemBuffer(Length, ModuleID.c_str()));
|
MemoryBuffer::getMemBufferCopy(StringRef(BufPtr, Length),ModuleID.c_str()));
|
||||||
memcpy(const_cast<char *>(Buffer->getBufferStart()), BufPtr, Length);
|
|
||||||
|
|
||||||
Module *M = ParseBitcodeFile(Buffer.get(), Context, ErrMsg);
|
Module *M = ParseBitcodeFile(Buffer.get(), Context, ErrMsg);
|
||||||
if (!M)
|
if (!M)
|
||||||
|
@ -77,7 +77,7 @@ namespace llvm {
|
|||||||
std::vector<std::string>& symbols,
|
std::vector<std::string>& symbols,
|
||||||
std::string* ErrMsg);
|
std::string* ErrMsg);
|
||||||
|
|
||||||
Module* GetBitcodeSymbols(const unsigned char*Buffer,unsigned Length,
|
Module* GetBitcodeSymbols(const char *Buffer, unsigned Length,
|
||||||
const std::string& ModuleID,
|
const std::string& ModuleID,
|
||||||
LLVMContext& Context,
|
LLVMContext& Context,
|
||||||
std::vector<std::string>& symbols,
|
std::vector<std::string>& symbols,
|
||||||
|
@ -348,9 +348,8 @@ Archive::getAllModules(std::vector<Module*>& Modules,
|
|||||||
std::string FullMemberName = archPath.str() +
|
std::string FullMemberName = archPath.str() +
|
||||||
"(" + I->getPath().str() + ")";
|
"(" + I->getPath().str() + ")";
|
||||||
MemoryBuffer *Buffer =
|
MemoryBuffer *Buffer =
|
||||||
MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
|
MemoryBuffer::getMemBufferCopy(StringRef(I->getData(), I->getSize()),
|
||||||
memcpy(const_cast<char *>(Buffer->getBufferStart()),
|
FullMemberName.c_str());
|
||||||
I->getData(), I->getSize());
|
|
||||||
|
|
||||||
Module *M = ParseBitcodeFile(Buffer, Context, ErrMessage);
|
Module *M = ParseBitcodeFile(Buffer, Context, ErrMessage);
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
@ -488,10 +487,9 @@ Archive::findModuleDefiningSymbol(const std::string& symbol,
|
|||||||
// Now, load the bitcode module to get the Module.
|
// Now, load the bitcode module to get the Module.
|
||||||
std::string FullMemberName = archPath.str() + "(" +
|
std::string FullMemberName = archPath.str() + "(" +
|
||||||
mbr->getPath().str() + ")";
|
mbr->getPath().str() + ")";
|
||||||
MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(mbr->getSize(),
|
MemoryBuffer *Buffer =
|
||||||
FullMemberName.c_str());
|
MemoryBuffer::getMemBufferCopy(StringRef(mbr->getData(), mbr->getSize()),
|
||||||
memcpy(const_cast<char *>(Buffer->getBufferStart()),
|
FullMemberName.c_str());
|
||||||
mbr->getData(), mbr->getSize());
|
|
||||||
|
|
||||||
Module *m = getLazyBitcodeModule(Buffer, Context, ErrMsg);
|
Module *m = getLazyBitcodeModule(Buffer, Context, ErrMsg);
|
||||||
if (!m)
|
if (!m)
|
||||||
@ -540,8 +538,8 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
|
|||||||
std::string FullMemberName = archPath.str() + "(" +
|
std::string FullMemberName = archPath.str() + "(" +
|
||||||
mbr->getPath().str() + ")";
|
mbr->getPath().str() + ")";
|
||||||
Module* M =
|
Module* M =
|
||||||
GetBitcodeSymbols((const unsigned char*)At, mbr->getSize(),
|
GetBitcodeSymbols(At, mbr->getSize(), FullMemberName, Context,
|
||||||
FullMemberName, Context, symbols, error);
|
symbols, error);
|
||||||
|
|
||||||
if (M) {
|
if (M) {
|
||||||
// Insert the module's symbols into the symbol table
|
// Insert the module's symbols into the symbol table
|
||||||
@ -618,9 +616,8 @@ bool Archive::isBitcodeArchive() {
|
|||||||
archPath.str() + "(" + I->getPath().str() + ")";
|
archPath.str() + "(" + I->getPath().str() + ")";
|
||||||
|
|
||||||
MemoryBuffer *Buffer =
|
MemoryBuffer *Buffer =
|
||||||
MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
|
MemoryBuffer::getMemBufferCopy(StringRef(I->getData(), I->getSize()),
|
||||||
memcpy(const_cast<char *>(Buffer->getBufferStart()),
|
FullMemberName.c_str());
|
||||||
I->getData(), I->getSize());
|
|
||||||
Module *M = ParseBitcodeFile(Buffer, Context);
|
Module *M = ParseBitcodeFile(Buffer, Context);
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
if (!M)
|
if (!M)
|
||||||
|
@ -226,8 +226,7 @@ Archive::writeMember(
|
|||||||
std::string FullMemberName = archPath.str() + "(" + member.getPath().str()
|
std::string FullMemberName = archPath.str() + "(" + member.getPath().str()
|
||||||
+ ")";
|
+ ")";
|
||||||
Module* M =
|
Module* M =
|
||||||
GetBitcodeSymbols((const unsigned char*)data,fSize,
|
GetBitcodeSymbols(data, fSize, FullMemberName, Context, symbols, ErrMsg);
|
||||||
FullMemberName, Context, symbols, ErrMsg);
|
|
||||||
|
|
||||||
// If the bitcode parsed successfully
|
// If the bitcode parsed successfully
|
||||||
if ( M ) {
|
if ( M ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user