I'm in a bit of an exceptional situation: I have an application that compiles, links and launches when compiling with MSVC. I'm now in progress of recompiling it clang-cl, which causes it to compile, link and crash.
Thanks to Dependency Walker, I've found that unexpected DLLs are being loaded. In my case to find a symbol for std::allocator<char>::allocator(allocator const &)
.
With this, I currently have the following information:
In order to log a bug, I should be able to reduce the code to an acceptable size. Uploading the whole proprietary code base ain't an option, uploading a 20 line .cpp file is.
To reduce, I need to find the .cpp/.obj-file which requires this symbol. From there, reducing it becomes the easy work.
With this, I'm searching for a way to detect if an .obj file searches for a symbol in a different DLL.
I've already found:
dumpbin /DEPENDENTS
states:
Does not dump the names of the imported functions.
How do I dump the names of the imported functions, based on an .obj file?
dumpbin /symbols
is indeed the correct tool for the job as it also lists undefined symbols.
For example, when using dumpbin /symbols
to print the symbols in the object file generated from a source file containing
void foo();
void bar() {
foo();
}
we get
File Type: COFF OBJECT
COFF SYMBOL TABLE
[...]
008 00000000 UNDEF notype () External | ?foo@@YAXXZ (void __cdecl foo(void))
009 00000000 SECT3 notype () External | ?bar@@YAXXZ (void __cdecl bar(void))
[...]
As you can see, it contains both the symbol for the defined function bar
and the symbol for the function foo
that is merely declared. The difference is that for bar
it says that the symbol can be found in SECT3
wheras for foo
it prints UNDEF
.
So in order to find all symbols that are imported from somewhere else (e.g. a DLL) you just need to search for UNDEF
in the output of dumpbin /symbols
.