Git Product home page Git Product logo

Comments (4)

CensoredUsername avatar CensoredUsername commented on June 3, 2024

(I'm assuming the relevant instruction was cbz, not cbs 😉)

I'm not sure what's happening here unfortunately. cbz's target has to be a signed immediate multiple of 4, and the range is like +/- 1MB. As long as these requirements are met it should be able to work.

The relevant check that supposedly is creating the error would be here: https://github.com/CensoredUsername/dynasm-rs/blob/master/runtime/src/aarch64.rs#L70 . That'd probably be a good point to start debugging. Unfortunately with your example I really cannot really reproduce it easily. Do you may

Are you sure this is the location causing the error? I tried making a simple reproduction case:

    let mut ops = dynasmrt::VecAssembler::<dynasmrt::aarch64::Aarch64Relocation>::new(0);
    let start = ops.new_dynamic_label();
    let end = ops.new_dynamic_label();
    dynasm!(ops
        ; .arch aarch64
        ; ldrb w1, [x0]
        ; cbz w1, =>end
        ; .align 4
        ; =>start
        ; .bytes b"abcdef123"
        ; .align 4
        ; => end
    );
    let buf = ops.finalize().unwrap();

but that assembled just fine.

from dynasm-rs.

john-h-k avatar john-h-k commented on June 3, 2024

Thanks, turns out it was user error, I'd managed to use dynasmrt::x64::Assembler accidentally and it seems that was causing the issue.

That's all resolved, but if I can point out one other issue - it seems mov w0, <immediate> expects a u64 and mov x0, <immediate> expects a u32, which to my understanding is the wrong way round

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on June 3, 2024

Thanks, turns out it was user error, I'd managed to use dynasmrt::x64::Assembler accidentally and it seems that was causing the issue.

A yep, that'd do it. Due to a lack of nice to use associated types on structs in rust the interface between assemblers is somewhat weakly typed unfortunately.

That's all resolved, but if I can point out one other issue - it seems mov w0, expects a u64 and mov x0, expects a u32, which to my understanding is the wrong way round

Looking at the code both seem to actually expect an u64 if encoded at runtime, does that match your observations? That's indeed a bit useless for mov w0, . https://github.com/CensoredUsername/dynasm-rs/blob/master/plugin/src/arch/aarch64/compiler.rs#L609 is the offending line, but fixing that right now is both low priority and a breaking change.

It's probably an artifact from the fact that compile-time encoding of constants always uses u64's internally

from dynasm-rs.

john-h-k avatar john-h-k commented on June 3, 2024

All resolved thanks

from dynasm-rs.

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.