M
Marcin Balcerzak
Hi,
after some googling I've found the post, in which there was a recipe how
to convert C to NASM. I'd copied and compiled remnum.c and wrote
Makefile like:
x.asm: x.bin
ndisasm -u x.bin | ./remnum > x.asm
x.bin: x.o
lnkflat -o x.bin x.o
x.o: x.c
gcc -Wall -c -ffreestanding -O2 -s x.c
clean:
rm -f x.o x.bin
and x.c is:
#include <stdio.h>
int main()
{
printf("Test\n");
return 0;
}
And there is a problem
I obtain:
gcc -Wall -c -ffreestanding -O2 -s x.c
lnkflat -o x.bin x.o
x.o(.text+0x11): In function `main':
: undefined reference to `printf'
error linking file x.bin
make: *** [x.bin] Error 2
Apparently, it doesn't recognize printf. So I tried:
gcc -Wall -c -ffreestanding -O2 -s x.c -I /usr/lib
or gcc -Wall -c -ffreestanding -O2 -s x.c -I /usr/include
and then even:
lnkflat -o x.bin x.o -l libc
and when reported that libc not found:
lnkflat -o x.bin x.o -l libc -L /usr/lib
where in /usr/lib I've got libc.a and libc.so
that gives me back:
lnkflat -o x.bin x.o -l libc -L /usr/lib
ld: cannot find -llibc
error linking file x.bin
make: *** [x.bin] Error 2
(** to everyone who don't know/trust/heard of remnum.c - listing **)
#include <stdio.h>
int main()
{
char s[4096];
while(fgets(s,4096,stdin)!=NULL)
{
if(strlen(s)>28)
printf("%s",s+28);
}
return 0;
}
(** end of remnum.c **)
My invention is currently close to death.
What should I do to convert C programs (using scanf, printf, stdio.h,
stdlib.h, string.h, and runtime parameters: char *argv[], int argc)?
A big THANK YOU to everybody who will write something helpful.
after some googling I've found the post, in which there was a recipe how
to convert C to NASM. I'd copied and compiled remnum.c and wrote
Makefile like:
x.asm: x.bin
ndisasm -u x.bin | ./remnum > x.asm
x.bin: x.o
lnkflat -o x.bin x.o
x.o: x.c
gcc -Wall -c -ffreestanding -O2 -s x.c
clean:
rm -f x.o x.bin
and x.c is:
#include <stdio.h>
int main()
{
printf("Test\n");
return 0;
}
And there is a problem
I obtain:
gcc -Wall -c -ffreestanding -O2 -s x.c
lnkflat -o x.bin x.o
x.o(.text+0x11): In function `main':
: undefined reference to `printf'
error linking file x.bin
make: *** [x.bin] Error 2
Apparently, it doesn't recognize printf. So I tried:
gcc -Wall -c -ffreestanding -O2 -s x.c -I /usr/lib
or gcc -Wall -c -ffreestanding -O2 -s x.c -I /usr/include
and then even:
lnkflat -o x.bin x.o -l libc
and when reported that libc not found:
lnkflat -o x.bin x.o -l libc -L /usr/lib
where in /usr/lib I've got libc.a and libc.so
that gives me back:
lnkflat -o x.bin x.o -l libc -L /usr/lib
ld: cannot find -llibc
error linking file x.bin
make: *** [x.bin] Error 2
(** to everyone who don't know/trust/heard of remnum.c - listing **)
#include <stdio.h>
int main()
{
char s[4096];
while(fgets(s,4096,stdin)!=NULL)
{
if(strlen(s)>28)
printf("%s",s+28);
}
return 0;
}
(** end of remnum.c **)
My invention is currently close to death.
What should I do to convert C programs (using scanf, printf, stdio.h,
stdlib.h, string.h, and runtime parameters: char *argv[], int argc)?
A big THANK YOU to everybody who will write something helpful.