I've some confusion with named regions and their attributes. In my case, I've a named region as below:
#define SHARED_DATA_ZI __attribute__((section("data_shared_zi"),zero_init)
and then in the linker scatter file, I have:
SHARED_DATA_REGION_LOAD 0x40000000 0x100000
* (data_shared_zi_first, +first)
* (data_shared_zi_last, +last)
Now, let's say I declare a global variable as below in some .c file:
SHARED_DATA_ZI uint32_t testVariable;
Now according to the information here, my understanding is that as 'testVariable' is a Read/write variable and as I've 'zero_init' attribute also mentioned, here, 'testVariable' will be zero initialized (i.e. testVariable = 0) and will be placed in this named region 'data_shared_zi'. Please confirm and also, please let me know, how i can verify this. (I know, at the runtime, i can at least check if 'testVariable' is indeed set to zero, but i think, it should be somehow possible to verify the placement of 'testVariable' and it's initial value by some tools before running the program as well.
P.S.I've some more follow up question on named regions :-)
Hello, can you confirm which compiler (armcc or armclang) you are using? There are some changes to behavior in this area between the two toolshttps://developer.arm.com/documentation/100068/0614/Compiler-Source-Code-Compatibility/Language-extension-compatibility--attributes?lang=enWith armclang (i.e Arm Compiler 6), I believe you should declare as:
#define SHARED_DATA_ZI __attribute__((section(".bss"),data_shared_zi)
Thanks a lot for your help.
I'm using ARMCC version 5.06. So, according to the ARM documentation link that you have provided. it does seem that indeed that variable ('testVariable') will be zero initialized and will be put into this named region.
Now coming back to the other question that i had; the verification part. Are there any tools (maybe 'fromelf') that can give a little more insight into the regions ?
You will need to link with —bss_threshold=0 to put this int into the bss section.
fromelf -s will output the symbol table, which should confirm the address of the variable.
View all questions in Arm Compilers forum