This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Change the thunk that get inserted when calling a function in a dealyloaded DLL to leave 32 unused bytes on top of the stack on x64
Needs ReviewPublic

Authored by a_Tom on Feb 6 2022, 9:15 AM.

Details

Reviewers
ruiu
Summary

When linking a DLL with /delayload, lld insert a thunk that will call __delayLoadHelper2 on first invocation of a function located in the delayloaded DLL.
Prior to the call to __delayLoadHelper2, registers are saved on the stack (and restored after) but it seems that, at least on x64, the __delayLoadHelper2 function writes into the top of the stack, overwritting the value of the saved registers.
This change makes the thunk allocate 32 more bytes on the stack but doesn't use them so that __delayLoadHelper2 won't overwrite anything.

Diff Detail

Event Timeline

a_Tom requested review of this revision.Feb 6 2022, 9:15 AM
a_Tom created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2022, 9:15 AM
a_Tom edited the summary of this revision. (Show Details)Feb 6 2022, 9:16 AM