> > Currently, the macro is used twice in the symbols.c. This
change seems
> > not complicated. Any thoughts?
>
> do I understand your suggestion correct, you propose to replace the
>
> #define SYMNAME_HASH_INDEX(name) ...
>
> in defs.h by something like
>
> static unsigned long long SYMNAME_HASH_INDEX(const unsigned char * const
name) {
> return (name[0] ^ (name[strlen(name)-1] * name[strlen(name)/2]) %
SYMNAME_HASH);
> }
>
> in symbols.c? If so, I think that should be fine.
>
Yes, you are right, Philipp.
Please correct me if I'm wrong. I don't think the function can work.
Let's say name[0] ^ (name[strlen(name)-1] * name[strlen(name)/2]) ==
-1, then we will have:
static unsigned long long SYMNAME_HASH_INDEX(const unsigned char * const name) {
return (-1) % 512;
}
The returned value is a very large number, and will overflow the array.
No, this is a modulo operation, and its result will never exceed '512'
anyway.
(unsigned long long)(-1) % 512 = 511
Thanks.
Lianbo