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

ODR violation in macroAssembler_aarch64.cpp

XMLWordPrintable

    • b07
    • 20
    • b13
    • aarch64
    • os_x

        There's a violation of the C++ one definition rule in src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp where the class Decoder conflicts with src/hotspot/share/utilities/decoder.hpp:Decoder

        This can lead to undefined behavior. I found it to cause crashes in the Sulong LLVM toolchain inside Apple's `ld`.

        Attached patch fixes it (or rather, gets me onto the next linker crash...)

        --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
        +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
        @@ -392,13 +392,13 @@ static bool offset_for(uint32_t insn1, uint32_t insn2, ptrdiff_t &byte_offset) {
           return false;
         }

        -class Decoder : public RelocActions {
        - virtual reloc_insn adrpMem() { return &Decoder::adrpMem_impl; }
        - virtual reloc_insn adrpAdd() { return &Decoder::adrpAdd_impl; }
        - virtual reloc_insn adrpMovk() { return &Decoder::adrpMovk_impl; }
        +class Aarch64Decoder : public RelocActions {
        + virtual reloc_insn adrpMem() { return &Aarch64Decoder::adrpMem_impl; }
        + virtual reloc_insn adrpAdd() { return &Aarch64Decoder::adrpAdd_impl; }
        + virtual reloc_insn adrpMovk() { return &Aarch64Decoder::adrpMovk_impl; }

         public:
        - Decoder(address insn_addr, uint32_t insn) : RelocActions(insn_addr, insn) {}
        + Aarch64Decoder(address insn_addr, uint32_t insn) : RelocActions(insn_addr, insn) {}

           virtual int loadStore(address insn_addr, address &target) {
             intptr_t offset = Instruction_aarch64::sextract(_insn, 23, 5);
        @@ -494,7 +494,7 @@ class Decoder : public RelocActions {
         };

         address MacroAssembler::target_addr_for_insn(address insn_addr, uint32_t insn) {
        - Decoder decoder(insn_addr, insn);
        + Aarch64Decoder decoder(insn_addr, insn);
           address target;
           decoder.run(insn_addr, target);
           return target;

              aph Andrew Haley
              mhearn Mike Hearn
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: