Default section mapping for c++ constructors / destructors

I'm attempting to map some user c++ classes to user defined memory regions.

I've studed the "#pragma section/#pragma default_section" page of the help docs  but I'm finding that no matter which SECTKIND keyword or QUALIFIER I use, I cannot get the constructors & destructors to map to anything other than seg_pmco.

These are the default sections I've got already mapped :-

#pragma default_section(ALLDATA, "alg_seg_dmda")
#pragma default_section(CODE, "alg_seg_swco",SW)
#pragma default_section(CODE, "alg_seg_nwco",NW)
#pragma default_section(DATA, "alg_seg_dmda",PM)
#pragma default_section(CONSTDATA, "alg_seg_pmda",PM)
#pragma default_section(SWITCH, "alg_seg_dmda")
#pragma default_section(VTABLE, "alg_seg_vtbl")
#pragma default_section(STI, "alg_seg_sti")

Does anyone know which SECTKIND I need to use to remap constructors / destructors ?

Thanks

  • 0
    •  Analog Employees 
    on Oct 21, 2019 12:41 PM 9 months ago

    Hello,

    You can use #pragma section("section_name") directive to force your code(constructor) into specific memory.

    For example, you can use the below code snippet to map the constructor of class "test" in specific memory section (seg_l1_block2).

    class test
    {
    public:
    int b;
    test();
    };

    #pragma section("seg_l1_block2")
    test::test()
    {
    b= 10;
    }

    Also please note that, instances of classes are allocated as a single block of memory, so it is not possible for different members within the class to be placed in different sections of memory.

    We are able to map constructor in specific memory section using the above code snippet successfully.Please refer the attached screenshot of map file.

    Regards,
    Santha kumari.K

  • Hi Santha, thanks for your response. I was wondering if there was a method I could use that uses the default_section #pragma, so I could make the change "globally" without having to modify each source file, i.e by including a file containing #pragma default_section 

    Thanks

    Rob

  • 0
    •  Analog Employees 
    on Nov 13, 2019 8:50 AM 8 months ago in reply to Rob Belcham

    Hello Rob,

    As instances of a class are allocated as a block, you cannot control the placement of individual members within the class. You can, however, place your entire instance of the class in desired memory section by declaring the class globally as we said in the example code snippet previously.
     
    For example,

    class test
    {
    public:
    int b;
    test();
    };

    #pragma section("seg_l1_block2")
    test::test()
    {
    b= 10;
    }

    This maps your entire class in memory section "seg_l1_block2" (both class and constructor).

    Regards,
    Santha kumari.K