Page MenuHomePhabricator

[COFF] Add SymbolName as a distinct field in COFFImportFile
ClosedPublic

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

Details

Summary

The previous Name and ExtName aren't enough to convey all the nuances between weak aliases and stdcall decorated function names.

A test for this will be added in LLD.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Aug 9 2017, 12:48 PM
rnk added inline comments.Aug 9 2017, 12:58 PM
lib/Object/COFFImportFile.cpp
593 ↗(On Diff #110458)

Do we not need to look at ExtName for weak symbols?

mstorsjo added inline comments.Aug 9 2017, 1:03 PM
lib/Object/COFFImportFile.cpp
593 ↗(On Diff #110458)

If E.isWeak(), we created a weak external above and never even get here (extend the diff by some lines above to see more context). So E.isWeak() could never be true here before.

This brings it back to more or less exact the same logic that was used before this was split out of LLD.

mstorsjo added inline comments.Aug 10 2017, 10:31 PM
lib/Object/COFFImportFile.cpp
582 ↗(On Diff #110458)

Should we extend isWeak() to check SymbolName instead of Name, if set? Or just avoid touching the decoration altogether in llvm-dlltool D36548 if we want to create a weak alias?

mstorsjo added a comment.EditedAug 10 2017, 10:56 PM

Instead of this patch, we could also update getNameType to check for decoration, e.g like this:

if (!Sym.startswith("?") && Sym.find('@', 1) != Sym.npos)
  return IMPORT_NAME_UNDECORATE;

This patch tries to get things back to match how things were in lld prior to factorizing it, while the snippet above takes it into a different direction. I'd appreciate if @ruiu could chime in on which direction is better to take here.

ruiu accepted this revision.Aug 15 2017, 1:49 PM

LGTM

This revision is now accepted and ready to land.Aug 15 2017, 1:49 PM
This revision was automatically updated to reflect the committed changes.