diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2005-11-30 05:21:10 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2005-11-30 05:21:10 +0000 |
commit | 3fd1b4c9bf5a360060564de0fccb742d49db2412 (patch) | |
tree | 2211db53339d99548a36e7d7736d150bd689718a /llvm/lib/Bytecode/Archive/Archive.cpp | |
parent | 9c7af08bc9d3587be04d18994658ddaadd5f107e (diff) | |
download | bcm5719-llvm-3fd1b4c9bf5a360060564de0fccb742d49db2412.tar.gz bcm5719-llvm-3fd1b4c9bf5a360060564de0fccb742d49db2412.zip |
Fix a problem with llvm-ranlib that (on some platforms) caused the archive
file to become corrupted due to interactions between mmap'd memory segments
and file descriptors closing. The problem is completely avoiding by using
a third temporary file.
Patch provided by Evan Jones
llvm-svn: 24527
Diffstat (limited to 'llvm/lib/Bytecode/Archive/Archive.cpp')
-rw-r--r-- | llvm/lib/Bytecode/Archive/Archive.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Archive/Archive.cpp b/llvm/lib/Bytecode/Archive/Archive.cpp index c2a80ebbc72..6e4d14c6a93 100644 --- a/llvm/lib/Bytecode/Archive/Archive.cpp +++ b/llvm/lib/Bytecode/Archive/Archive.cpp @@ -140,13 +140,28 @@ Archive::Archive(const sys::Path& filename, bool map ) } } -// Archive destructor - just clean up memory -Archive::~Archive() { +void Archive::cleanUpMemory() { // Shutdown the file mapping if (mapfile) { mapfile->close(); delete mapfile; + + mapfile = 0; + base = 0; } + + // Forget the entire symbol table + symTab.clear(); + symTabSize = 0; + + firstFileOffset = 0; + + // Free the foreign symbol table member + if (foreignST) { + delete foreignST; + foreignST = 0; + } + // Delete any ModuleProviders and ArchiveMember's we've allocated as a result // of symbol table searches. for (ModuleMap::iterator I=modules.begin(), E=modules.end(); I != E; ++I ) { @@ -155,3 +170,8 @@ Archive::~Archive() { } } +// Archive destructor - just clean up memory +Archive::~Archive() { + cleanUpMemory(); +} + |