@@ -680,7 +680,7 @@ getSymbols(MemoryBufferRef Buf, uint16_t Index, raw_ostream &SymNames,
680
680
static Expected<std::vector<MemberData>>
681
681
computeMemberData (raw_ostream &StringTable, raw_ostream &SymNames,
682
682
object::Archive::Kind Kind, bool Thin, bool Deterministic,
683
- bool NeedSymbols, SymMap *SymMap,
683
+ SymtabWritingMode NeedSymbols, SymMap *SymMap,
684
684
ArrayRef<NewArchiveMember> NewMembers) {
685
685
static char PaddingData[8 ] = {' \n ' , ' \n ' , ' \n ' , ' \n ' , ' \n ' , ' \n ' , ' \n ' , ' \n ' };
686
686
@@ -796,7 +796,7 @@ computeMemberData(raw_ostream &StringTable, raw_ostream &SymNames,
796
796
Out.flush ();
797
797
798
798
std::vector<unsigned > Symbols;
799
- if (NeedSymbols) {
799
+ if (NeedSymbols != SymtabWritingMode::NoSymtab ) {
800
800
Expected<std::vector<unsigned >> SymbolsOrErr =
801
801
getSymbols (Buf, Index, SymNames, SymMap, HasObject);
802
802
if (!SymbolsOrErr)
@@ -860,7 +860,8 @@ Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To) {
860
860
861
861
static Error writeArchiveToStream (raw_ostream &Out,
862
862
ArrayRef<NewArchiveMember> NewMembers,
863
- bool WriteSymtab, object::Archive::Kind Kind,
863
+ SymtabWritingMode WriteSymtab,
864
+ object::Archive::Kind Kind,
864
865
bool Deterministic, bool Thin, bool IsEC) {
865
866
assert ((!Thin || !isBSDLike (Kind)) && " Only the gnu format has a thin mode" );
866
867
@@ -897,6 +898,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
897
898
uint64_t LastMemberHeaderOffset = 0 ;
898
899
uint64_t NumSyms = 0 ;
899
900
uint64_t NumSyms32 = 0 ; // Store symbol number of 32-bit member files.
901
+ bool ShouldWriteSymtab = WriteSymtab != SymtabWritingMode::NoSymtab;
900
902
901
903
for (const auto &M : Data) {
902
904
// Record the start of the member's offset
@@ -910,7 +912,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
910
912
// symbols; the second global symbol table does the same for 64-bit file
911
913
// members. As a big archive can have both 32-bit and 64-bit file members,
912
914
// we need to know the number of symbols in each symbol table individually.
913
- if (isAIXBigArchive (Kind) && WriteSymtab ) {
915
+ if (isAIXBigArchive (Kind) && ShouldWriteSymtab ) {
914
916
Expected<bool > Is64BitOrErr = is64BitSymbolicFile (M.Data );
915
917
if (Error E = Is64BitOrErr.takeError ())
916
918
return E;
@@ -924,7 +926,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
924
926
925
927
// The symbol table is put at the end of the big archive file. The symbol
926
928
// table is at the start of the archive file for other archive formats.
927
- if (WriteSymtab && !is64BitKind (Kind)) {
929
+ if (ShouldWriteSymtab && !is64BitKind (Kind)) {
928
930
// We assume 32-bit offsets to see if 32-bit symbols are possible or not.
929
931
HeadersSize = computeHeadersSize (Kind, Data.size (), StringTableSize,
930
932
NumSyms, SymNamesBuf.size (),
@@ -962,7 +964,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
962
964
Out << " !<arch>\n " ;
963
965
964
966
if (!isAIXBigArchive (Kind)) {
965
- if (WriteSymtab ) {
967
+ if (ShouldWriteSymtab ) {
966
968
if (!HeadersSize)
967
969
HeadersSize = computeHeadersSize (
968
970
Kind, Data.size (), StringTableSize, NumSyms, SymNamesBuf.size (),
@@ -978,7 +980,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
978
980
Out << StringTableMember.Header << StringTableMember.Data
979
981
<< StringTableMember.Padding ;
980
982
981
- if (WriteSymtab && SymMap.ECMap .size ())
983
+ if (ShouldWriteSymtab && SymMap.ECMap .size ())
982
984
writeECSymbols (Out, Kind, Deterministic, Data, SymMap);
983
985
984
986
for (const MemberData &M : Data)
@@ -1017,7 +1019,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
1017
1019
raw_svector_ostream SymNames32 (SymNamesBuf32);
1018
1020
raw_svector_ostream SymNames64 (SymNamesBuf64);
1019
1021
1020
- if (WriteSymtab && NumSyms)
1022
+ if (ShouldWriteSymtab && NumSyms)
1021
1023
// Generate the symbol names for the members.
1022
1024
for (const NewArchiveMember &M : NewMembers) {
1023
1025
MemoryBufferRef Buf = M.Buf ->getMemBufferRef ();
@@ -1041,11 +1043,15 @@ static Error writeArchiveToStream(raw_ostream &Out,
1041
1043
// the offset to the 32-bit global symbol table, and the 'GlobSym64Offset'
1042
1044
// contains the offset to the 64-bit global symbol table.
1043
1045
uint64_t GlobalSymbolOffset =
1044
- (WriteSymtab && NumSyms32 > 0 ) ? MemberTableEndOffset : 0 ;
1046
+ (ShouldWriteSymtab &&
1047
+ (WriteSymtab != SymtabWritingMode::BigArchive64) && NumSyms32 > 0 )
1048
+ ? MemberTableEndOffset
1049
+ : 0 ;
1045
1050
1046
1051
uint64_t GlobalSymbolOffset64 = 0 ;
1047
1052
uint64_t NumSyms64 = NumSyms - NumSyms32;
1048
- if (WriteSymtab && NumSyms64 > 0 ) {
1053
+ if (ShouldWriteSymtab && (WriteSymtab != SymtabWritingMode::BigArchive32) &&
1054
+ NumSyms64 > 0 ) {
1049
1055
if (GlobalSymbolOffset == 0 )
1050
1056
GlobalSymbolOffset64 = MemberTableEndOffset;
1051
1057
else
@@ -1095,7 +1101,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
1095
1101
Out << ' \0 ' ; // Name table must be tail padded to an even number of
1096
1102
// bytes.
1097
1103
1098
- if (WriteSymtab ) {
1104
+ if (ShouldWriteSymtab ) {
1099
1105
// Write global symbol table for 32-bit file members.
1100
1106
if (GlobalSymbolOffset) {
1101
1107
writeSymbolTable (Out, Kind, Deterministic, Data, SymNamesBuf32,
@@ -1121,7 +1127,7 @@ static Error writeArchiveToStream(raw_ostream &Out,
1121
1127
}
1122
1128
1123
1129
Error writeArchive (StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
1124
- bool WriteSymtab, object::Archive::Kind Kind,
1130
+ SymtabWritingMode WriteSymtab, object::Archive::Kind Kind,
1125
1131
bool Deterministic, bool Thin,
1126
1132
std::unique_ptr<MemoryBuffer> OldArchiveBuf, bool IsEC) {
1127
1133
Expected<sys::fs::TempFile> Temp =
@@ -1153,9 +1159,9 @@ Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
1153
1159
}
1154
1160
1155
1161
Expected<std::unique_ptr<MemoryBuffer>>
1156
- writeArchiveToBuffer (ArrayRef<NewArchiveMember> NewMembers, bool WriteSymtab,
1157
- object::Archive::Kind Kind, bool Deterministic ,
1158
- bool Thin) {
1162
+ writeArchiveToBuffer (ArrayRef<NewArchiveMember> NewMembers,
1163
+ SymtabWritingMode WriteSymtab, object::Archive::Kind Kind,
1164
+ bool Deterministic, bool Thin) {
1159
1165
SmallVector<char , 0 > ArchiveBufferVector;
1160
1166
raw_svector_ostream ArchiveStream (ArchiveBufferVector);
1161
1167
0 commit comments