-
Notifications
You must be signed in to change notification settings - Fork 44
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
Zasm wrong jump calculation #115
Labels
bug
Something isn't working
Comments
Dont pay attention to ASSERT_EQ I just copied some code from google test,rewrite and forgot to delete these macros |
Thanks for the report, I'll look into it once I get a bit of time. |
ZehMatt
added a commit
that referenced
this issue
Mar 26, 2024
ZehMatt
added a commit
that referenced
this issue
Mar 26, 2024
Fix #115: Don't rely on address drift to determine extra pass
Should be fixed, thanks again. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,recently I have faced a problem with incorrect jump encoding.Do not think about the sense of the god it is just an example.
` Program program(MachineMode::I386);
x86::Assembler assembler(program);
auto label = assembler.createLabel();
ASSERT_EQ(assembler.jmp(label), Error::None);
for (int i = 0; i < 100; i++)
ASSERT_EQ(assembler.nop(), Error::None);
ASSERT_EQ(assembler.bind(label), Error::None);
ASSERT_EQ(assembler.int3(), Error::None);
ASSERT_EQ(assembler.align(Align::Type::Code, 10), Error::None);
Serializer serializer;
ASSERT_EQ(serializer.serialize(program, 0x0000000000401000), Error::None);`
My jmp should went to int3 instruction but it goes 3 bytes futher.I looked at the source code of zasm and noticed possible incorrect logic(I think).When jmp is encoding first time its size is 5.But on extrapass its value 2(cause now we already have bounded label and it changes from far jmp to short).So now ctx.drift is 3 and we should run pass one more time.But because of aligning at the end of the code drift becomes 0(3 - 3).And now zasm does not run the third pass (despite aligning happens not in range of our jmp)and he thinks that offset of int 3 is still 105 instead of 103.Am I doing something wrong or it is a bug?
P.S.Code is just an example dont take it as smth meaningful.
The text was updated successfully, but these errors were encountered: