Giter Site home page Giter Site logo

Comments (7)

kobalicek avatar kobalicek commented on June 5, 2024

Can you please elaborate?

I don't see a bug anywhere right now. AsmJit assembles far jumps as other assemblers via ljmp and lcall instructions.

from asmjit.

kkptm avatar kkptm commented on June 5, 2024
    Assembler assembler;
    CodeHolder asmcode;
    asmcode.reset();
    asmcode.init(asmjit::Environment(Arch::kX64), 0);
    asmcode.attach(&assembler);
    assembler.addDiagnosticOptions(asmjit::DiagnosticOptions::kValidateAssembler);
    {
	    assembler.jmp(0xA123456789);
	    assembler.call(0xA123456789);
    }
    asmjit::String encodedOpcode;
    asmjit::Section* text = asmcode.textSection();
    text->buffer()[0];
    encodedOpcode.appendHex(text->data(), text->bufferSize());
    printf(encodedOpcode.data());

it outputs:
40 E9 00000000
40 E8 00000000

from asmjit.

kkptm avatar kkptm commented on June 5, 2024

the correct absolute address jump in 64-bit programs should be:
FF25 00 00 00 00 [64bit address]
and absolute address call:
FF15 02 00 00 00 [64bit address]

from asmjit.

kobalicek avatar kobalicek commented on June 5, 2024

FF25/FF15 encodes jmp|call r64/m64 forms - you can have that if you use jmp [mem] form of the instruction. When you specify absolute address as an immediate AsmJit bails to relative encoding and in some cases it would output a relocable code so it can patch it later.

In your case there is REX prefix so it can patch the instruction to FFxx form later when relative addressing would be out of reach.

from asmjit.

kkptm avatar kkptm commented on June 5, 2024

so it is

from asmjit.

kobalicek avatar kobalicek commented on June 5, 2024

I'm going to clarify this.

The instruction sequences proposed are not instructions, but they are instructions or multiple instructions + data. To do a jump with absolute address that is stored next to the jump, you can simply do:

Label L = assembler->newLabel();
assembler->jmp(x86::mem(L));
assembler->bind(L);
assembler->dq(uint64_t(address));

Alternatively, without a label with RIP addressing:

assembler->jmp(x86::ptr(x86::rip));
assembler->dq(uint64_t(address));

The thing is that I don't want to create a macro-assembler from AsmJit as that would be much more confusing than just offering what the target ISA offers. AsmJit still supports some extra functionality (for example the address-table stuff), but that's just for convenience.

from asmjit.

kobalicek avatar kobalicek commented on June 5, 2024

Closing as the behavior of AsmJit is OK.

from asmjit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.