[llvm] [llvm-objdump] Implement decoding auxiliary header for xcoff with llvm-objdump --private-headers (PR #105682)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 11 02:38:59 PDT 2024
================
@@ -67,6 +75,182 @@ void XCOFFDumper::printStrHex(StringRef Name, StringRef Str, uint64_t Value) {
<< ")\n";
}
+void XCOFFDumper::printBinary(StringRef Name, ArrayRef<uint8_t> B) {
+ unsigned OrgWidth = getWidth();
+ setWidth(0);
+ outs() << formatName(Name) << " (" << format_bytes(B) << ")\n";
+ setWidth(OrgWidth);
+}
+
+void XCOFFDumper::printAuxiliaryHeader() {
+ setWidth(36);
+ if (Obj.is64Bit())
+ printAuxiliaryHeader(Obj.auxiliaryHeader64());
+ else
+ printAuxiliaryHeader(Obj.auxiliaryHeader32());
+}
+
+enum PrintStyle { Hex, Number };
+template <typename T, typename V>
+static void printAuxMemberHelper(PrintStyle Style, const char *MemberName,
+ const T &Member, const V *AuxHeader,
+ uint16_t AuxSize, uint16_t &PartialFieldOffset,
+ const char *&PartialFieldName,
+ XCOFFDumper *Dumper) {
+ ptrdiff_t Offset = reinterpret_cast<const char *>(&Member) -
+ reinterpret_cast<const char *>(AuxHeader);
+ if (Offset + sizeof(Member) <= AuxSize)
+ Style == Hex ? Dumper->printHex(MemberName, Member)
+ : Dumper->printNumber(MemberName, Member);
+ else if (Offset < AuxSize) {
+ PartialFieldOffset = Offset;
+ PartialFieldName = MemberName;
+ }
+}
+
+template <class T>
----------------
jh7370 wrote:
Same comment as above re. clearer name. Also, be consistent with using `typename`/`class` for type parameters in templates.
https://github.com/llvm/llvm-project/pull/105682
More information about the llvm-commits
mailing list