nkdm
nkdm

Reputation: 1240

"Segmentation fault (core dumped)" after explicit glibc linking.

For some reason I have to link glibc manually. I am trying to run the following program:

#include <stdio.h>
int _start(){
    printf("ABCDE");
    return 0;
}

In order to compile it I type the following commands:

gcc -c main.c -o main.o
gcc -L/lib/x86_64-linux-gnu/ -nostdlib main.o -o main -lc

Unfortunately, after running ./main i get only Segmentation fault (core dumped)

Could anyone tell mi what i am doing wrong?

Upvotes: 0

Views: 1689

Answers (1)

जलजनक
जलजनक

Reputation: 3071

an _exit(0); should do the trick.

However, what are you trying to achieve? Sample

Upvotes: 2

Related Questions