tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Tests requiring MD hooks



On Mon, Jul 11, 2011 at 12:34:03 +0100, jean-Yves Migeon wrote:

> I can't do that simply through rtld, as I need to memcpy(2) the payload 
> and therefore have access to the beginning (which is not necessarily 
> trivial given certain architectures), and the end (never found a way to 
> properly label those without using assembly routines).

Come to think of it, if all you need is a trivial function, don't use
compiler to produce one, just hardcode it in an array:

unsigned char code[] =
#if defined(__i386__)
{
  0xde, 0xad, 0xbe, 0xaf, ...
}
#elif defined(...)
{
  /* ... */
}
...

That way you don't depend on compiler to produce self-contained code.
Since that trivial function is only a couple of instructions, and is
not likely to ever change, you just need to manually assemble it once.

-uwe


Home | Main Index | Thread Index | Old Index