GCC, add the code in a certain place makes the program after hours (due to code size probably)?

0 like 0 dislike
38 views
So, we have the code to debug what is happening:
#define x86_emit_byte(value) \\
*translation_ptr = value; \\
translation_ptr++ \\

void function_cc x86_emit_translation_exit(p_u8 *p_translation_ptr)
{
u8* translation_ptr = *p_translation_ptr;
x86_emit_byte(0x90);
.... and so 100 rows...
x86_emit_byte(0x90);
*p_translation_ptr = translation_ptr;
}



It's a piece of a dynamic translator, or precompiler. Initially there should amicitia code size is about 100 bytes, for the test imagine that this is all nop-s. So. If you hemitite these 100 bytes so vlob, the translator stops working, no crashes, just stops. For unknown reasons. If this code is replaced by the cycle emitting even kilobyte nop-s — all wonderful. Ie it depends on the size of the compiler and not the code that he emetic. Objectice translator is relatively small, up to a meter 10 Grand. I have 2 days working on this, but nothing is impossible. Initially, the translator is not mine, I edit, especially because many can not tell. Because if something important is not said, ask of course. What bothers me is that is one feature which causes this piece. It is the size of objectice about 0x70000 bytes (o_o?). Do not know on what to sin, because the translator does not fall. It just stops to work properly.
by | 38 views

4 Answers

0 like 0 dislike
And if you record defayn in one place, will work?
#define x86_emit_byte(value) *(translation_ptr++) = value;
by
0 like 0 dislike
Information, of course, is not enough for meaningful advice, but here's what I would do:
\r
0) to clear my conscience and exceptions gcc bug would be turned off optimization -O0, it's likely the problem will remain, and can be overlooked unoptimized code for that function and make sure GCC nothing lied;
\r
1) instead of eight nop (the smallest value at which one stops working), would be issued 7 nop 1 int 3 (0xCC). or lots and lots of int 3 and look who comes to them, these "nope" and that it is followed where there is then control after these nopow should be (maybe there is a piece of rubbish?)
by
0 like 0 dislike
And the pointer passed into the function, what it indicates?
It can senopati a piece of some code, and after the rubbing of a fragment of a certain size may not lead to bad consequences, but more or less will cause the problem.
by
0 like 0 dislike
Looked.
In short, you write assembler inserts some range of addresses *p_translation_ptr = 0x90, then why is it shoved to the address of the last instruction:
\r
*p_translation_ptr = translation_ptr;
\r
It turns out some unknown assembler instruction (if you tell me the address, then you will probably say — what kind of work), in which every 128 loop was inverted some important bits, resulting in manual, constructed at the rolls, it rolls.
\r
Sorry if you do not understand in the code — want to sleep.
by

Related questions

0 like 0 dislike
2 answers
asked Mar 28, 2019 by vlad9486
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Apr 13, 2019 by includedlibrary
0 like 0 dislike
1 answer
asked Apr 13, 2019 by sealnix
110,608 questions
257,186 answers
0 comments
32,902 users