HELP! With cygwin
HELP! With cygwin
Hey everyone,
I been using djgpp to link/build my kernel, but I recently decided to switch over to cygwin. I get to it compile but it wants to link with a __main and _alloca. I know there is a switch to turn this off, but for the life of me I can't remember it. Also, linking with the cygwin ld tells me I can't link a.out files, and my kernel is now 20kb bigger, and I haven't added any code. <what a run on sentence>. I would appreciate any help
thanks
-t0xic
I been using djgpp to link/build my kernel, but I recently decided to switch over to cygwin. I get to it compile but it wants to link with a __main and _alloca. I know there is a switch to turn this off, but for the life of me I can't remember it. Also, linking with the cygwin ld tells me I can't link a.out files, and my kernel is now 20kb bigger, and I haven't added any code. <what a run on sentence>. I would appreciate any help
thanks
-t0xic
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Sounds like a FAQ question to me:
as for the switch, my first guess would be reading the manpages
( GCC Cross-Compiler )OSDev Wiki wrote:Creating a dedicated (cross-) compiler for your OS development work can save you many headaches. If...
* ...your system compiler drags in references to alloca() or other OS-dependent things,
as for the switch, my first guess would be reading the manpages
The switches I use are
for my c files and
for my c++ files.
EDIT: You will really want to build a cross compiler, so that should be the first thing that you do. Unless you like PE files.
Code: Select all
-fno-builtin -nostdlib -ffreestanding
Code: Select all
-fno-builtin -nostdlib -fno-exceptions -fno-rtti
EDIT: You will really want to build a cross compiler, so that should be the first thing that you do. Unless you like PE files.
I use those switches too. Two questions...
- Why can't I use --no-leading-underscores?
- What did you guys use as your target machine for yuor cross compiler. When ever I try i386-pc-none or i486-linux, the makefile freaks out. If I am not trying to use elf, what exe format should I use, and how do I put it in the switch? ?i386-coff?
Any help would be appreciated.
Thanks
--t0xic
- Why can't I use --no-leading-underscores?
- What did you guys use as your target machine for yuor cross compiler. When ever I try i386-pc-none or i486-linux, the makefile freaks out. If I am not trying to use elf, what exe format should I use, and how do I put it in the switch? ?i386-coff?
Any help would be appreciated.
Thanks
--t0xic
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Well, For one isn't it -fno-leading-underscores ?
BTW The target for ELF is clearly defined in the Wiki article GCC Cross-Compiler.
Most people use the target i486-elf or i586-elf.. But I'm guessing i386/i686 are valid as well.
BTW The target for ELF is clearly defined in the Wiki article GCC Cross-Compiler.
Most people use the target i486-elf or i586-elf.. But I'm guessing i386/i686 are valid as well.
Well I do believe that cygwin defaults to no leading underscores. As for the target i686-pc-elf or i586-pc-elf is usually the one people use. Objdump says it supports
However I think that i586-pc-msdosdjgpp is also a valid target. I can't tell you what it supports though.elf32-i386 coff-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
I think djgpp uses coff (Microsoft style) as the object file for output from gcc/gas, and pe as the executable format that ld produces. Typically, to specify an executable format, you pass the --oformat TARGET option to ld, where TARGET is one of the targets produced by the output to ld --help.t0xic wrote:I meant I don't want to use elf. I'm not really sure which format I'm using lol.
In particular, my Cygwin ld produces:
Code: Select all
ld: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
ld: supported emulations: i386pe
On the other hand, a cross compiled binutils will give:
Code: Select all
i586-elf-ld: supported targets: elf32-i386 coff-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
i586-elf-ld: supported emulations: elf_i386
The 'target' which people are discussing here, like 'i586-elf' etc is actually a machine name for the target that you want your code to run on, and is passed to gcc through use of the '-b <machine>' options. All this does is run the particular version of gcc that you have requested, e.g. running 'gcc -b i586-elf' will actually just pass all your options on to i586-elf-gcc. Now each particular version of gcc you have installed will have default values for certain options, e.g. the default executable version for i586-elf is elf. Its default architecture is to generate x86 code for an i586 or above, and it doesn't add any os specific code (like i586-linux-elf would).
I would suggest you cross compile a new version of gcc and binutils under cygwin, by following the instructions in GCC_Cross-Compiler.
Regards,
John.
First off are you following the wiki instructions and are building in a separate directory? If you are try deleting everything in build-binutils and running configure and make again.
Also when you first installed cygwin did you pick the Unix/binary option for file mode? If you picked text mode then that could be a problem.
Finally do you have a the necessary packages for building binutils. I can't remember all of them but I know you need flex and bison.
Also when you first installed cygwin did you pick the Unix/binary option for file mode? If you picked text mode then that could be a problem.
Finally do you have a the necessary packages for building binutils. I can't remember all of them but I know you need flex and bison.