This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cannot open crt0.o


Thanks Kai,

Probably I have built binutils, gcc and newlib successfully!! I mean, I 
didn't get compilation or installation error during the entire process.

I have built these tools for mips-elf target.

But now, when I try to compile a simple 'C' source code, it fails to do so 
with following messages:

crt0.S:81: undefined reference to `hardware_hazard_hook'
crt0.S:147: undefined reference to `get_mem_info'
crt0.S:151: undefined reference to `__stack'
crt0.S:193: undefined reference to `software_init_hook'
crt0.S:200: undefined reference to `atexit'
crt0.S:221: undefined reference to `exit'
crt0.o: In function `_exit'
crt0.S:259: undefined reference to `hardware_exit_hook'

I found some information related to startup code at
http://billgatliff.com/twiki/bin/view/Crossgcc/Crt0, which says

1. Set stack pointer to value of __STACK if set 
2. Set the initial value of the frame pointer 
3. Clear .bss (where all the values that start at zero go) 
4. Call indirect of hardware_init_hook if set to initialize hardware 
5. Call indirect of software_init_hook if set to initialize software 
6. Add __do_global_dtors and __FINI_SECTION__ to the atexit function so 
   destructors and other cleanup functions are called when the program 
   exits by either returning from main, or calling exit 
7. setup the paramters for argc, argv, argp and call main 
8. call exit if main returns 

But didn't get exactly, what am I supposed to do.

Regards,
Abhijit.

On Thu, 10 Jul 2003, Kai Ruottu wrote:

> Bill Gatliff <bgat@billgatliff.com> wrote:
> 
> > Abhijit:
> > Check your gcc build against the FAQ and/or Wiki.  Among other things, 
> > you're leaving off the --without-headers.
> > 
> > http://crossgcc.billgatliff.com/index.html
> > http://billgatliff.com/twiki/bin/view/Crossgcc/WebHome
> 
>  All this is basically bullshitism, building first binutils
> then GCC and last newlib using the official build instructions
> in the GCC manual should succeed with gcc-3.2.x ...
> 
>  I recently built binutils-2.13.2.1, gcc-3.2.3 and newlib-1.11.0
> for 'arm-elf', m68k-elf' and 'mips-elf' from scratch with the
> official method and all these builds succeeded nicely. Of course
> one must know the specific workarounds like using '--with-gnu-as'
> and '--with-gnu-ld' for all the MIPS-targets, and all the generic
> workarounds like symlinking 'limits.h', 'stdlib.h' and 'unistd.h'
> into the '$prefix/$target/sys-include' from the headers install
> directory, '$prefix/$target/include', where the manual tells one
> to preinstall the target headers before the GCC build (this is
> the only generic workaround needed just now).
> 
> > Abhijit Deshpande wrote:
> > >Here is my build script:
> 
>  Your binutils and GCC builds were somehow right, but you should
> be able to build the final-GCC immediately after copying the
> newlib headers from 'newlib-1.11.0/newlib/libc/include' into your
> chosen '$prefix/mipsel-elf/include' and doing the needed symlinks
> into the '$prefix/mipsel-elf/sys-include'. And remembering to use
> the '--with-newlib' in your GCC-configure.
> 
>  However your newlib-configure is wrong:
> 
> > >env CC=$mipsgcc \
> > >    $srcdir/configure --host=${target} --prefix=$prefix \
> > >    --build=i386-linux \
> > >    --with-elf
> 
>  The values for '--build=', '--host=' and '--target=' should
> of course be the same as when configuring binutils and GCC
> because in those 'source tree' (binutils, GCC, newlib, GDB etc.
> all together under same tree) cases a single 'configure'
> handles all the stuff. And one can simply copy the 'newlib'
> and 'libgloss' subdirs from the newlib-1.11.0 sources into
> the main GCC source directory, 'gcc-3.2.2' in your case, and
> build GCC and newlib at the same time. The preinstall of the
> newlib-headers may then be vain because the '--with-newlib'
> then adds options to search the target headers from the sources.
> 
>  If you leave the '--host=' away and use something like:
>  
>     $srcdir/configure ${target} --prefix=$prefix \
>     --build=i386-linux \
>     --with-elf
> 
> your build should succeed. I really don't know for which
> purpose you would need the '--with-elf'. Never needed by
> me...
> 
>  And the 'env CC=$mipsgcc' is of course totally wrong.
> 
> 
>  Basically using:
> 
>    $srcdir/configure ${target} --prefix=$prefix
> 
> should be enough, but my habit is to include the '--build=',
> '--host=' and '--target=' always, so not letting 'configure'
> to guess these things.
> 
> > >And it fails while configuring newlib, with the message:
> > >
> > >...../mipsel-elf-install/lib/gcc-lib/mipsel-elf/3.2.2/../../../../mipsel-elf/bin/ld: 
> > >cannot open crt0.o: No such file or directory
> > >collect2: ld returned 1 exit status
> > >
> > >*** The command '....../mipsel-elf-install/bin/mipsel-elf-gcc -o 
> > >conftest -g -O2 conftest.c' failed.
> > >*** You must set the environment variable CC to a working compiler.
> 
>  Your faulty '--host=mipsel-elf' of course can select the 'mipsel-elf-gcc'
> as your 'GCC_FOR_HOST' ie. 'CC' too, but the 'CC = $mipsgcc' most probably
> did this. And this means usually the native 'gcc', which should work when
> producing possible executables for the becoming host.
> 
>  In the 'Canadian Cross' cases one is not expected to rebuild newlib, ie.
> when building a 'mipsel-elf' target toolchain for Windoze-host on Linux,
> using existing working 'Linux-x-Cygwin' (or '-MinGW') and 'Linux-x-mipsel-elf'
> toolchains, the latter already includes the prebuilt newlib for 'mipsel-elf',
> which should only be copied to the new host platform.
> 
> Cheers, Kai
> 
> PS. I'm tired to argue with the 'Bill & Bull' (or was it 'Dan') about these
> basic issues again and again, when opening the GCC-manual and reading the
> "Install GNU CC / Building and Installing a Cross-Compiler" seems to be
> totally impossible to them (and for many others)...  And I'm tired to pay
> for all the spam coming to me because of helping people on maillists and NGs
> with real mail addresses -- maybe 90% of the incoming messages is now pure
> penis, viagra, breasts and such so that I'm already in bad moon when
> replying... The mail servers I use, don't filter spam yet, one filters
> viruses though...
> 
> BTW, the 'www.algor.co.uk' and 'ftp.oarcorp.com' should have prebuilt tools
> for MIPS on Linux host...
> 

-- 

Attachment: VirusWall_Message.txt
Description: Text document

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]