[PATCH] D143538: [Object][NFC] Don't insert string table into object members vector.
Jacek Caban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 9 07:13:59 PST 2023
jacek updated this revision to Diff 496116.
jacek added a comment.
rebased
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143538/new/
https://reviews.llvm.org/D143538
Files:
llvm/lib/Object/ArchiveWriter.cpp
Index: llvm/lib/Object/ArchiveWriter.cpp
===================================================================
--- llvm/lib/Object/ArchiveWriter.cpp
+++ llvm/lib/Object/ArchiveWriter.cpp
@@ -398,7 +398,8 @@
}
}
-static uint64_t computeHeadersSize(object::Archive::Kind Kind, uint64_t NumSyms,
+static uint64_t computeHeadersSize(object::Archive::Kind Kind,
+ uint64_t StringMemberSize, uint64_t NumSyms,
uint64_t SymNamesSize) {
uint32_t OffsetSize = is64BitKind(Kind) ? 8 : 4;
uint64_t SymtabSize =
@@ -410,7 +411,7 @@
return TmpBuf.size();
};
- return strlen("!<arch>\n") + computeSymbolTableHeaderSize() + SymtabSize;
+ return strlen("!<arch>\n") + computeSymbolTableHeaderSize() + SymtabSize + StringMemberSize;
}
static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind,
@@ -689,8 +690,14 @@
return E;
std::vector<MemberData> &Data = *DataOrErr;
- if (!StringTableBuf.empty() && !isAIXBigArchive(Kind))
- Data.insert(Data.begin(), computeStringTable(StringTableBuf));
+ uint64_t StringTableSize = 0;
+ MemberData StringTableMember;
+ if (!StringTableBuf.empty() && !isAIXBigArchive(Kind)) {
+ StringTableMember = computeStringTable(StringTableBuf);
+ StringTableSize = StringTableMember.Header.size() +
+ StringTableMember.Data.size() +
+ StringTableMember.Padding.size();
+ }
// We would like to detect if we need to switch to a 64-bit symbol table.
uint64_t LastMemberEndOffset =
@@ -711,7 +718,8 @@
// table is at the start of the archive file for other archive formats.
if (WriteSymtab && !is64BitKind(Kind)) {
// We assume 32-bit offsets to see if 32-bit symbols are possible or not.
- HeadersSize = computeHeadersSize(Kind, NumSyms, SymNamesBuf.size());
+ HeadersSize =
+ computeHeadersSize(Kind, StringTableSize, NumSyms, SymNamesBuf.size());
// The SYM64 format is used when an archive's member offsets are larger than
// 32-bits can hold. The need for this shift in format is detected by
@@ -747,10 +755,16 @@
if (!isAIXBigArchive(Kind)) {
if (WriteSymtab) {
if (!HeadersSize)
- HeadersSize = computeHeadersSize(Kind, NumSyms, SymNamesBuf.size());
+ HeadersSize = computeHeadersSize(Kind, StringTableSize, NumSyms,
+ SymNamesBuf.size());
writeSymbolTable(Out, Kind, Deterministic, Data, SymNamesBuf,
HeadersSize);
}
+
+ if (StringTableSize)
+ Out << StringTableMember.Header << StringTableMember.Data
+ << StringTableMember.Padding;
+
for (const MemberData &M : Data)
Out << M.Header << M.Data << M.Padding;
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143538.496116.patch
Type: text/x-patch
Size: 2791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230209/904a646b/attachment.bin>
More information about the llvm-commits
mailing list