Binary and ELF in cygwin
Re:Binary and ELF in cygwin
hmm well I am still getting this error message:df wrote: you dont needx to build gcc, just binutils.
main.o(.text+0x23):main.c: undefined reference to `__alloca'
main.o(.text+0x28):main.c: undefined reference to `___main'
main.o(.text+0x34):main.c: undefined reference to `_printf'
I'm assuming it's because their object files meant to be linked to pe, as elf doesn't like symbols with an underscore.
Re:Binary and ELF in cygwin
yeah elf has this underscore thing going on, pe does not.
1st error about enrtry point is easy fixed with -E option in ld.
my guess is your are trying to link against the libc with an os kernel, which is a no-no.ld: warning: cannot find entry symbol _start; defaulting to 08048080
main.o(.text+0x23):main.c: undefined reference to `__alloca'
main.o(.text+0x28):main.c: undefined reference to `___main'
main.o(.text+0x34):main.c: undefined reference to `_printf'
1st error about enrtry point is easy fixed with -E option in ld.
-- Stu --
Re:Binary and ELF in cygwin
removed anything to do with libc and used the -E switch, I still get this:
main.o(.text+0x23):main.c: undefined reference to `__alloca'
main.o(.text+0x28):main.c: undefined reference to `___main'
main.o(.text+0x23):main.c: undefined reference to `__alloca'
main.o(.text+0x28):main.c: undefined reference to `___main'
Re:Binary and ELF in cygwin
coz you still compiled it like a standard program ::) you need to compile it standalone...
you need tyo compile with
gcc -nostdlib -nostdinc++ -nostdinc -fno-builtin -fsigned-char -ffreestanding
you need tyo compile with
gcc -nostdlib -nostdinc++ -nostdinc -fno-builtin -fsigned-char -ffreestanding
-- Stu --
Re:Binary and ELF in cygwin
no change
BTW This is the first time I have ever tried to use gcc. So am very new to this.
BTW This is the first time I have ever tried to use gcc. So am very new to this.
Re:Binary and ELF in cygwin
Are _alloca and __main symbols defined in the code you are compiling (meaning its not looking for something in an external library) ?
Re:Binary and ELF in cygwin
_alloca is in libgcc. This is necessary in gcc 3.x, but luckily it doesn't contain any OS-specific calls. You might have to provide your own empty __main.