Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 7412860

Browse files
committed
Revert "Add support for writing 64-bit symbol tables for archives when offsets become too large for 32-bit"
This reverts commit r316805. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316813 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b3d6348 commit 7412860

File tree

2 files changed

+9
-86
lines changed

2 files changed

+9
-86
lines changed

lib/Object/ArchiveWriter.cpp

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ static void printWithSpacePadding(raw_ostream &OS, T Data, unsigned Size) {
122122
static bool isBSDLike(object::Archive::Kind Kind) {
123123
switch (Kind) {
124124
case object::Archive::K_GNU:
125-
case object::Archive::K_GNU64:
126125
return false;
127126
case object::Archive::K_BSD:
128127
case object::Archive::K_DARWIN:
129128
return true;
129+
case object::Archive::K_GNU64:
130130
case object::Archive::K_DARWIN64:
131131
case object::Archive::K_COFF:
132132
break;
133133
}
134134
llvm_unreachable("not supported for writting");
135135
}
136136

137-
template <class T>
138-
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val) {
137+
static void print32(raw_ostream &Out, object::Archive::Kind Kind,
138+
uint32_t Val) {
139139
if (isBSDLike(Kind))
140140
support::endian::Writer<support::little>(Out).write(Val);
141141
else
@@ -216,20 +216,6 @@ static std::string computeRelativePath(StringRef From, StringRef To) {
216216
return Relative.str();
217217
}
218218

219-
static bool is64BitKind(object::Archive::Kind Kind) {
220-
switch (Kind) {
221-
case object::Archive::K_GNU:
222-
case object::Archive::K_BSD:
223-
case object::Archive::K_DARWIN:
224-
case object::Archive::K_COFF:
225-
return false;
226-
case object::Archive::K_DARWIN64:
227-
case object::Archive::K_GNU64:
228-
return true;
229-
}
230-
llvm_unreachable("not supported for writting");
231-
}
232-
233219
static void addToStringTable(raw_ostream &Out, StringRef ArcName,
234220
const NewArchiveMember &M, bool Thin) {
235221
StringRef ID = M.Buf->getBufferIdentifier();
@@ -302,14 +288,6 @@ static bool isArchiveSymbol(const object::BasicSymbolRef &S) {
302288
return true;
303289
}
304290

305-
static void printNBits(raw_ostream &Out, object::Archive::Kind Kind,
306-
uint64_t Val) {
307-
if (is64BitKind(Kind))
308-
print<uint64_t>(Out, Kind, Val);
309-
else
310-
print<uint32_t>(Out, Kind, Val);
311-
}
312-
313291
static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind,
314292
bool Deterministic, ArrayRef<MemberData> Members,
315293
StringRef StringTable) {
@@ -321,11 +299,9 @@ static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind,
321299
NumSyms += M.Symbols.size();
322300

323301
unsigned Size = 0;
324-
Size += is64BitKind(Kind) ? 8 : 4; // Number of entries
302+
Size += 4; // Number of entries
325303
if (isBSDLike(Kind))
326304
Size += NumSyms * 8; // Table
327-
else if (is64BitKind(Kind))
328-
Size += NumSyms * 8; // Table
329305
else
330306
Size += NumSyms * 4; // Table
331307
if (isBSDLike(Kind))
@@ -342,30 +318,27 @@ static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind,
342318
if (isBSDLike(Kind))
343319
printBSDMemberHeader(Out, Out.tell(), "__.SYMDEF", now(Deterministic), 0, 0,
344320
0, Size);
345-
else if (is64BitKind(Kind))
346-
printGNUSmallMemberHeader(Out, "/SYM64", now(Deterministic), 0, 0, 0, Size);
347321
else
348322
printGNUSmallMemberHeader(Out, "", now(Deterministic), 0, 0, 0, Size);
349323

350324
uint64_t Pos = Out.tell() + Size;
351325

352326
if (isBSDLike(Kind))
353-
print<uint32_t>(Out, Kind, NumSyms * 8);
327+
print32(Out, Kind, NumSyms * 8);
354328
else
355-
printNBits(Out, Kind, NumSyms);
329+
print32(Out, Kind, NumSyms);
356330

357331
for (const MemberData &M : Members) {
358332
for (unsigned StringOffset : M.Symbols) {
359333
if (isBSDLike(Kind))
360-
print<uint32_t>(Out, Kind, StringOffset);
361-
printNBits(Out, Kind, Pos); // member offset
334+
print32(Out, Kind, StringOffset);
335+
print32(Out, Kind, Pos); // member offset
362336
}
363337
Pos += M.Header.size() + M.Data.size() + M.Padding.size();
364338
}
365339

366340
if (isBSDLike(Kind))
367-
// byte count of the string table
368-
print<uint32_t>(Out, Kind, StringTable.size());
341+
print32(Out, Kind, StringTable.size()); // byte count of the string table
369342
Out << StringTable;
370343

371344
while (Pad--)
@@ -469,25 +442,6 @@ Error llvm::writeArchive(StringRef ArcName,
469442
if (!StringTableBuf.empty())
470443
Data.insert(Data.begin(), computeStringTable(StringTableBuf));
471444

472-
// We would like to detect if we need to switch to a 64-bit symbol table.
473-
if (WriteSymtab) {
474-
uint64_t MaxOffset = 0;
475-
uint64_t LastOffset = MaxOffset;
476-
for (const auto& M : Data) {
477-
// Record the start of the member's offset
478-
LastOffset = MaxOffset;
479-
// Account for the size of each part associated with the member.
480-
MaxOffset += M.Header.size() + M.Data.size() + M.Padding.size();
481-
// We assume 32-bit symbols to see if 32-bit symbols are possible or not.
482-
MaxOffset += M.Symbols.size() * 4;
483-
}
484-
// If LastOffset isn't going to fit in a 32-bit varible we need to switch
485-
// to 64-bit. Note that the file can be larger than 4GB as long as the last
486-
// member starts before the 4GB offset.
487-
if (LastOffset >> 32 != 0)
488-
Kind = object::Archive::K_GNU64;
489-
}
490-
491445
SmallString<128> TmpArchive;
492446
int TmpArchiveFD;
493447
if (auto EC = sys::fs::createUniqueFile(ArcName + ".temp-archive-%%%%%%%.a",

test/Object/archive-SYM64-write.test

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)