gccdebug-symbolsobjdumpdwarfobjcopy

Display source code with disassembly when path has changed


We have some static libraries for a know arch (e.g. powerpc) in which we need to display source code with disassembly to perform some asm review activities.

However, the binaries were cross-compiled in different locations and even in some cases different OSes (Linux and Windows), e.g. C:/path-to-mylib/common/src and others others /home/user-name/path-to-mylib/common/src, and so, objdump -S mylib.a isn't able to find the source. An option that we have is to replicate the path

I could replicate the compilation path and place the source there. However, I find that method a bit dirty and I guess that won't work from cross platform (between Linux and Windows).

Is there away to tell objdump -S where is the source path located or modify the path with objcopy?

Some important assumptions:

Let me know if you need more information, thanks.


Solution

  • As ssbssa user said, there is an undocumented --include= option (also as -I) in objdump. With this option, you have to place all source code files into a folder and then call objdump the path to the source code:

    objdump -I path-to-mylib/common/src -S mylib.a
    

    Nevertheless, in this other page they suggest an alternative solution to the problem. By using options --prefix=”.” --prefix-strip=3 we can replace the prefix of the path when calling objdump. E.g.

    objdump -S --prefix=”./myfolder” --prefix-strip=3 mylib.a
    

    This will allow objdump to search the src as ./myfolder/driver/common/src, instead of the original /home/user/source/driver/common/src. However, I didn't manage to make it work with different OSes (E.g compiled in Windows, asm+src dump in Linux),