Author Topic: Mach-O alignment issue in Mac OS X  (Read 5337 times)


  • Guest
Mach-O alignment issue in Mac OS X
« on: January 14, 2008, 01:29:51 PM »
Although this is undocumented, the Mach-O output supports the "align" section directive qualifier. Now, when I specify

section .rodata align=16
align 16
const0 dd 1,2,3,4
const1 dd 5,6,7,8

then nm(1) says that const0 is at 0xa16 and const1 at 0xa26 in the object file. The Apple linker then places const0 at 0x4250, but const1 at... 0x4266 in the a.out file, i.e. it is NOT aligned at 16-byte boundary! This issue can be worked around by omitting the "align=16" qualifier above and using the linker option

-sectalign __DATA __const 10

but this isn't very convenient. Is this a bug in NASM or in ld(1) of Mac OS X 10.5? What do the NASM developers think? (The problem occurs with both NASM 0.98.40 and 2.00.)