flat assembler
Message board for the users of flat assembler.

Index > Linux > Can't declare sections

Author
Thread Post new topic Reply to topic
flynet



Joined: 15 Dec 2013
Posts: 3
flynet 15 Dec 2013, 20:59
Hello everyone,

I wanted to have proper sections in my asm code for making it easier to use with gdb and objdump but I am having some issue with declaring sections. I have read the documentation and asked on other forums but can't seem to find my answer. Here is the code I wrote:

Code:
format elf executable 3
entry start
 
section '.text' readable executable
 
start:
mov ebx, 0
mov eax, 1
int 0x80    


the line 4 was borrowed from examples from the web.

and the error fasm is giving me:
Quote:
flat assembler version 1.70.03 (16384 kilobytes memory)
exit.asm[4]: section '.text' readable executable
error: illegal instruction.


BTW, why is that I can't give a name to a segment like :
Quote:
segment mySegment readable executable
Post 15 Dec 2013, 20:59
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 16 Dec 2013, 01:06
To create executable file, follow the format choice directive with the executable keyword and optionally the number specifying the brand of the target operating system (for example value 3 would mark the executable for Linux systems). With this format selected it is allowed 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 by one or more segment permission flags and optionally a marker of special ELF executable segment, which can be interpreter, dynamic or note. The origin of segment is aligned to page (4096 bytes), and available permission flags are: readable, writeable and executable.
Also it should be noted that section directive for ELF object file accepts only writeable and executable flags (SysV ABI specifies only SHF_WRITE and SHF_EXECINSTR bits for sh_flags value).
Post 16 Dec 2013, 01:06
View user's profile Send private message Reply with quote
flynet



Joined: 15 Dec 2013
Posts: 3
flynet 16 Dec 2013, 08:42
Then it's impossible to name a section and to have sections like .data, .text, etc... ? I have tried to use the -s option to create symbolic info but gdb says that it can't recognize the executable format.
Post 16 Dec 2013, 08:42
View user's profile Send private message Reply with quote
randall



Joined: 03 Dec 2011
Posts: 155
Location: Poland
randall 16 Dec 2013, 08:57
You can still use gdb declaring only segments.
Post 16 Dec 2013, 08:57
View user's profile Send private message Visit poster's website Reply with quote
flynet



Joined: 15 Dec 2013
Posts: 3
flynet 16 Dec 2013, 09:22
But I can't put breakpoints since I don't have the debugging infos....
Post 16 Dec 2013, 09:22
View user's profile Send private message Reply with quote
randall



Joined: 03 Dec 2011
Posts: 155
Location: Poland
randall 16 Dec 2013, 12:24
You can use memory address to put breakpoint:

For example:

b *0x4003d
Post 16 Dec 2013, 12:24
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.