[PATCH] D74273: [MachO] Pad section data to pointer size bytes

Peng Guo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 14:22:39 PST 2020


pguo updated this revision to Diff 244004.
pguo added a comment.

- Fix unit test after changing macho pad bytes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74273/new/

https://reviews.llvm.org/D74273

Files:
  llvm/lib/MC/MachObjectWriter.cpp
  llvm/test/MC/MachO/darwin-x86_64-diff-relocs.s
  llvm/test/MC/MachO/variable-exprs.s


Index: llvm/test/MC/MachO/variable-exprs.s
===================================================================
--- llvm/test/MC/MachO/variable-exprs.s
+++ llvm/test/MC/MachO/variable-exprs.s
@@ -298,7 +298,7 @@
 // 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)
Index: llvm/test/MC/MachO/darwin-x86_64-diff-relocs.s
===================================================================
--- llvm/test/MC/MachO/darwin-x86_64-diff-relocs.s
+++ llvm/test/MC/MachO/darwin-x86_64-diff-relocs.s
@@ -147,7 +147,7 @@
 // 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)
@@ -174,7 +174,7 @@
 // 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)
Index: llvm/lib/MC/MachObjectWriter.cpp
===================================================================
--- llvm/lib/MC/MachObjectWriter.cpp
+++ llvm/lib/MC/MachObjectWriter.cpp
@@ -831,11 +831,11 @@
     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...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74273.244004.patch
Type: text/x-patch
Size: 2047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200211/46551825/attachment.bin>


More information about the llvm-commits mailing list