Russell Wallace via llvm-dev
2016-Apr-02 07:23 UTC
[llvm-dev] getSymbolAddressInProcess returning null
I've finally managed to extract from Kaleidoscope one particular thing that it seems to me should be working and isn't. Given the global declaration extern "C" void foo() {} within the same program I have RTDyldMemoryManager::getSymbolAddressInProcess("foo") And it's returning null. (LLVM 3.8, Windows 7 x64.) What am I missing? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160402/4bb593a4/attachment.html>
NAKAMURA Takumi via llvm-dev
2016-Apr-02 08:29 UTC
[llvm-dev] getSymbolAddressInProcess returning null
Have you tried to add dllexport? On Sat, Apr 2, 2016 at 4:23 PM Russell Wallace via llvm-dev < llvm-dev at lists.llvm.org> wrote:> I've finally managed to extract from Kaleidoscope one particular thing > that it seems to me should be working and isn't. Given the global > declaration > > extern "C" void foo() {} > > within the same program I have > > RTDyldMemoryManager::getSymbolAddressInProcess("foo") > > And it's returning null. (LLVM 3.8, Windows 7 x64.) What am I missing? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160402/e1be88e4/attachment.html>
Russell Wallace via llvm-dev
2016-Apr-02 08:31 UTC
[llvm-dev] getSymbolAddressInProcess returning null
Going a few more layers down the rabbit hole, it looks like this is the call chain C:\llvm\lib\ExecutionEngine\RuntimeDyld\RTDyldMemoryManager.cpp uint64_t RTDyldMemoryManager::getSymbolAddressInProcess(const std::string &Name) { ... return (uint64_t)sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr); C:\llvm\lib\Support\DynamicLibrary.cpp #include "Windows/DynamicLibrary.inc" C:\llvm\lib\Support\Windows\DynamicLibrary.inc void *DynamicLibrary::getAddressOfSymbol(const char *symbolName) { ... if (Data == &OpenedHandles) return SearchForAddressOfSymbol(symbolName); return (void *)(intptr_t)GetProcAddress((HMODULE)Data, symbolName); void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { ... return 0; but wait, getAddressOfSymbol was never called. The call skipped that function - which presumably would have done the job - and hopped directly to SearchForAddressOfSymbol, which only checked OpenedHandles, and didn't do a straight check on the current process? Am I reading this correctly? On Sat, Apr 2, 2016 at 8:23 AM, Russell Wallace <russell.wallace at gmail.com> wrote:> I've finally managed to extract from Kaleidoscope one particular thing > that it seems to me should be working and isn't. Given the global > declaration > > extern "C" void foo() {} > > within the same program I have > > RTDyldMemoryManager::getSymbolAddressInProcess("foo") > > And it's returning null. (LLVM 3.8, Windows 7 x64.) What am I missing? >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160402/00c8c008/attachment.html>
Russell Wallace via llvm-dev
2016-Apr-02 10:43 UTC
[llvm-dev] getSymbolAddressInProcess returning null
Tried that, still didn't work. Then I tried making a direct API call, GetProcAddress(GetModuleHandle(0),"foo") And this works if and only if __declspec(dllexport) is supplied. So it looks like we were both right. On Sat, Apr 2, 2016 at 9:29 AM, NAKAMURA Takumi <geek4civic at gmail.com> wrote:> Have you tried to add dllexport? > > On Sat, Apr 2, 2016 at 4:23 PM Russell Wallace via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> I've finally managed to extract from Kaleidoscope one particular thing >> that it seems to me should be working and isn't. Given the global >> declaration >> >> extern "C" void foo() {} >> >> within the same program I have >> >> RTDyldMemoryManager::getSymbolAddressInProcess("foo") >> >> And it's returning null. (LLVM 3.8, Windows 7 x64.) What am I missing? >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160402/af1bd363/attachment.html>