This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Confusing Region$$Table$$Limit value

Hello everybody, I have a question regarding the Region$$Table$$Limit value.

I have following simple scatter file:

LR_1 0x08000000 0x100000 {
	ER_RO 0x08000000 0xffffffff {
        	*.o (RESET, +First)
        	*(+RO)
			*(InRoot$$Sections)
	}

	ER_RW 0x20000000 0xffffffff{
        	*(+RW)
	}

	ER_ZI 0x20001000 0xffffffff {
	       	*(+ZI)
	}
}

after compiling and linking I'm getting these values related to Region$$Table:

    Region$$Table$$Base                      0x080003b0   Number         0  anon$$obj.o(Region$$Table)
    Region$$Table$$Limit                     0x080003d0   Number         0  anon$$obj.o(Region$$Table)

also I have some test variables:

    0x20000000   0x080003d0   0x00000004   Data   RW            4    .data.a             main.o
    0x20000004   0x080003d4   0x00000004   Data   RW            5    .data.c             main.o
    0x20000008   0x080003d8   0x00000004   Data   RW            6    .data.d             main.o

and init function called from my startup code:

void init(void){
	int limit = Region$$Table$$Limit;
	void** size = &Region$$Table$$Base + 2;
	int __rw_len  = ((int)*size)/4;
	int __rw_start = (int)Region$$Table$$Base;
	main();
}

So Region$$Table$$Base points to correct address of the data to be copied, but the Region$$Table$$Limit, as far as I know should point to the address of the byte beyond the end of the section which is 0x080003dc (after .data.d variable from the second code) but it points to itself 0x080003d0 so i'm getting the value of .data.a variable instead of the address of the byte beyond, so I can't really tell where this section to be copied to ram ends.

So if I'm missing something I will appreciate any thoughts.

  • Ok so my bad, it's like Region$$Table$$Base value coresponds to the end of the ER_RO section.

    So to know the limit of the data to be copied to ram you have to use 

    extern int Load$$ER_RW$$Limit[];

    I thought that this is the purpose of the Region$$Table$$Limit symbol.