-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
NOP instructions for code alignment #336
Comments
AsmJit has a known NOP sequence list, which can be activated by:
The table looks like this:
It's not active by default and it doesn't favor any CPU vendor. Does this answer the question? |
."....Does this answer the question?" |
You can either use align() to emit nops or you can also emit nops directly if you need a custom one:
If you don't have the API then maybe it's time to update asmjit :) BTW I don't think I understand the question, I think you should elaborate and be more specific in what you want / expect. |
updated, but did not connect aling api yet. @L00000002: |
Could you share some code instead and describe what you want to do? I'm still unable to get what you want / what are you missing. AsmJit would not generate multiple 66 66 prefix bytes with any instruction at the moment, only
for example, if that's what you need. |
The goal is to create a block of code with a specific size with a specific predefined alignment. All this needs to be done without unnecessary action. |
I still don't understand what's the problem with |
Can you elaborate about "unnecessary action"? I really don't get it sorry :) |
@kobalicek |
Ok, and can you show the code you are assembling, binary that asmjit encodes, and binary that is encoded by some other assembler? Because it's really hard to tell without some sample whether asmjit does something right or wrong. |
@kobalicek |
If you remove |
I fixed the prefech strictness, but not sure what else to fix. |
thanks for the fixes, the code has been updated uint32_t i = uint32_t(Support::alignUpDiff<size_t>(offset(), alignment)); |
It aligns the code buffer to the specified alignment, in bytes, what is not clear about that? |
the logic of the derivative is clear, the conditions for the code are not clear.
@L_00000001518F7042: @L_00000001518F7057: |
I think the most important information was |
I have already corrected. the alignment is encoded in automation. if (tmp.u64> std :: numeric_limits <uint32_t> :: max () / * ||! Support :: isPowerOf2 (tmp.u64) * /) |
I can fix the issue with base address, but the power of 2 check is needed, that cannot just go away |
You are the author, you decide what to leave and what to fix. |
As far as I understand, the database has been updated for a long time, although double nops appeared in the engine in the spring of 2020. But the instruction mnemonics are not unique in the list. Is there an option in the engine to use the nop instruction to align the code?
If so, show an example.
90 NOP1_OVERRIDE_NOP
6690 NOP2_OVERRIDE_NOP
0f1f00 NOP3_OVERRIDE_NOP
0f1f4000 NOP4_OVERRIDE_NOP
0f1f440000 NOP5_OVERRIDE_NOP
660f1f440000 NOP6_OVERRIDE_NOP
0f1f8000000000 NOP7_OVERRIDE_NOP
0f1f840000000000 NOP8_OVERRIDE_NOP
660f1f840000000000 NOP9_OVERRIDE_NOP
66660f1f840000000000 NOP10_OVERRIDE_NOP
6666660f1f840000000000 NOP11_OVERRIDE_NOP
666666660f1f840000000000 NOP12_OVERRIDE_NOP
66666666660f1f840000000000 NOP13_OVERRIDE_NOP
6666666666660f1f840000000000 NOP14_OVERRIDE_NOP
666666666666660f1f840000000000 NOP15_OVERRIDE_NOP
https://coderoad.ru/25545470/%D0%94%D0%BB%D0%B8%D0%BD%D0%BD%D1%8B%D0%B9-%D0%BC%D0%BD%D0%BE%D0%B3%D0%BE%D0%B1%D0%B0%D0%B9%D1%82%D0%BE%D0%B2%D1%8B%D0%B9-NOPs-%D0%BE%D0%B1%D1%89%D0%B5%D0%BF%D1%80%D0%B8%D0%BD%D1%8F%D1%82%D0%B0%D1%8F-macros-%D0%B8%D0%BB%D0%B8-%D0%B4%D1%80%D1%83%D0%B3%D0%B0%D1%8F-%D0%BD%D0%BE%D1%82%D0%B0%D1%86%D0%B8%D1%8F
The text was updated successfully, but these errors were encountered: