Comments (14)
Neither dladdr nor Dl_info is POSIX.
from dlfcn-win32.
Neither dladdr nor Dl_info is POSIX.
Eh, it's a common and very useful extension. One use is for supporting deploy-time relocation of code on the filesystem (e.g., to open asset files relative to install location that is not known at build-time).
I have written a WIN32 version in Heimdal, in lib/roken/dlfcn.hin and lib/roken/dlfcn_w32.c.
That said, there's no way in WIN32 that I can tell to get a symbol name that an address relates to, only the module's filename. If anyone knows how to get a symbol name, I'm all ears! EDIT: Ah, there is a way, look for get_symbol_name()
.
from dlfcn-win32.
there's no way in WIN32 that I can tell to get a symbol name that an address relates to
Ou, we have not known that there is no way :-) and togther with @rhabacker we have implemented it!
dladdr pull request is now ready for merge, see: #72
from dlfcn-win32.
@nicowilliams: You could probably switch Heimdal to this dlfcn-win32 implementation which supports more features. dladdr() with symbol name support is going to be merged ASAP.
from dlfcn-win32.
Ah, I see that, #72. I might just switch Heimdal to use this when you've merged #72 (ah, you just did). The license is compatible, and I do have a use for getting symbol names.
@pali @rhabacker Do you happen to know if the new dladdr()
in #72 will support DATA
symbols?
from dlfcn-win32.
Now (really now!), I'm going to extend dladdr to support reading symbols also from EXPORT table.
About DATA symbols, I'm not sure where are they stored in PE headers...
from dlfcn-win32.
OK, I can always test it, but I probably won't get to it soon. Thanks!
from dlfcn-win32.
Do you happen to know if the new
dladdr()
in #72 will supportDATA
symbols?
That has not been tested, but should be possible with minor adjustments in a different pr, when the variable is decorated with __declspec(dllexport) and __declspec(dllimport).
from dlfcn-win32.
@rhabacker yes, dladdr()
too is not guaranteed to work for non-exported symbols, and I assume the same reasons would apply to PE.
For the curious, my immediate need is that I'm modifying a "templating" ASN.1 compiler that produces something like bytecode as named arrays of entries, and I need to either enhance those with additional metadata that... happens to be in their symbolic names anyways, or use dladdr()
portably 😊. (I'm inclined to make more of those symbols static
so they can be stripped and extend the template data structures with the metadata I need, and hope the net effect on object size is roughly neutral or better. That certainly seems simpler in a way, but using dladdr()
would do no violence to the template generator, which is a big plus.) Beyond that, having implemented a partial dladdr()
for WIN32, I'm naturally curious about the rest of it, and I thank you again for this work.
from dlfcn-win32.
FWIW, I don't get symbol names for pointers to data symbols. I tried applying the patch from #94 and still.
Hmm, this might be user error on my part. The variable addresses in the test in question are not in a DLL.
from dlfcn-win32.
That has not been tested, but should be possible with minor adjustments in a different pr, when the variable is decorated with __declspec(dllexport) and __declspec(dllimport).
I suggest to add a feature request for such support.
from dlfcn-win32.
FWIW, I don't get symbol names for pointers to data symbols.
I have put __declspec(dllexport) unsigned char big_array[100];
into the library and then in executable I called:
__declspec(dllimport) extern unsigned char big_array[100];
...
dladdr(&big_array, &info);
and it worked, I get in info
infromation about library and name of symbol big_array
.
from dlfcn-win32.
and it worked, I get in
info
infromation about library and name of symbolbig_array
.
Nice to hear. Is this result with or without #94 applied ?
from dlfcn-win32.
I tested it only with gcc + #94.
from dlfcn-win32.
Related Issues (20)
- Understand why settting cmake_minimum_required to 3.20 make test fail HOT 1
- Use of LoadLibraryExA with LOAD_WITH_ALTERED_SEARCH_PATH flag HOT 9
- config.mak: No such file or directory HOT 5
- can I dlsym malloc function? HOT 5
- Add support and docs for using dlfcn-win32 using CMake's FetchContent module HOT 1
- Installation instructions HOT 7
- MAX_PATH restriction feasible after Windows dropped it for Win10? HOT 3
- ERROR Non-library file %TEMP%\temp.dll was processed via WINAPI: 18 From line 138 HOT 3
- Should common subset of ZDICT_cover_params_t and ZDICT_fastCover_params_t be moved into a separate struct and put it into the front of the struct, implementing inheritance this way? HOT 1
- UTF-8 path failes to dlopen HOT 11
- Add automatic tests with Dr. Memory
- dlsym multiple defintion HOT 2
- undefined reference to `GetModuleHandleExA' HOT 6
- AppVeyor test problems HOT 4
- Using dlfcn-win32 as a subproject of libbacktrace, gollvm HOT 3
- Write docs on how to use the dlfcn-win32 in a buildsystem agnostic way
- no RTLD_NOLOAD HOT 6
- Add support to dladdr() to inspect export table for additional symbols
- Release 1.3.0 HOT 7
- Testing i586-mingw32msvc-gcc builds via cmake HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dlfcn-win32.