At the top of my head, I don't know any libraries that do this.
I know that if you are writing your own or modifying an existing library, the hard thing you need to do is to track and fix any code that uses pointers and replace it with code that uses the base offset +.
The base will be a pointer returned by the functions for creating / opening shared memory, and in each process it will be different . An offset replaces what would be a pointer. When you need to find a value using an offset, you put the base on char* , add an offset to it, and then translate it to your_type* . Something like (bucket_t*)((char*)base + offset) .
Assuming your hash implementation needs pointers in general. Some do not if they use only unambiguous buckets and there are no lists of values.
Another tricky thing is that you need to manage your memory yourself. Instead of calling malloc (), you create your own function, perhaps call it shm_hash_alloc (). A quick start is simply to keep the pointer and increase it when allocating memory and not bother to free it. Later you can use an array of pointers (offsets) for free lists of various sizes and sizes, or if you know your types of objects, a list for each type. In each free block, you save a pointer to the next free block, and you know the size, due to the list in which it is included. There are even more fancy methods, but they probably don't need you.
source share