From 0bd982b79f9620379719834ba6008c0a487b0645 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 22 Sep 2017 18:36:00 +0000 Subject: llvm-ar: align the first archive member consistently. Before we were aligning the member after the symbol table to 4 but other members to 8. llvm-svn: 314010 --- llvm/lib/Object/ArchiveWriter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Object/ArchiveWriter.cpp') diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index ce83cb1245f..4586d4427fe 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -349,9 +349,11 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind, if (StringTable.size() == 0) print32(Out, Kind, 0); - // ld64 requires the next member header to start at an offset that is - // 4 bytes aligned. - unsigned Alignment = isBSDLike(Kind) ? 4 : 2; + // ld64 expects the members to be 8-byte aligned for 64-bit content and at + // least 4-byte aligned for 32-bit content. Opt for the larger encoding + // uniformly. + // We do this for all bsd formats because it simplifies aligning members. + unsigned Alignment = isBSDLike(Kind) ? 8 : 2; unsigned Pad = OffsetToAlignment(Out.tell(), Alignment); while (Pad--) Out.write(uint8_t(0)); -- cgit v1.2.3