In order to get reproducible builds, we use the --ffile-prefix-map=/path/to/src=SRC --file-prefix-map=/path/to/lib=LIB option when compiling. And similarly, for gdb I can set substitute-path SRC=/path/to/src etc.
However, I cannot figure out how to do a similar thing with objdump -S. I can work around it with a small maze of symlinks, but I don't understand the --prefix option to objdump, or know if it is the right thing to use. I tried --prefix-strip=1 --prefix=/path/to/src but it did not seem to do what I expected (well, it didn't manage to include any source code!)
Is there any way to do this?
After a bit of experimentation and a quick insight into the source code of the
objdumputility, just to make sure I got it all right fromobjdump(1), I managed to achieve the desired outcome. This is probably going to be puzzling because I did nothing special, yet it all worked out as expected.First, I created a simple "Hello, world!" program in a file named
test.c:Got it compiled using the following command:
Using
strings test | grep /srcverified that/srcactually got into the resultingtestbinary, so it was time to getobjdump -Sto find the source code, using the following command:Here's an excerpt from the produced output, which shows the desired source code fragments in the disassembled code:
Thus, it must be that something isn't exactly right in the environment you're using. Perhaps it would be good to try reproducing a simple example like this one first, to see will it work as expected. I hope this helps.
See also this question for an additional insight.