Page 2 of 2

Re:Binary and ELF in cygwin

Posted: Sun Feb 02, 2003 5:57 am
by df
you dont needx to build gcc, just binutils.

Re:Binary and ELF in cygwin

Posted: Sun Feb 02, 2003 6:08 am
by srg
df wrote: you dont needx to build gcc, just binutils.
hmm well I am still getting this error message:

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

Posted: Sun Feb 02, 2003 9:33 am
by df
yeah elf has this underscore thing going on, pe does not.
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'
my guess is your are trying to link against the libc with an os kernel, which is a no-no.

1st error about enrtry point is easy fixed with -E option in ld.

Re:Binary and ELF in cygwin

Posted: Sun Feb 02, 2003 9:48 am
by srg
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'

Re:Binary and ELF in cygwin

Posted: Sun Feb 02, 2003 12:21 pm
by df
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

Re:Binary and ELF in cygwin

Posted: Sun Feb 02, 2003 1:34 pm
by srg
no change

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

Posted: Mon Jul 21, 2003 6:25 pm
by nullify
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

Posted: Fri Jul 25, 2003 4:08 am
by Tim
_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.