C++ Memory Address of const class instances

Asked by Gergely Budai on 2017-11-29

If i have a simple class instance like this:

class Test
    void Print(void) const
const static Test test;

And later somewhere I refer the address of that object like:
printf("Address: %X", &test);

Then I can see in the map file that the compiler reserves one byte for that address in the .bss segment:
.bss._ZL4test 0x20005308 0x1

I would assume that for something simple like this the compiler would reserve space in the .text segment which does not cost any RAM space.

Is there any way to tell g++ to put the address of such objects (without any member variables) into the FLASH instead of RAM?

(GCC 6 2017-q2-update on CORTEX-M4)

Question information

English Edit question
GNU Arm Embedded Toolchain Edit question
No assignee Edit question
Last query:
Last reply:
Launchpad Janitor (janitor) said : #1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.