MC/Mach-O: Fix address compution for zero fill sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-03-08 21:10:42 +00:00
parent 0ce6bd55c3
commit 37fad5ce4d
2 changed files with 37 additions and 2 deletions

View File

@ -1049,8 +1049,8 @@ void MCAssembler::LayoutSection(MCSectionData &SD) {
// Align the fragment offset; it is safe to adjust the offset freely since
// this is only in virtual sections.
uint64_t Aligned = RoundUpToAlignment(Address, ZFF.getAlignment());
F.setOffset(Aligned - SD.getAddress());
Address = RoundUpToAlignment(Address, ZFF.getAlignment());
F.setOffset(Address - SD.getAddress());
// FIXME: This is misnamed.
F.setFileSize(ZFF.getSize());

View File

@ -0,0 +1,35 @@
// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
.zerofill __DATA,__bss,_fill0,1,0
.zerofill __DATA,__bss,_a,4,2
.zerofill __DATA,__bss,_fill1,1,0
.zerofill __DATA,__bss,_b,4,3
.zerofill __DATA,__bss,_fill2,1,0
.zerofill __DATA,__bss,_c,4,4
.zerofill __DATA,__bss,_fill3,1,0
.zerofill __DATA,__bss,_d,4,5
// CHECK: # Symbol 0
// CHECK: ('n_value', 0)
// CHECK: ('_string', '_fill0')
// CHECK: # Symbol 1
// CHECK: ('n_value', 4)
// CHECK: ('_string', '_a')
// CHECK: # Symbol 2
// CHECK: ('n_value', 8)
// CHECK: ('_string', '_fill1')
// CHECK: # Symbol 3
// CHECK: ('n_value', 16)
// CHECK: ('_string', '_b')
// CHECK: # Symbol 4
// CHECK: ('n_value', 20)
// CHECK: ('_string', '_fill2')
// CHECK: # Symbol 5
// CHECK: ('n_value', 32)
// CHECK: ('_string', '_c')
// CHECK: # Symbol 6
// CHECK: ('n_value', 36)
// CHECK: ('_string', '_fill3')
// CHECK: # Symbol 7
// CHECK: ('n_value', 64)
// CHECK: ('_string', '_d')