flat assembler
Message board for the users of flat assembler.

Index > Linux > segmentation fault after placing exit in a separate unit

Author
Thread Post new topic Reply to topic
drobole



Joined: 03 Nov 2010
Posts: 67
Location: Norway
drobole
Hi,

I'm getting a segmentation fault when exiting from this code

foo.asm
Code:
format ELF

public main as 'main'

extrn exit

section '.text' executable

main:

        mov edi, hello
        call print

        mov ebx, 0
        call exit

print:
        mov ebx, edi
        xor ecx, ecx
        xor al, al
        not ecx
        cld
        repne scasb
        not ecx
        dec ecx

        mov edx, ecx
        mov ecx, ebx
        mov eax, 4
        mov ebx, 1
        int 0x80
        ret

section '.data' writable

        hello db "Hello, world",10,0
    


bar.asm
Code:
format ELF

public exit

section '.text' executable

exit:
        mov eax, 1
        call 0x80
        ret
    


$fasm bar.asm
$fasm foo.asm
$ld -e main foo.o bar.o -o foo

Anyone know what the problem is?
Post 09 Nov 2010, 18:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17273
Location: In your JS exploiting you and your system
revolution
drobole wrote:
Code:
        call 0x80    
Anyone know what the problem is?
Try it with int 0x80
Post 09 Nov 2010, 23:54
View user's profile Send private message Visit poster's website Reply with quote
drobole



Joined: 03 Nov 2010
Posts: 67
Location: Norway
drobole
Ahh, I'll try that when I get back home
Post 10 Nov 2010, 06:12
View user's profile Send private message 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-2020, Tomasz Grysztar.

Powered by rwasa.