This patch intends to fix incomplete relocation printing for XCOFF (potentially for other targets).
Details
Diff Detail
Event Timeline
llvm/tools/llvm-objdump/llvm-objdump.cpp | ||
---|---|---|
1593 | 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? |
llvm/tools/llvm-objdump/llvm-objdump.cpp | ||
---|---|---|
1593 | Thanks. Comment added. |
llvm/tools/llvm-objdump/llvm-objdump.cpp | ||
---|---|---|
1593 |
I think the idea is that the relocations that may modify the instruction are printed after the instruction. |
llvm/test/tools/llvm-objdump/XCOFF/disassemble-all.test | ||
---|---|---|
1 | 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. | |
llvm/tools/llvm-objdump/llvm-objdump.cpp | ||
1590 | Split the sentence using a period instead of using ", and". | |
1591 | s/. But this matches/, but this is what matches/; |
llvm/tools/llvm-objdump/llvm-objdump.cpp | ||
---|---|---|
1591 | 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." |
llvm/test/tools/llvm-objdump/MachO/Inputs/relocs-data-macho-x86_64.yaml | ||
---|---|---|
3 | 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? |
llvm/test/tools/llvm-objdump/MachO/Inputs/relocs-data-macho-x86_64.yaml | ||
---|---|---|
1 | Is this file used in only one test? If so, it could just be folded into that test. |
@MaskRay
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.
As written, this test writes to the current directory, which assumes that the current directory is writable, but that is not true in all builds. I have committed 215e6bfcfb5af7713ec348f679c7be4d2f32dc82 to fix.
llvm/test/tools/llvm-objdump/MachO/disassemble-relocs-data-x86_64.test | ||
---|---|---|
3 | This should be yaml2obj %s -o %.o (yaml2obj does not record the source filename in the output, which may make FileCheck tests brittle sometimes.) |
@saugustine Thanks for the quick fix.
llvm/test/tools/llvm-objdump/MachO/disassemble-relocs-data-x86_64.test | ||
---|---|---|
3 | Thanks for pointing that out. Addressed in post commit: rGd5143e3f102a91599682fc630205e5c6fec58c76. |
Is this file used in only one test? If so, it could just be folded into that test.