Cross gcc Mailing List Archive

[Prev][Next][Index][Thread]

Re: RTEMS questions



Tony Bennett <tbennett@divnc.com> wrote in reply to me:
> 
> > 2) what to I need to do to get C++ support going. I've turned on support in
> > the .cfg file, the cdtest compiles, but bombs out straight away when 
> > the program runs. I can run c++ programs OK stand-alone.
> 
> Assuming that gcc sets your global constructor's up to be called via
> the __main() --> do_global_ctors() technique, then you need to verify
> that __main() is being called before cdtest's main_task().  

> Another easy mistake to make here is to have your global constructors
> called before malloc() is initialized.  Basically, you have to make sure
> rtems_initialize_executive_early() is called and malloc is setup before
> calling your global constructors.  This can be tricky to get all the
> dependencies right.

All of this proved to be true, and there _was_ fiddling to get the 
linker dependancies right. After putting in the stuff that the c++ 
enabled bsps had, renaming main() to bsp_start(), maodifying the make 
cfgs for my bsp etc., I had to try several linker dependancy 
combinations to get the rtems-ctor.cc global constructor called 
before the main.cc ones. Are all of the boards tested for c++ 
support? 

Having got this far, cdtest runs but the global constructors aren't 
getting their printfs executed. The instantiation order reported by 
the non-global instances constructors show that they have been 
called.

Right now I can live with this, I'll just avoid global classes. I 
still have to write the application to show off to our customer by Monday, 
there's a lot to learn still about the RTOS and I may need to 
hack the hardware some more!

The question is - is something dangerous lurking there? I can't 
afford the time to figure out why the output isn't being generated, 
but thats OK as long as there's no suspicion that I'm corrupting 
memory or messing up any internal buffers.

I'll try to submit the bsp changes when I've got everything sorted 
out with my application, and I can figure out the best way to package 
it.

Thanks (again) for your help.

Follow-Ups:

Home | Subject Index | Thread Index