lucasg / Dependencies

A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues.
MIT License
8.91k stars 727 forks source link

Cannot undecorate C++ symbols generated by MinGW #12

Closed ZgblKylin closed 6 years ago

lucasg commented 6 years ago

2 probable causes for this issue :

I've fixed cause#1 with this commit : dc624147841872fbfcae93a90a7bc7a1e3579584 (release is here : https://ci.appveyor.com/api/buildjobs/m3ft0c0pn5vc9685/artifacts/output%2FDependencies.zip ). Can you tell me if this fixed your issue ? If not, is it possible for you to send me a test dll reproducing the issue ?

Cheers,

ZgblKylin commented 6 years ago

Still cannot undecorate, I use Qt5Core.dll(Qt framework, MinGW version) to test, it's symbols look like this - _ZN10QByteArray5clearEv(void QByteArray::clear()). C++ symbols generated by MinGW are decorated same as gcc, not msvc, so UnDecorateSymbolName cannot resolve it.

I suggest use _cxa_demangle in libstdc++.

We could use MinGW to build a c-library, link it to libstdc++, and export this function as extern "C", then this library can be linked to msvc projects.

So when UnDecorateSymbolName failed, we can call that c-library for _cxa_demangle instead.

lucasg commented 6 years ago

I've packaged a Windows-based _cxa_demangle lib in order to undecorate GCC symbols : https://github.com/lucasg/Dependencies/commit/76a0eb053e86a0bef59fc1be2e1a0e5ceafe7f39.

The lib is two years old, so recent symbols may not be undecorated correctly, but it should work for your case. I tested it on C:\Program Files\Git\mingw64\bin\libstdc++-6 and it demangled most of the exports.

You can test it here : https://ci.appveyor.com/project/lucasg/dependencies/build/1.0.145/job/pghdl4w4uiew4q0e/artifacts

ZgblKylin commented 6 years ago

That's great! It works perfect now.

Thanks a lot!