freenode/#clasp - IRC Chatlog
Search
15:09:15
drmeister
For some reason dlsym is return NULL for everything at snapshot load time. But it works fine when I call (core:dlsym... ). it from the CL repl Grrrrr
15:48:52
drmeister
In the snapshot save function I call dladdr on every address that I need to identify the symbol name and then I dlsym on the symbol name and at 6073/9084 the dlsym calls start failing.
15:51:55
drmeister
But I want to turn my head to the sky and just start screaming incoherently. This is so frustrating.
15:53:14
beach
I guess it's because you are trying to do it the Unix/C++ way with the standard dynamic linker.
15:53:20
drmeister
It's navigating the unix dynamic linking layer and ELF files and macho files and my own stupid bugs.
15:54:42
drmeister
It's because I have to use symbols and basically implement my own linker because I need this to be robust to linking new executables if I want to embed the snapshot within an executable.
15:56:55
drmeister
This looks like it's probably my fault - everything works for about 6000 symbols and then it starts failing. That smells like my problem.
15:58:20
drmeister
This appears to work on linux - but I'm moving the code back into linux to look at the output of this address -> dladdr -> dlsym -> address test.
16:56:13
frgo
drmeister: Some code to stare at? Do you use dlinfo to check symbol visibility? Hey, btw.
18:23:29
drmeister
I have lots of function pointers, method pointers and vtable pointers from objects in memory to addresses in the executable (and later to dynamic libraries).
18:24:18
drmeister
So when I save the snapshot I now use 'dladdr' to convert those address to mangled names and I save the mangled names in a symbol table and reference them with an integer offset.
18:24:49
drmeister
Then when the snapshot loads I'll pass the name to 'dlsym' to recover the address of the function/method/vtable pointer at load time.
18:25:47
drmeister
I've struggled with this for weeks because of reasons I can go into later. But now I think this idea of save-address -> dladdr -> name -> dlsym -> load-address should work.
18:26:54
drmeister
I'm testing this when I save the snapshot - I'm checking if save-address -> dladdr -> name -> dlsym -> save-address works. I'm running into a problem where after about 6050 addresses (out of about 9050) the dlsym starts returning NULL.
18:27:56
drmeister
I just got into my office before I started talking and I'm testing one idea and cleaning up the code a bit and then Ill push and post the link.
18:29:43
drmeister
https://github.com/clasp-developers/clasp/blob/future/src/gctools/imageSaveLoad.cc#L1262