if (!isVirtualSection(SD.getSection()))
continue;
+ // Align this section if necessary by adding padding bytes to the previous
+ // section.
+ if (uint64_t Pad = OffsetToAlignment(Address, it->getAlignment())) {
+ assert(Prev && "Missing prev section!");
+ Prev->setFileSize(Prev->getFileSize() + Pad);
+ Address += Pad;
+ }
+
SD.setAddress(Address);
LayoutSection(SD);
Address += SD.getSize();
+
+ Prev = &SD;
}
DEBUG_WITH_TYPE("mc-dump", {
-// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump | FileCheck %s
.zerofill __DATA,__bss,_fill0,1,0
.zerofill __DATA,__bss,_a,4,2
--- /dev/null
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump | FileCheck %s
+//
+// Check that the section itself is aligned.
+
+ .byte 0
+
+.zerofill __DATA,__bss,_a,1,0
+.zerofill __DATA,__bss,_b,4,4
+
+// CHECK: # Symbol 0
+// CHECK: ('n_value', 16)
+// CHECK: ('_string', '_a')
+// CHECK: # Symbol 1
+// CHECK: ('n_value', 32)
+// CHECK: ('_string', '_b')