public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/102292] New: R_ARM_THM_JUMP24 incorrect link result if symbol duplicated
@ 2021-09-11 16:21 eason.lai at mediatek dot com
  2021-09-11 18:28 ` [Bug lto/102292] " pinskia at gcc dot gnu.org
  2021-09-13  1:28 ` sen2403 at hotmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: eason.lai at mediatek dot com @ 2021-09-11 16:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102292

            Bug ID: 102292
           Summary: R_ARM_THM_JUMP24 incorrect link result if symbol
                    duplicated
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eason.lai at mediatek dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 51439
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51439&action=edit
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug lto/102292] R_ARM_THM_JUMP24 incorrect link result if symbol duplicated
  2021-09-11 16:21 [Bug lto/102292] New: R_ARM_THM_JUMP24 incorrect link result if symbol duplicated eason.lai at mediatek dot com
@ 2021-09-11 18:28 ` pinskia at gcc dot gnu.org
  2021-09-13  1:28 ` sen2403 at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-11 18:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102292

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Are you sure this is not a linker issue?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug lto/102292] R_ARM_THM_JUMP24 incorrect link result if symbol duplicated
  2021-09-11 16:21 [Bug lto/102292] New: R_ARM_THM_JUMP24 incorrect link result if symbol duplicated eason.lai at mediatek dot com
  2021-09-11 18:28 ` [Bug lto/102292] " pinskia at gcc dot gnu.org
@ 2021-09-13  1:28 ` sen2403 at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: sen2403 at hotmail dot com @ 2021-09-13  1:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102292

--- Comment #2 from Eason Lai <sen2403 at hotmail dot com> ---
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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-13  1:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 16:21 [Bug lto/102292] New: R_ARM_THM_JUMP24 incorrect link result if symbol duplicated eason.lai at mediatek dot com
2021-09-11 18:28 ` [Bug lto/102292] " pinskia at gcc dot gnu.org
2021-09-13  1:28 ` sen2403 at hotmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).