Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8244819

hsdis does not compile with binutils 2.34+

    Details

    • Subcomponent:
    • Resolved In Build:
      b24

      Description

      binutils 2.34 introduces new section flag: SEC_ELF_OCTETS, and it affects arguments of bfd_octets_per_byte() [1]. So we can see new compiler error as below:

      ```
      gcc -o build/linux-amd64/hsdis-amd64.so -I/home/ysuenaga/rpmbuild/BUILD/binutils-2.34/include -I/home/ysuenaga/rpmbuild/BUILD/binutils-2.34/bfd -Ibuild/linux-amd64/bfd -DLIBARCH_amd64 -DLIBARCH=\"amd64\" -DLIB_EXT=\".so\" -fPIC -O hsdis.c -shared build/linux-amd64/bfd/libbfd.a build/linux-amd64/opcodes/libopcodes.a build/linux-amd64/libiberty/libiberty.a
      hsdis.c: In function 'init_disassemble_info_from_bfd':
      hsdis.c:571:28: error: too few arguments to function 'bfd_octets_per_byt
      '
        571 | dinfo->octets_per_byte = bfd_octets_per_byte (abfd);
            | ^~~~~~~~~~~~~~~~~~~
      In file included from hsdis.c:58:
      build/linux-amd64/bfd/bfd.h:1999:14: note: declared here
       1999 | unsigned int bfd_octets_per_byte (const bfd *abfd,
            | ^~~~~~~~~~~~~~~~~~~
      make: *** [Makefile:229: build/linux-amd64/hsdis-amd64.so] Error 1
      ```

      We can fix it with following patch:

      ```
      diff --git a/src/utils/hsdis/hsdis.c b/src/utils/hsdis/hsdis.c
      --- a/src/utils/hsdis/hsdis.c
      +++ b/src/utils/hsdis/hsdis.c
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * The Universal Permissive License (UPL), Version 1.0
      @@ -568,7 +568,12 @@
         dinfo->arch = bfd_get_arch(abfd);
         dinfo->mach = bfd_get_mach(abfd);
         dinfo->disassembler_options = disassembler_options;
      +#if BFD_VERSION >= 234000000
      + /* bfd_octets_per_byte() has 2 args since binutils 2.34 */
      + dinfo->octets_per_byte = bfd_octets_per_byte (abfd, NULL);
      +#else
         dinfo->octets_per_byte = bfd_octets_per_byte (abfd);
      +#endif
         dinfo->skip_zeroes = sizeof(void*) * 2;
         dinfo->skip_zeroes_at_end = sizeof(void*)-1;
         dinfo->disassembler_needs_relocs = FALSE;
      ```

      [1] https://sourceware.org/git/?p=binutils-gdb.git;h=618265039f697eab9e72bb58b95fc2d32925df58

        Attachments

          Activity

            People

            • Assignee:
              ysuenaga Yasumasa Suenaga
              Reporter:
              ysuenaga Yasumasa Suenaga
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: