forked from OSchip/llvm-project
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
This commit is contained in:
parent
25eb54f789
commit
0bd982b79f
|
@ -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));
|
||||
|
|
|
@ -115,7 +115,7 @@ COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
|
|||
COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
|
||||
COFF-SHORT-IMPORT-NOT: _bar in coff-short-import-data
|
||||
|
||||
Test that we pad the symbol table so that it ends in a multiple of 4 bytes:
|
||||
Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
|
||||
8 + 60 + 36 == 104
|
||||
RUN: rm -f %t.a
|
||||
RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
|
||||
|
@ -123,6 +123,14 @@ RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
|
|||
MACHO-SYMTAB-ALIGN: !<arch>
|
||||
MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `
|
||||
|
||||
Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
|
||||
8 + 60 + 52 == 120
|
||||
RUN: rm -f %t.a
|
||||
RUN: llvm-ar --format=bsd rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test.macho-x86-64
|
||||
RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN2 %s < %t.a
|
||||
MACHO-SYMTAB-ALIGN2: !<arch>
|
||||
MACHO-SYMTAB-ALIGN2-NEXT: #1/12 0 0 0 0 52 `
|
||||
|
||||
With a gnu symbol table we only align to two
|
||||
8 + 60 + 14 = 82
|
||||
RUN: rm -f %t.a
|
||||
|
|
Loading…
Reference in New Issue