13

I am only aware of 2:

wozname
  • 213
  • 3
  • 10

3 Answers3

4

There is DbgHelp, but it's geared more toward the PE file rather than the object file. And Its intended to be used as an API rather than a tool.

the COFF format itself originated on unix https://en.wikipedia.org/wiki/COFF although Microsoft has extended the format somewhat and the unix seems to have abandoned that format in favor of ELF. But you might find some useful tools in the Unix world, for instance this dump tool from SCO http://docsrv.sco.com:507/en/man/html.CP/dump.CP.html

Klaus Gütter
  • 11,151
  • 6
  • 31
  • 36
John Knoeller
  • 33,512
  • 4
  • 61
  • 92
  • DbgHelp is a set of APIs, a library essentially. Not a viewer. Binutils, however, are -- and were at the time of your answer -- perfectly capable of dealing with COFF files, provided the tools had been configured to support COFF during build. These days there are tools from LLVM which also provide the capability to view COFF files. – 0xC0000022L Jan 21 '23 at 00:08
1

Just convert the COFF format to ELF and use some ELF viewer:

objcopy.exe --input-target=pe-i386 --output-target=elf32-i386 somefile.o somefile.elf

For example in Python you can then use this one-file-implementation, which only depends on the struct module: http://www.tinyos.net/tinyos-2.1.0/tools/platforms/msp430/pybsl/elf.py

kungfooman
  • 4,473
  • 1
  • 44
  • 33
0

Hmm, its odd this option hadn't been mentioned, but Binutils built with support for COFF and your target architecture are perfectly capable of showing you COFF file contents (and were at the time you asked).

This includes tools like nm, objdump and -- depending on what it is you are trying -- also strip, objcopy, ld.

If you're after a lot of detail, llvm-readobj may be closest to what you are looking for it is very detailed and descriptive at the same time; at least if you have a rough idea about what's in a COFF file.

On the other hand LLVM also brings clones of tools from Binutils but prefixed llvm-. So you are likely to find llvm-objdump, llvm-objcopy, llvm-strip, llvm-nm etc.

With modern versions of Visual Studio (since VS2019, IIRC), you can install the full Clang/LLVM toolchain from the Visual Studio Installer, which contains these tools -- otherwise it can also be found prepackaged from the Clang/LLVM project website.

Binutils and LLVM are also perfectly capable of dealing with the .lib file format produced by the Library Manager (lib.exe); ar and 7-Zip can be used to unpack them. If you need certain advanced functionality to manipulate object files or libraries, you may want to have a look at objconv, though.

Honorable mention: some hex editors, like ImHex, also have the ability to show a more structured view of COFF files.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
  • The LLVM provided `llvm-cxxfilt.exe` still (as of LLVM16.0) cannot demangle some symbols correctly. People still have to `undname.exe` sometimes. – ChrisZZ Jun 21 '23 at 09:37
  • @ChrisZZ Interesting. Do you have an example? – 0xC0000022L Jun 21 '23 at 11:43
  • 1
    I made and issue in LLVM repo: https://github.com/llvm/llvm-project/issues/63342 . I use "cannot demangle some symbols" to describe cases that the input and output of llvm-cxxfilt.exe is the same, both the symbol name, not the C/C++ code names. – ChrisZZ Jun 25 '23 at 02:24
  • Cool @ChrisZZ! I'm fairly positive it'll get fixed now it's been raised. I still don't quite understand why you remarked about it, given I didn't even mention anything about `undname` or `c++filt`/`llvm-cxxfilt`, but I guess you mean to say that the LLVM utils aren't always a 100% replacement? While this is true, even for `lld`, I have found that for the majority of cases they work reliably enough to recommend them. – 0xC0000022L Jun 25 '23 at 20:41
  • 1
    I was writing an ODRV (One Rule Definition Violation) detection tool, and I would like to know each symbols' corresponding C/C++ code. For my case, each failed-to-demangled-symbol may be source of ODRV. For other case, not so strict required. 0xC0000022L – ChrisZZ Jun 26 '23 at 02:20
  • @ChrisZZ sounds interesting. Hope it will be available publicly some time. I myself dabble in COFF to coerce existing certain-party hybrid (static and import in one) libraries in picking up _my_ symbols instead of the imported ones. – 0xC0000022L Jun 27 '23 at 07:59