Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 1498f1d

Browse files
committed
Revert r351529 "[llvm-objdump][NFC] Improve readability."
msan errors in ELF/strip-all.s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351556 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 54d67b5 commit 1498f1d

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,7 @@ cl::alias DisassembleZeroesShort("z",
279279

280280
static StringRef ToolName;
281281

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;
294283

295284
SectionFilter llvm::ToolSectionFilter(llvm::object::ObjectFile const &O) {
296285
return SectionFilter(
@@ -1046,8 +1035,8 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
10461035
std::vector<uint64_t> TextMappingSymsAddr;
10471036
if (isArmElf(Obj)) {
10481037
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);
10511040
if (Name.startswith("$d"))
10521041
DataMappingSymsAddr.push_back(Address - SectionAddr);
10531042
if (Name.startswith("$x"))
@@ -1096,11 +1085,11 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
10961085
error(Section.getName(SectionName));
10971086

10981087
// 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) {
11001089
Symbols.insert(
11011090
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));
11041093
}
11051094

11061095
SmallString<40> Comments;
@@ -1119,11 +1108,12 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
11191108
std::vector<RelocationRef>::const_iterator RelEnd = Rels.end();
11201109
// Disassemble symbol by symbol.
11211110
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;
11231112
// The end is either the section end or the beginning of the next
11241113
// 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;
11271117
// Don't try to disassemble beyond the end of section contents.
11281118
if (End > SectSize)
11291119
End = SectSize;
@@ -1139,7 +1129,8 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
11391129
}
11401130

11411131
/// 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])))
11431134
continue;
11441135

11451136
if (!PrintedSection) {
@@ -1155,12 +1146,12 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
11551146
End = StopAddress - SectionAddr;
11561147

11571148
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) {
11591150
// skip amd_kernel_code_t at the begining of kernel symbol (256 bytes)
11601151
Start += 256;
11611152
}
11621153
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) {
11641155
// cut trailing zeroes at the end of kernel
11651156
// cut up to 256 bytes
11661157
const uint64_t EndAlign = 256;
@@ -1175,7 +1166,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
11751166
if (!NoLeadingAddr)
11761167
outs() << format("%016" PRIx64 " ", SectionAddr + Start);
11771168

1178-
StringRef SymbolName = Symbols[SI].Name();
1169+
StringRef SymbolName = std::get<1>(Symbols[SI]);
11791170
if (Demangle)
11801171
outs() << demangle(SymbolName) << ":\n";
11811172
else
@@ -1213,7 +1204,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
12131204
// same section. We rely on the markers introduced to
12141205
// understand what we need to dump. If the data marker is within a
12151206
// 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 &&
12171208
!DisassembleAll) {
12181209
uint64_t Stride = 0;
12191210

@@ -1277,7 +1268,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
12771268
// disassembling text (applicable all architectures),
12781269
// we are in a situation where we must print the data and not
12791270
// disassemble it.
1280-
if (Obj->isELF() && Symbols[SI].Type() == ELF::STT_OBJECT &&
1271+
if (Obj->isELF() && std::get<2>(Symbols[SI]) == ELF::STT_OBJECT &&
12811272
!DisassembleAll && Section.isText()) {
12821273
// print out data up to 8 bytes at a time in hex and ascii
12831274
uint8_t AsciiData[9] = {'\0'};
@@ -1374,21 +1365,25 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
13741365
// the target, find the nearest preceding absolute symbol.
13751366
auto TargetSym = std::upper_bound(
13761367
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);
13791371
});
13801372
if (TargetSym == TargetSectionSymbols->begin()) {
13811373
TargetSectionSymbols = &AbsoluteSymbols;
13821374
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+
});
13871380
}
13881381
if (TargetSym != TargetSectionSymbols->begin()) {
13891382
--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;
13921387
if (Disp)
13931388
outs() << "+0x" << Twine::utohexstr(Disp);
13941389
outs() << '>';

0 commit comments

Comments
 (0)