Comments (4)
(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.
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.
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.
All resolved thanks
from dynasm-rs.
Related Issues (20)
- Language dialect reference for AArch64 has some stale x86/x86-64 references HOT 2
- omit known zero offset HOT 2
- Consider using `MAP_JIT` on macOS HOT 1
- Link to GitHub pages is broken HOT 3
- Question: dynamically replacing code while running it HOT 4
- Executable buffer relocations HOT 5
- Aarch64: mov w0, immu32 expects a u64 when encoded at runtime
- Aarch64: dynamic registers prevent immediates HOT 2
- Symbols for dynamic labels HOT 6
- Improve documentation of `ExecutableBuffer::ptr`. HOT 2
- Mismatched type error when writing generic code HOT 2
- Address to label HOT 2
- Dynamic Memory Operands HOT 3
- Handling out-of-bounds AArch64 immediates HOT 1
- Label clarifications HOT 3
- Arch::name() unused. HOT 2
- Can't run `cargo doc` using stable rust? HOT 1
- Precedence issue when using typemapped operands in x64 mode HOT 2
- Support of int 0x80 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynasm-rs.