This is an archive of the discontinued LLVM Phabricator instance.

demangle undefined symbol names in error message
ClosedPublic

Authored by kledzik on Sep 30 2014, 2:08 PM.

Details

Summary

The darwin linker has the -demangle option which directs it to demangle C++ (and soon Swift) mangled symbol names. Long term we need some Diagnostics object for formatting errors and warnings. But for now we have the Core linker just writing messages to llvm::errs(). So, to enable demangling, I changed the Resolver to call a LinkingContext method on the symbol name.

To make this more interesting, the demangling code is done via __cxa_demangle() which is part of the C++ ABI, which is only supported on some platforms, so I had to conditionalize the code with the config generated HAVE_CXXABI_H.

Diff Detail

Event Timeline

kledzik updated this revision to Diff 14246.Sep 30 2014, 2:08 PM
kledzik retitled this revision from to demangle undefined symbol names in error message.
kledzik updated this object.
kledzik edited the test plan for this revision. (Show Details)
kledzik added a project: lld.
kledzik added a subscriber: Unknown Object (MLST).
ruiu accepted this revision.Sep 30 2014, 2:20 PM
ruiu edited edge metadata.

LGTM with nits

include/lld/Core/LinkingContext.h
274

I'd name demangle rather than demangleSymbol because it's shorter and yet conveys enough information.

include/lld/ReaderWriter/MachOLinkingContext.h
100

And rename doDemangle, enableDemangle or something like that.

This revision is now accepted and ready to land.Sep 30 2014, 2:20 PM
t.p.northover edited edge metadata.Sep 30 2014, 2:28 PM

Hi Nick,

The code looks reasonable to me. One comment on the tests though...

Cheers.

Tim.

test/mach-o/demangle.yaml
33–34

Any chance you could add 1 or 2 weird symbols here too (non-C++ and perhaps one without any underscore)? Since this is used for diagnostics when things have gone wrong, it's fairly important it won't crash and burn then.

kledzik closed this revision.Sep 30 2014, 4:26 PM

committed in r218718