@@ -122,20 +122,20 @@ static void printWithSpacePadding(raw_ostream &OS, T Data, unsigned Size) {
122
122
static bool isBSDLike (object::Archive::Kind Kind) {
123
123
switch (Kind) {
124
124
case object::Archive::K_GNU:
125
- case object::Archive::K_GNU64:
126
125
return false ;
127
126
case object::Archive::K_BSD:
128
127
case object::Archive::K_DARWIN:
129
128
return true ;
129
+ case object::Archive::K_GNU64:
130
130
case object::Archive::K_DARWIN64:
131
131
case object::Archive::K_COFF:
132
132
break ;
133
133
}
134
134
llvm_unreachable (" not supported for writting" );
135
135
}
136
136
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) {
139
139
if (isBSDLike (Kind))
140
140
support::endian::Writer<support::little>(Out).write (Val);
141
141
else
@@ -216,20 +216,6 @@ static std::string computeRelativePath(StringRef From, StringRef To) {
216
216
return Relative.str ();
217
217
}
218
218
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
-
233
219
static void addToStringTable (raw_ostream &Out, StringRef ArcName,
234
220
const NewArchiveMember &M, bool Thin) {
235
221
StringRef ID = M.Buf ->getBufferIdentifier ();
@@ -302,14 +288,6 @@ static bool isArchiveSymbol(const object::BasicSymbolRef &S) {
302
288
return true ;
303
289
}
304
290
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
-
313
291
static void writeSymbolTable (raw_ostream &Out, object::Archive::Kind Kind,
314
292
bool Deterministic, ArrayRef<MemberData> Members,
315
293
StringRef StringTable) {
@@ -321,11 +299,9 @@ static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind,
321
299
NumSyms += M.Symbols .size ();
322
300
323
301
unsigned Size = 0 ;
324
- Size += is64BitKind (Kind) ? 8 : 4 ; // Number of entries
302
+ Size += 4 ; // Number of entries
325
303
if (isBSDLike (Kind))
326
304
Size += NumSyms * 8 ; // Table
327
- else if (is64BitKind (Kind))
328
- Size += NumSyms * 8 ; // Table
329
305
else
330
306
Size += NumSyms * 4 ; // Table
331
307
if (isBSDLike (Kind))
@@ -342,30 +318,27 @@ static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind,
342
318
if (isBSDLike (Kind))
343
319
printBSDMemberHeader (Out, Out.tell (), " __.SYMDEF" , now (Deterministic), 0 , 0 ,
344
320
0 , Size);
345
- else if (is64BitKind (Kind))
346
- printGNUSmallMemberHeader (Out, " /SYM64" , now (Deterministic), 0 , 0 , 0 , Size);
347
321
else
348
322
printGNUSmallMemberHeader (Out, " " , now (Deterministic), 0 , 0 , 0 , Size);
349
323
350
324
uint64_t Pos = Out.tell () + Size;
351
325
352
326
if (isBSDLike (Kind))
353
- print< uint32_t > (Out, Kind, NumSyms * 8 );
327
+ print32 (Out, Kind, NumSyms * 8 );
354
328
else
355
- printNBits (Out, Kind, NumSyms);
329
+ print32 (Out, Kind, NumSyms);
356
330
357
331
for (const MemberData &M : Members) {
358
332
for (unsigned StringOffset : M.Symbols ) {
359
333
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
362
336
}
363
337
Pos += M.Header .size () + M.Data .size () + M.Padding .size ();
364
338
}
365
339
366
340
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
369
342
Out << StringTable;
370
343
371
344
while (Pad--)
@@ -469,25 +442,6 @@ Error llvm::writeArchive(StringRef ArcName,
469
442
if (!StringTableBuf.empty ())
470
443
Data.insert (Data.begin (), computeStringTable (StringTableBuf));
471
444
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
-
491
445
SmallString<128 > TmpArchive;
492
446
int TmpArchiveFD;
493
447
if (auto EC = sys::fs::createUniqueFile (ArcName + " .temp-archive-%%%%%%%.a" ,
0 commit comments