OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:08 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Binary and ELF in cygwin
PostPosted: Fri Jan 31, 2003 8:45 am 
Hi

How do I create binary files and ELF executables in cygwin?

Thanks


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Fri Jan 31, 2003 8:51 am 
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.


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Fri Jan 31, 2003 12:30 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
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

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Fri Jan 31, 2003 1:32 pm 
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?


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Fri Jan 31, 2003 3:02 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
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

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Fri Jan 31, 2003 4:16 pm 
done that

what next


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Fri Jan 31, 2003 4:41 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
'make'

then

make install

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sat Feb 01, 2003 12:05 pm 
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?


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sat Feb 01, 2003 12:29 pm 
The last ouput means that the linker cannot find the functions...
Did you include the appropriate headers?


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sat Feb 01, 2003 12:48 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
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...

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sat Feb 01, 2003 4:35 pm 
make install doesn't make the slightest bit of difference

I'm going to reinstall cygwin


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sat Feb 01, 2003 6:31 pm 
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


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sun Feb 02, 2003 3:06 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
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

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sun Feb 02, 2003 4:18 am 
The problem is not with binutils, it's with cygwin's gcc, it only supports pe


Top
  
 
 Post subject: Re:Binary and ELF in cygwin
PostPosted: Sun Feb 02, 2003 5:54 am 
I'm having troubles building a new version of gcc with all targets enabled.

What lines should I use?


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 72 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group