[PATCH] D13360: [llvm-objdump] Teach -d about AArch64 mapping symbols
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 11:55:10 PDT 2015
davide removed rL LLVM as the repository for this revision.
davide updated this revision to Diff 36642.
davide added a comment.
Reworked as per Rafael request.
http://reviews.llvm.org/D13360
Files:
tools/llvm-objdump/llvm-objdump.cpp
Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -917,8 +917,6 @@
// Make a list of all the symbols in this section.
std::vector<std::pair<uint64_t, StringRef>> Symbols;
- std::vector<uint64_t> DataMappingSymsAddr;
- std::vector<uint64_t> TextMappingSymsAddr;
for (const SymbolRef &Symbol : Obj->symbols()) {
if (Section.containsSymbol(Symbol)) {
ErrorOr<uint64_t> AddressOrErr = Symbol.getAddress();
@@ -931,19 +929,11 @@
ErrorOr<StringRef> Name = Symbol.getName();
error(Name.getError());
Symbols.push_back(std::make_pair(Address, *Name));
- if (Obj->isELF() && Obj->getArch() == Triple::aarch64) {
- if (Name->startswith("$d"))
- DataMappingSymsAddr.push_back(Address);
- if (Name->startswith("$x"))
- TextMappingSymsAddr.push_back(Address);
- }
}
}
// Sort the symbols by address, just in case they didn't come in that way.
array_pod_sort(Symbols.begin(), Symbols.end());
- std::sort(DataMappingSymsAddr.begin(), DataMappingSymsAddr.end());
- std::sort(TextMappingSymsAddr.begin(), TextMappingSymsAddr.end());
// Make a list of all the relocations for this section.
std::vector<RelocationRef> Rels;
@@ -1011,36 +1001,37 @@
// AArch64 ELF binaries can interleave data and text in the
// same section. We rely on the markers introduced to
// understand what we need to dump.
- if (Obj->isELF() && Obj->getArch() == Triple::aarch64) {
- uint64_t Stride = 0;
-
- auto DAI = std::lower_bound(DataMappingSymsAddr.begin(),
- DataMappingSymsAddr.end(), Index);
- if (DAI != DataMappingSymsAddr.end() && *DAI == Index) {
- // Switch to data.
- while (Index < End) {
- outs() << format("%8" PRIx64 ":", SectionAddr + Index);
- outs() << "\t";
- if (Index + 4 <= End) {
- Stride = 4;
- dumpBytes(Bytes.slice(Index, 4), outs());
- outs() << "\t.word";
- } else if (Index + 2 <= End) {
- Stride = 2;
- dumpBytes(Bytes.slice(Index, 2), outs());
- outs() << "\t.short";
- } else {
- Stride = 1;
- dumpBytes(Bytes.slice(Index, 1), outs());
- outs() << "\t.byte";
- }
- Index += Stride;
- outs() << "\n";
- auto TAI = std::lower_bound(TextMappingSymsAddr.begin(),
- TextMappingSymsAddr.end(), Index);
- if (TAI != TextMappingSymsAddr.end() && *TAI == Index)
- break;
+ auto SymCmp = [](std::pair<uint64_t, StringRef> Sym, uint64_t Index)
+ -> bool { return Sym.first < Index; };
+ uint64_t Stride = 0;
+
+ auto DAI =
+ std::lower_bound(Symbols.begin(), Symbols.end(), Index, SymCmp);
+ if (DAI != Symbols.end() && DAI->first == Index &&
+ DAI->second.startswith("$d")) {
+ while (Index < End) {
+ outs() << format("%8" PRIx64 ":", SectionAddr + Index);
+ outs() << "\t";
+ if (Index + 4 <= End) {
+ Stride = 4;
+ dumpBytes(Bytes.slice(Index, 4), outs());
+ outs() << "\t.word";
+ } else if (Index + 2 <= End) {
+ Stride = 2;
+ dumpBytes(Bytes.slice(Index, 2), outs());
+ outs() << "\t.short";
+ } else {
+ Stride = 1;
+ dumpBytes(Bytes.slice(Index, 1), outs());
+ outs() << "\t.byte";
}
+ Index += Stride;
+ outs() << "\n";
+ auto TAI =
+ std::lower_bound(Symbols.begin(), Symbols.end(), Index, SymCmp);
+ if (TAI != Symbols.end() && TAI->first == Index &&
+ TAI->second.startswith("$x"))
+ break;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13360.36642.patch
Type: text/x-patch
Size: 4215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151006/eec85992/attachment.bin>
More information about the llvm-commits
mailing list