-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AARCH64 demo #17
base: master
Are you sure you want to change the base?
Add AARCH64 demo #17
Conversation
Thanks for your contribution! JavaScript doesn't support 64-bit integers natively. Upper limit is 52-bit, and consequently heavy changes to Below, I'll point several places where this could cause trouble in your patch. |
return e.reg_read_i64(uc.ARM64_REG_PC); | ||
} | ||
function pcWrite(value) { | ||
return e.reg_write_i64(uc.ARM64_REG_PC, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails when value >= (1 << 52)
, we need to add another method:
this.reg_write_i64 = function (regid, value_lo, value_hi) { /* ... */ }
in: https://github.com/AlexAltea/unicorn.js/blob/dd2972c/src/unicorn-wrapper.js#L359
@@ -89,6 +89,7 @@ function Register(name, type, id) { | |||
case 'i8': this.dataHex = utilIntToHex(value, 2); break; | |||
case 'i16': this.dataHex = utilIntToHex(value, 4); break; | |||
case 'i32': this.dataHex = utilIntToHex(value, 8); break; | |||
case 'i64': this.dataHex = utilIntToHex(value, 16); break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails when value >= (1 << 52)
. Additionally, note that utilIntToHex
forces unsignedness via:
if (n < 0) {
n += Math.pow(2, 32);
}
This works only in integers up to 32 bits in size, but not beyond that. The signature of utilIntToHex
needs to be changed and add support for value_lo
and value_hi
.
@@ -104,6 +105,7 @@ function Register(name, type, id) { | |||
case 'i8': | |||
case 'i16': | |||
case 'i32': | |||
case 'i64': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this._update_int
refreshes only (up to) 32-bit integers via:
var value = e.reg_read_i32(this.id);
This will fail at updating the upper 32 bits of 64-bit registers.
That said, I don't mind if we merge this patch, as long as the code mentions these limitations in the form of comments and we place a disclaimer/alert message when entering the demo. |
Cool, I had the feeling I was missing something. |
Im having a hard time trying to compile unicorn into the dist packages. I managed to compile a sample c application using emscripten (with a makefile) but when trying to compile unicorn it fails on @AlexAltea do you have any idea what am I missing? running grunt build results in the error
For some reason this configure does not work , here is a detailed error:
Note that |
@bitterbit It's quite possible that some regression happened in Emscripten (quite commonplace, unfortunately). I'm a bit busy this week, but I'll check what's wrong in my macOS machine next Monday/Tuesday and let you know. |
I have this same error on ubuntu 18.04 |
Just thought I'd drop by and mention I got unicorn.js to work with real ARM64 code using very large 64-bit PC addresses and register values. PR #46 has some needed changes, and here is the code where I used it. Maybe that demo is useful as an example of how to get everything 64-bit clean and working? |
This is incredible, thank you very much for sharing it and for your PR. I hope it can be useful to others. @bitterbit If you have time and are interested, try rebasing your PR on top of @asahilina's latest changes (merged now). |
Arm64 demo like mentioned issue #15 😺