RA6M5 gcc variable allocation address order


if I declare some variables, for example:

int v1;

int v2;

int v3;

then are allocated in memory in reverse order, for example in the map file:

0x20001100                v3

0x20001104                v2

0x20001108                v1

There is the possibility to indicate to the linker to allocate them in the expected crescent order? I.e.:

0x20001100                v1

0x20001104                v2

0x20001108                v3

Parents Reply Children
  • Hello,

    this is not easy to apply, because I need to make the porting of a lot a sw that expects to have the variables, thousands of variables, allocated in ascending order of addresses. I think this is a very strange philosophy for the gcc linker to allocate the variables...

    Also I thinked to declare a very big array and then the single variables declared as define to a specifica array, for example:

    int array[2000];

    #define v1 array[100]

    #define v2 array[101]

    #define v3 array[102]

    but this preclude lot of debug possibility, and is prone to many mastakes.

    Also may I add the attribute:

    int v1 __attribute__ ((address (0x20001100)));

    int v2 __attribute__ ((address (0x20001104)));

    int v3 __attribute__ ((address (0x20001108)));

    but is not a good solution...

    Best regards