[Lldb-commits] [lldb] [lldb][AIX] Header Parsing for XCOFF Object File in AIX (PR #116338)

Dhruv Srivastava via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 13 07:24:34 PST 2024


================
@@ -130,19 +164,41 @@ bool ObjectFileXCOFF::MagicBytesMatch(DataBufferSP &data_sp,
                                       lldb::addr_t data_length) {
   lldb_private::DataExtractor data;
   data.SetData(data_sp, data_offset, data_length);
+
+  // Need to set this as XCOFF is only compatible with Big Endian
   data.SetByteOrder(eByteOrderBig);
   lldb::offset_t offset = 0;
   uint16_t magic = data.GetU16(&offset);
   return XCOFFHeaderSizeFromMagic(magic) != 0;
 }
 
-bool ObjectFileXCOFF::ParseHeader() { return false; }
+bool ObjectFileXCOFF::ParseHeader() {
+
+  bool retVal = false;
+  ModuleSP module_sp(GetModule());
+  if (module_sp) {
+    // Only 64-bit is supported for now
+    if (m_binary->fileHeader64()->Magic == XCOFF::XCOFF64)
+      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 {
+
+  /* TODO: Need to handle 32-bit support, until then
+   * return 8 for 64-bit XCOFF::XCOFF64 */
----------------
DhruvSrivastavaX wrote:

Sure, that should be better.

https://github.com/llvm/llvm-project/pull/116338


More information about the lldb-commits mailing list