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
{
  public:
    void Print(void) const
    {
      printf("Test");
    }
};
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

Language:
English Edit question
Status:
Expired
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-11-29
Last reply:
2017-12-15
Launchpad Janitor (janitor) said : #1

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