Skip to content

Commit

Permalink
[MachO] Pad section data to pointer size bytes
Browse files Browse the repository at this point in the history
https://reviews.llvm.org/D74273

Pad macho section data to pointer size bytes, so that relocation
table and symbol table following section data will be pointer size
aligned.

Patch by pguo.
  • Loading branch information
Aditya Nandakumar committed Feb 11, 2020
1 parent aedda89 commit bdc3c73
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/MC/MachObjectWriter.cpp
Expand Up @@ -831,11 +831,11 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
SectionDataFileSize = std::max(SectionDataFileSize, Address + FileSize);
}

// The section data is padded to 4 bytes.
// The section data is padded to pointer size bytes.
//
// FIXME: Is this machine dependent?
unsigned SectionDataPadding =
offsetToAlignment(SectionDataFileSize, Align(4));
offsetToAlignment(SectionDataFileSize, is64Bit() ? Align(8) : Align(4));
SectionDataFileSize += SectionDataPadding;

// Write the prolog, starting with the header and load command...
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MC/MachO/darwin-x86_64-diff-relocs.s
Expand Up @@ -147,7 +147,7 @@ L3:
// CHECK: Size: 0x5E
// CHECK: Offset: 384
// CHECK: Alignment: 0
// CHECK: RelocationOffset: 0x26C
// CHECK: RelocationOffset: 0x270
// CHECK: RelocationCount: 12
// CHECK: Type: Regular (0x0)
// CHECK: Attributes [ (0x800004)
Expand All @@ -174,7 +174,7 @@ L3:
// CHECK: Size: 0x8E
// CHECK: Offset: 478
// CHECK: Alignment: 0
// CHECK: RelocationOffset: 0x2CC
// CHECK: RelocationOffset: 0x2D0
// CHECK: RelocationCount: 16
// CHECK: Type: Regular (0x0)
// CHECK: Attributes [ (0x4)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/MachO/variable-exprs.s
Expand Up @@ -298,7 +298,7 @@ Lt0_x = Lt0_a - Lt0_b
// CHECK-X86_64: Size: 0x38
// CHECK-X86_64: Offset: 385
// CHECK-X86_64: Alignment: 0
// CHECK-X86_64: RelocationOffset: 0x1BC
// CHECK-X86_64: RelocationOffset: 0x1C0
// CHECK-X86_64: RelocationCount: 9
// CHECK-X86_64: Type: Regular (0x0)
// CHECK-X86_64: Attributes [ (0x0)
Expand Down

0 comments on commit bdc3c73

Please sign in to comment.