|
From: Olly B. <ol...@su...> - 2005-05-19 15:56:44
|
On 2005-05-19, Julian Seward <js...@ac...> wrote:
> So, what I'm thinking is to calculate a 32-bit CRC of the code
> and store it in the translation; then rerun the crc for the
> self-check. Except a CRC is expensive in terms of insns and
> cache misses (it requires a table). Mark Adler (co-author
> of gzip) had some other magic checksum scheme that gzip uses, which
> doesn't require a table and is fast. Maybe use that instead.
It's called "adler32".
But had you considered simply copying the raw instructions and just
doing a full compare?
For a standard short (10 byte for x86) trampoline sequence, this will
probably be about as quick as calculating a 64 bit checksum. For a
longer sequence it may be a little slower if the code hasn't change,
but it also has absolutely no risk of failing to spot a change. And if
the code has changed, it can terminate the comparison early, which a
checksum can't...
Cheers,
Olly
|