Skip to content
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

Precedence issue when using typemapped operands in x64 mode #95

Closed
CensoredUsername opened this issue Apr 25, 2024 · 2 comments
Closed

Comments

@CensoredUsername
Copy link
Owner

struct Test {
    a: u32,
    b: u32
}

dynasm!(ops
    ; mov rbx => Test[2 + 1].b, rax
);

Generates a displacement of 0x15 instead of 0x1C for some reason.

The code it should generate for the displacement is:

0x1C == (::std::mem::size_of<Test> as i32) * (2 + 1) + offset_of(Test, b).

However it generates 0x15, and the only explanation for that is something like:

0x15 == (::std::mem::size_of<Test> as i32) * 2 + 1 + offset_of(Test, b).

Now this shouldn't be happening, as the code generation for all of this does use delimited groups to avoid this. But it is.

@CensoredUsername
Copy link
Owner Author

This is an instance of rust-lang/rust#67062 . Currently rustc does not handle proc_macro::Delimiter::None correctly, leading to issues with interpolated code that uses those due to macro hygiene.

@CensoredUsername
Copy link
Owner Author

CensoredUsername commented Apr 25, 2024

This annoyingly means delimiting is going to be annoying, as the compiler will warn on unnecessary parenthesis as well. A delimit-if-not-already-delimited function is probably a good idea.

CensoredUsername added a commit that referenced this issue May 3, 2024
…rust issue 67062

- Also some general refactoring around where delimiter is used, and the fact that it now is
  only useful for expressions.
- Also added a testcase.
CensoredUsername added a commit that referenced this issue Oct 29, 2024
… complex immediates and displacements, due to changes needed for #95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant