@@ -279,7 +279,18 @@ cl::alias DisassembleZeroesShort("z",
279
279
280
280
static StringRef ToolName;
281
281
282
- typedef std::vector<std::tuple<uint64_t , StringRef, uint8_t >> SectionSymbolsTy;
282
+ namespace {
283
+ struct SectionSymbol : public std ::tuple<uint64_t , StringRef, uint8_t > {
284
+ SectionSymbol (uint64_t Address, StringRef Name, uint8_t Type)
285
+ : std::tuple<uint64_t , StringRef, uint8_t >(Address, Name, Type) {}
286
+
287
+ uint64_t Address () const { return std::get<0 >(*this ); }
288
+ StringRef Name () const { return std::get<1 >(*this ); }
289
+ uint8_t Type () const { return std::get<2 >(*this ); }
290
+ };
291
+
292
+ typedef std::vector<SectionSymbol> SectionSymbolsTy;
293
+ } // namespace
283
294
284
295
SectionFilter llvm::ToolSectionFilter (llvm::object::ObjectFile const &O) {
285
296
return SectionFilter (
@@ -1035,8 +1046,8 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1035
1046
std::vector<uint64_t > TextMappingSymsAddr;
1036
1047
if (isArmElf (Obj)) {
1037
1048
for (const auto &Symb : Symbols) {
1038
- uint64_t Address = std::get< 0 >( Symb);
1039
- StringRef Name = std::get< 1 >( Symb);
1049
+ uint64_t Address = Symb. Address ( );
1050
+ StringRef Name = Symb. Name ( );
1040
1051
if (Name.startswith (" $d" ))
1041
1052
DataMappingSymsAddr.push_back (Address - SectionAddr);
1042
1053
if (Name.startswith (" $x" ))
@@ -1085,11 +1096,11 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1085
1096
error (Section.getName (SectionName));
1086
1097
1087
1098
// If the section has no symbol at the start, just insert a dummy one.
1088
- if (Symbols.empty () || std::get< 0 >( Symbols[0 ]) != 0 ) {
1099
+ if (Symbols.empty () || Symbols[0 ]. Address ( ) != 0 ) {
1089
1100
Symbols.insert (
1090
1101
Symbols.begin (),
1091
- std::make_tuple (SectionAddr, SectionName,
1092
- Section.isText () ? ELF::STT_FUNC : ELF::STT_OBJECT));
1102
+ SectionSymbol (SectionAddr, SectionName,
1103
+ Section.isText () ? ELF::STT_FUNC : ELF::STT_OBJECT));
1093
1104
}
1094
1105
1095
1106
SmallString<40 > Comments;
@@ -1108,12 +1119,11 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1108
1119
std::vector<RelocationRef>::const_iterator RelEnd = Rels.end ();
1109
1120
// Disassemble symbol by symbol.
1110
1121
for (unsigned SI = 0 , SE = Symbols.size (); SI != SE; ++SI) {
1111
- uint64_t Start = std::get< 0 >( Symbols[SI]) - SectionAddr;
1122
+ uint64_t Start = Symbols[SI]. Address ( ) - SectionAddr;
1112
1123
// The end is either the section end or the beginning of the next
1113
1124
// symbol.
1114
- uint64_t End = (SI == SE - 1 )
1115
- ? SectSize
1116
- : std::get<0 >(Symbols[SI + 1 ]) - SectionAddr;
1125
+ uint64_t End =
1126
+ (SI == SE - 1 ) ? SectSize : Symbols[SI + 1 ].Address () - SectionAddr;
1117
1127
// Don't try to disassemble beyond the end of section contents.
1118
1128
if (End > SectSize)
1119
1129
End = SectSize;
@@ -1129,8 +1139,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1129
1139
}
1130
1140
1131
1141
// / Skip if user requested specific symbols and this is not in the list
1132
- if (!DisasmFuncsSet.empty () &&
1133
- !DisasmFuncsSet.count (std::get<1 >(Symbols[SI])))
1142
+ if (!DisasmFuncsSet.empty () && !DisasmFuncsSet.count (Symbols[SI].Name ()))
1134
1143
continue ;
1135
1144
1136
1145
if (!PrintedSection) {
@@ -1146,12 +1155,12 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1146
1155
End = StopAddress - SectionAddr;
1147
1156
1148
1157
if (Obj->isELF () && Obj->getArch () == Triple::amdgcn) {
1149
- if (std::get< 2 >( Symbols[SI]) == ELF::STT_AMDGPU_HSA_KERNEL) {
1158
+ if (Symbols[SI]. Type ( ) == ELF::STT_AMDGPU_HSA_KERNEL) {
1150
1159
// skip amd_kernel_code_t at the begining of kernel symbol (256 bytes)
1151
1160
Start += 256 ;
1152
1161
}
1153
1162
if (SI == SE - 1 ||
1154
- std::get< 2 >( Symbols[SI + 1 ]) == ELF::STT_AMDGPU_HSA_KERNEL) {
1163
+ Symbols[SI + 1 ]. Type ( ) == ELF::STT_AMDGPU_HSA_KERNEL) {
1155
1164
// cut trailing zeroes at the end of kernel
1156
1165
// cut up to 256 bytes
1157
1166
const uint64_t EndAlign = 256 ;
@@ -1166,7 +1175,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1166
1175
if (!NoLeadingAddr)
1167
1176
outs () << format (" %016" PRIx64 " " , SectionAddr + Start);
1168
1177
1169
- StringRef SymbolName = std::get< 1 >( Symbols[SI]);
1178
+ StringRef SymbolName = Symbols[SI]. Name ( );
1170
1179
if (Demangle)
1171
1180
outs () << demangle (SymbolName) << " :\n " ;
1172
1181
else
@@ -1204,7 +1213,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1204
1213
// same section. We rely on the markers introduced to
1205
1214
// understand what we need to dump. If the data marker is within a
1206
1215
// function, it is denoted as a word/short etc
1207
- if (isArmElf (Obj) && std::get< 2 >( Symbols[SI]) != ELF::STT_OBJECT &&
1216
+ if (isArmElf (Obj) && Symbols[SI]. Type ( ) != ELF::STT_OBJECT &&
1208
1217
!DisassembleAll) {
1209
1218
uint64_t Stride = 0 ;
1210
1219
@@ -1268,7 +1277,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1268
1277
// disassembling text (applicable all architectures),
1269
1278
// we are in a situation where we must print the data and not
1270
1279
// disassemble it.
1271
- if (Obj->isELF () && std::get< 2 >( Symbols[SI]) == ELF::STT_OBJECT &&
1280
+ if (Obj->isELF () && Symbols[SI]. Type ( ) == ELF::STT_OBJECT &&
1272
1281
!DisassembleAll && Section.isText ()) {
1273
1282
// print out data up to 8 bytes at a time in hex and ascii
1274
1283
uint8_t AsciiData[9 ] = {' \0 ' };
@@ -1365,25 +1374,21 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
1365
1374
// the target, find the nearest preceding absolute symbol.
1366
1375
auto TargetSym = std::upper_bound (
1367
1376
TargetSectionSymbols->begin (), TargetSectionSymbols->end (),
1368
- Target, [](uint64_t LHS,
1369
- const std::tuple<uint64_t , StringRef, uint8_t > &RHS) {
1370
- return LHS < std::get<0 >(RHS);
1377
+ Target, [](uint64_t LHS, const SectionSymbol &RHS) {
1378
+ return LHS < RHS.Address ();
1371
1379
});
1372
1380
if (TargetSym == TargetSectionSymbols->begin ()) {
1373
1381
TargetSectionSymbols = &AbsoluteSymbols;
1374
1382
TargetSym = std::upper_bound (
1375
- AbsoluteSymbols.begin (), AbsoluteSymbols.end (),
1376
- Target, [](uint64_t LHS,
1377
- const std::tuple<uint64_t , StringRef, uint8_t > &RHS) {
1378
- return LHS < std::get<0 >(RHS);
1379
- });
1383
+ AbsoluteSymbols.begin (), AbsoluteSymbols.end (), Target,
1384
+ [](uint64_t LHS, const SectionSymbol &RHS) {
1385
+ return LHS < RHS.Address ();
1386
+ });
1380
1387
}
1381
1388
if (TargetSym != TargetSectionSymbols->begin ()) {
1382
1389
--TargetSym;
1383
- uint64_t TargetAddress = std::get<0 >(*TargetSym);
1384
- StringRef TargetName = std::get<1 >(*TargetSym);
1385
- outs () << " <" << TargetName;
1386
- uint64_t Disp = Target - TargetAddress;
1390
+ outs () << " <" << TargetSym->Name ();
1391
+ uint64_t Disp = Target - TargetSym->Address ();
1387
1392
if (Disp)
1388
1393
outs () << " +0x" << Twine::utohexstr (Disp);
1389
1394
outs () << ' >' ;
0 commit comments