llvm.org GIT mirror llvm / 86cf232
Hexagon: Put relocations after instructions not packets. Change relocation output so that relocation information follows individual instructions rather than clustering them at the end of packets. This change required shifting block of code but the actual change is in HexagonPrettyPrinter's PrintInst. Differential Revision: https://reviews.llvm.org/D46728 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332283 91177308-0d34-0410-b5e6-96231b3b80d8 Sid Manning 1 year, 5 months ago
4 changed file(s) with 338 addition(s) and 294 deletion(s). Raw diff Collapse all Expand all
77 }
88
99 ; CHECK: { call 0
10 ; CHECK: 00000000: R_HEX_B22_PCREL
1011 ; CHECK: allocframe(#0)
11 ; CHECK: 00000000: R_HEX_B22_PCREL
1212 ; CHECK: { dealloc_return }
0 # RUN: llvm-mc -filetype=obj -triple=hexagon %s | llvm-objdump -r -d - | FileCheck %s
1 {
2 call ##foo
3 memw(##a) = r0
4 }
5 #CHECK: { immext(#0)
6 #CHECK: : R_HEX_B32_PCREL_X foo
7 #CHECK: call
8 #CHECK: R_HEX_B22_PCREL_X foo
9 #CHECK: immext(#0)
10 #CHECK: R_HEX_32_6_X a
11 #CHECK: memw(##0) = r0 }
12 #CHECK: R_HEX_16_X a
13
14
33 # CHECK: R_HEX_GD_PLT_B22_PCREL
44 call ##foo@GDPLT
55 # CHECK: R_HEX_GD_PLT_B32_PCREL_X
6 # CHECK-NEXT: R_HEX_GD_PLT_B22_PCREL_X
6 # CHECK: R_HEX_GD_PLT_B22_PCREL_X
77
88 call foo@LDPLT
99 # CHECK: R_HEX_LD_PLT_B22_PCREL
1010 call ##foo@LDPLT
1111 # CHECK: R_HEX_LD_PLT_B32_PCREL_X
12 # CHECK-NEXT: R_HEX_LD_PLT_B22_PCREL_X
12 # CHECK: R_HEX_LD_PLT_B22_PCREL_X
400400 return a.getOffset() < b.getOffset();
401401 }
402402
403 namespace {
404 class SourcePrinter {
405 protected:
406 DILineInfo OldLineInfo;
407 const ObjectFile *Obj = nullptr;
408 std::unique_ptr Symbolizer;
409 // File name to file contents of source
410 std::unordered_map> SourceCache;
411 // Mark the line endings of the cached source
412 std::unordered_map> LineCache;
413
414 private:
415 bool cacheSource(const DILineInfo& LineInfoFile);
416
417 public:
418 SourcePrinter() = default;
419 SourcePrinter(const ObjectFile *Obj, StringRef DefaultArch) : Obj(Obj) {
420 symbolize::LLVMSymbolizer::Options SymbolizerOpts(
421 DILineInfoSpecifier::FunctionNameKind::None, true, false, false,
422 DefaultArch);
423 Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts));
424 }
425 virtual ~SourcePrinter() = default;
426 virtual void printSourceLine(raw_ostream &OS, uint64_t Address,
427 StringRef Delimiter = "; ");
428 };
429
430 bool SourcePrinter::cacheSource(const DILineInfo &LineInfo) {
431 std::unique_ptr Buffer;
432 if (LineInfo.Source) {
433 Buffer = MemoryBuffer::getMemBuffer(*LineInfo.Source);
434 } else {
435 auto BufferOrError = MemoryBuffer::getFile(LineInfo.FileName);
436 if (!BufferOrError)
437 return false;
438 Buffer = std::move(*BufferOrError);
439 }
440 // Chomp the file to get lines
441 size_t BufferSize = Buffer->getBufferSize();
442 const char *BufferStart = Buffer->getBufferStart();
443 for (const char *Start = BufferStart, *End = BufferStart;
444 End < BufferStart + BufferSize; End++)
445 if (*End == '\n' || End == BufferStart + BufferSize - 1 ||
446 (*End == '\r' && *(End + 1) == '\n')) {
447 LineCache[LineInfo.FileName].push_back(StringRef(Start, End - Start));
448 if (*End == '\r')
449 End++;
450 Start = End + 1;
451 }
452 SourceCache[LineInfo.FileName] = std::move(Buffer);
453 return true;
454 }
455
456 void SourcePrinter::printSourceLine(raw_ostream &OS, uint64_t Address,
457 StringRef Delimiter) {
458 if (!Symbolizer)
459 return;
460 DILineInfo LineInfo = DILineInfo();
461 auto ExpectecLineInfo =
462 Symbolizer->symbolizeCode(Obj->getFileName(), Address);
463 if (!ExpectecLineInfo)
464 consumeError(ExpectecLineInfo.takeError());
465 else
466 LineInfo = *ExpectecLineInfo;
467
468 if ((LineInfo.FileName == "") || OldLineInfo.Line == LineInfo.Line ||
469 LineInfo.Line == 0)
470 return;
471
472 if (PrintLines)
473 OS << Delimiter << LineInfo.FileName << ":" << LineInfo.Line << "\n";
474 if (PrintSource) {
475 if (SourceCache.find(LineInfo.FileName) == SourceCache.end())
476 if (!cacheSource(LineInfo))
477 return;
478 auto FileBuffer = SourceCache.find(LineInfo.FileName);
479 if (FileBuffer != SourceCache.end()) {
480 auto LineBuffer = LineCache.find(LineInfo.FileName);
481 if (LineBuffer != LineCache.end()) {
482 if (LineInfo.Line > LineBuffer->second.size())
483 return;
484 // Vector begins at 0, line numbers are non-zero
485 OS << Delimiter << LineBuffer->second[LineInfo.Line - 1].ltrim()
486 << "\n";
487 }
488 }
489 }
490 OldLineInfo = LineInfo;
491 }
492
493 static bool isArmElf(const ObjectFile *Obj) {
494 return (Obj->isELF() &&
495 (Obj->getArch() == Triple::aarch64 ||
496 Obj->getArch() == Triple::aarch64_be ||
497 Obj->getArch() == Triple::arm || Obj->getArch() == Triple::armeb ||
498 Obj->getArch() == Triple::thumb ||
499 Obj->getArch() == Triple::thumbeb));
500 }
501
502 class PrettyPrinter {
503 public:
504 virtual ~PrettyPrinter() = default;
505 virtual void printInst(MCInstPrinter &IP, const MCInst *MI,
506 ArrayRef Bytes, uint64_t Address,
507 raw_ostream &OS, StringRef Annot,
508 MCSubtargetInfo const &STI, SourcePrinter *SP) {
509 if (SP && (PrintSource || PrintLines))
510 SP->printSourceLine(OS, Address);
511 if (!NoLeadingAddr)
512 OS << format("%8" PRIx64 ":", Address);
513 if (!NoShowRawInsn) {
514 OS << "\t";
515 dumpBytes(Bytes, OS);
516 }
517 if (MI)
518 IP.printInst(MI, OS, "", STI);
519 else
520 OS << " ";
521 }
522 };
523 PrettyPrinter PrettyPrinterInst;
524 class HexagonPrettyPrinter : public PrettyPrinter {
525 public:
526 void printLead(ArrayRef Bytes, uint64_t Address,
527 raw_ostream &OS) {
528 uint32_t opcode =
529 (Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | Bytes[0];
530 if (!NoLeadingAddr)
531 OS << format("%8" PRIx64 ":", Address);
532 if (!NoShowRawInsn) {
533 OS << "\t";
534 dumpBytes(Bytes.slice(0, 4), OS);
535 OS << format("%08" PRIx32, opcode);
536 }
537 }
538 void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef Bytes,
539 uint64_t Address, raw_ostream &OS, StringRef Annot,
540 MCSubtargetInfo const &STI, SourcePrinter *SP) override {
541 if (SP && (PrintSource || PrintLines))
542 SP->printSourceLine(OS, Address, "");
543 if (!MI) {
544 printLead(Bytes, Address, OS);
545 OS << " ";
546 return;
547 }
548 std::string Buffer;
549 {
550 raw_string_ostream TempStream(Buffer);
551 IP.printInst(MI, TempStream, "", STI);
552 }
553 StringRef Contents(Buffer);
554 // Split off bundle attributes
555 auto PacketBundle = Contents.rsplit('\n');
556 // Split off first instruction from the rest
557 auto HeadTail = PacketBundle.first.split('\n');
558 auto Preamble = " { ";
559 auto Separator = "";
560 while(!HeadTail.first.empty()) {
561 OS << Separator;
562 Separator = "\n";
563 if (SP && (PrintSource || PrintLines))
564 SP->printSourceLine(OS, Address, "");
565 printLead(Bytes, Address, OS);
566 OS << Preamble;
567 Preamble = " ";
568 StringRef Inst;
569 auto Duplex = HeadTail.first.split('\v');
570 if(!Duplex.second.empty()){
571 OS << Duplex.first;
572 OS << "; ";
573 Inst = Duplex.second;
574 }
575 else
576 Inst = HeadTail.first;
577 OS << Inst;
578 Bytes = Bytes.slice(4);
579 Address += 4;
580 HeadTail = HeadTail.second.split('\n');
581 }
582 OS << " } " << PacketBundle.second;
583 }
584 };
585 HexagonPrettyPrinter HexagonPrettyPrinterInst;
586
587 class AMDGCNPrettyPrinter : public PrettyPrinter {
588 public:
589 void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef Bytes,
590 uint64_t Address, raw_ostream &OS, StringRef Annot,
591 MCSubtargetInfo const &STI, SourcePrinter *SP) override {
592 if (SP && (PrintSource || PrintLines))
593 SP->printSourceLine(OS, Address);
594
595 typedef support::ulittle32_t U32;
596
597 if (MI) {
598 SmallString<40> InstStr;
599 raw_svector_ostream IS(InstStr);
600
601 IP.printInst(MI, IS, "", STI);
602
603 OS << left_justify(IS.str(), 60);
604 } else {
605 // an unrecognized encoding - this is probably data so represent it
606 // using the .long directive, or .byte directive if fewer than 4 bytes
607 // remaining
608 if (Bytes.size() >= 4) {
609 OS << format("\t.long 0x%08" PRIx32 " ",
610 static_cast(*reinterpret_cast(Bytes.data())));
611 OS.indent(42);
612 } else {
613 OS << format("\t.byte 0x%02" PRIx8, Bytes[0]);
614 for (unsigned int i = 1; i < Bytes.size(); i++)
615 OS << format(", 0x%02" PRIx8, Bytes[i]);
616 OS.indent(55 - (6 * Bytes.size()));
617 }
618 }
619
620 OS << format("// %012" PRIX64 ": ", Address);
621 if (Bytes.size() >=4) {
622 for (auto D : makeArrayRef(reinterpret_cast(Bytes.data()),
623 Bytes.size() / sizeof(U32)))
624 // D should be explicitly casted to uint32_t here as it is passed
625 // by format to snprintf as vararg.
626 OS << format("%08" PRIX32 " ", static_cast(D));
627 } else {
628 for (unsigned int i = 0; i < Bytes.size(); i++)
629 OS << format("%02" PRIX8 " ", Bytes[i]);
630 }
631
632 if (!Annot.empty())
633 OS << "// " << Annot;
634 }
635 };
636 AMDGCNPrettyPrinter AMDGCNPrettyPrinterInst;
637
638 class BPFPrettyPrinter : public PrettyPrinter {
639 public:
640 void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef Bytes,
641 uint64_t Address, raw_ostream &OS, StringRef Annot,
642 MCSubtargetInfo const &STI, SourcePrinter *SP) override {
643 if (SP && (PrintSource || PrintLines))
644 SP->printSourceLine(OS, Address);
645 if (!NoLeadingAddr)
646 OS << format("%8" PRId64 ":", Address / 8);
647 if (!NoShowRawInsn) {
648 OS << "\t";
649 dumpBytes(Bytes, OS);
650 }
651 if (MI)
652 IP.printInst(MI, OS, "", STI);
653 else
654 OS << " ";
655 }
656 };
657 BPFPrettyPrinter BPFPrettyPrinterInst;
658
659 PrettyPrinter &selectPrettyPrinter(Triple const &Triple) {
660 switch(Triple.getArch()) {
661 default:
662 return PrettyPrinterInst;
663 case Triple::hexagon:
664 return HexagonPrettyPrinterInst;
665 case Triple::amdgcn:
666 return AMDGCNPrettyPrinterInst;
667 case Triple::bpfel:
668 case Triple::bpfeb:
669 return BPFPrettyPrinterInst;
670 }
671 }
672 }
673
674403 template
675404 static std::error_code getRelocationValueString(const ELFObjectFile *Obj,
676405 const RelocationRef &RelRef,
1159888 }
1160889
1161890 return false;
891 }
892
893 namespace {
894 class SourcePrinter {
895 protected:
896 DILineInfo OldLineInfo;
897 const ObjectFile *Obj = nullptr;
898 std::unique_ptr Symbolizer;
899 // File name to file contents of source
900 std::unordered_map> SourceCache;
901 // Mark the line endings of the cached source
902 std::unordered_map> LineCache;
903
904 private:
905 bool cacheSource(const DILineInfo& LineInfoFile);
906
907 public:
908 SourcePrinter() = default;
909 SourcePrinter(const ObjectFile *Obj, StringRef DefaultArch) : Obj(Obj) {
910 symbolize::LLVMSymbolizer::Options SymbolizerOpts(
911 DILineInfoSpecifier::FunctionNameKind::None, true, false, false,
912 DefaultArch);
913 Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts));
914 }
915 virtual ~SourcePrinter() = default;
916 virtual void printSourceLine(raw_ostream &OS, uint64_t Address,
917 StringRef Delimiter = "; ");
918 };
919
920 bool SourcePrinter::cacheSource(const DILineInfo &LineInfo) {
921 std::unique_ptr Buffer;
922 if (LineInfo.Source) {
923 Buffer = MemoryBuffer::getMemBuffer(*LineInfo.Source);
924 } else {
925 auto BufferOrError = MemoryBuffer::getFile(LineInfo.FileName);
926 if (!BufferOrError)
927 return false;
928 Buffer = std::move(*BufferOrError);
929 }
930 // Chomp the file to get lines
931 size_t BufferSize = Buffer->getBufferSize();
932 const char *BufferStart = Buffer->getBufferStart();
933 for (const char *Start = BufferStart, *End = BufferStart;
934 End < BufferStart + BufferSize; End++)
935 if (*End == '\n' || End == BufferStart + BufferSize - 1 ||
936 (*End == '\r' && *(End + 1) == '\n')) {
937 LineCache[LineInfo.FileName].push_back(StringRef(Start, End - Start));
938 if (*End == '\r')
939 End++;
940 Start = End + 1;
941 }
942 SourceCache[LineInfo.FileName] = std::move(Buffer);
943 return true;
944 }
945
946 void SourcePrinter::printSourceLine(raw_ostream &OS, uint64_t Address,
947 StringRef Delimiter) {
948 if (!Symbolizer)
949 return;
950 DILineInfo LineInfo = DILineInfo();
951 auto ExpectecLineInfo =
952 Symbolizer->symbolizeCode(Obj->getFileName(), Address);
953 if (!ExpectecLineInfo)
954 consumeError(ExpectecLineInfo.takeError());
955 else
956 LineInfo = *ExpectecLineInfo;
957
958 if ((LineInfo.FileName == "") || OldLineInfo.Line == LineInfo.Line ||
959 LineInfo.Line == 0)
960 return;
961
962 if (PrintLines)
963 OS << Delimiter << LineInfo.FileName << ":" << LineInfo.Line << "\n";
964 if (PrintSource) {
965 if (SourceCache.find(LineInfo.FileName) == SourceCache.end())
966 if (!cacheSource(LineInfo))
967 return;
968 auto FileBuffer = SourceCache.find(LineInfo.FileName);
969 if (FileBuffer != SourceCache.end()) {
970 auto LineBuffer = LineCache.find(LineInfo.FileName);
971 if (LineBuffer != LineCache.end()) {
972 if (LineInfo.Line > LineBuffer->second.size())
973 return;
974 // Vector begins at 0, line numbers are non-zero
975 OS << Delimiter << LineBuffer->second[LineInfo.Line - 1].ltrim()
976 << "\n";
977 }
978 }
979 }
980 OldLineInfo = LineInfo;
981 }
982
983 static bool isArmElf(const ObjectFile *Obj) {
984 return (Obj->isELF() &&
985 (Obj->getArch() == Triple::aarch64 ||
986 Obj->getArch() == Triple::aarch64_be ||
987 Obj->getArch() == Triple::arm || Obj->getArch() == Triple::armeb ||
988 Obj->getArch() == Triple::thumb ||
989 Obj->getArch() == Triple::thumbeb));
990 }
991
992 class PrettyPrinter {
993 public:
994 virtual ~PrettyPrinter() = default;
995 virtual void printInst(MCInstPrinter &IP, const MCInst *MI,
996 ArrayRef Bytes, uint64_t Address,
997 raw_ostream &OS, StringRef Annot,
998 MCSubtargetInfo const &STI, SourcePrinter *SP,
999 std::vector *Rels = nullptr) {
1000 if (SP && (PrintSource || PrintLines))
1001 SP->printSourceLine(OS, Address);
1002 if (!NoLeadingAddr)
1003 OS << format("%8" PRIx64 ":", Address);
1004 if (!NoShowRawInsn) {
1005 OS << "\t";
1006 dumpBytes(Bytes, OS);
1007 }
1008 if (MI)
1009 IP.printInst(MI, OS, "", STI);
1010 else
1011 OS << " ";
1012 }
1013 };
1014 PrettyPrinter PrettyPrinterInst;
1015 class HexagonPrettyPrinter : public PrettyPrinter {
1016 public:
1017 void printLead(ArrayRef Bytes, uint64_t Address,
1018 raw_ostream &OS) {
1019 uint32_t opcode =
1020 (Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | Bytes[0];
1021 if (!NoLeadingAddr)
1022 OS << format("%8" PRIx64 ":", Address);
1023 if (!NoShowRawInsn) {
1024 OS << "\t";
1025 dumpBytes(Bytes.slice(0, 4), OS);
1026 OS << format("%08" PRIx32, opcode);
1027 }
1028 }
1029 void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef Bytes,
1030 uint64_t Address, raw_ostream &OS, StringRef Annot,
1031 MCSubtargetInfo const &STI, SourcePrinter *SP,
1032 std::vector *Rels) override {
1033 if (SP && (PrintSource || PrintLines))
1034 SP->printSourceLine(OS, Address, "");
1035 if (!MI) {
1036 printLead(Bytes, Address, OS);
1037 OS << " ";
1038 return;
1039 }
1040 std::string Buffer;
1041 {
1042 raw_string_ostream TempStream(Buffer);
1043 IP.printInst(MI, TempStream, "", STI);
1044 }
1045 StringRef Contents(Buffer);
1046 // Split off bundle attributes
1047 auto PacketBundle = Contents.rsplit('\n');
1048 // Split off first instruction from the rest
1049 auto HeadTail = PacketBundle.first.split('\n');
1050 auto Preamble = " { ";
1051 auto Separator = "";
1052 StringRef Fmt = "\t\t\t%08" PRIx64 ": ";
1053 std::vector::const_iterator rel_cur = Rels->begin();
1054 std::vector::const_iterator rel_end = Rels->end();
1055
1056 // Hexagon's packets require relocations to be inline rather than
1057 // clustered at the end of the packet.
1058 auto PrintReloc = [&]() -> void {
1059 while ((rel_cur != rel_end) && (rel_cur->getOffset() <= Address)) {
1060 if (rel_cur->getOffset() == Address) {
1061 SmallString<16> name;
1062 SmallString<32> val;
1063 rel_cur->getTypeName(name);
1064 error(getRelocationValueString(*rel_cur, val));
1065 OS << Separator << format(Fmt.data(), Address) << name << "\t" << val
1066 << "\n";
1067 return;
1068 }
1069 rel_cur++;
1070 }
1071 };
1072
1073 while(!HeadTail.first.empty()) {
1074 OS << Separator;
1075 Separator = "\n";
1076 if (SP && (PrintSource || PrintLines))
1077 SP->printSourceLine(OS, Address, "");
1078 printLead(Bytes, Address, OS);
1079 OS << Preamble;
1080 Preamble = " ";
1081 StringRef Inst;
1082 auto Duplex = HeadTail.first.split('\v');
1083 if(!Duplex.second.empty()){
1084 OS << Duplex.first;
1085 OS << "; ";
1086 Inst = Duplex.second;
1087 }
1088 else
1089 Inst = HeadTail.first;
1090 OS << Inst;
1091 HeadTail = HeadTail.second.split('\n');
1092 if (HeadTail.first.empty())
1093 OS << " } " << PacketBundle.second;
1094 PrintReloc();
1095 Bytes = Bytes.slice(4);
1096 Address += 4;
1097 }
1098 }
1099 };
1100 HexagonPrettyPrinter HexagonPrettyPrinterInst;
1101
1102 class AMDGCNPrettyPrinter : public PrettyPrinter {
1103 public:
1104 void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef Bytes,
1105 uint64_t Address, raw_ostream &OS, StringRef Annot,
1106 MCSubtargetInfo const &STI, SourcePrinter *SP,
1107 std::vector *Rels) override {
1108 if (SP && (PrintSource || PrintLines))
1109 SP->printSourceLine(OS, Address);
1110
1111 typedef support::ulittle32_t U32;
1112
1113 if (MI) {
1114 SmallString<40> InstStr;
1115 raw_svector_ostream IS(InstStr);
1116
1117 IP.printInst(MI, IS, "", STI);
1118
1119 OS << left_justify(IS.str(), 60);
1120 } else {
1121 // an unrecognized encoding - this is probably data so represent it
1122 // using the .long directive, or .byte directive if fewer than 4 bytes
1123 // remaining
1124 if (Bytes.size() >= 4) {
1125 OS << format("\t.long 0x%08" PRIx32 " ",
1126 static_cast(*reinterpret_cast(Bytes.data())));
1127 OS.indent(42);
1128 } else {
1129 OS << format("\t.byte 0x%02" PRIx8, Bytes[0]);
1130 for (unsigned int i = 1; i < Bytes.size(); i++)
1131 OS << format(", 0x%02" PRIx8, Bytes[i]);
1132 OS.indent(55 - (6 * Bytes.size()));
1133 }
1134 }
1135
1136 OS << format("// %012" PRIX64 ": ", Address);
1137 if (Bytes.size() >=4) {
1138 for (auto D : makeArrayRef(reinterpret_cast(Bytes.data()),
1139 Bytes.size() / sizeof(U32)))
1140 // D should be explicitly casted to uint32_t here as it is passed
1141 // by format to snprintf as vararg.
1142 OS << format("%08" PRIX32 " ", static_cast(D));
1143 } else {
1144 for (unsigned int i = 0; i < Bytes.size(); i++)
1145 OS << format("%02" PRIX8 " ", Bytes[i]);
1146 }
1147
1148 if (!Annot.empty())
1149 OS << "// " << Annot;
1150 }
1151 };
1152 AMDGCNPrettyPrinter AMDGCNPrettyPrinterInst;
1153
1154 class BPFPrettyPrinter : public PrettyPrinter {
1155 public:
1156 void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef Bytes,
1157 uint64_t Address, raw_ostream &OS, StringRef Annot,
1158 MCSubtargetInfo const &STI, SourcePrinter *SP,
1159 std::vector *Rels) override {
1160 if (SP && (PrintSource || PrintLines))
1161 SP->printSourceLine(OS, Address);
1162 if (!NoLeadingAddr)
1163 OS << format("%8" PRId64 ":", Address / 8);
1164 if (!NoShowRawInsn) {
1165 OS << "\t";
1166 dumpBytes(Bytes, OS);
1167 }
1168 if (MI)
1169 IP.printInst(MI, OS, "", STI);
1170 else
1171 OS << " ";
1172 }
1173 };
1174 BPFPrettyPrinter BPFPrettyPrinterInst;
1175
1176 PrettyPrinter &selectPrettyPrinter(Triple const &Triple) {
1177 switch(Triple.getArch()) {
1178 default:
1179 return PrettyPrinterInst;
1180 case Triple::hexagon:
1181 return HexagonPrettyPrinterInst;
1182 case Triple::amdgcn:
1183 return AMDGCNPrettyPrinterInst;
1184 case Triple::bpfel:
1185 case Triple::bpfeb:
1186 return BPFPrettyPrinterInst;
1187 }
1188 }
11621189 }
11631190
11641191 static uint8_t getElfSymbolType(const ObjectFile *Obj, const SymbolRef &Sym) {
16461673
16471674 PIP.printInst(*IP, Disassembled ? &Inst : nullptr,
16481675 Bytes.slice(Index, Size), SectionAddr + Index, outs(), "",
1649 *STI, &SP);
1676 *STI, &SP, &Rels);
16501677 outs() << CommentStream.str();
16511678 Comments.clear();
16521679
17031730 }
17041731 outs() << "\n";
17051732
1706 // Print relocation for instruction.
1707 while (rel_cur != rel_end) {
1708 bool hidden = getHidden(*rel_cur);
1709 uint64_t addr = rel_cur->getOffset();
1710 SmallString<16> name;
1711 SmallString<32> val;
1712
1713 // If this relocation is hidden, skip it.
1714 if (hidden || ((SectionAddr + addr) < StartAddress)) {
1733 // Hexagon does this in pretty printer
1734 if (Obj->getArch() != Triple::hexagon)
1735 // Print relocation for instruction.
1736 while (rel_cur != rel_end) {
1737 bool hidden = getHidden(*rel_cur);
1738 uint64_t addr = rel_cur->getOffset();
1739 SmallString<16> name;
1740 SmallString<32> val;
1741
1742 // If this relocation is hidden, skip it.
1743 if (hidden || ((SectionAddr + addr) < StartAddress)) {
1744 ++rel_cur;
1745 continue;
1746 }
1747
1748 // Stop when rel_cur's address is past the current instruction.
1749 if (addr >= Index + Size) break;
1750 rel_cur->getTypeName(name);
1751 error(getRelocationValueString(*rel_cur, val));
1752 outs() << format(Fmt.data(), SectionAddr + addr) << name
1753 << "\t" << val << "\n";
17151754 ++rel_cur;
1716 continue;
17171755 }
1718
1719 // Stop when rel_cur's address is past the current instruction.
1720 if (addr >= Index + Size) break;
1721 rel_cur->getTypeName(name);
1722 error(getRelocationValueString(*rel_cur, val));
1723 outs() << format(Fmt.data(), SectionAddr + addr) << name
1724 << "\t" << val << "\n";
1725 ++rel_cur;
1726 }
17271756 }
17281757 }
17291758 }