forked from OSchip/llvm-project
[PECOFF] Resolve __delayLoadHelper2 if /delayload is given
DLL delay importing is a feature to load a DLL lazily, instead of at program start-up time. If the feature is turned on with the /delayload flag, the linker resolves the delay-load helper function. All function pointer table entries for the DLL are initially pointing to the helper function. When called, the function loads and resolves the DLL symbols using dlopen-ish Windows system calls and then write the reuslts to the function pointer table. The helper function is in "delayimp.lib". Note that this feature is not completely implemented yet. LLD also needs to emit the table that's consumed by the delay-load helper function. That'll be done in another patch. llvm-svn: 218943
This commit is contained in:
parent
4075f6ce21
commit
711471ea1e
|
@ -1189,6 +1189,11 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
|
|||
ctx.setOutputImportLibraryPath(inputArg->getValue());
|
||||
break;
|
||||
|
||||
case OPT_delayload:
|
||||
ctx.addInitialUndefinedSymbol(
|
||||
ctx.is64Bit() ? "__delayLoadHelper2" : "___delayLoadHelper2@8");
|
||||
break;
|
||||
|
||||
case OPT_stub: {
|
||||
ArrayRef<uint8_t> contents;
|
||||
if (!readFile(ctx, inputArg->getValue(), contents)) {
|
||||
|
|
|
@ -38,6 +38,7 @@ def subsystem : P<"subsystem", "Specify subsystem">;
|
|||
def stub : P<"stub", "Specify DOS stub file">;
|
||||
def opt : P<"opt", "Control optimizations">;
|
||||
def implib : P<"implib", "Import library name">;
|
||||
def delayload : P<"delayload", "Delay loaded DLL name">;
|
||||
|
||||
def manifest : F<"manifest">;
|
||||
def manifest_colon : P<"manifest", "Create manifest file">;
|
||||
|
@ -106,7 +107,6 @@ def no_incremental : F<"incremental:no">;
|
|||
def nologo : F<"nologo">;
|
||||
|
||||
def delay : QF<"delay">;
|
||||
def delayload : QF<"delayload">;
|
||||
def errorreport : QF<"errorreport">;
|
||||
def idlout : QF<"idlout">;
|
||||
def ignore : QF<"ignore">;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# RUN: yaml2obj %p/Inputs/vars-main.obj.yaml > %t.obj
|
||||
#
|
||||
# RUN: not lld -flavor link /out:%t1.exe /subsystem:console /entry:main \
|
||||
# RUN: /delayload:vars.dll -- %t.obj %p/Inputs/vars.lib >& %t.log
|
||||
# RUN: FileCheck -check-prefix=X86 %s < %t.log
|
||||
#
|
||||
# RUN: not lld -flavor link /out:%t1.exe /subsystem:console /entry:main \
|
||||
# RUN: /machine:x64 /delayload:vars.dll -- %t.obj %p/Inputs/vars.lib >& %t.log
|
||||
# RUN: FileCheck -check-prefix=X64 %s < %t.log
|
||||
|
||||
X86: Undefined symbol: {{.*}} ___delayLoadHelper2@8
|
||||
X64: Undefined symbol: {{.*}} __delayLoadHelper2
|
Loading…
Reference in New Issue