llvm.org GIT mirror llvm / b99ee32
[llvm-objdump] Print the call target next to the instruction GNU binutils provides this behavior. objdump -r doesn't really help when you aren't dealing with relocation object files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241631 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 5 years ago
2 changed file(s) with 47 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
55 # Will be bundle-aligning to 16 byte boundaries
66 .bundle_align_mode 4
77 .text
8 # CHECK-LABEL: foo
8 # CHECK-LABEL: foo:
99 foo:
1010 # Test that bundle alignment mode can be set more than once.
1111 .bundle_align_mode 4
1818 callq bar
1919 .bundle_unlock
2020 .bundle_unlock
21 # CHECK: 10: callq
22 # CHECK-NEXT: 15: callq
21 # CHECK: 10: callq {{.*}}
22 # CHECK-NEXT: 15: callq {{.*}}
2323
2424 .p2align 4
25 # CHECK-LABEL: bar
25 # CHECK-LABEL: bar:
2626 bar:
2727 callq foo
2828 callq foo
3434 callq bar
3535 .bundle_unlock
3636 .bundle_unlock
37 # CHECK: 36: callq
38 # CHECK-NEXT: 3b: callq
37 # CHECK: 36: callq {{.*}}
38 # CHECK-NEXT: 3b: callq {{.*}}
3939
40 # CHECK-LABEL: baz
40 # CHECK-LABEL: baz:
4141 baz:
4242 callq foo
4343 callq foo
4949 callq bar
5050 .bundle_unlock
5151 .bundle_unlock
52 # CHECK: 56: callq
53 # CHECK-NEXT: 5b: callq
52 # CHECK: 56: callq {{.*}}
53 # CHECK-NEXT: 5b: callq {{.*}}
5454
5555 # CHECK-LABEL: quux
5656 quux:
6464 .bundle_unlock
6565 # Check that the calls are bundled together when the second one is after the
6666 # inner nest is closed.
67 # CHECK: 70: callq
68 # CHECK-NEXT: 75: callq
67 # CHECK: 70: callq {{.*}}
68 # CHECK-NEXT: 75: callq {{.*}}
807807 SectionRelocMap[*Sec2].push_back(Section);
808808 }
809809
810 // Create a mapping from virtual address to symbol name. This is used to
811 // pretty print the target of a call.
812 std::vector> AllSymbols;
813 if (MIA) {
814 for (const SymbolRef &Symbol : Obj->symbols()) {
815 ErrorOr AddressOrErr = Symbol.getAddress();
816 if (error(AddressOrErr.getError()))
817 break;
818 uint64_t Address = *AddressOrErr;
819
820 ErrorOr Name = Symbol.getName();
821 if (error(Name.getError()))
822 break;
823 if (Name->empty())
824 continue;
825 AllSymbols.push_back(std::make_pair(Address, *Name));
826 }
827
828 array_pod_sort(AllSymbols.begin(), AllSymbols.end());
829 }
830
810831 for (const SectionRef &Section : Obj->sections()) {
811832 if (!Section.isText() || Section.isVirtual())
812833 continue;
911932 SectionAddr + Index, outs(), "", *STI);
912933 outs() << CommentStream.str();
913934 Comments.clear();
935 if (MIA && (MIA->isCall(Inst) || MIA->isUnconditionalBranch(Inst))) {
936 uint64_t Target;
937 if (MIA->evaluateBranch(Inst, SectionAddr + Index, Size, Target)) {
938 const auto &TargetSym =
939 std::lower_bound(AllSymbols.begin(), AllSymbols.end(),
940 std::make_pair(Target, StringRef()));
941 if (TargetSym != AllSymbols.end()) {
942 outs() << " <" << TargetSym->second;
943 uint64_t Disp = TargetSym->first - Target;
944 if (Disp)
945 outs() << '-' << Disp;
946 outs() << '>';
947 }
948 }
949 }
914950 outs() << "\n";
915951 } else {
916952 errs() << ToolName << ": warning: invalid instruction encoding\n";