I have encountered an issue that;
Under Mach-O, "section .data" ignores align directive. (using nasm 2.5.1)
I guess that:
- if "align" is used at data section, pre-padding is required for Mach-O object file.
//
1)With meaningless sample asm code following, line 1: align directive is ignored:
section .data align=16
;align 16
hello db 'Hello World','$'
;align 16
const0 dw 1,2,3,4
;align 16
const1 dw 5,6,7,8
section .text
_start:
mov eax, 1
mov ebx, 2
int 80h
;align 16
; times 8 dw 0
$ nasm -fmacho -o a.o a.asm ; nm a.o
00000000 t _start
00000012 d const0
0000001a d const1
0000000c d hello
//
2)Uncomment line 2, 4, 6, "align=16", then each data is placed at every 16byte, but not aligned yet.
$ nasm -fmacho -o a.o a.asm ; nm a.o
00000000 t _start
0000001c d const0
0000002c d const1
0000000c d hello
3)Uncomment last two line, it finally align objects:
nasm -fmacho -o a.o a.asm ; nm a.o
00000000 t _start
00000030 d const0
00000040 d const1
00000020 d hello
//