llvm-ar: Don't add an unnecessary alignment in gnu mode.

This is mostly for getting stricter testing in preparation for future
changes.

llvm-svn: 314000
This commit is contained in:
Rafael Espindola 2017-09-22 18:16:13 +00:00
parent fbccb0a8d2
commit d5d77372d4
2 changed files with 10 additions and 1 deletions

View File

@ -351,7 +351,8 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind,
// ld64 requires the next member header to start at an offset that is
// 4 bytes aligned.
unsigned Pad = OffsetToAlignment(Out.tell(), 4);
unsigned Alignment = isBSDLike(Kind) ? 4 : 2;
unsigned Pad = OffsetToAlignment(Out.tell(), Alignment);
while (Pad--)
Out.write(uint8_t(0));

View File

@ -122,3 +122,11 @@ RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
MACHO-SYMTAB-ALIGN: !<arch>
MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `
With a gnu symbol table we only align to two
8 + 60 + 14 = 82
RUN: rm -f %t.a
RUN: llvm-ar --format=gnu rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64
RUN: FileCheck --check-prefix=GNU-SYMTAB-ALIGN %s < %t.a
GNU-SYMTAB-ALIGN: !<arch>
GNU-SYMTAB-ALIGN-NEXT: / 0 0 0 0 14 `