diff options
author | Jake Ehrlich <jakehehrlich@google.com> | 2017-10-27 23:39:31 +0000 |
---|---|---|
committer | Jake Ehrlich <jakehehrlich@google.com> | 2017-10-27 23:39:31 +0000 |
commit | f22728e6369b75061cecde953d38162f7eeba53e (patch) | |
tree | 76db0cce1d270d458e3af3672b23e6e85cce50da /llvm/lib/Object/ArchiveWriter.cpp | |
parent | da524d021a442c2ecfa365e9d2533d70114293b8 (diff) | |
download | bcm5719-llvm-f22728e6369b75061cecde953d38162f7eeba53e.tar.gz bcm5719-llvm-f22728e6369b75061cecde953d38162f7eeba53e.zip |
Revert "Add support for writing 64-bit symbol tables for archives when offsets become too large for 32-bit"
This reverts commit r316805.
llvm-svn: 316813
Diffstat (limited to 'llvm/lib/Object/ArchiveWriter.cpp')
-rw-r--r-- | llvm/lib/Object/ArchiveWriter.cpp | 64 |
1 files changed, 9 insertions, 55 deletions
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index 63f5082c29d..919e2676802 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -122,11 +122,11 @@ static void printWithSpacePadding(raw_ostream &OS, T Data, unsigned Size) { static bool isBSDLike(object::Archive::Kind Kind) { switch (Kind) { case object::Archive::K_GNU: - case object::Archive::K_GNU64: return false; case object::Archive::K_BSD: case object::Archive::K_DARWIN: return true; + case object::Archive::K_GNU64: case object::Archive::K_DARWIN64: case object::Archive::K_COFF: break; @@ -134,8 +134,8 @@ static bool isBSDLike(object::Archive::Kind Kind) { llvm_unreachable("not supported for writting"); } -template <class T> -static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val) { +static void print32(raw_ostream &Out, object::Archive::Kind Kind, + uint32_t Val) { if (isBSDLike(Kind)) support::endian::Writer<support::little>(Out).write(Val); else @@ -216,20 +216,6 @@ static std::string computeRelativePath(StringRef From, StringRef To) { return Relative.str(); } -static bool is64BitKind(object::Archive::Kind Kind) { - switch (Kind) { - case object::Archive::K_GNU: - case object::Archive::K_BSD: - case object::Archive::K_DARWIN: - case object::Archive::K_COFF: - return false; - case object::Archive::K_DARWIN64: - case object::Archive::K_GNU64: - return true; - } - llvm_unreachable("not supported for writting"); -} - static void addToStringTable(raw_ostream &Out, StringRef ArcName, const NewArchiveMember &M, bool Thin) { StringRef ID = M.Buf->getBufferIdentifier(); @@ -302,14 +288,6 @@ static bool isArchiveSymbol(const object::BasicSymbolRef &S) { return true; } -static void printNBits(raw_ostream &Out, object::Archive::Kind Kind, - uint64_t Val) { - if (is64BitKind(Kind)) - print<uint64_t>(Out, Kind, Val); - else - print<uint32_t>(Out, Kind, Val); -} - static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, ArrayRef<MemberData> Members, StringRef StringTable) { @@ -321,11 +299,9 @@ static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind, NumSyms += M.Symbols.size(); unsigned Size = 0; - Size += is64BitKind(Kind) ? 8 : 4; // Number of entries + Size += 4; // Number of entries if (isBSDLike(Kind)) Size += NumSyms * 8; // Table - else if (is64BitKind(Kind)) - Size += NumSyms * 8; // Table else Size += NumSyms * 4; // Table if (isBSDLike(Kind)) @@ -342,30 +318,27 @@ static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind, if (isBSDLike(Kind)) printBSDMemberHeader(Out, Out.tell(), "__.SYMDEF", now(Deterministic), 0, 0, 0, Size); - else if (is64BitKind(Kind)) - printGNUSmallMemberHeader(Out, "/SYM64", now(Deterministic), 0, 0, 0, Size); else printGNUSmallMemberHeader(Out, "", now(Deterministic), 0, 0, 0, Size); uint64_t Pos = Out.tell() + Size; if (isBSDLike(Kind)) - print<uint32_t>(Out, Kind, NumSyms * 8); + print32(Out, Kind, NumSyms * 8); else - printNBits(Out, Kind, NumSyms); + print32(Out, Kind, NumSyms); for (const MemberData &M : Members) { for (unsigned StringOffset : M.Symbols) { if (isBSDLike(Kind)) - print<uint32_t>(Out, Kind, StringOffset); - printNBits(Out, Kind, Pos); // member offset + print32(Out, Kind, StringOffset); + print32(Out, Kind, Pos); // member offset } Pos += M.Header.size() + M.Data.size() + M.Padding.size(); } if (isBSDLike(Kind)) - // byte count of the string table - print<uint32_t>(Out, Kind, StringTable.size()); + print32(Out, Kind, StringTable.size()); // byte count of the string table Out << StringTable; while (Pad--) @@ -469,25 +442,6 @@ Error llvm::writeArchive(StringRef ArcName, if (!StringTableBuf.empty()) Data.insert(Data.begin(), computeStringTable(StringTableBuf)); - // We would like to detect if we need to switch to a 64-bit symbol table. - if (WriteSymtab) { - uint64_t MaxOffset = 0; - uint64_t LastOffset = MaxOffset; - for (const auto& M : Data) { - // Record the start of the member's offset - LastOffset = MaxOffset; - // Account for the size of each part associated with the member. - MaxOffset += M.Header.size() + M.Data.size() + M.Padding.size(); - // We assume 32-bit symbols to see if 32-bit symbols are possible or not. - MaxOffset += M.Symbols.size() * 4; - } - // If LastOffset isn't going to fit in a 32-bit varible we need to switch - // to 64-bit. Note that the file can be larger than 4GB as long as the last - // member starts before the 4GB offset. - if (LastOffset >> 32 != 0) - Kind = object::Archive::K_GNU64; - } - SmallString<128> TmpArchive; int TmpArchiveFD; if (auto EC = sys::fs::createUniqueFile(ArcName + ".temp-archive-%%%%%%%.a", |