From: Kai R. <kai...@lu...> - 2003-07-01 07:58:50
|
Steven Graham wrote: > There seems to be a lot of documentation the other way, > but I need to make a cross compiler (and binutils of > course) that is hosted on MinGW on Windows and targeted > i386-elf. As This is for compiling my own operating system > Kernel and other own os bits and libraries I don't need > any linux runtime libraries. > > How do I do this? Most probably with big difficulties :( The 'i386-elf' target is just the target causing weird problems, my recent try to update to binutils-2.13.2.1 caused the linker give the error: e:/usr/local/lib/gcc-lib/i386-elf/3.2.2/crtbegin.o: could not read symbols: File truncated ie. it claimed the startup produced during the GCC build being faulty. The toolchain build was done on Linux and the Linux-hosted binutils (for 'i386-elf') handled this same startup ok. When looking at this, I found both 'as.exe' and 'ld.exe' being broken. When first replacing the 'ld.exe' with an older (working) version (expecting only the linker being broken), the error changed to be: D:\temp/cciCaaaa.o: file not recognized: File truncated ie. the startup(s) will be approved but now the 'as.exe' caused an faulty object file being produced... The binutils-2.13.2.1 were produced using gcc-3.2.2 for MinGW. When trying gcc-2.95.3, the produced binutils were still broken. Both GCCs had the MSVCRT.DLL as the default runtime C library. The old working binutils had the older CRTDLL.DLL as their runtime-DLL... Ok, if the runtime-DLL seemed to cause the difference, then what about producing binutils-2.13.2.1 for CRTDLL.DLL ? My oldest egcs-1.1.2 based toolchain had this as default, and building with it then caused seemingly working binutils: <snip> e:\usr\local\lib\gcc-lib\i386-elf\3.2.2\..\..\..\..\i386-elf\bin\as.exe --traditional-format -o D:\temp/ccaCaaaa.o D:\temp/ccaoaaaa.s e:\usr\local\lib\gcc-lib\i386-elf\3.2.2\..\..\..\..\i386-elf\bin\ld.exe -m elf_i386 -o tst_i386-elf.x e:/usr/local/lib/gcc-lib/i386-elf/3.2.2/crtbegin.o -Le:/usr/local/lib/gcc-lib/i386-elf/3.2.2 -Le:/usr/local/lib/gcc-lib -L/usr/local/lib/gcc-lib/i386-elf/3.2.2 -Le:/usr/local/lib/gcc-lib/i386-elf/3.2.2/../../../../i386-elf/lib -L/usr/local/lib/gcc-lib/i386-elf/3.2.2/../../../../i386-elf/lib -Le:/usr/local/lib/gcc-lib/i386-elf/3.2.2/../../.. D:\temp/ccaCaaaa.o e:/usr/local/lib/gcc-lib/i386-elf/3.2.2/crtend.o -T e:/usr/local/lib/gcc-lib/i386-elf/3.2.2/../../../../i386-elf/lib/cygmon.ld e:\usr\local\samples>e:\usr\local\i386-elf\bin\readelf -h tst_i386-elf.x ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: Intel 80386 Version: 0x1 Entry point address: 0x10000c Start of program headers: 52 (bytes into file) Start of section headers: 32136 (bytes into file) Flags: 0x0 Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 2 Size of section headers: 40 (bytes) Number of section headers: 17 Section header string table index: 14 I'm going to try the gcc-2.95.3 and 3.2.2 too with the '-mcrtdll' option and will see if the MSVCRT.DLL really is the big problem here or if the newer GCCs have problems too... BTW, the default config options for the 'i386-elf' in GCC-sources are not set for any real target... Ok, elves usually are not real but not all know this yet (in german 'elf' is 'eleven', it is a French oil-company, means "Earth Liberation Force" and maybe many other things, like a common object format, but AFAIK not any opsys, target board etc. which could make it being a 'real target'). So all problems related to someone thinking elves being real targets will not get any help from me... The ' -T .../i386-elf/lib/cygmon.ld' seen previously should tell something to all embedded people, there is that Cygmon-support in newlib for 'i386-elf', but GCCs then have something else (and totally unknown elf-magic) as default. > (P.S If I can't get this to cross compile then I plan to make > my os use PE executables and libraries) Generally a 'i386-pe' target toolchain shouldn't differ much from a 'i386-elf' or 'i386-coff' one, but if you consider using the prebuilt MinGW-tools, prepare to learn defining your own 'specs' to be used during compiles or to do something equal... Those who have tried to produce 'i386-wince-pe' executables for the WinCE emulator-DLLs using plain vanilla MinGW tools probably can help here (I haven't tried but surely there are people who have tried to replace MSVC in this job...) Cheers, Kai |