This patch intends to fix incomplete relocation printing for XCOFF (potentially for other targets).
This was mainly a comment about how the output would be displayed. The status quo (relocation prints "in the middle") felt weird to me, but I have now found that it matches the binutils objdump output.
00000000000000c8 <main>: c8: 00 00 00 00 .long 0x0 c8: R_POS_64 .main cc: 00 00 00 00 .long 0x0
Should we add a comment that this checks only the start of the relocation (and not its end) on purpose?
I think the idea is that the relocations that may modify the instruction are printed after the instruction.
I would suggest adding an x86_64 test file (llvm/test/tools/llvm-objdump/MachO/disassemble-relocs-data-x86_64.test) for another object file format that can expose similar issues.
The following, compiled for x86_64-apple-darwin would seem to fit:
extern char s; void *p = s + 0x60606060606060;
yaml2obj/obj2yaml does not seem to preserve relocation information for Mach-O, but the output seems to be good enough for the test.
Split the sentence using a period instead of using ", and".
s/. But this matches/, but this is what matches/;
Actually, I think "but this matches" is a better phrasing (but should be part of the sentence before as you suggest). I'd also use a colon rather than a full stop for the end of the "Note..." bit. I'd recommend the following, with some other minor rewording too:
"... is not the complete data: we might see the relocation printed in the middle of the data, but this matches the binutils objdump output."
|3 ↗||(On Diff #256086)|
The existing problem with obj2yaml's Mach-O port is that the output is too verbose.
Can you check whether some fields can be deleted and reduce the YAML as much as possible?
I was trying to remove some fields, but I will get " truncated or malformed object" error from "llvm-objdump -D -r" command for those objects.
I suspect after removing some fields, I will need to edit other fields in order for every offset/length to add up correctly.
So I kept the yaml file as it is.
This should be yaml2obj %s -o %.o
(yaml2obj does not record the source filename in the output, which may make FileCheck tests brittle sometimes.)