Skip to content

[SR-15399] async function pointer handling does not account for GOT/IAT #57713

Closed
@compnerd

Description

@compnerd
Previous ID SR-15399
Radar None
Original Reporter @compnerd
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Windows
Assignee @compnerd
Priority Medium

md5: 60d118265670b2fd126a9cf46ade5005

Issue Description:

Cross-module async function pointer references are made directly without consulting the GOT. This results in an unsatisfiable link request on Windows.

// %swiftc -emit-module -emit-library -o L.dll %s -DL
// %swiftc -emit-executable -o E.exe %s -I. -lL

#if L
open class C {
 open func f() async throws {}
}
#else
import L
class D: C {
}
#endif

When linking we observe the following:
reduced-e4271c.o : error LNK2001: unresolved external symbol $s1L1CC1fyyYaKFTu

Due to the unresolved symbol reference.

The full type metadata for D is emitted thusly:

$s4main1DCMf:
        .quad   ($s4main1DCfD)
        .quad   0
        .quad   0
        .quad   0
        .long   2
        .long   0
        .long   16
        .short  7
        .short  0
        .long   88
        .long   16
        .quad   ($s4main1DCMn)
        .quad   0
        .quad   ($s1L1CC1fyyYaKFTu)
        .quad   ($s1L1CCACycfC)

Because the member is not overridden, the async function pointer reference is emitted directly. However, because the symbol is module external, it needs to be indirected on Windows via the IAT. The address of the variable is not known at compile time and will need to be resolved at runtime.

Metadata

Metadata

Assignees

Labels

WindowsPlatform: WindowsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions