[PATCH] D78387: [AIX][XCOFF] add symbol priority for the llvm-objdump -D -symbol-description
Digger via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 10:47:28 PDT 2020
DiggerLin created this revision.
DiggerLin added reviewers: hubert.reinterpretcast, jasonliu.
Herald added subscribers: llvm-commits, rupprecht, MaskRay.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78387
Files:
llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
llvm/test/tools/llvm-objdump/XCOFF/disassemble-symbol-description.test
llvm/tools/llvm-objdump/XCOFFDump.cpp
Index: llvm/tools/llvm-objdump/XCOFFDump.cpp
===================================================================
--- llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -72,3 +72,27 @@
outs() << "[" << XCOFF::getMappingClassString(Smc) << "]";
}
}
+
+bool objdump::compareXCOFFSymbolInfo(const XCOFFSymbolInfo &SymInfo1,
+ const XCOFFSymbolInfo &SymInfo2) {
+ // Compare Label first. If the symbol is Label, it is in high priority.
+ if (SymInfo1.IsLabel != SymInfo2.IsLabel)
+ return SymInfo1.IsLabel < SymInfo2.IsLabel;
+
+ // If symbol have not StorageMappingClass, it is in low proirity.
+ if (!SymInfo1.StorageMappingClass)
+ return true;
+
+ if (!SymInfo2.StorageMappingClass)
+ return false;
+
+ // TC0 symbol is low prority than other SMC.
+ if (SymInfo1.StorageMappingClass.getValue() == XCOFF::XMC_TC0)
+ return true;
+
+ if (SymInfo2.StorageMappingClass.getValue() == XCOFF::XMC_TC0)
+ return false;
+
+ return SymInfo1.StorageMappingClass.getValue() <=
+ SymInfo1.StorageMappingClass.getValue();
+}
Index: llvm/test/tools/llvm-objdump/XCOFF/disassemble-symbol-description.test
===================================================================
--- llvm/test/tools/llvm-objdump/XCOFF/disassemble-symbol-description.test
+++ llvm/test/tools/llvm-objdump/XCOFF/disassemble-symbol-description.test
@@ -22,7 +22,7 @@
COMMON: Inputs/xcoff-section-headers.o: file format aixcoff-rs6000
COMMON: Disassembly of section .text:
PLAIN: 00000000 <.text>:
-DESC: 00000000 (idx: 4) .text:
+DESC: 00000000 (idx: 16) .func:
COMMON-NEXT: 0: 80 62 00 04 lwz 3, 4(2)
COMMON-NEXT: 4: 80 63 00 00 lwz 3, 0(3)
COMMON-NEXT: 8: 4e 80 00 20 blr
Index: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
===================================================================
--- llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
+++ llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
@@ -28,6 +28,11 @@
: StorageMappingClass(Smc), Index(Idx), IsLabel(Label) {}
};
+namespace objdump {
+bool compareXCOFFSymbolInfo(const XCOFFSymbolInfo &SymInfo1,
+ const XCOFFSymbolInfo &SymInfo2);
+}
+
struct SymbolInfoTy {
uint64_t Addr;
StringRef Name;
@@ -52,9 +57,12 @@
friend bool operator<(const SymbolInfoTy &P1, const SymbolInfoTy &P2) {
assert(P1.IsXCOFF == P2.IsXCOFF &&
"P1.IsXCOFF should be equal to P2.IsXCOFF.");
- if (P1.IsXCOFF)
- return std::tie(P1.Addr, P1.Name) < std::tie(P2.Addr, P2.Name);
- else
+ if (P1.IsXCOFF) {
+ if (P1.Addr == P2.Addr)
+ return objdump::compareXCOFFSymbolInfo(P1.XCOFFSymInfo,
+ P2.XCOFFSymInfo);
+ return P1.Addr < P2.Addr;
+ } else
return std::tie(P1.Addr, P1.Name, P1.Type) <
std::tie(P2.Addr, P2.Name, P2.Type);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78387.258366.patch
Type: text/x-patch
Size: 3014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200417/5a17e170/attachment-0001.bin>
More information about the llvm-commits
mailing list