flat assembler
Message board for the users of flat assembler.

Index > Linux > Segmentation Fault

Author
Thread Post new topic Reply to topic
chorus



Joined: 16 Mar 2004
Posts: 23
chorus 17 Jul 2004, 03:08
Hello,

This following simple "Hello World" example keeps giving me a segmentation fault:
Code:
format ELF executable
entry start

section writeable
      dummy            dd ?
      
section writeable

      msg             db 'Hello world!',0xA,0xA
      MSG_SIZE        = $-msg
      
      nBytesWritten   dd ?

section executable
start:
      mov ebx,1
      mov ecx,msg
      mov edx,MSG_SIZE
      mov eax,4
      int 80h
      mov [nBytesWritten],eax

.ExitProcess:
      mov eax,1
      xor ebx,ebx
      int 0x80
    


The instruction causing the segmentation fault is "mov [nBytesWritten],eax". I can't write to that section... It doesn't do this if the first section (with the variable "dummy") is removed or placed after the section containing "nBytesWritten".

This isn't a big problem in this particular little program, but it's annoying because several larger applications I've written (and are converting to Linux from Windows) rely on libraries I've written with their own .data and .code sections.

Is this a bug in FASM? Are the sections not being marked "writeable" after the first one is? Or is this a limitation of Linux (i.e., can you only have one writeable section in your ELF executable?)

Any insight is welcome.
Thanks
--Chorus
Post 17 Jul 2004, 03:08
View user's profile Send private message Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 20 Jul 2004, 21:54
also I experienced this strange behavior of fasm. I guess it's a bug in fasm. As I remember a section should have a size of at least 4K (Page, even they should be aligned on 4K boundary) but fasm allocates this size only for the first section.

Endre.
Post 20 Jul 2004, 21:54
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 20 Jul 2004, 23:31
Both those problems were caused by the same bug, please download the latest updated 1.53 release, it should be OK now.
Post 20 Jul 2004, 23:31
View user's profile Send private message Visit poster's website Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 21 Jul 2004, 19:42
I made some tests with 1.53. It already listens to the section definitions. It remained only a little thing: I always want to write writable instead of writeable. The english word writeable may be incorrect. It's not so disturbing for me though.

Endre.
Post 21 Jul 2004, 19:42
View user's profile Send private message Reply with quote
Dragontamer



Joined: 24 Aug 2003
Posts: 84
Dragontamer 21 Jul 2004, 19:46
Endre wrote:
I made some tests with 1.53. It already listens to the section definitions. It remained only a little thing: I always want to write writable instead of writeable. The english word writeable may be incorrect. It's not so disturbing for me though.

Endre.


Just checked the dictionary
Both are correct spellings. I think Fasm should support both.
Post 21 Jul 2004, 19:46
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 21 Jul 2004, 20:03
yes, I am also swayed to write "writable". both are rightable

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 21 Jul 2004, 20:03
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number 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.