This helps to avoid ambiguity when the address contains only digits 0..9.
Details
- Reviewers
MaskRay jhenderson int3 thakis hvdijk compnerd gkm - Group Reviewers
Restricted Project - Commits
- rGe7fffa6f032b: [llvm-objdump] Prefix memory operand addresses with '0x'
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I like the 0x, but the addresses at the start of the lines get printed without it so it introduces an inconsistency. I personally would prefer it if either both used 0x, or both leave out 0x. Is it possible to change both or does that introduce compatibility issues?
In fact, this patch fixes some inconsistencies in printing instructions and their comments. Hexadecimal constants are already prefixed with 0x (see, for example, lld/test/ELF/x86-64-gotpc-relax-nopic.s), as well as targets of branch instructions (lld/test/ELF/symver.s), etc.
As for addresses of the instructions, personally, I do not believe they need to be prefixed. They are printed as a sequence, so there are for sure some "letter" digits among them, and thus the actual format is easily recognized. In any case, I guess that that is something unrelated to this patch, and should be done separately, if decided.
They are closer in meaning to the addresses at the start of the line, not just instructions but data as well, than to anything else though. When we want to see what e.g. pushq 8346(%rip) # 203280 actually refers to, we look for the line that starts with 203280. Yes, I have actually looked things up this way, this isn't hypothetical.
Thanks. pushq 8346(%rip) # 203280 is the perfect example of why this patch is useful. The offset here is decimal while the calculated address is hexadecimal, but that is not obvious.
Yes, I have actually looked things up this way, this isn't hypothetical.
Well, in that case, would you like to prepare the corresponding patch? You seem to be able to substantiate it. Note that the disassembler already prints target addresses of jump/branch instructions with the '0x' prefix.