Created attachment 51439 [details] simple code to reproduce this issue If a program is linked with duplicated symbol, one in symbol file and another one in object file, the R_ARM_THM_JUMP24(b.w) result will be incorrect. Please find the simple code from the attachment. Following are the results of simple code. (Correct) The veneer stay in THUMB mode if LTO is disabled. Disassembly of section .text: 00001000 <dummy>: 1000: f04f 0004 mov.w r0, #4 1004: f04f 0105 mov.w r1, #5 1008: f000 b806 b.w 1018 <__foo_veneer> 100c: 4770 bx lr 0000100e <main>: 100e: b508 push {r3, lr} 1010: f7ff fff6 bl 1000 <dummy> 1014: 2000 movs r0, #0 1016: bd08 pop {r3, pc} 00001018 <__foo_veneer>: 1018: b401 push {r0} 101a: 4802 ldr r0, [pc, #8] ; (1024 <__foo_veneer+0xc>) 101c: 4684 mov ip, r0 101e: bc01 pop {r0} 1020: 4760 bx ip 1022: bf00 nop 1024: 10009ed1 .word 0x10009ed1 (Incorrect) The veneer switch to ARM mode if LTO is enabled. Disassembly of section .text: 00001000 <dummy>: 1000: f04f 0004 mov.w r0, #4 1004: f04f 0105 mov.w r1, #5 1008: f000 b806 b.w 1018 <__foo_veneer> 100c: 4770 bx lr 0000100e <main>: 100e: b510 push {r4, lr} 1010: 2000 movs r0, #0 1012: f7ff fff5 bl 1000 <dummy> 1016: bd10 pop {r4, pc} 00001018 <__foo_veneer>: 1018: 4778 bx pc 101a: e7fd b.n 1018 <__foo_veneer> 101c: e51ff004 ldr pc, [pc, #-4] ; 1020 <__foo_veneer+0x8> 1020: 10009ed0 .word 0x10009ed0 1024: 00000000 .word 0x00000000 (Correct) After removing foo.o from C_OBJS in Makefile, the veneer stay in THUMB mode as expected when LTO is enabled. Disassembly of section .text: 00001000 <dummy>: 1000: f04f 0004 mov.w r0, #4 1004: f04f 0105 mov.w r1, #5 1008: f000 b806 b.w 1018 <__foo_veneer> 100c: 4770 bx lr 0000100e <main>: 100e: b510 push {r4, lr} 1010: 2000 movs r0, #0 1012: f7ff fff5 bl 1000 <dummy> 1016: bd10 pop {r4, pc} 00001018 <__foo_veneer>: 1018: b401 push {r0} 101a: 4802 ldr r0, [pc, #8] ; (1024 <__foo_veneer+0xc>) 101c: 4684 mov ip, r0 101e: bc01 pop {r0} 1020: 4760 bx ip 1022: bf00 nop 1024: 10009ed1 .word 0x10009ed1
Are you sure this is not a linker issue?
sorry, I'm not sure whether this is a linker issue or not. Only thing I know is enabling or disabling LTO makes the result different. I can do more experiments to provide information if any suggestions. Thank you very much.