g++ compiler removes global variable (residing in user defined section) from object file when opt level >= O1
Hi,
I have following test case, where a global variable (InterruptVector) is placed into a user defined section ".vect_table".
file: test.c :
#if __cplusplus
extern "C" {
#endif
extern int glob;
void test(void);
#if __cplusplus
}
#endif
void (* const InterruptVector
0,
0,
0,
0,
0
};
void test()
{
glob++;
}
when i compile test.c with following command:
arm-none-eabi-g++ test.c -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -c -O0
variable "InterruptVector" is retained in the object file.
if i use -O1, this variable gets removed from the obj file.
Is this expected behavior. How do i retain the global variable at opt levels >= -O1
Please let me know. Thanks for your time.
I used gcc 4.7.3.
regards,
Mallikarjuna
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Thomas Preud'homme
- Solved:
- Last query:
- Last reply: