This is an archive of the discontinued LLVM Phabricator instance.

[ORC][COFF] Introduce DLLImportDefinitionGenerator.
ClosedPublic

Authored by sunho on Aug 13 2022, 3:02 AM.

Details

Summary

This class will be used to properly solve the __imp_ symbol and jump-thunk generation issues. It is assumed to be the last definition generator to be called, and as it's the last generator the only symbols remaining in the lookup set are the symbols that are supposed to be queried outside this jitdylib. Instead of just letting them through, we issue another lookup invocation and fetch the allocated addresses, and then create jitlink graph containing __imp_ GOT symbols and jump-thunks targetting the fetched addresses.

Diff Detail

Event Timeline

sunho created this revision.Aug 13 2022, 3:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2022, 3:02 AM
sunho requested review of this revision.Aug 13 2022, 3:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2022, 3:02 AM
lhames accepted this revision.Aug 14 2022, 9:33 PM

This should probably carry a warning that it's x86-64 only for now.

Could you file a GitHub issue to look at generalizing the pointer / stub synthesis? (You don't have to tackle it, but we should track it)

Otherwise LGTM -- Thanks @sunho!

This revision is now accepted and ready to land.Aug 14 2022, 9:33 PM
sunho updated this revision to Diff 452711.Aug 15 2022, 9:34 AM
This revision was landed with ongoing or failed builds.Aug 15 2022, 10:07 AM
This revision was automatically updated to reflect the committed changes.
kuhar added a subscriber: kuhar.Aug 15 2022, 10:26 AM
kuhar added inline comments.
llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
512

FYI, this produces build warnings:

[539/656] Building CXX object lib/ExecutionEngine/Orc/CMakeFiles/LLVMOrcJIT.dir/ExecutionUtils.cpp.o
/usr/local/google/home/kubak/llvm/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp:512:12: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
    return std::move(PointerSize.takeError());
           ^
/usr/local/google/home/kubak/llvm/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp:512:12: note: remove std::move call here
    return std::move(PointerSize.takeError());
           ^~~~~~~~~~                       ~
/usr/local/google/home/kubak/llvm/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp:515:12: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
    return std::move(Endianness.takeError());
           ^
/usr/local/google/home/kubak/llvm/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp:515:12: note: remove std::move call here
    return std::move(Endianness.takeError());
           ^~~~~~~~~~                      ~

@kuhar Commited a fix. Thanks for reporting this!