[llvm-commits] [llvm] r97991 - in /llvm/trunk: lib/MC/MCAssembler.cpp test/MC/MachO/zerofill-4.s test/MC/MachO/zerofill-sect-align.s
Daniel Dunbar
daniel at zuster.org
Mon Mar 8 14:03:42 PST 2010
Author: ddunbar
Date: Mon Mar 8 16:03:42 2010
New Revision: 97991
URL: http://llvm.org/viewvc/llvm-project?rev=97991&view=rev
Log:
MC/Macho-O: Align the zerofill section itself to the maximum alignment.
Added:
llvm/trunk/test/MC/MachO/zerofill-sect-align.s
Modified:
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/test/MC/MachO/zerofill-4.s
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=97991&r1=97990&r2=97991&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Mon Mar 8 16:03:42 2010
@@ -1279,9 +1279,19 @@
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", {
Modified: llvm/trunk/test/MC/MachO/zerofill-4.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/zerofill-4.s?rev=97991&r1=97990&r2=97991&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/zerofill-4.s (original)
+++ llvm/trunk/test/MC/MachO/zerofill-4.s Mon Mar 8 16:03:42 2010
@@ -1,4 +1,4 @@
-// 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
Added: llvm/trunk/test/MC/MachO/zerofill-sect-align.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/zerofill-sect-align.s?rev=97991&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/zerofill-sect-align.s (added)
+++ llvm/trunk/test/MC/MachO/zerofill-sect-align.s Mon Mar 8 16:03:42 2010
@@ -0,0 +1,15 @@
+// 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')
More information about the llvm-commits
mailing list