bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/28474] New: R_ARM_THM_JUMP24 incorrect link result if symbol dup


From: sen2403 at hotmail dot com
Subject: [Bug ld/28474] New: R_ARM_THM_JUMP24 incorrect link result if symbol duplicated
Date: Tue, 19 Oct 2021 15:37:28 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=28474

            Bug ID: 28474
           Summary: R_ARM_THM_JUMP24 incorrect link result if symbol
                    duplicated
           Product: binutils
           Version: 2.35.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: sen2403 at hotmail dot com
  Target Milestone: ---

Created attachment 13726
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13726&action=edit
simple code to reproduce this issue

Hello Sir,

I am link a program with a symbol file which defined the address of
functions/global variables already put in flash.

And, there are some duplicated function name existing in symbol file and the c
file part of the program. The linker have selected the function in the c file
part of the program.

However, the linker selects the function/global variables defined in the symbol
file after enabling LTO.

Moreover, the link result of R_ARM_THM_JUMP24 is also incorrect. Without the
LTO, the veneer jump to a function from THUMB mode to THUMB mode. With the LTO,
the veneer jump to a function from THUMB mode to ARM mode which is not expected
result.

I have wrote a simple code to reproduce this problem. You can change the
toolchain path and reproduce it by enabling/disabling the LTO option in the
makefile and check the result as shown below.

PS: I'm not sure whether this is a linker issue or not. I can do more
experiments to provide information if any suggestions. Thank you very much.

Toolchain: 10-2020-q4-major from
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]