Binary and ELF in cygwin
Binary and ELF in cygwin
Hi
How do I create binary files and ELF executables in cygwin?
Thanks
How do I create binary files and ELF executables in cygwin?
Thanks
Re:Binary and ELF in cygwin
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.
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
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
then i just do ld --oformat = elf_i386
-- Stu --
Re:Binary and ELF in cygwin
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?
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
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
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
-- Stu --
Re:Binary and ELF in cygwin
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?
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
The last ouput means that the linker cannot find the functions...
Did you include the appropriate headers?
Did you include the appropriate headers?
Re:Binary and ELF in cygwin
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...
make install puts them in the correct place anyway. if you just copy them you miss the important BFD files ld needs...
-- Stu --
Re:Binary and ELF in cygwin
make install doesn't make the slightest bit of difference
I'm going to reinstall cygwin
I'm going to reinstall cygwin
Re:Binary and ELF in cygwin
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
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
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
then when you link, to get elf you can do
ld --oformat=elf_i386 -mi386bsd blah.o -o blah.elf
-- Stu --
Re:Binary and ELF in cygwin
The problem is not with binutils, it's with cygwin's gcc, it only supports pe
Re:Binary and ELF in cygwin
I'm having troubles building a new version of gcc with all targets enabled.
What lines should I use?
What lines should I use?