summaryrefslogtreecommitdiff
path: root/lib/Archive/ArchiveWriter.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-11-20 07:29:40 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-11-20 07:29:40 +0000
commit9a29db43a7a906162b0fde012b5d16f3b0895023 (patch)
tree06fa06b97a97438781c98d21ac2bb84dcb7ac447 /lib/Archive/ArchiveWriter.cpp
parente651c954aade4d23f4976af6ade3f767ca387976 (diff)
Distinguish between BSD4.4 and SVR4 symbol tables
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18044 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Archive/ArchiveWriter.cpp')
-rw-r--r--lib/Archive/ArchiveWriter.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp
index c3c7d12676e..8651e95391f 100644
--- a/lib/Archive/ArchiveWriter.cpp
+++ b/lib/Archive/ArchiveWriter.cpp
@@ -105,8 +105,10 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr,
bool writeLongName = false;
if (mbr.isStringTable()) {
memcpy(hdr.name,ARFILE_STRTAB_NAME,16);
- } else if (mbr.isForeignSymbolTable()) {
- memcpy(hdr.name,ARFILE_SYMTAB_NAME,16);
+ } else if (mbr.isSVR4SymbolTable()) {
+ memcpy(hdr.name,ARFILE_SVR4_SYMTAB_NAME,16);
+ } else if (mbr.isBSD4SymbolTable()) {
+ memcpy(hdr.name,ARFILE_BSD4_SYMTAB_NAME,16);
} else if (mbr.isLLVMSymbolTable()) {
memcpy(hdr.name,ARFILE_LLVM_SYMTAB_NAME,16);
} else if (TruncateNames) {
@@ -240,10 +242,11 @@ Archive::writeMember(
// Determine if we actually should compress this member
bool willCompress =
(ShouldCompress &&
- !member.isForeignSymbolTable() &&
- !member.isLLVMSymbolTable() &&
!member.isCompressed() &&
- !member.isCompressedBytecode());
+ !member.isCompressedBytecode() &&
+ !member.isLLVMSymbolTable() &&
+ !member.isSVR4SymbolTable() &&
+ !member.isBSD4SymbolTable());
// Perform the compression. Note that if the file is uncompressed bytecode
// then we turn the file into compressed bytecode rather than treating it as
@@ -418,7 +421,11 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){
// Write the file magic number
FinalFile << ARFILE_MAGIC;
- // If there is a foreign symbol table, put it into the file now.
+ // If there is a foreign symbol table, put it into the file now. Most
+ // ar(1) implementations require the symbol table to be first but llvm-ar
+ // can deal with it being after a foreign symbol table. This ensures
+ // compatibility with other ar(1) implementations as well as allowing the
+ // archive to store both native .o and LLVM .bc files, both indexed.
if (foreignST) {
writeMember(*foreignST, FinalFile, false, false, false);
}