Request for Approval: Add BFD_VERSION for JDK-8191006: hsdis disassembler plugin does not compile with binutils 2.29+

Leslie Zhai zhaixiang at loongson.cn
Thu Aug 9 09:57:14 UTC 2018


Hi David,

Thanks for your response!

Because our operating system[1] use GCC old version toolchain, for 
example, gcc 4.9.3, binutils-gdb 2.24, and glibc 2.20 for long term 
support. Fortunately there are some patches had been merged by 
upstream[2], but we still need to maintain the ones not be approved by 
upstream, that is the usecase for building with old version of 
binutils-gdb. And we are migrating[3] to gcc-5/6/7/8 branches from 
gcc-4-branch. So there might be less and less backport requirement[4]

BTW, hsdis perhaps also need nonexecstack flag set for linking with 
binutils/ld:

diff -r 119d4695c1ed hotspot/src/share/tools/hsdis/Makefile
--- a/hotspot/src/share/tools/hsdis/Makefile    Mon Aug 06 11:15:26 2018 
+0800
+++ b/hotspot/src/share/tools/hsdis/Makefile    Thu Aug 09 17:56:21 2018 
+0800
@@ -94,6 +94,7 @@
  endif
  CFLAGS        += -O
  DLDFLAGS    += -shared
+DLDFLAGS        += -Wl,-z,noexecstack
  LDFLAGS         += -ldl
  OUTFLAGS    += -o $@
  else

1. Loongnix http://ftp.loongnix.org/os/loongnix/1.0/liveinst/

2. 
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=8095d2f70e1a982c006f306be1a9e1c892758914

3. http://github.com/loongson-community/gcc

4. https://gcc.gnu.org/ml/gcc/2018-08/msg00041.html


在 2018年08月09日 17:13, David Buck 写道:
> Hi Leslie!
>
> What exactly is the use-case for building with older versions of BINUTILS? It would be good to know what benefit(s) there might be that would justify the cost of (slightly) complicating the code.
>
> Cheers,
> -Buck
>
>> On Aug 9, 2018, at 17:12, Leslie Zhai <zhaixiang at loongson.cn> wrote:
>>
>> Hi all,
>>
>> Thanks for David's patch to fix:
>>
>> https://bugs.openjdk.java.net/browse/JDK-8191006
>>
>> But hsdis plugin does not compiled with binutils old version 2.27, so I just add `BFD_VERSION` for supporting old version binutils:
>>
>> Here is the patch:
>>
>> diff -r 09cc8813ae51 src/utils/hsdis/hsdis.c
>> --- a/src/utils/hsdis/hsdis.c    Wed Aug 08 18:38:34 2018 -0700
>> +++ b/src/utils/hsdis/hsdis.c    Thu Aug 09 15:49:31 2018 +0800
>> @@ -338,10 +338,14 @@
>>
>>    /* Finish linking together the various callback blocks. */
>>    app_data->dinfo.application_data = (void*) app_data;
>> +#if BFD_VERSION >= 229000000
>>    app_data->dfn = disassembler(bfd_get_arch(native_bfd),
>>                                 bfd_big_endian(native_bfd),
>>                                 bfd_get_mach(native_bfd),
>>                                 native_bfd);
>> +#else
>> +  app_data->dfn = disassembler(native_bfd);
>> +#endif
>>    app_data->dinfo.print_address_func = hsdis_print_address_func;
>>    app_data->dinfo.read_memory_func = hsdis_read_memory_func;
>>
>> And I would like to backport the fix to OpenJDK8 updates dev:
>>
>> http://hg.openjdk.java.net/jdk8u/jdk8u-dev
>>
>> So here is the backport patch:
>>
>> diff -r b4ee249eb1c4 src/share/tools/hsdis/hsdis.c
>> --- a/src/share/tools/hsdis/hsdis.c    Tue Aug 07 11:55:44 2018 -0400
>> +++ b/src/share/tools/hsdis/hsdis.c    Thu Aug 09 15:49:57 2018 +0800
>> @@ -337,10 +337,14 @@
>>
>>    /* Finish linking together the various callback blocks. */
>>    app_data->dinfo.application_data = (void*) app_data;
>> +#if BFD_VERSION >= 229000000
>>    app_data->dfn = disassembler(bfd_get_arch(native_bfd),
>>                                 bfd_big_endian(native_bfd),
>>                                 bfd_get_mach(native_bfd),
>>                                 native_bfd);
>> +#else
>> +  app_data->dfn = disassembler(native_bfd);
>> +#endif
>>    app_data->dinfo.print_address_func = hsdis_print_address_func;
>>    app_data->dinfo.read_memory_func = hsdis_read_memory_func;
>>
>> And I make demo[1] to test for OpenJDK8 mips64el[2].
>>
>> A patch by Loongson! Please sponsor it, thanks a lot!
>>
>>
>> 1.
>>
>> $ ./build/linux-mips64/hsdis-demo
>> Hello, world!
>> ...And now for something completely different:
>>
>> Decoding from 0x120000dd0 to 0x120001090...with decode_instructions_virtual
>> Decoding for CPU 'mips:loongson_3a'
>> main:
>> 0x120000dd0    daddiu    sp,sp,-80
>> 0x120000dd4    gssq    ra,s8,64(sp)
>> 0x120000dd8    sd    gp,56(sp)
>> 0x120000ddc    move    s8,sp
>> 0x120000de0    lui    gp,0x2
>> 0x120000de4    daddu    gp,gp,t9
>> 0x120000de8    daddiu    gp,gp,-23968
>> 0x120000dec    move    v0,a0
>> 0x120000df0    sd    a1,40(s8)
>> 0x120000df4    sll    v0,v0,0x0
>> 0x120000df8    sw    v0,32(s8)
>> 0x120000dfc    sw    zero,0(s8)
>> 0x120000e00    li    v0,1
>> 0x120000e04    sw    v0,4(s8)
>> 0x120000e08    b    0x0000000120000f6c
>> 0x120000e0c    nop
>> 0x120000e10    lw    v0,4(s8)
>> 0x120000e14    dsll    v0,v0,0x3
>> 0x120000e18    ld    v1,40(s8)
>> 0x120000e1c    daddu    v0,v1,v0
>> 0x120000e20    ld    v0,0(v0)
>> 0x120000e24    sd    v0,8(s8)
>> 0x120000e28    ld    v0,8(s8)
>> 0x120000e2c    lb    v1,0(v0)
>> 0x120000e30    li    v0,45
>> 0x120000e34    bne    v1,v0,0x0000000120000f44
>> 0x120000e38    nop
>> 0x120000e3c    ld    a0,8(s8)
>> 0x120000e40    ld    v0,-32696(gp)
>> 0x120000e44    daddiu    a1,v0,7424
>> 0x120000e48    ld    v0,-32456(gp)
>> 0x120000e4c    move    t9,v0
>> 0x120000e50    jalr    t9
>> 0x120000e54    nop
>> 0x120000e58    bnez    v0,0x0000000120000e80
>> 0x120000e5c    nop
>> 0x120000e60    ld    v0,-32688(gp)
>> 0x120000e64    lw    v0,0(v0)
>> 0x120000e68    xori    v0,v0,0x1
>> 0x120000e6c    move    v1,v0
>> 0x120000e70    ld    v0,-32688(gp)
>> 0x120000e74    sw    v1,0(v0)
>> 0x120000e78    b    0x0000000120000f3c
>> 0x120000e7c    nop
>> 0x120000e80    ld    a0,8(s8)
>> 0x120000e84    ld    v0,-32696(gp)
>> 0x120000e88    daddiu    a1,v0,7432
>> 0x120000e8c    ld    v0,-32456(gp)
>> 0x120000e90    move    t9,v0
>> 0x120000e94    jalr    t9
>> 0x120000e98    nop
>> 0x120000e9c    bnez    v0,0x0000000120000ec4
>> 0x120000ea0    nop
>> 0x120000ea4    ld    v0,-32680(gp)
>> 0x120000ea8    lw    v0,0(v0)
>> 0x120000eac    xori    v0,v0,0x1
>> 0x120000eb0    move    v1,v0
>> 0x120000eb4    ld    v0,-32680(gp)
>> 0x120000eb8    sw    v1,0(v0)
>> 0x120000ebc    b    0x0000000120000f3c
>> 0x120000ec0    nop
>> 0x120000ec4    ld    a0,8(s8)
>> 0x120000ec8    ld    v0,-32696(gp)
>> 0x120000ecc    daddiu    a1,v0,7440
>> 0x120000ed0    li    a2,9
>> 0x120000ed4    ld    v0,-32592(gp)
>> 0x120000ed8    move    t9,v0
>> 0x120000edc    jalr    t9
>> 0x120000ee0    nop
>> 0x120000ee4    bnez    v0,0x0000000120000f04
>> 0x120000ee8    nop
>> 0x120000eec    ld    v0,8(s8)
>> 0x120000ef0    daddiu    v1,v0,9
>> 0x120000ef4    ld    v0,-32672(gp)
>> 0x120000ef8    sd    v1,0(v0)
>> 0x120000efc    b    0x0000000120000f3c
>> 0x120000f00    nop
>> 0x120000f04    ld    v0,40(s8)
>> 0x120000f08    ld    v1,0(v0)
>> 0x120000f0c    ld    v0,-32696(gp)
>> 0x120000f10    daddiu    a0,v0,7456
>> 0x120000f14    move    a1,v1
>> 0x120000f18    ld    v0,-32472(gp)
>> 0x120000f1c    move    t9,v0
>> 0x120000f20    jalr    t9
>> 0x120000f24    nop
>> 0x120000f28    li    a0,2
>> 0x120000f2c    ld    v0,-32512(gp)
>> 0x120000f30    move    t9,v0
>> 0x120000f34    jalr    t9
>> 0x120000f38    nop
>> 0x120000f3c    b    0x0000000120000f60
>> 0x120000f40    nop
>> 0x120000f44    ld    a0,8(s8)
>> 0x120000f48    ld    v0,-32664(gp)
>> 0x120000f4c    move    t9,v0
>> 0x120000f50    bal    &greet (0x12000103c)
>> 0x120000f54    nop
>> 0x120000f58    li    v0,1
>> 0x120000f5c    sw    v0,0(s8)
>> 0x120000f60    lw    v0,4(s8)
>> 0x120000f64    addiu    v0,v0,1
>> 0x120000f68    sw    v0,4(s8)
>> 0x120000f6c    lw    v1,4(s8)
>> 0x120000f70    lw    v0,32(s8)
>> 0x120000f74    slt    v0,v1,v0
>> 0x120000f78    bnez    v0,0x0000000120000e10
>> 0x120000f7c    nop
>> 0x120000f80    lw    v0,0(s8)
>> 0x120000f84    bnez    v0,0x0000000120000fa4
>> 0x120000f88    nop
>> 0x120000f8c    ld    v0,-32696(gp)
>> 0x120000f90    daddiu    a0,v0,7488
>> 0x120000f94    ld    v0,-32664(gp)
>> 0x120000f98    move    t9,v0
>> 0x120000f9c    bal    &greet (0x12000103c)
>> 0x120000fa0    nop
>> 0x120000fa4    ld    v0,-32696(gp)
>> 0x120000fa8    daddiu    a0,v0,7496
>> 0x120000fac    ld    v0,-32496(gp)
>> 0x120000fb0    move    t9,v0
>> 0x120000fb4    jalr    t9
>> 0x120000fb8    nop
>> 0x120000fbc    ld    v0,-32736(gp)
>> 0x120000fc0    sd    v0,16(s8)
>> 0x120000fc4    ld    v0,-32656(gp)
>> 0x120000fc8    sd    v0,24(s8)
>> 0x120000fcc    ld    a0,16(s8)
>> 0x120000fd0    ld    v1,24(s8)
>> 0x120000fd4    ld    v0,16(s8)
>> 0x120000fd8    sltu    v0,v0,v1
>> 0x120000fdc    bnez    v0,0x0000000120000ff4
>> 0x120000fe0    nop
>> 0x120000fe4    ld    v0,16(s8)
>> 0x120000fe8    daddiu    v0,v0,64
>> 0x120000fec    b    0x0000000120000ff8
>> 0x120000ff0    nop
>> 0x120000ff4    ld    v0,24(s8)
>> 0x120000ff8    move    a1,v0
>> 0x120000ffc    ld    v0,-32648(gp)
>> 0x120001000    move    t9,v0
>> 0x120001004    bal    0x0000000120001840
>> 0x120001008    nop
>> 0x12000100c    ld    v0,-32696(gp)
>> 0x120001010    daddiu    a0,v0,7544
>> 0x120001014    ld    v0,-32496(gp)
>> 0x120001018    move    t9,v0
>> 0x12000101c    jalr    t9
>> 0x120001020    nop
>> 0x120001024    move    sp,s8
>> 0x120001028    gslq    ra,s8,64(sp)
>> 0x12000102c    ld    gp,56(sp)
>> 0x120001030    daddiu    sp,sp,80
>> 0x120001034    jr    ra
>> 0x120001038    nop
>> greet:
>> 0x12000103c    daddiu    sp,sp,-48
>> 0x120001040    gssq    ra,s8,32(sp)
>> 0x120001044    sd    gp,24(sp)
>> 0x120001048    move    s8,sp
>> 0x12000104c    lui    gp,0x2
>> 0x120001050    daddu    gp,gp,t9
>> 0x120001054    daddiu    gp,gp,-24588
>> 0x120001058    sd    a0,0(s8)
>> 0x12000105c    ld    v0,-32696(gp)
>> 0x120001060    daddiu    a0,v0,7552
>> 0x120001064    ld    a1,0(s8)
>> 0x120001068    ld    v0,-32472(gp)
>> 0x12000106c    move    t9,v0
>> 0x120001070    jalr    t9
>> 0x120001074    nop
>> 0x120001078    move    sp,s8
>> 0x12000107c    gslq    ra,s8,32(sp)
>> 0x120001080    ld    gp,24(sp)
>> 0x120001084    daddiu    sp,sp,48
>> 0x120001088    jr    ra
>> 0x12000108c    nop
>>
>> Decoding from 0x120000dd0 to 0x120001090...with old decode_instructions
>> Decoding for CPU 'mips:loongson_3a'
>> main:
>> 0x120000dd0    daddiu    sp,sp,-80
>> 0x120000dd4    gssq    ra,s8,64(sp)
>> 0x120000dd8    sd    gp,56(sp)
>> 0x120000ddc    move    s8,sp
>> 0x120000de0    lui    gp,0x2
>> 0x120000de4    daddu    gp,gp,t9
>> 0x120000de8    daddiu    gp,gp,-23968
>> 0x120000dec    move    v0,a0
>> 0x120000df0    sd    a1,40(s8)
>> 0x120000df4    sll    v0,v0,0x0
>> 0x120000df8    sw    v0,32(s8)
>> 0x120000dfc    sw    zero,0(s8)
>> 0x120000e00    li    v0,1
>> 0x120000e04    sw    v0,4(s8)
>> 0x120000e08    b    0x0000000120000f6c
>> 0x120000e0c    nop
>> 0x120000e10    lw    v0,4(s8)
>> 0x120000e14    dsll    v0,v0,0x3
>> 0x120000e18    ld    v1,40(s8)
>> 0x120000e1c    daddu    v0,v1,v0
>> 0x120000e20    ld    v0,0(v0)
>> 0x120000e24    sd    v0,8(s8)
>> 0x120000e28    ld    v0,8(s8)
>> 0x120000e2c    lb    v1,0(v0)
>> 0x120000e30    li    v0,45
>> 0x120000e34    bne    v1,v0,0x0000000120000f44
>> 0x120000e38    nop
>> 0x120000e3c    ld    a0,8(s8)
>> 0x120000e40    ld    v0,-32696(gp)
>> 0x120000e44    daddiu    a1,v0,7424
>> 0x120000e48    ld    v0,-32456(gp)
>> 0x120000e4c    move    t9,v0
>> 0x120000e50    jalr    t9
>> 0x120000e54    nop
>> 0x120000e58    bnez    v0,0x0000000120000e80
>> 0x120000e5c    nop
>> 0x120000e60    ld    v0,-32688(gp)
>> 0x120000e64    lw    v0,0(v0)
>> 0x120000e68    xori    v0,v0,0x1
>> 0x120000e6c    move    v1,v0
>> 0x120000e70    ld    v0,-32688(gp)
>> 0x120000e74    sw    v1,0(v0)
>> 0x120000e78    b    0x0000000120000f3c
>> 0x120000e7c    nop
>> 0x120000e80    ld    a0,8(s8)
>> 0x120000e84    ld    v0,-32696(gp)
>> 0x120000e88    daddiu    a1,v0,7432
>> 0x120000e8c    ld    v0,-32456(gp)
>> 0x120000e90    move    t9,v0
>> 0x120000e94    jalr    t9
>> 0x120000e98    nop
>> 0x120000e9c    bnez    v0,0x0000000120000ec4
>> 0x120000ea0    nop
>> 0x120000ea4    ld    v0,-32680(gp)
>> 0x120000ea8    lw    v0,0(v0)
>> 0x120000eac    xori    v0,v0,0x1
>> 0x120000eb0    move    v1,v0
>> 0x120000eb4    ld    v0,-32680(gp)
>> 0x120000eb8    sw    v1,0(v0)
>> 0x120000ebc    b    0x0000000120000f3c
>> 0x120000ec0    nop
>> 0x120000ec4    ld    a0,8(s8)
>> 0x120000ec8    ld    v0,-32696(gp)
>> 0x120000ecc    daddiu    a1,v0,7440
>> 0x120000ed0    li    a2,9
>> 0x120000ed4    ld    v0,-32592(gp)
>> 0x120000ed8    move    t9,v0
>> 0x120000edc    jalr    t9
>> 0x120000ee0    nop
>> 0x120000ee4    bnez    v0,0x0000000120000f04
>> 0x120000ee8    nop
>> 0x120000eec    ld    v0,8(s8)
>> 0x120000ef0    daddiu    v1,v0,9
>> 0x120000ef4    ld    v0,-32672(gp)
>> 0x120000ef8    sd    v1,0(v0)
>> 0x120000efc    b    0x0000000120000f3c
>> 0x120000f00    nop
>> 0x120000f04    ld    v0,40(s8)
>> 0x120000f08    ld    v1,0(v0)
>> 0x120000f0c    ld    v0,-32696(gp)
>> 0x120000f10    daddiu    a0,v0,7456
>> 0x120000f14    move    a1,v1
>> 0x120000f18    ld    v0,-32472(gp)
>> 0x120000f1c    move    t9,v0
>> 0x120000f20    jalr    t9
>> 0x120000f24    nop
>> 0x120000f28    li    a0,2
>> 0x120000f2c    ld    v0,-32512(gp)
>> 0x120000f30    move    t9,v0
>> 0x120000f34    jalr    t9
>> 0x120000f38    nop
>> 0x120000f3c    b    0x0000000120000f60
>> 0x120000f40    nop
>> 0x120000f44    ld    a0,8(s8)
>> 0x120000f48    ld    v0,-32664(gp)
>> 0x120000f4c    move    t9,v0
>> 0x120000f50    bal    &greet (0x12000103c)
>> 0x120000f54    nop
>> 0x120000f58    li    v0,1
>> 0x120000f5c    sw    v0,0(s8)
>> 0x120000f60    lw    v0,4(s8)
>> 0x120000f64    addiu    v0,v0,1
>> 0x120000f68    sw    v0,4(s8)
>> 0x120000f6c    lw    v1,4(s8)
>> 0x120000f70    lw    v0,32(s8)
>> 0x120000f74    slt    v0,v1,v0
>> 0x120000f78    bnez    v0,0x0000000120000e10
>> 0x120000f7c    nop
>> 0x120000f80    lw    v0,0(s8)
>> 0x120000f84    bnez    v0,0x0000000120000fa4
>> 0x120000f88    nop
>> 0x120000f8c    ld    v0,-32696(gp)
>> 0x120000f90    daddiu    a0,v0,7488
>> 0x120000f94    ld    v0,-32664(gp)
>> 0x120000f98    move    t9,v0
>> 0x120000f9c    bal    &greet (0x12000103c)
>> 0x120000fa0    nop
>> 0x120000fa4    ld    v0,-32696(gp)
>> 0x120000fa8    daddiu    a0,v0,7496
>> 0x120000fac    ld    v0,-32496(gp)
>> 0x120000fb0    move    t9,v0
>> 0x120000fb4    jalr    t9
>> 0x120000fb8    nop
>> 0x120000fbc    ld    v0,-32736(gp)
>> 0x120000fc0    sd    v0,16(s8)
>> 0x120000fc4    ld    v0,-32656(gp)
>> 0x120000fc8    sd    v0,24(s8)
>> 0x120000fcc    ld    a0,16(s8)
>> 0x120000fd0    ld    v1,24(s8)
>> 0x120000fd4    ld    v0,16(s8)
>> 0x120000fd8    sltu    v0,v0,v1
>> 0x120000fdc    bnez    v0,0x0000000120000ff4
>> 0x120000fe0    nop
>> 0x120000fe4    ld    v0,16(s8)
>> 0x120000fe8    daddiu    v0,v0,64
>> 0x120000fec    b    0x0000000120000ff8
>> 0x120000ff0    nop
>> 0x120000ff4    ld    v0,24(s8)
>> 0x120000ff8    move    a1,v0
>> 0x120000ffc    ld    v0,-32648(gp)
>> 0x120001000    move    t9,v0
>> 0x120001004    bal    0x0000000120001840
>> 0x120001008    nop
>> 0x12000100c    ld    v0,-32696(gp)
>> 0x120001010    daddiu    a0,v0,7544
>> 0x120001014    ld    v0,-32496(gp)
>> 0x120001018    move    t9,v0
>> 0x12000101c    jalr    t9
>> 0x120001020    nop
>> 0x120001024    move    sp,s8
>> 0x120001028    gslq    ra,s8,64(sp)
>> 0x12000102c    ld    gp,56(sp)
>> 0x120001030    daddiu    sp,sp,80
>> 0x120001034    jr    ra
>> 0x120001038    nop
>> greet:
>> 0x12000103c    daddiu    sp,sp,-48
>> 0x120001040    gssq    ra,s8,32(sp)
>> 0x120001044    sd    gp,24(sp)
>> 0x120001048    move    s8,sp
>> 0x12000104c    lui    gp,0x2
>> 0x120001050    daddu    gp,gp,t9
>> 0x120001054    daddiu    gp,gp,-24588
>> 0x120001058    sd    a0,0(s8)
>> 0x12000105c    ld    v0,-32696(gp)
>> 0x120001060    daddiu    a0,v0,7552
>> 0x120001064    ld    a1,0(s8)
>> 0x120001068    ld    v0,-32472(gp)
>> 0x12000106c    move    t9,v0
>> 0x120001070    jalr    t9
>> 0x120001074    nop
>> 0x120001078    move    sp,s8
>> 0x12000107c    gslq    ra,s8,32(sp)
>> 0x120001080    ld    gp,24(sp)
>> 0x120001084    daddiu    sp,sp,48
>> 0x120001088    jr    ra
>> 0x12000108c    nop
>> Cheers!
>>
>> 2. http://hg.loongnix.org/jdk8-mips64-public/hotspot/file/tip/src/share/tools/hsdis/Makefile#l85
>>
>>
>> -- 
>> Regards,
>> Leslie Zhai
>>
>>

-- 
Regards,
Leslie Zhai




More information about the jdk-dev mailing list