Jump to content
  • 0

microblaze C++ constuctors


tcmichals

Question

I asked this question @ https://forums.xilinx.com/t5/Embedded-Development-Tools/Invoking-C-constuctors-before-main/td-p/1121717  but so far no answers, so see if any one knows the answer here.

The issue is __init is not loading the CTORS table to invoke global  constructors.

__init function is in crti.S, but I cannot find the file in the source, here is the disassembly,  does not look it tries and load a point and jump to the CTORS table.

          __init:
0000abbc:   addik         r1 , r1 , -16
0000abc0:   sw            r15, r0 , r1
0000abc4:   addik         r11, r0 , -1
0000abc8:   mts           rSHR, r11
0000abcc:   addik         r11, r0 , 0
0000abd0:   mts           rSLR, r11
0000abd4:   lw            r15, r0 , r1
0000abd8:   rtsd          r15, 8
0000abdc:   addik         r1 , r1 , 16

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Hello, tcmichals.

 

You are indeed right that this is supposed to work. This is probably an issue with the compiler.

 

Can you try one of the following options?

  • dynamically allocate an instance of the class using the `new` keyword
  • instantiate the class in a non-global context (although I do understand that's what you want)
  • initialize the class member in the declaration itself (although this is probably just a semantic change)
Link to comment
Share on other sites

4 hours ago, Cosmin said:
  • dynamically allocate an instance of the class using the `new` keyword
  • instantiate the class in a non-global context (although I do understand that's what you want)
  • initialize the class member in the declaration itself (although this is probably just a semantic change)

>instantiate the class in a non-global context (although I do understand that's what you want)
Yes this works. (I did the example in main.cpp to validate the class does call the constructor, just did't copy all the code)

>initialize the class member in the declaration itself (although this is probably just a semantic change)
Yes, I changed the code and called the init in main.

I did not try new, since local instantiation, works, I would think new  works.

When I get some time, will look at the CTORs table, it should be list of function pointers, so, I can just do a function call in main, to call the table.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...