Skip to content

lld-link: delay load stub sometimes not marked as a CFG target #142868

Open
@jstarks

Description

@jstarks

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:

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.

> lld-link --version
LLD 19.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions