<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">align file offset with address layout

&lt;rdar://problem/10445047&gt;

--- src/ld/OutputFile.cpp
+++ src/ld/OutputFile.cpp
@@ -551,8 +551,8 @@ void OutputFile::assignFileOffsets(ld::Internal&amp; state)
 				throwf("section %s (address=0x%08llX, size=%llu) would make the output executable exceed available address range", 
 						sect-&gt;sectionName(), address, sect-&gt;size);
 		
-		if ( log ) fprintf(stderr, "  address=0x%08llX, hidden=%d, alignment=%02d, padBytes=%d, section=%s,%s\n",
-							sect-&gt;address, sect-&gt;isSectionHidden(), sect-&gt;alignment, sect-&gt;alignmentPaddingBytes, 
+		if ( log ) fprintf(stderr, "  address=0x%08llX, size=0x%08llX, hidden=%d, alignment=%02d, padBytes=%d, section=%s,%s\n",
+							sect-&gt;address, sect-&gt;size, sect-&gt;isSectionHidden(), sect-&gt;alignment, sect-&gt;alignmentPaddingBytes, 
 							sect-&gt;segmentName(), sect-&gt;sectionName());
 		// update running totals
 		if ( !sect-&gt;isSectionHidden() || hiddenSectionsOccupyAddressSpace )
@@ -569,6 +569,9 @@ void OutputFile::assignFileOffsets(ld::Internal&amp; state)
 		if ( hasZeroForFileOffset(sect) ) {
 			// fileoff of zerofill sections is moot, but historically it is set to zero
 			sect-&gt;fileOffset = 0;
+
+			// &lt;rdar://problem/10445047&gt; align file offset with address layout
+			fileOffset += sect-&gt;alignmentPaddingBytes;
 		}
 		else {
 			// page align file offset at start of each segment
</pre></body></html>