This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM2634-Q1: pragma to set section for switch in CLANG compiler?

Part Number: AM2634-Q1

Dear Champs,

Is there any pragma to set section for 'switch/case' statement of C language in CLANG compiler?

When switch statement was used, it was allocated in '.rodata' region, not '.text'.

My customer wants to check this '.rodata' section for switch to specific section like '.rodata_fusa', and wants to check if there is pragma for switch statement like below for variables and data to allocate codes into separated section.

Thanks and Best Regards,

SI.

  • Is there any pragma to set section for 'switch/case' statement of C language in CLANG compiler?

    No.

    But there is another way to control the allocation of the switch table for a function.  When such a table is created, it is put into a section with a name similar to ...

    .rodata..Lswitch.table.name_of_function

    The last part is the name of the function.  Adjust as needed.

    This means, in the SECTIONS directive of the linker command file, you can have an entry similar to ...

    .rodata..Lswitch.table.name_of_function > SPECIAL_MEMORY_RANGE

    That creates an output section of that name.  It is made up of all the input sections with the same name, of which there is only one.  That output section is allocated to the named memory range.

    Thanks and regards,

    -George