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