The documentation states the following:
To create executable file, follow the format choice directive with the executable keyword. It allows to use entry directive followed by the value to set as entry point of program. On the other hand it makes extrn and public directives unavailable, and instead of section there should be the segment directive used, followed only by one or more segment permission flags. The origin of segment is aligned to page (4096 bytes), and available flags for are: readable, writeable and executable.
However when compiling the following example:
; fasm demonstration of writing simple ELF executable
format ELF executable
entry start
segment readable executable
start:
mov eax,4
mov ebx,1
mov ecx,msg
mov edx,msg_size
int 0x80
mov eax,1
xor ebx,ebx
int 0x80
segment readable writeable
msg db 'Hello world!',0xA
msg_size = $-msg
IDApro says:
LOAD:08048074 ; Format : ELF (Executable)
LOAD:08048074 ;
LOAD:08048074
LOAD:08048074 .686p
LOAD:08048074 .mmx
LOAD:08048074 .model flat
LOAD:08048074 .intel_syntax noprefix
LOAD:08048074
LOAD:08048074 ; ---------------------------------------------------------------------------
LOAD:08048074
LOAD:08048074 ; Segment type: Pure code
LOAD:08048074 ; Segment permissions: Read/Execute
LOAD:08048074 LOAD segment mempage public 'CODE' use32
LOAD:08048074 assume cs:LOAD
LOAD:08048074 ;org 8048074h
LOAD:08048074 assume es:nothing, ss:nothing, ds:LOAD, fs:nothing, gs:nothing
LOAD:08048074
LOAD:08048074 ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
LOAD:08048074
LOAD:08048074
LOAD:08048074 public start
LOAD:08048074 start proc near
LOAD:08048074 mov eax, 4
LOAD:08048079 mov ebx, 1 ; fd
LOAD:0804807E mov ecx, offset unk_8049093 ; addr
LOAD:08048083 mov edx, 0Dh ; len
LOAD:08048088 int 80h ; LINUX - sys_write
LOAD:0804808A mov eax, 1
LOAD:0804808F xor ebx, ebx ; status
LOAD:08048091 int 80h ; LINUX - sys_exit
LOAD:08048091 start endp
LOAD:08048091
LOAD:08048091 LOAD ends
LOAD:08048091
LOAD:08049093 ; ---------------------------------------------------------------------------
LOAD:08049093
LOAD:08049093 ; Segment type: Pure data
LOAD:08049093 ; Segment permissions: Read/Write
LOAD:08049093 LOAD segment mempage public 'DATA' use32
LOAD:08049093 assume cs:LOAD
LOAD:08049093 ;org 8049093h
LOAD:08049093 ; const void unk_8049093
LOAD:08049093 unk_8049093 db 48h ; H ; DATA XREF: start+Ao
LOAD:08049094 db 65h ; e
LOAD:08049095 db 6Ch ; l
LOAD:08049096 db 6Ch ; l
LOAD:08049097 db 6Fh ; o
LOAD:08049098 db 20h
LOAD:08049099 db 77h ; w
LOAD:0804909A db 6Fh ; o
LOAD:0804909B db 72h ; r
LOAD:0804909C db 6Ch ; l
LOAD:0804909D db 64h ; d
LOAD:0804909E db 21h ; !
LOAD:0804909F db 0Ah
LOAD:0804909F LOAD ends
LOAD:0804909F
LOAD:0804909F
LOAD:0804909F end start
(Take special attention to the last segment)
I've realised the lack of aligment when I've tried "movdqa xmm0, [$]" in another thread and also crashed until I used "align 16".
Is this a documentation bug?