- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
43xxx_Wi-Fi project:
I modified linker script to add a section by name '.vtable' .Changes are as follows.
.vtable :
{
link_vtable_start = .;
*(.vtable)
link_vtable_end = .;
}> SRAM AT>SRAM :bss
I declared and used two variables in a file 43xxx_Wi-Fi_Check\apps\snip\scan\scan.c as follows
static int My_Variable_One __attribute__((section (".vtable")));
static int My_Variable_Two;
void application_start( )
{
My_Variable_One = 1;
My_Variable_Two = My_Variable_One;
}
I am able to see variable My_Variable_Two in map file.
I am not able to see variable My_Variable_One in map file.
Why this difference even though both are static variables?
Solved! Go to Solution.
- Labels:
-
Wi-Fi Direct
-
WICED Studio
-
Wifi+Bluetooth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The inclusion of static variables in the map file is dependent on linker. You may check the wiced_toolchain_ARM_GNU.mk file in WICED to check the flags for release build and debug build.
Please check these two flags which are mainly responsible for optimization:
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
For release build, the optimization is -Os whereas for debug build there is no optimization O0. Hence all the symbols will be included in case of debug build while the release build has ~O2 level of optimization which removes the static variables which are not used in the code. The variable My_Variable_Two is assigned the value of My_Variable_One in application_start and hence it appears in the map file.
If you want to check how optimization affects the symbols in the map file, kindly build a project for debug and check the map file. Since there is no optimization, all the symbols(whether static and not used) are shown in the map file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The inclusion of static variables in the map file is dependent on linker. You may check the wiced_toolchain_ARM_GNU.mk file in WICED to check the flags for release build and debug build.
Please check these two flags which are mainly responsible for optimization:
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
For release build, the optimization is -Os whereas for debug build there is no optimization O0. Hence all the symbols will be included in case of debug build while the release build has ~O2 level of optimization which removes the static variables which are not used in the code. The variable My_Variable_Two is assigned the value of My_Variable_One in application_start and hence it appears in the map file.
If you want to check how optimization affects the symbols in the map file, kindly build a project for debug and check the map file. Since there is no optimization, all the symbols(whether static and not used) are shown in the map file.