elf.c: section limit inference for linux, fixes for stb_ds.h hashing, more compilation flags

This commit is contained in:
2024-07-28 01:44:39 +03:00
parent 36dcf14db7
commit 5ddf0eb879
9 changed files with 137 additions and 33 deletions

View File

@ -1121,7 +1121,7 @@ size_t stbds_hash_bytes(void *p, size_t len, size_t seed)
unsigned char *d = (unsigned char *) p;
if (len == 4) {
unsigned int hash = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24);
uint32_t hash = (uint32_t)d[0] | ((uint32_t)d[1] << 8) | ((uint32_t)d[2] << 16) | ((uint32_t)d[3] << 24);
#if 0
// HASH32-A Bob Jenkin's hash function w/o large constants
hash ^= seed;
@ -1177,8 +1177,8 @@ size_t stbds_hash_bytes(void *p, size_t len, size_t seed)
return (((size_t) hash << 16 << 16) | hash) ^ seed;
} else if (len == 8 && sizeof(size_t) == 8) {
size_t hash = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24);
hash |= (size_t) (d[4] | (d[5] << 8) | (d[6] << 16) | (d[7] << 24)) << 16 << 16; // avoid warning if size_t == 4
size_t hash = (size_t)d[0] | ((size_t)d[1] << 8) | ((size_t)d[2] << 16) | ((size_t)d[3] << 24);
hash |= ((size_t)d[4] | ((size_t)d[5] << 8) | ((size_t)d[6] << 16) | ((size_t)d[7] << 24)) << 16 << 16;
hash ^= seed;
hash = (~hash) + (hash << 21);
hash ^= STBDS_ROTATE_RIGHT(hash,24);