On 3/13/20 4:22 PM, wjoe wrote:

I wasn't aware that pragma(mangle, ..) can practically name any function anything. So from what I understand, because, at least on Posix, since there's only a symbol name there's nothing I can do in my loader to verify that a function is or does what it claim to be/do.

But that's the same as the linker anyway. It's possible to stub the function as @safe, but implement it as @system and just pragma(mangle) the thing. Therefore the compiler is no safer.

I would expect that something could be written to turn a signature string into a mangling and also provide the correct type upon return. Something like:

auto f = getFunction!(@safe void function(int))("package.module.symbol");

and have it properly mangle the expected function name and pull it from the dynamic library.

-Steve

Reply via email to