diff options
author | diggerlin <digger.llvm@gmail.com> | 2020-05-29 11:08:51 -0400 |
---|---|---|
committer | diggerlin <digger.llvm@gmail.com> | 2020-05-29 11:08:51 -0400 |
commit | 34cfed24ebd3a2a9f286877d142a68dbf2c42c96 (patch) | |
tree | 09fc0bc384319b8bc63b1605133c22bf9ec94ec3 /llvm/lib/MC/MCDisassembler/MCDisassembler.cpp | |
parent | 0384446c7c2458b12ce3ef1c2bdf438af1f78ad7 (diff) | |
download | llvm-34cfed24ebd3a2a9f286877d142a68dbf2c42c96.zip llvm-34cfed24ebd3a2a9f286877d142a68dbf2c42c96.tar.gz llvm-34cfed24ebd3a2a9f286877d142a68dbf2c42c96.tar.bz2 |
[AIX][XCOFF] add symbol priority for the llvm-objdump -D -symbol-description
SUMMARY:
when there are two symbol has the same address. llvm-objdump -D -symbol-description will select symbol based on the following rule:
1. using Label first if there is a Label symbol.
2. If there is not Label, using a symbol which has Storage Mapping class.
3. if more than one symbol has storage mapping class, put the TC0 has the low priority, for other storage mapping class , compare based on the value.
Reviewers: James Henderson ,hubert.reinterpretcast,
Differential Revision: https://reviews.llvm.org/D78387
Diffstat (limited to 'llvm/lib/MC/MCDisassembler/MCDisassembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCDisassembler/MCDisassembler.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp index 373916f..40ffd1f 100644 --- a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp +++ b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp @@ -43,3 +43,56 @@ void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value, void MCDisassembler::setSymbolizer(std::unique_ptr<MCSymbolizer> Symzer) { Symbolizer = std::move(Symzer); } + +#define SMC_PCASE(A, P) \ + case XCOFF::XMC_##A: \ + return P; + +uint8_t getSMCPriority(XCOFF::StorageMappingClass SMC) { + switch (SMC) { + SMC_PCASE(PR, 1) + SMC_PCASE(RO, 1) + SMC_PCASE(DB, 1) + SMC_PCASE(GL, 1) + SMC_PCASE(XO, 1) + SMC_PCASE(SV, 1) + SMC_PCASE(SV64, 1) + SMC_PCASE(SV3264, 1) + SMC_PCASE(TI, 1) + SMC_PCASE(TB, 1) + SMC_PCASE(RW, 1) + SMC_PCASE(TC0, 0) + SMC_PCASE(TC, 1) + SMC_PCASE(TD, 1) + SMC_PCASE(DS, 1) + SMC_PCASE(UA, 1) + SMC_PCASE(BS, 1) + SMC_PCASE(UC, 1) + SMC_PCASE(TL, 1) + SMC_PCASE(UL, 1) + SMC_PCASE(TE, 1) +#undef SMC_PCASE + } + return 0; +} + +/// The function is for symbol sorting when symbols have the same address. +/// The symbols in the same section are sorted in ascending order. +/// llvm-objdump -D will choose the highest priority symbol to display when +/// there are symbols with the same address. +bool XCOFFSymbolInfo::operator<(const XCOFFSymbolInfo &SymInfo) const { + // Label symbols have higher priority than non-label symbols. + if (IsLabel != SymInfo.IsLabel) + return SymInfo.IsLabel; + + // Symbols with a StorageMappingClass have higher priority than those without. + if (StorageMappingClass.hasValue() != SymInfo.StorageMappingClass.hasValue()) + return SymInfo.StorageMappingClass.hasValue(); + + if (StorageMappingClass.hasValue()) { + return getSMCPriority(StorageMappingClass.getValue()) < + getSMCPriority(SymInfo.StorageMappingClass.getValue()); + } + + return false; +} |