Issue with LTO (-flto) in assembly and C combined
Please see following code snippet:
-------
$ cat x.c
void _exit(int code)
{
while(1);
}
int add(int a, int b)
{
return a+b;
}
void main()
{
__asm volatile ("mov r0, #1");
__asm volatile ("mov r1, #2");
__asm volatile ("b add");
}
-------
If compiled using following options it gives error,
$ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -flto x.c
`add' referenced in section `.text' of /tmp/cclOkQHk.
collect2: error: ld returned 1 exit status
$ arm-none-eabi-gcc -v
gcc version 4.8.4 20140725 (release) [ARM/embedded-
Based on above I have few questions:
1. Is this code snippet correct (at-least it works without -flto)?
2. Any workarounds to overcome this problem?
Thanks.
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Mahavir for more information if necessary.