[Lldb-commits] [lldb] [lldb][AIX] Header Parsing for XCOFF Object File in AIX (PR #116338)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 9 07:14:05 PST 2024
================
@@ -136,13 +169,42 @@ bool ObjectFileXCOFF::MagicBytesMatch(DataBufferSP &data_sp,
return XCOFFHeaderSizeFromMagic(magic) != 0;
}
-bool ObjectFileXCOFF::ParseHeader() { return false; }
+bool ObjectFileXCOFF::ParseHeader() {
+
+ bool retVal = false;
+ ModuleSP module_sp(GetModule());
+ if (module_sp) {
+ std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
+
+ const auto *fileHeaderPtr = m_binary->fileHeader64();
+ m_xcoff_header = *fileHeaderPtr;
+ if (m_xcoff_header.Magic != 0) {
+ if (m_xcoff_header.AuxHeaderSize > 0) {
+ const auto *fileAuxHeader = m_binary->auxiliaryHeader64();
+ m_xcoff_aux_header = *fileAuxHeader;
+ }
+ retVal = true;
+ }
+ }
+
+ return retVal;
+}
ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
bool ObjectFileXCOFF::IsExecutable() const { return true; }
-uint32_t ObjectFileXCOFF::GetAddressByteSize() const { return 8; }
+uint32_t ObjectFileXCOFF::GetAddressByteSize() const {
+ if (m_xcoff_header.Magic == XCOFF::XCOFF64)
+ return 8;
+ else if (m_xcoff_header.Magic == XCOFF::XCOFF32)
+ return 4;
+ return 4;
+}
----------------
labath wrote:
If you're going to be supporting only the 64-bit version, then I think the previous version is actually better. :)
https://github.com/llvm/llvm-project/pull/116338
More information about the lldb-commits
mailing list