This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Respect weak externals for mangled symbol searching
ClosedPublic

Authored by smeenai on Dec 9 2022, 8:17 PM.

Details

Summary

We were previously ignoring weak externals during these searches (which
are used for the entry point, exports, and subsystem inference), which
differed from link.exe behavior. It also meant that we could get
different behavior when linking an object file directly vs. packaging it
into a static library, because static library symbol name directories
include weak externals.

Diff Detail

Event Timeline

smeenai created this revision.Dec 9 2022, 8:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 8:17 PM
smeenai requested review of this revision.Dec 9 2022, 8:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 8:17 PM
smeenai edited the summary of this revision. (Show Details)Dec 9 2022, 8:21 PM
mstorsjo added inline comments.Dec 11 2022, 12:59 AM
lld/COFF/SymbolTable.cpp
817

What this symbol is non-null but is Undefined (with itself possibly might be a weak symbol)? Do we need to make this a loop which inspects that aspect? Or is it not relevant for the usecases of findMangle where it is enough to see that we apparently did hit a real symbol and don’t need to check for prefixes?

mstorsjo accepted this revision.Dec 11 2022, 2:05 PM

This looks reasonable to me!

lld/COFF/SymbolTable.cpp
817

Ah, thanks!

This revision is now accepted and ready to land.Dec 11 2022, 2:05 PM
yozhu accepted this revision.Dec 11 2022, 5:56 PM