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

Peng Guo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 7 18:02:17 PST 2020


pguo created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
pguo added reviewers: gchatelet, pete, pcc.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74273

Files:
  llvm/lib/MC/MachObjectWriter.cpp


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.243337.patch
Type: text/x-patch
Size: 723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200208/d25c0a82/attachment.bin>


More information about the llvm-commits mailing list