Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Segmentation fault(core dumped)

Segmentation fault(core dumped)

Segmentation fault(core dumped)

Program is running normally do the job but is killed at the end and I get this error message

a very simple example:

global OpenFile

section .text

    push ebp
    mov ebp,esp

    mov eax,5
    mov ebx,[ebp+8]
    mov ecx,0
    int 80h


extern int OpenFile(const char *);

int main(int argc,char *argv[]){
    int result = 0;
    if(argc > 1)
       result = OpenFile(argv[1]);

    return 1;

try : main.o asm.o
    gcc -o try main.o asm.o
main.o : main.c
    gcc -c main.c
asm.o : asm.s
    nasm -f elf asm.s

RE: Segmentation fault(core dumped)

Presumably, your OS is not DOS.

What part crashed?

Incidentally, the ENTER and LEAVE instructions are considered obsolete...

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

RE: Segmentation fault(core dumped)

I've found my problem, its that I dont push-pop the registers that I'm modifying in the function...

RE: Segmentation fault(core dumped)

No, that's not it.  LEAVE pops off ebp from the stack.  Better yet, forget about using LEAVE and ENTER, they're considered obsolete and downright dangerous.

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close