Certain tests and embedded systems use sectionless symbols
as the target of branches or calls. Handle them in the disassembly.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 19789 Build 19789: arc lint + arc unit
Event Timeline
test/tools/llvm-objdump/call-absolute-symbol-elf.test | ||
---|---|---|
2 | Should this test be synthesized from a .s file using llvm-mc? |
test/tools/llvm-objdump/call-absolute-symbol-elf.test | ||
---|---|---|
4 | I find that on AArch64 PowerPC x86_64 ... all these call/branch instructions print the immediate value without taking account of PC (what they print are relative addresses, instead of absolute addresses as printed by objdump) The PowerPC one at least appends .+ before the immediate to tell you it is a relative address. https://github.com/llvm-mirror/llvm/tree/master/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp#L386 raw_ostream &O) { if (!MI->getOperand(OpNo).isImm()) return printOperand(MI, OpNo, O); // Branches can take an immediate operand. This is used by the branch // selection pass to print .+8, an eight byte displacement from the PC. O << ".+"; printAbsBranchOperand(MI, OpNo, O); } | |
tools/llvm-objdump/llvm-objdump.cpp | ||
1725 | Reasonable behavior. I have verified that objdump does something similar (foo + 4). It has one extra heuristic: if the target address is less than the absolute symbol of the smallest address, it can print something like foo - 4. But I think we don't need such heuristic. |
test/tools/llvm-objdump/call-absolute-symbol-elf.test | ||
---|---|---|
2 | This is a good question, and I debated. But only about five of the ~100 files in llbm-objdump/Inputs are normal ASCII source of one kind or another. The rest are binaries. So I went that way. Totally willing to change it if you think it is important. | |
4 | This patch doesn't change the printed value, it just adds the symbol it targets. This is sufficient for my needs, and I'm not sure what the dependencies of the current format are, or if it is a principled decision. Before this patch: 201000: e8 fb f0 df ff callq -2100997 After: 201000: e8 fb f0 df ff callq -2100997 <foo> |
test/tools/llvm-objdump/call-absolute-symbol-elf.test | ||
---|---|---|
2 | I can elaborate here:
My preference here, I think, is going to be:
| |
4 | Almost assuredly no particular planning on the format of objdump output here. |
test/tools/llvm-objdump/call-absolute-symbol-elf.test | ||
---|---|---|
2 | It turns out that yaml2obj doesn't handle absolute symbols cleanly either. So I've just converted the very simple input to inline text in the test itself. |
test/tools/llvm-objdump/call-absolute-symbol-elf.test | ||
---|---|---|
2 | Nit: trailing \n should be unnecessary. |
This is committed as r335903, with a small update to fix targets that don't have ld.lld available in r335908.
test/tools/llvm-objdump/call-absolute-symbol-elf.test | ||
---|---|---|
1 | btw, I think \n can be avoided here with the use of ;. # RUN: echo '.section .init_array, "aw"; .quad 0' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o It perhaps looks a bit cleaner. I see that you switched to use the binary file in rL335908. I think it is a better way because does not seem A good practice is to add the description of how to rebuild the binary object used. |
btw, I think \n can be avoided here with the use of ;.
Here is how we do such things in LLD tests:
It perhaps looks a bit cleaner.
I see that you switched to use the binary file in rL335908. I think it is a better way because does not seem
that adding a dependency to ld.lld was good for llvm-objdump tests.
That is also consistent with another test we have which is test\tools\llvm-objdump\X86\phdrs.test.
A good practice is to add the description of how to rebuild the binary object used.
Because in some rare cases it might be needed, but without such descriptions, it can be a painful task.
phdrs.test, for example, contains such description. May I request you to add one too, please?