Pragma mangle and D shared objects

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Oct 25 18:26:14 PDT 2014


On Sat, Oct 25, 2014 at 08:05:18PM +0000, John Colvin via Digitalmars-d-learn wrote:
> On Saturday, 25 October 2014 at 18:40:23 UTC, H. S. Teoh via
> Digitalmars-d-learn wrote:
> >Actually, the object file (library) itself should already have a list
> >of exported symbols; you could then use core.demangle to extract the
> >function signatures from the mangled symbols and construct a hash of
> >all exported symbols and their types. The only thing is, I don't know
> >of any cross-platform method of retrieving the list of exported
> >symbols -- the Posix dlsym() family of functions only allow lookup by
> >explicit symbol name, no iteration primitives are specified. But the
> >information is definitely there, since that's how the OS's dynamic
> >linker figures out how to link dynamic libraries in the first place!
> >
> >T
> 
> I wonder what nm uses. AFAIK it works on everything posix.

Not sure what nm uses, but a lot of posix tools for manipulating object
files are based on binutils, which understands the local system's object
file format and deal directly with the binary representation. The
problem is, I don't know of any *standard* system functions that can do
this, so you'd have to rely on OS-specific stuff to make it work, which
is less than ideal.


T

-- 
Indifference will certainly be the downfall of mankind, but who cares? -- Miquel van Smoorenburg


More information about the Digitalmars-d-learn mailing list