[Top][All Lists]

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

[Bug ld/22756] New: Linker relaxation miscalculates symbol addresses on

From: address@hidden
Subject: [Bug ld/22756] New: Linker relaxation miscalculates symbol addresses on riscv
Date: Sat, 27 Jan 2018 23:22:31 +0000


            Bug ID: 22756
           Summary: Linker relaxation miscalculates symbol addresses on
           Product: binutils
           Version: 2.30
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: address@hidden
  Target Milestone: ---
            Target: riscv64-*-*

The test program created by the copy_setup proc in
testsuite/binutils-all/objcopy.exp is broken by linker relaxation.

$ objdump -d tmpdir/testprog

tmpdir/testprog:     file format elf64-littleriscv

Disassembly of section .plt:

0000000000000690 <.plt>:
 690:   00002397                auipc   t2,0x2
 694:   41c30333                sub     t1,t1,t3
 698:   9883be03                ld      t3,-1656(t2) # 2018 <__TMC_END__>
 69c:   fd430313                addi    t1,t1,-44
 6a0:   98838293                addi    t0,t2,-1656
 6a4:   00135313                srli    t1,t1,0x1
 6a8:   0082b283                ld      t0,8(t0)
 6ac:   000e0067                jr      t3

00000000000006b0 <address@hidden>:
 6b0:   00002e17                auipc   t3,0x2
 6b4:   978e3e03                ld      t3,-1672(t3) # 2028
 6b8:   000e0367                jalr    t1,t3
 6bc:   00000013                nop

00000000000006c0 <address@hidden>:
 6c0:   00002e17                auipc   t3,0x2
 6c4:   970e3e03                ld      t3,-1680(t3) # 2030 <address@hidden>
 6c8:   000e0367                jalr    t1,t3
 6cc:   00000013                nop

00000000000006d0 <address@hidden>:
 6d0:   00002e17                auipc   t3,0x2
 6d4:   968e3e03                ld      t3,-1688(t3) # 2038 <address@hidden>
 6d8:   000e0367                jalr    t1,t3
 6dc:   00000013                nop

00000000000006e0 <address@hidden>:
 6e0:   00002e17                auipc   t3,0x2
 6e4:   960e3e03                ld      t3,-1696(t3) # 2040 <address@hidden>
 6e8:   000e0367                jalr    t1,t3
 6ec:   00000013                nop

00000000000006f0 <address@hidden>:
 6f0:   00002e17                auipc   t3,0x2
 6f4:   958e3e03                ld      t3,-1704(t3) # 2048 <address@hidden>
 6f8:   000e0367                jalr    t1,t3
 6fc:   00000013                nop

0000000000000700 <address@hidden>:
 700:   00002e17                auipc   t3,0x2
 704:   950e3e03                ld      t3,-1712(t3) # 2050 <address@hidden>
 708:   000e0367                jalr    t1,t3
 70c:   00000013                nop

0000000000000710 <address@hidden>:
 710:   00002e17                auipc   t3,0x2
 714:   948e3e03                ld      t3,-1720(t3) # 2058 <address@hidden>
 718:   000e0367                jalr    t1,t3
 71c:   00000013                nop

Disassembly of section .text:

0000000000000720 <_start>:
 720:   02c000ef                jal     ra,74c <_start+0x2c>
 724:   87aa                    mv      a5,a0
 726:   00002517                auipc   a0,0x2
 72a:   94a53503                ld      a0,-1718(a0) # 2070
 72e:   6582                    ld      a1,0(sp)
 730:   0030                    addi    a2,sp,8
 732:   ff017113                andi    sp,sp,-16
 736:   00000697                auipc   a3,0x0
 73a:   35c68693                addi    a3,a3,860 # a92 <__libc_csu_init>
 73e:   00000717                auipc   a4,0x0
 742:   3ac70713                addi    a4,a4,940 # aea <__libc_csu_fini>
 746:   880a                    mv      a6,sp
 748:   f69ff06f                j       6b0 <address@hidden>
 74c:   00002197                auipc   gp,0x2
 750:   14418193                addi    gp,gp,324 # 2890 <__global_pointer$>
 754:   8082                    ret

0000000000000756 <deregister_tm_clones>:
 756:   00002517                auipc   a0,0x2
 75a:   8c250513                addi    a0,a0,-1854 # 2018 <__TMC_END__>
 75e:   00002797                auipc   a5,0x2
 762:   8ba78793                addi    a5,a5,-1862 # 2018 <__TMC_END__>
 766:   00a78963                beq     a5,a0,778 <deregister_tm_clones+0x22>
 76a:   00002317                auipc   t1,0x2
 76e:   8fe33303                ld      t1,-1794(t1) # 2068
 772:   00030363                beqz    t1,778 <deregister_tm_clones+0x22>
 776:   8302                    jr      t1
 778:   8082                    ret

000000000000077a <register_tm_clones>:
 77a:   00002517                auipc   a0,0x2
 77e:   89e50513                addi    a0,a0,-1890 # 2018 <__TMC_END__>
 782:   00002597                auipc   a1,0x2
 786:   89658593                addi    a1,a1,-1898 # 2018 <__TMC_END__>
 78a:   8d89                    sub     a1,a1,a0
 78c:   858d                    srai    a1,a1,0x3
 78e:   03f5d793                srli    a5,a1,0x3f
 792:   95be                    add     a1,a1,a5
 794:   8585                    srai    a1,a1,0x1
 796:   c981                    beqz    a1,7a6 <register_tm_clones+0x2c>
 798:   00002317                auipc   t1,0x2
 79c:   8f033303                ld      t1,-1808(t1) # 2088
 7a0:   00030363                beqz    t1,7a6 <register_tm_clones+0x2c>
 7a4:   8302                    jr      t1
 7a6:   8082                    ret

00000000000007a8 <__do_global_dtors_aux>:
 7a8:   00002797                auipc   a5,0x2
 7ac:   8e87c783                lbu     a5,-1816(a5) # 2090 <_edata>
 7b0:   eb85                    bnez    a5,7e0 <__do_global_dtors_aux+0x38>
 7b2:   1141                    addi    sp,sp,-16
 7b4:   e406                    sd      ra,8(sp)
 7b6:   00002797                auipc   a5,0x2
 7ba:   8ca7b783                ld      a5,-1846(a5) # 2080
 7be:   c799                    beqz    a5,7cc <__do_global_dtors_aux+0x24>
 7c0:   00002717                auipc   a4,0x2
 7c4:   84070713                addi    a4,a4,-1984 # 2000 <__data_start>
 7c8:   6308                    ld      a0,0(a4)
 7ca:   9782                    jalr    a5
 7cc:   f8bff0ef                jal     ra,756 <deregister_tm_clones>
 7d0:   60a2                    ld      ra,8(sp)
 7d2:   4785                    li      a5,1
 7d4:   00002717                auipc   a4,0x2
 7d8:   8af70e23                sb      a5,-1860(a4) # 2090 <_edata>
 7dc:   0141                    addi    sp,sp,16
 7de:   8082                    ret
 7e0:   8082                    ret

00000000000007e2 <frame_dummy>:
 7e2:   f99ff06f                j       77a <register_tm_clones>

00000000000007e6 <fn>:
 7e6:   1141                    addi    sp,sp,-16
 7e8:   e422                    sd      s0,8(sp)
 7ea:   0800                    addi    s0,sp,16
 7ec:   478d                    li      a5,3
 7ee:   853e                    mv      a0,a5
 7f0:   6422                    ld      s0,8(sp)
 7f2:   0141                    addi    sp,sp,16
 7f4:   8082                    ret

00000000000007f6 <main>:
 7f6:   1141                    addi    sp,sp,-16
 7f8:   e406                    sd      ra,8(sp)
 7fa:   e022                    sd      s0,0(sp)
 7fc:   0800                    addi    s0,sp,16
 7fe:   00002797                auipc   a5,0x2
 802:   87a7b783                ld      a5,-1926(a5) # 2078 <common@@Base-0x20>
 806:   439c                    lw      a5,0(a5)
 808:   e39d                    bnez    a5,82e <main+0x38>
 80a:   00001797                auipc   a5,0x1
 80e:   7fe78793                addi    a5,a5,2046 # 2008 <global>
 812:   439c                    lw      a5,0(a5)
 814:   873e                    mv      a4,a5
 816:   4785                    li      a5,1
 818:   00f71b63                bne     a4,a5,82e <main+0x38>
 81c:   00001797                auipc   a5,0x1
 820:   7f078793                addi    a5,a5,2032 # 200c <local>
 824:   439c                    lw      a5,0(a5)
 826:   873e                    mv      a4,a5
 828:   4789                    li      a5,2
 82a:   00f70a63                beq     a4,a5,83e <main+0x48>
 82e:   00000517                auipc   a0,0x0
 832:   2d250513                addi    a0,a0,722 # b00 <string+0x8>
 836:   ebbff0ef                jal     ra,6f0 <address@hidden>
 83a:   4785                    li      a5,1
 83c:   a801                    j       84c <main+0x56>
 83e:   00000517                auipc   a0,0x0
 842:   2ca50513                addi    a0,a0,714 # b08 <string+0x10>
 846:   eabff0ef                jal     ra,6f0 <address@hidden>
 84a:   4781                    li      a5,0
 84c:   853e                    mv      a0,a5
 84e:   60a2                    ld      ra,8(sp)
 850:   6402                    ld      s0,0(sp)
 852:   0141                    addi    sp,sp,16
 854:   8082                    ret

0000000000000856 <write_int>:
 856:   7179                    addi    sp,sp,-48
 858:   f406                    sd      ra,40(sp)
 85a:   f022                    sd      s0,32(sp)
 85c:   1800                    addi    s0,sp,48
 85e:   87aa                    mv      a5,a0
 860:   fcb43823                sd      a1,-48(s0)
 864:   fcf42e23                sw      a5,-36(s0)
 868:   fdc42783                lw      a5,-36(s0)
 86c:   2781                    sext.w  a5,a5
 86e:   0207d263                bgez    a5,892 <write_int+0x3c>
 872:   fd043783                ld      a5,-48(s0)
 876:   00178713                addi    a4,a5,1
 87a:   fce43823                sd      a4,-48(s0)
 87e:   02d00713                li      a4,45
 882:   00e78023                sb      a4,0(a5)
 886:   fdc42783                lw      a5,-36(s0)
 88a:   40f007bb                negw    a5,a5
 88e:   fcf42e23                sw      a5,-36(s0)
 892:   fdc42783                lw      a5,-36(s0)
 896:   0007871b                sext.w  a4,a5
 89a:   47a5                    li      a5,9
 89c:   00e7df63                ble     a4,a5,8ba <write_int+0x64>
 8a0:   fdc42703                lw      a4,-36(s0)
 8a4:   47a9                    li      a5,10
 8a6:   02f747bb                divw    a5,a4,a5
 8aa:   2781                    sext.w  a5,a5
 8ac:   fd043583                ld      a1,-48(s0)
 8b0:   853e                    mv      a0,a5
 8b2:   fa5ff0ef                jal     ra,856 <write_int>
 8b6:   fca43823                sd      a0,-48(s0)
 8ba:   fdc42703                lw      a4,-36(s0)
 8be:   47a9                    li      a5,10
 8c0:   02f767bb                remw    a5,a4,a5
 8c4:   2781                    sext.w  a5,a5
 8c6:   0ff7f793                andi    a5,a5,255
 8ca:   0307879b                addiw   a5,a5,48
 8ce:   fef407a3                sb      a5,-17(s0)
 8d2:   fd043783                ld      a5,-48(s0)
 8d6:   00178713                addi    a4,a5,1
 8da:   fce43823                sd      a4,-48(s0)
 8de:   fef44703                lbu     a4,-17(s0)
 8e2:   00e78023                sb      a4,0(a5)
 8e6:   fd043783                ld      a5,-48(s0)
 8ea:   853e                    mv      a0,a5
 8ec:   70a2                    ld      ra,40(sp)
 8ee:   7402                    ld      s0,32(sp)

00000000000008f0 <__wrap_exit>:
 8f0:   6145                    addi    sp,sp,48
 8f2:   8082                    ret
 8f4:   715d                    addi    sp,sp,-80
 8f6:   e486                    sd      ra,72(sp)
 8f8:   e0a2                    sd      s0,64(sp)
 8fa:   0880                    addi    s0,sp,80
 8fc:   87aa                    mv      a5,a0
 8fe:   faf42e23                sw      a5,-68(s0)
 902:   fc840793                addi    a5,s0,-56
 906:   00000717                auipc   a4,0x0
 90a:   20a70713                addi    a4,a4,522 # b10 <string+0x18>
 90e:   6314                    ld      a3,0(a4)
 910:   e394                    sd      a3,0(a5)
 912:   6718                    ld      a4,8(a4)
 914:   e798                    sd      a4,8(a5)
 916:   fc840793                addi    a5,s0,-56
 91a:   853e                    mv      a0,a5
 91c:   dc5ff0ef                jal     ra,6e0 <address@hidden>
 920:   872a                    mv      a4,a0
 922:   fc840793                addi    a5,s0,-56
 926:   973e                    add     a4,a4,a5
 928:   fbc42783                lw      a5,-68(s0)
 92c:   85ba                    mv      a1,a4
 92e:   853e                    mv      a0,a5
 930:   f27ff0ef                jal     ra,856 <write_int>
 934:   fea43423                sd      a0,-24(s0)
 938:   fe843783                ld      a5,-24(s0)
 93c:   00178713                addi    a4,a5,1
 940:   fee43423                sd      a4,-24(s0)
 944:   4729                    li      a4,10
 946:   00e78023                sb      a4,0(a5)
 94a:   fc840793                addi    a5,s0,-56
 94e:   fe843703                ld      a4,-24(s0)
 952:   40f707b3                sub     a5,a4,a5
 956:   873e                    mv      a4,a5
 958:   fc840793                addi    a5,s0,-56
 95c:   863a                    mv      a2,a4
 95e:   85be                    mv      a1,a5
 960:   4505                    li      a0,1
 962:   dafff0ef                jal     ra,710 <address@hidden>
 966:   00001797                auipc   a5,0x1
 96a:   72e78793                addi    a5,a5,1838 # 2094 <done_exit_message>
 96e:   4705                    li      a4,1
 970:   c398                    sw      a4,0(a5)
 972:   fbc42783                lw      a5,-68(s0)
 976:   853e                    mv      a0,a5
 978:   d89ff0ef                jal     ra,700 <address@hidden>
 97c:   0001                    nop
 97e:   00001797                auipc   a5,0x1
 982:   69278793                addi    a5,a5,1682 # 2010 <___constval>
 986:   439c                    lw      a5,0(a5)
 988:   fbfd                    bnez    a5,97e <__wrap_exit+0x8e>
 98a:   0001                    nop
 98c:   60a6                    ld      ra,72(sp)
 98e:   6406                    ld      s0,64(sp)
 990:   6161                    addi    sp,sp,80
 992:   8082                    ret

0000000000000994 <__wrap__exit>:
 994:   715d                    addi    sp,sp,-80
 996:   e486                    sd      ra,72(sp)
 998:   e0a2                    sd      s0,64(sp)
 99a:   0880                    addi    s0,sp,80
 99c:   87aa                    mv      a5,a0
 99e:   faf42e23                sw      a5,-68(s0)
 9a2:   00001797                auipc   a5,0x1
 9a6:   6f278793                addi    a5,a5,1778 # 2094 <done_exit_message>
 9aa:   439c                    lw      a5,0(a5)
 9ac:   e3bd                    bnez    a5,a12 <__wrap__exit+0x7e>
 9ae:   fc840793                addi    a5,s0,-56
 9b2:   00000717                auipc   a4,0x0
 9b6:   15e70713                addi    a4,a4,350 # b10 <string+0x18>
 9ba:   6314                    ld      a3,0(a4)
 9bc:   e394                    sd      a3,0(a5)
 9be:   6718                    ld      a4,8(a4)
 9c0:   e798                    sd      a4,8(a5)
 9c2:   fc840793                addi    a5,s0,-56
 9c6:   853e                    mv      a0,a5
 9c8:   d19ff0ef                jal     ra,6e0 <address@hidden>
 9cc:   872a                    mv      a4,a0
 9ce:   fc840793                addi    a5,s0,-56
 9d2:   973e                    add     a4,a4,a5
 9d4:   fbc42783                lw      a5,-68(s0)
 9d8:   85ba                    mv      a1,a4
 9da:   853e                    mv      a0,a5
 9dc:   e7bff0ef                jal     ra,856 <write_int>
 9e0:   fea43423                sd      a0,-24(s0)
 9e4:   fe843783                ld      a5,-24(s0)
 9e8:   00178713                addi    a4,a5,1
 9ec:   fee43423                sd      a4,-24(s0)
 9f0:   4729                    li      a4,10
 9f2:   00e78023                sb      a4,0(a5)
 9f6:   fc840793                addi    a5,s0,-56
 9fa:   fe843703                ld      a4,-24(s0)
 9fe:   40f707b3                sub     a5,a4,a5
 a02:   873e                    mv      a4,a5
 a04:   fc840793                addi    a5,s0,-56
 a08:   863a                    mv      a2,a4
 a0a:   85be                    mv      a1,a5
 a0c:   4505                    li      a0,1
 a0e:   d03ff0ef                jal     ra,710 <address@hidden>
 a12:   fbc42783                lw      a5,-68(s0)
 a16:   853e                    mv      a0,a5

0000000000000a18 <__wrap_abort>:
 a18:   cb9ff0ef                jal     ra,6d0 <address@hidden>
 a1c:   0001                    nop
 a1e:   00001797                auipc   a5,0x1
 a22:   5f278793                addi    a5,a5,1522 # 2010 <___constval>
 a26:   439c                    lw      a5,0(a5)
 a28:   fbfd                    bnez    a5,a1e <__wrap_abort+0x6>
 a2a:   0001                    nop
 a2c:   60a6                    ld      ra,72(sp)
 a2e:   6406                    ld      s0,64(sp)
 a30:   6161                    addi    sp,sp,80
 a32:   8082                    ret
 a34:   1141                    addi    sp,sp,-16
 a36:   e406                    sd      ra,8(sp)
 a38:   e022                    sd      s0,0(sp)
 a3a:   0800                    addi    s0,sp,16
 a3c:   4651                    li      a2,20
 a3e:   00000597                auipc   a1,0x0
 a42:   0e258593                addi    a1,a1,226 # b20 <string+0x28>
 a46:   4505                    li      a0,1
 a48:   cc9ff0ef                jal     ra,710 <address@hidden>
 a4c:   c75ff0ef                jal     ra,6c0 <address@hidden>
 a50:   0001                    nop
 a52:   00001797                auipc   a5,0x1
 a56:   5be78793                addi    a5,a5,1470 # 2010 <___constval>
 a5a:   439c                    lw      a5,0(a5)
 a5c:   fbfd                    bnez    a5,a52 <__wrap_abort+0x3a>
 a5e:   fbbff0ef                jal     ra,a18 <__wrap_abort>

0000000000000a62 <__wrap_main>:
 a62:   7179                    addi    sp,sp,-48
 a64:   f406                    sd      ra,40(sp)
 a66:   f022                    sd      s0,32(sp)
 a68:   1800                    addi    s0,sp,48
 a6a:   87aa                    mv      a5,a0
 a6c:   feb43023                sd      a1,-32(s0)
 a70:   fcc43c23                sd      a2,-40(s0)
 a74:   fef42623                sw      a5,-20(s0)
 a78:   fec42783                lw      a5,-20(s0)
 a7c:   fd843603                ld      a2,-40(s0)
 a80:   fe043583                ld      a1,-32(s0)
 a84:   853e                    mv      a0,a5
 a86:   d71ff0ef                jal     ra,7f6 <main>
 a8a:   87aa                    mv      a5,a0
 a8c:   853e                    mv      a0,a5
 a8e:   e63ff0ef                jal     ra,8f0 <__wrap_exit>

0000000000000a92 <__libc_csu_init>:
 a92:   7139                    addi    sp,sp,-64
 a94:   f822                    sd      s0,48(sp)
 a96:   f04a                    sd      s2,32(sp)
 a98:   00001417                auipc   s0,0x1
 a9c:   36840413                addi    s0,s0,872 # 1e00
 aa0:   00001917                auipc   s2,0x1
 aa4:   36890913                addi    s2,s2,872 # 1e08 <__init_array_end>
 aa8:   40890933                sub     s2,s2,s0
 aac:   fc06                    sd      ra,56(sp)
 aae:   f426                    sd      s1,40(sp)
 ab0:   ec4e                    sd      s3,24(sp)
 ab2:   e852                    sd      s4,16(sp)
 ab4:   e456                    sd      s5,8(sp)
 ab6:   40395913                srai    s2,s2,0x3
 aba:   00090f63                beqz    s2,ad8 <__libc_csu_init+0x46>
 abe:   8ab2                    mv      s5,a2
 ac0:   8a2e                    mv      s4,a1
 ac2:   89aa                    mv      s3,a0
 ac4:   4481                    li      s1,0
 ac6:   601c                    ld      a5,0(s0)
 ac8:   8656                    mv      a2,s5
 aca:   85d2                    mv      a1,s4
 acc:   854e                    mv      a0,s3
 ace:   0485                    addi    s1,s1,1
 ad0:   9782                    jalr    a5
 ad2:   0421                    addi    s0,s0,8
 ad4:   fe9919e3                bne     s2,s1,ac6 <__libc_csu_init+0x34>
 ad8:   70e2                    ld      ra,56(sp)
 ada:   7442                    ld      s0,48(sp)
 adc:   74a2                    ld      s1,40(sp)
 ade:   7902                    ld      s2,32(sp)
 ae0:   69e2                    ld      s3,24(sp)
 ae2:   6a42                    ld      s4,16(sp)
 ae4:   6aa2                    ld      s5,8(sp)
 ae6:   6121                    addi    sp,sp,64
 ae8:   8082                    ret

0000000000000aea <__libc_csu_fini>:
 aea:   8082                    ret

Note how both __wrap_exit and __warp_abort are pointing to the wrong addresses:
__wrap_exit should point to 0x8f4, and __wrap_abort should point to 0xa34.

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]