C++ problems with sh4

Joel Sherrill joel.sherrill at OARcorp.com
Mon Nov 5 13:06:42 UTC 2001



Alexandra Kossovsky wrote:
> 
> Hi!
> 
> I have gensh4 bsp, and I need C++ to work.
> It worked perfectly with ss-20010816
> 
> Now, in ss-20011017 (or ss-20011025) it does not work.
> The problem is with global constructors -- they are not called.
> 
> gcc does not define __USE_INIT_FINI__ for sh4.
> In 'gcc-2.95.3/gcc/config/sh/elf.h' there is:
> ---------
> /* Arrange to call __main, rather than using crtbegin.o and crtend.o
>    and relying on .init and .fini being executed at appropriate times.  */
> ---------
> 
> In ss-20010816 gcc calls '__do_global_ctors' on the begining of 'main()',
> and all is OK. In ss-20011025 where are no 'main()'.
> 
> What can I do?
> Should I patch gcc to do all this things through init & fini ?
> Or something else?

We did this because making main() available in user space is generally
a good thing.  

Hmm... I see two possibilities.  As an experiment, change the name of
the first task to main() and verify things work.  

If that does in fact work, then we might want make the toolset 
define __USE__MAIN__ and have an alternative next to the
__USE_INIT_FINI__.
That presupposes that this won't result in the global ctors being
called twice if someone uses main().

> Regards,
>         Alexandra.
> --
> 
> Alexandra Kossovsky
> OKTET Ltd.
> 1 Ulianovskaya st., Petergof, St.Petersburg, 198904 Russia
> Phones: +7(812)428-43-84(work) +7(812)184-52-58(home) +7(812)956-42-86(mobile)
> e-mail: sasha at oktet.ru (or sasha at gate.ort.spb.ru)

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985



More information about the users mailing list