Page 1 of 2
Binary and ELF in cygwin
Posted: Fri Jan 31, 2003 8:45 am
by srg
Hi
How do I create binary files and ELF executables in cygwin?
Thanks
Re:Binary and ELF in cygwin
Posted: Fri Jan 31, 2003 8:51 am
by DarylD
The way I did it is this:
Download the latest binutils/gcc.
Extract binutils (note: you will need bunzip2)
./configure --target=i386-elf
make
make install
Then do similar for gcc-core/gcc.
Then you use the i386-elf prefix on the executables. I.e. to run elf gcc use i386-elf-gcc.
Works an absolute dream.
Re:Binary and ELF in cygwin
Posted: Fri Jan 31, 2003 12:30 pm
by df
i built it with targets all, and just replaced ld.exe with the new one, same for the objcopy/objdump/as/ld etc that get built by binutils.
then i just do ld --oformat = elf_i386
Re:Binary and ELF in cygwin
Posted: Fri Jan 31, 2003 1:32 pm
by srg
I get this error when building it:
make[1]: *** No rule to make target `../libiberty/libiberty.a', needed by `size.
exe'. Stop.
make[1]: Leaving directory `/binutils-2.9/binutils'
make: *** [install-binutils] Error 2
I have put the binutils folder in my cygwin folder, what have I done wrong?
Re:Binary and ELF in cygwin
Posted: Fri Jan 31, 2003 3:02 pm
by df
i unzipped it into my home dir
export BISON="/bin/bison.exe"
export YACC="/bin/bison.exe -y"
(not sure if i did an export for flex as lex or something? mmm i dont rmemeber....)
./configure --enable-targets=all --with-gnu-as --with-gnu-ld --with-stabs
Re:Binary and ELF in cygwin
Posted: Fri Jan 31, 2003 4:16 pm
by srg
done that
what next
Re:Binary and ELF in cygwin
Posted: Fri Jan 31, 2003 4:41 pm
by df
'make'
then
make install
Re:Binary and ELF in cygwin
Posted: Sat Feb 01, 2003 12:05 pm
by srg
done that (it took a long time)
copied the files to my bin dir replacing the old ones.
When I try this:
gcc main.c -o sgoskrnl.exe
I get this:
/usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../../i686-pc-cygwin/bin/ld: cannot fi
nd -luser32
collect2: ld returned 1 exit status
If I try this:
gcc -c main.c
ld main.o -o sgoskrnl.exe -m elf_i386
I get this:
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'
What am I doing wrong?
Re:Binary and ELF in cygwin
Posted: Sat Feb 01, 2003 12:29 pm
by Whatever5k
The last ouput means that the linker cannot find the functions...
Did you include the appropriate headers?
Re:Binary and ELF in cygwin
Posted: Sat Feb 01, 2003 12:48 pm
by df
you need to make install not just copy them into the bin directory!!
make install puts them in the correct place anyway. if you just copy them you miss the important BFD files ld needs...
Re:Binary and ELF in cygwin
Posted: Sat Feb 01, 2003 4:35 pm
by srg
make install doesn't make the slightest bit of difference
I'm going to reinstall cygwin
Re:Binary and ELF in cygwin
Posted: Sat Feb 01, 2003 6:31 pm
by srg
right, I now have ld running ok
my trouble is that my gcc only supports pe
I have downloaded gcc 3.2.1 but how would ou recommend that I install it?
Thanks
Re:Binary and ELF in cygwin
Posted: Sun Feb 02, 2003 3:06 am
by df
well rebuild and make install your binutils again.
then when you link, to get elf you can do
ld --oformat=elf_i386 -mi386bsd blah.o -o blah.elf
Re:Binary and ELF in cygwin
Posted: Sun Feb 02, 2003 4:18 am
by srg
The problem is not with binutils, it's with cygwin's gcc, it only supports pe
Re:Binary and ELF in cygwin
Posted: Sun Feb 02, 2003 5:54 am
by srg
I'm having troubles building a new version of gcc with all targets enabled.
What lines should I use?