diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-11-17 18:28:29 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-11-17 18:28:29 +0000 |
commit | d4543da9b0e81c234143c493458674f634dab970 (patch) | |
tree | cb65651be9bb9d5e122958ac2d6220e45deca7c4 /lib/Archive | |
parent | 6ab7a4f9ef212ef6824677d0de84189c1233e56a (diff) | |
download | external_llvm-d4543da9b0e81c234143c493458674f634dab970.zip external_llvm-d4543da9b0e81c234143c493458674f634dab970.tar.gz external_llvm-d4543da9b0e81c234143c493458674f634dab970.tar.bz2 |
Fix some things for Mac OSX archives:
* ensure trailing spaces are eliminated so they don't factor into the
length of a member's name.
* make sure all the bytes of a name are written even if the name ends in
multiple null characters (bug in OSX ar)
* make sure we provide the full member name when searching for symbols so
the module name is not accidentally duplicated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Archive')
-rw-r--r-- | lib/Archive/ArchiveWriter.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp index 545f4ee..bd9851e 100644 --- a/lib/Archive/ArchiveWriter.cpp +++ b/lib/Archive/ArchiveWriter.cpp @@ -93,9 +93,16 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, sprintf(buffer,"%-12u", unsigned(secondsSinceEpoch)); memcpy(hdr.date,buffer,12); + // Get rid of trailing blanks in the name + std::string mbrPath = mbr.getPath().get(); + size_t mbrLen = mbrPath.length(); + while (mbrLen > 0 && mbrPath[mbrLen-1] == ' ') { + mbrPath.erase(mbrLen-1,1); + mbrLen--; + } + // Set the name field in one of its various flavors. bool writeLongName = false; - const std::string& mbrPath = mbr.getPath().get(); if (mbr.isStringTable()) { memcpy(hdr.name,ARFILE_STRTAB_NAME,16); } else if (mbr.isForeignSymbolTable()) { @@ -115,12 +122,12 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, memcpy(hdr.name,nm,len); hdr.name[len] = '/'; } else if (mbrPath.length() < 16 && mbrPath.find('/') == std::string::npos) { - mbrPath.copy(hdr.name,mbrPath.length()); + memcpy(hdr.name,mbrPath.c_str(),mbrPath.length()); hdr.name[mbrPath.length()] = '/'; } else { std::string nm = "#1/"; nm += utostr(mbrPath.length()); - nm.copy(hdr.name,nm.length()); + memcpy(hdr.name,nm.data(),nm.length()); if (sz < 0) sz -= mbrPath.length(); else @@ -203,8 +210,10 @@ Archive::writeMember( if (CreateSymbolTable && (member.isBytecode() || member.isCompressedBytecode())) { std::vector<std::string> symbols; + std::string FullMemberName = archPath.get() + "(" + member.getPath().get() + + ")"; ModuleProvider* MP = GetBytecodeSymbols( - (const unsigned char*)data,fSize,member.getPath().get(), symbols); + (const unsigned char*)data,fSize,FullMemberName, symbols); // If the bytecode parsed successfully if ( MP ) { @@ -270,7 +279,7 @@ Archive::writeMember( // Write the long filename if its long if (writeLongName) { - ARFile << member.getPath().c_str(); + ARFile.write(member.getPath().get().data(),member.getPath().get().length()); } // Make sure we write the compressed bytecode magic number if we should. |