Answer the question
In order to leave comments, you need to log in
GCC, adding code in a certain place makes the program broken (because of code size apparently)?
So, we have the code to debug what is happening:
#define x86_emit_byte(value) \<br/>
*translation_ptr = value; \<br/>
translation_ptr++ \<br/>
<br/>
void function_cc x86_emit_translation_exit(p_u8 *p_translation_ptr)<br/>
{<br/>
u8* translation_ptr = *p_translation_ptr;<br/>
x86_emit_byte(0x90);<br/>
.... и так 100 строк...<br/>
x86_emit_byte(0x90);<br/>
*p_translation_ptr = translation_ptr;<br/>
}<br/>
Answer the question
In order to leave comments, you need to log in
And if you write define in one line, will it work?
#define x86_emit_byte(value) *(translation_ptr++) = value;
Information, of course, is not enough for meaningful advice, but here's what I would do:
0) to clear my conscience and eliminate the bug, gcc would disable optimizations -O0, most likely the problem will remain the same, and you can look through the unoptimized code of this function and make sure that GCC did not lie;
1) instead of eight nop (the smallest value at which it stops working), it would give 7 nop and 1 int 3 (0xCC). or many, many int 3 and looked at who is stepping on them, on these "knobs" and what follows them, where should the control go after these nops (maybe there is some kind of garbage?)
And the pointer passed to the function, what exactly does it point to?
It can overwrite a piece of some code, and after overwriting a fragment of a certain size, it may not lead to bad consequences, but more or less will already cause a problem.
Looked.
In short, you write assembler inserts at some address range *p_translation_ptr = 0x90, and then for some reason shove the address itself there with the last instruction:
*p_translation_ptr = translation_ptr;
It turns out some kind of unknown assembler instruction (if you tell me the address, you can probably say which one it turns out), in which some important bit is inverted every 128 passes of the loop, as a result of which the instruction constructed at the address either rolls, or not rolls.
Sorry if I misunderstood the code, I want to sleep.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question