COFF: Support delay-load import tables.
authorRui Ueyama <ruiu@google.com>
Sun, 21 Jun 2015 22:31:52 +0000 (22:31 +0000)
committerRui Ueyama <ruiu@google.com>
Sun, 21 Jun 2015 22:31:52 +0000 (22:31 +0000)
commita77336bd5dc4eb2f3cf300a88c918aa2f7d4c108
treec2bd1a08b5c6ecf0b3b5641cdcc6f19fc5bb7e7c
parent5055f6dfe0df092ae81a838223f2216353c16064
COFF: Support delay-load import tables.

DLLs are usually resolved at process startup, but you can
delay-load them by passing /delayload option to the linker.

If a /delayload is specified, the linker has to create data
which is similar to regular import table.
One notable difference is that the pointers in a delay-load
import table are originally pointing to thunks that resolves
themselves. Each thunk loads a DLL, resolve its name, and then
overwrites the pointer with the result so that subsequent
function calls directly call a desired function. The linker
has to emit thunks.

llvm-svn: 240250
lld/COFF/Config.h
lld/COFF/DLL.cpp
lld/COFF/DLL.h
lld/COFF/Driver.cpp
lld/COFF/Writer.cpp
lld/COFF/Writer.h
lld/test/COFF/delayimports.test [new file with mode: 0644]