llvm.org GIT mirror llvm / f2c71ff
[llvm-objdump] Require that jump targets shown in -d are functions Don't let the disassembler pick call <.text> if a function happens to live at the start of the section by only using function symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241830 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 5 years ago
2 changed file(s) with 21 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
66 .bundle_align_mode 4
77 .text
88 # CHECK-LABEL: foo:
9 .type foo,@function
910 foo:
1011 # Test that bundle alignment mode can be set more than once.
1112 .bundle_align_mode 4
2324
2425 .p2align 4
2526 # CHECK-LABEL: bar:
27 .type bar,@function
2628 bar:
2729 callq foo
2830 callq foo
3840 # CHECK-NEXT: 3b: callq {{.*}}
3941
4042 # CHECK-LABEL: baz:
43 .type baz,@function
4144 baz:
4245 callq foo
4346 callq foo
5356 # CHECK-NEXT: 5b: callq {{.*}}
5457
5558 # CHECK-LABEL: quux
59 .type quux,@function
5660 quux:
5761 callq bar
5862 callq bar
816816 std::vector> AllSymbols;
817817 if (MIA) {
818818 for (const SymbolRef &Symbol : Obj->symbols()) {
819 if (Symbol.getType() != SymbolRef::ST_Function)
820 continue;
821
819822 ErrorOr AddressOrErr = Symbol.getAddress();
820823 if (error(AddressOrErr.getError()))
821824 break;
936939 SectionAddr + Index, outs(), "", *STI);
937940 outs() << CommentStream.str();
938941 Comments.clear();
939 if (MIA && (MIA->isCall(Inst) || MIA->isUnconditionalBranch(Inst))) {
942 if (MIA && (MIA->isCall(Inst) || MIA->isUnconditionalBranch(Inst) ||
943 MIA->isConditionalBranch(Inst))) {
940944 uint64_t Target;
941945 if (MIA->evaluateBranch(Inst, SectionAddr + Index, Size, Target)) {
942 const auto &TargetSym =
943 std::lower_bound(AllSymbols.begin(), AllSymbols.end(),
944 std::make_pair(Target, StringRef()));
946 auto TargetSym = std::upper_bound(
947 AllSymbols.begin(), AllSymbols.end(), Target,
948 [](uint64_t LHS, std::pair &RHS) {
949 return LHS < RHS.first;
950 });
951 if (TargetSym != AllSymbols.begin())
952 --TargetSym;
953 else
954 TargetSym = AllSymbols.end();
955
945956 if (TargetSym != AllSymbols.end()) {
946957 outs() << " <" << TargetSym->second;
947 uint64_t Disp = TargetSym->first - Target;
958 uint64_t Disp = Target - TargetSym->first;
948959 if (Disp)
949 outs() << '-' << Disp;
960 outs() << '+' << utohexstr(Disp);
950961 outs() << '>';
951962 }
952963 }