tech-userlevel archive

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

Re: Tests requiring MD hooks



On 11.07.2011 23:39, Valeriy E. Ushakov wrote:
> On Mon, Jul 11, 2011 at 12:34:03 +0100, jean-Yves Migeon wrote:
> 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.

Yep, I disliked this approach originally; but you are right, it's
probably the sanest way (and easiest too!) for arbitrary payload copy
anywhere in memory, without relying on black magic enhanced via libelf :o

Last issue being function pointers via function descriptors. Still
reading the PPC ABI docs now, but shouldn't be too difficult to tackle.

Cheers all,

-- 
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost


Home | Main Index | Thread Index | Old Index