Hacker News new | past | comments | ask | show | jobs | submit login

You can't even tell whether a given symbol looked up with dlsym is a function or data!

Re:> In some situations, in order to build against a DLL you need need an accompanying "lib" file. If you do not have one

.lib files are not required to use a DLL. A DLL is opened with LoadLibrary and symbols can be resolved with GetProcAddress. Those import .lib files are just some quirk of Microsoft Visual C.




> You can't even tell whether a given symbol looked up with dlsym is a function or data!

On many modern unixes you can! Functions will usually be in a "text" section (marked execute or read+execute) and data will usually be in a "data" or "bss" section (marked read-only, or read-write).

The dl* family of functions don't expose this information, but after getting a symbol you can check the protection bits on the page the pointer is on (using a system-defined mechanism).


Data could be placed into protected space. I think that a string literal in .text space could be exposed as a dynamic symbol.


It is not a quirk, it goes back to how Windows did dynamic libraries on Win16 and everyone had to use them, specially when linking at compile time.

Also it was how Symbian and Aix did dynamic loading as well (Aix eventually adopted other UNIXes model).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: