https://sourceware.org/bugzilla/show_bug.cgi?id=28603
Bug ID: 28603 Summary: Incorrect branch offset from the start of a function after enable LTO Product: binutils Version: 2.35.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gas Assignee: unassigned at sourceware dot org Reporter: sen2403 at hotmail dot com Target Milestone: --- After enabling LTO, the branch offset is incorrect in SVC_Handler of a FreeRTOS+CM4 project. Here is the simple code and assembler output. The branch address is offset 2 bytes from foo function and bypass the push instruction. It causes problem when returning from foo function. ========================================================== void SVC_Handler(void) { __asm volatile ( " cpsid i \n" " blx foo \n" " cpsie i \n" /* ..... code removed ... */ } 000010b0 <SVC_Handler>: 000010b0: b672 cpsid i 000010b2: f7ff f892 bl 000001da <foo+0x2> <<<---- this causes problem 000010b6: b662 cpsie i 000001d8: <foo>: 000001d8: e92d 4178 stmdb sp!, {r3, r4, r5, r6, r8, lr} 000001dc: f001 f8e8 bl 000013b0 <__foo2_veneer> ========================================================== If I change the blx to bl or insert push/pop, the result will be OK. ========================================================== void SVC_Handler(void) { __asm volatile ( " cpsid i \n" " bl foo \n" " cpsie i \n" /* ..... code removed ... */ } 000010b0 <SVC_Handler>: 000010b0: b672 cpsid i 000010b2: f7ff f892 bl 000001d8 <foo> 000010b6: b662 cpsie i 000001d8: <foo>: 000001d8: e92d 4178 stmdb sp!, {r3, r4, r5, r6, r8, lr} 000001dc: f001 f8e8 bl 000013b0 <__foo2_veneer> ========================================================== void SVC_Handler(void) { __asm volatile ( " cpsid i \n" " push {lr} \n" " blx foo \n" " pop {lr} \n" " cpsie i \n" /* ..... code removed ... */ } -- You are receiving this mail because: You are on the CC list for the bug.