Can't add a section in FASM Syntax

2.2k views Asked by At

I have some problem here with adding a section using FASM Syntax. I have checked on others websites and I am sure this is the right syntax. I must be missing something :

format elf executable 3
entry start

section '.text' readable executable

start:
mov ebx, 0
mov eax, 1
int 0x80

and FASM is giving me :

flat assembler version 1.70.03 (16384 kilobytes memory) exit.asm[4]: section '.text' readable executable error: illegal instruction.

Btw I can't also create a named segment like:

segment .data

but I can do :

segment readable executable

I can't find an explanation for this.

2

There are 2 answers

4
Jens Björnhager On

It seems that the FASM documentation for ELFs aren't up to date. You should go to the FASM forums and report and/or ask about it.

I got this to compile in 1.70.03, adapted from the elfexe example:

format elf executable 3
entry start

segment readable executable

start:
mov     ebx,0
mov     eax,1
int     0x80
1
johnfound On

The section keyword is to be used only if the result ELF will be later linked with external linkers.

If the format directive contains executable clause, only segment directives are allowed and the result file can be directly executed without linking.

This all is explained at the end of the related section in the FASM manual ch.2.4.4.