Page MenuHomePhabricator

[LLD] [COFF] Fix the name type for stdcall functions in import libraries
ClosedPublic

Authored by mstorsjo on Aug 9 2017, 12:51 PM.

Details

Summary

Since SVN r303491 and r304573, LLD used the COFFImportLibrary functions from LLVM. These only had two names, Name and ExtName, which wasn't enough to convey all the details of stdcall functions.

Stdcall functions got the wrong symbol name in the import library itself in r303491, which is why it was reverted in r304561. When re-landed and fixed in r304573 (after adding a test in r304572), the symbol name itself in the import library ended up right, but the name type of the import library entry was wrong.

This had the effect that linking to the import library succeeded (contrary to in r303491, where linking to such an import library failed), but at runtime, the symbol wouldn't be found in the DLL (since the caller linked to the stdcall decorated name).

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Aug 9 2017, 12:51 PM
mstorsjo retitled this revision from [COFF] Fix the name type for stdcall functions in import libraries to [LLD] [COFF] Fix the name type for stdcall functions in import libraries.
rnk accepted this revision.Aug 9 2017, 12:56 PM

lgtm

This revision is now accepted and ready to land.Aug 9 2017, 12:56 PM
mstorsjo added a subscriber: hans.Aug 10 2017, 1:55 AM

Forgot to say explicitly, that this depends on D36544. This also fixes a regression since 4.0, where linking to import libraries with stdcall creates broken executables. So once done, this and D36544 should be backported to 5.0, ping @hans.

This revision was automatically updated to reflect the committed changes.