@@ -278,9 +278,23 @@ cl::alias DisassembleZeroesShort("z",
278278
279279static StringRef ToolName;
280280
281- typedef std::vector<std::tuple<uint64_t , StringRef, uint8_t >> SectionSymbolsTy;
282-
283281namespace {
282+ struct SectionSymbol {
283+ SectionSymbol (uint64_t Address, StringRef Name, uint8_t Type)
284+ : Address(Address), Name(Name), Type(Type) {}
285+
286+ bool operator <(const SectionSymbol &Other) const {
287+ return std::tie (Address, Name, Type) <
288+ std::tie (Other.Address , Other.Name , Other.Type );
289+ }
290+
291+ uint64_t Address;
292+ StringRef Name;
293+ uint8_t Type;
294+ };
295+
296+ typedef std::vector<SectionSymbol> SectionSymbolsTy;
297+
284298typedef std::function<bool (llvm::object::SectionRef const &)> FilterPredicate;
285299
286300class SectionFilterIterator {
@@ -1455,8 +1469,8 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
14551469 std::vector<uint64_t > TextMappingSymsAddr;
14561470 if (isArmElf (Obj)) {
14571471 for (const auto &Symb : Symbols) {
1458- uint64_t Address = std::get< 0 >( Symb) ;
1459- StringRef Name = std::get< 1 >( Symb) ;
1472+ uint64_t Address = Symb. Address ;
1473+ StringRef Name = Symb. Name ;
14601474 if (Name.startswith (" $d" ))
14611475 DataMappingSymsAddr.push_back (Address - SectionAddr);
14621476 if (Name.startswith (" $x" ))
@@ -1505,11 +1519,11 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
15051519 error (Section.getName (SectionName));
15061520
15071521 // If the section has no symbol at the start, just insert a dummy one.
1508- if (Symbols.empty () || std::get< 0 >( Symbols[0 ]) != 0 ) {
1522+ if (Symbols.empty () || Symbols[0 ]. Address != 0 ) {
15091523 Symbols.insert (
15101524 Symbols.begin (),
1511- std::make_tuple (SectionAddr, SectionName,
1512- Section.isText () ? ELF::STT_FUNC : ELF::STT_OBJECT));
1525+ SectionSymbol (SectionAddr, SectionName,
1526+ Section.isText () ? ELF::STT_FUNC : ELF::STT_OBJECT));
15131527 }
15141528
15151529 SmallString<40 > Comments;
@@ -1528,12 +1542,12 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
15281542 std::vector<RelocationRef>::const_iterator RelEnd = Rels.end ();
15291543 // Disassemble symbol by symbol.
15301544 for (unsigned SI = 0 , SE = Symbols.size (); SI != SE; ++SI) {
1531- uint64_t Start = std::get< 0 >( Symbols[SI]) - SectionAddr;
1545+ uint64_t Start = Symbols[SI]. Address - SectionAddr;
15321546 // The end is either the section end or the beginning of the next
15331547 // symbol.
15341548 uint64_t End = (SI == SE - 1 )
15351549 ? SectSize
1536- : std::get< 0 >( Symbols[SI + 1 ]) - SectionAddr;
1550+ : Symbols[SI + 1 ]. Address - SectionAddr;
15371551 // Don't try to disassemble beyond the end of section contents.
15381552 if (End > SectSize)
15391553 End = SectSize;
@@ -1549,8 +1563,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
15491563 }
15501564
15511565 // / Skip if user requested specific symbols and this is not in the list
1552- if (!DisasmFuncsSet.empty () &&
1553- !DisasmFuncsSet.count (std::get<1 >(Symbols[SI])))
1566+ if (!DisasmFuncsSet.empty () && !DisasmFuncsSet.count (Symbols[SI].Name ))
15541567 continue ;
15551568
15561569 if (!PrintedSection) {
@@ -1566,12 +1579,12 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
15661579 End = StopAddress - SectionAddr;
15671580
15681581 if (Obj->isELF () && Obj->getArch () == Triple::amdgcn) {
1569- if (std::get< 2 >( Symbols[SI]) == ELF::STT_AMDGPU_HSA_KERNEL) {
1582+ if (Symbols[SI]. Type == ELF::STT_AMDGPU_HSA_KERNEL) {
15701583 // skip amd_kernel_code_t at the begining of kernel symbol (256 bytes)
15711584 Start += 256 ;
15721585 }
15731586 if (SI == SE - 1 ||
1574- std::get< 2 >( Symbols[SI + 1 ]) == ELF::STT_AMDGPU_HSA_KERNEL) {
1587+ Symbols[SI + 1 ]. Type == ELF::STT_AMDGPU_HSA_KERNEL) {
15751588 // cut trailing zeroes at the end of kernel
15761589 // cut up to 256 bytes
15771590 const uint64_t EndAlign = 256 ;
@@ -1586,7 +1599,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
15861599 if (!NoLeadingAddr)
15871600 outs () << format (" %016" PRIx64 " " , SectionAddr + Start);
15881601
1589- StringRef SymbolName = std::get< 1 >( Symbols[SI]) ;
1602+ StringRef SymbolName = Symbols[SI]. Name ;
15901603 if (Demangle)
15911604 outs () << demangle (SymbolName) << " :\n " ;
15921605 else
@@ -1624,7 +1637,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
16241637 // same section. We rely on the markers introduced to
16251638 // understand what we need to dump. If the data marker is within a
16261639 // function, it is denoted as a word/short etc
1627- if (isArmElf (Obj) && std::get< 2 >( Symbols[SI]) != ELF::STT_OBJECT &&
1640+ if (isArmElf (Obj) && Symbols[SI]. Type != ELF::STT_OBJECT &&
16281641 !DisassembleAll) {
16291642 uint64_t Stride = 0 ;
16301643
@@ -1688,7 +1701,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
16881701 // disassembling text (applicable all architectures),
16891702 // we are in a situation where we must print the data and not
16901703 // disassemble it.
1691- if (Obj->isELF () && std::get< 2 >( Symbols[SI]) == ELF::STT_OBJECT &&
1704+ if (Obj->isELF () && Symbols[SI]. Type == ELF::STT_OBJECT &&
16921705 !DisassembleAll && Section.isText ()) {
16931706 // print out data up to 8 bytes at a time in hex and ascii
16941707 uint8_t AsciiData[9 ] = {' \0 ' };
@@ -1785,25 +1798,21 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
17851798 // the target, find the nearest preceding absolute symbol.
17861799 auto TargetSym = std::upper_bound (
17871800 TargetSectionSymbols->begin (), TargetSectionSymbols->end (),
1788- Target, [](uint64_t LHS,
1789- const std::tuple<uint64_t , StringRef, uint8_t > &RHS) {
1790- return LHS < std::get<0 >(RHS);
1801+ Target, [](uint64_t LHS, const SectionSymbol &RHS) {
1802+ return LHS < RHS.Address ;
17911803 });
17921804 if (TargetSym == TargetSectionSymbols->begin ()) {
17931805 TargetSectionSymbols = &AbsoluteSymbols;
17941806 TargetSym = std::upper_bound (
1795- AbsoluteSymbols.begin (), AbsoluteSymbols.end (),
1796- Target, [](uint64_t LHS,
1797- const std::tuple<uint64_t , StringRef, uint8_t > &RHS) {
1798- return LHS < std::get<0 >(RHS);
1799- });
1807+ AbsoluteSymbols.begin (), AbsoluteSymbols.end (), Target,
1808+ [](uint64_t LHS, const SectionSymbol &RHS) {
1809+ return LHS < RHS.Address ;
1810+ });
18001811 }
18011812 if (TargetSym != TargetSectionSymbols->begin ()) {
18021813 --TargetSym;
1803- uint64_t TargetAddress = std::get<0 >(*TargetSym);
1804- StringRef TargetName = std::get<1 >(*TargetSym);
1805- outs () << " <" << TargetName;
1806- uint64_t Disp = Target - TargetAddress;
1814+ outs () << " <" << TargetSym->Name ;
1815+ uint64_t Disp = Target - TargetSym->Address ;
18071816 if (Disp)
18081817 outs () << " +0x" << Twine::utohexstr (Disp);
18091818 outs () << ' >' ;
0 commit comments