[llvm-dev] getSymbolAddressInProcess returning null

Russell Wallace via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 2 01:31:43 PDT 2016


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>


More information about the llvm-dev mailing list