Linker and stub problems on sh2
Dhananjay R. Deshpande
Tue May 21 07:40:00 GMT 2002
> I'm slowly starting to get things work, but I still have some
> doubts and
> I have build a program linking my own crt0.s, with the "start" symbol
> defined as the entry point and written the line ENTRY(start) in the
> linker script.
> In fact the linker will also load the crtbegin.o module with another
> start symbol in it and when I start gdb to debug the pc is set to the
> start in crtbegin. this may not be a so big problem because in the
> vector table the value is correct.
> Can someone explain me (or tell me where to find some docs) why the
> crtbegin is loaded and what are exactly their function?
For sh-elf, there are multiple crt* files instead of crt0. As per my knowledge start symbol is in crt1 and not in crtbegin.
Are you invoking linker explicitly (ld ) or using gcc to build final executable?. If you are using gcc, then it will link all crt* files. If you want to use your own crt0, then either use ld for linking or pass -nostartfiles option to gcc. The standard crt* files have the functionality for intializing bss, setting stack pointer, calling global constructors, etc. You will need your own crt file if you want to do hardware intialization before calling main and/or loading data area from rom to ram. In this case you can declare your start symbol as _start ( or anything else than start ) then call start at end of crt0 and use ENTRY( _start ) in linker script.
Hope this helps,
Free download of GNUSH and GNUH8 tool chains for Hitachi's SH and H8 Series.
The following site also offers free support to European customers.
Read more at http://www.kpit.com/products/support.htm
Latest versions of GNUSH and GNUH8 are released on Apr 1, 2002.
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to email@example.com
More information about the crossgcc