<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/142868>142868</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lld-link: delay load stub sometimes not marked as a CFG target
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jstarks
</td>
</tr>
</table>
<pre>
This is basically the same as #46961, which was fixed long ago. The only difference seems to be the function and DLL being referenced.
test.cpp:
```cxx
int main() {
extern "C" __declspec(dllimport) int WSACleanup(void);
decltype(WSACleanup)* volatile ptr = &WSACleanup;
ptr();
}
```
Build:
* Compile: `cl -c test.cpp -guard:cf -nologo test.cpp`
* Link: `<linker> test.obj -debug ws2_32.lib -guard:cf -delayload:ws2_32.dll dloadhelper.lib -nologo`
With `lld-link`, the resulting binary will hit a CFG failure. With `link`, the binary will successfully run.
The results are the same whether `cl` or `clang-cl` is used as the compiler.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxUU8FuqzoQ_RpnMwpyB0JgwYKmL2_T3at0l5XBE3A72Mg2TfP3Tw7c3F4pUrBnzpk5PjMqBDNYokYcnsXhZaeWODrffISo_GfYdU7fmrfRBDABOhVMr5hvEEeCoCYCFUBgXpR1-STwBNfR9CNcVYCL-SYN7OwAanAZvI0EzvINtLlcyJPtCQLRFCA66OjOeFlsH42zoKyGl9dX6MjYATxtAJ0J2QrZRgox6-dZ5OkkSrn--u9vIVtjI0zKWIGVwBrE8VnIFgCAviN5CwLxJBDh_V1Tz2GmXmClmc00Ox8TJDH8-q89MSm7zAKrL2e0wFrkv6kSMt5mElj9TKwFtvDlWEXDBHP0IPIXEFj-SHpwzNGvLa5X4vjyU8sq9HkxrDeV2MLJTbNhEnkLSS7DvoffbwH7YVE-JfcX2FvHbnCP4EaILbwa-7nhRX5iYz_Ji_yfNdN1H7DX1C0DXAO-55ix6f4m1sTqxk6l85ajmUGnq5F4Jr9i1gYeQn6ZOKaazHqfiqYAnu6mewoLx-RzZ6zyN7gaZhhNBAWn879wUYYXTxk8OP7G_0SFpe8phMuSZtQvdpuXt0eZAMrTn-m9jhRH8utrilKC276VHfbrjQmwBNJp0BOsXy3w2U43ua7zWu2oeToWtTyWiNVubHSFssci72SJ5SVXR43l8XCsD0VVSCS9Mw1KPMhSFoi5xCor6i4_atmhLJ-6WklRSJqU4Yz5a8qcH3YmhIWapwKrstqx6ojDfV8RLV3hHhWIaX19k0D7bhmCKCSbEMMfmmgiU_PwIG_hbick8yDEpYPgJopmogDWpTXyn6v01Yqo_EBxt3huxhjnkCYTzwLPg4nj0mW9mwSeU7ntbz9790F9FHi-NxkEnjcVXw3-HwAA__-Ey2nW">