[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 Nov 29 10:36:34 PST 2024
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/116338
>From 0c63800bdcbadcfceed4c9a81305eda7d5a15960 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 15 Nov 2024 02:16:31 -0600
Subject: [PATCH 1/5] Added XCOFF Header Parsing
---
.../ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 126 +++++++++++++++++-
.../ObjectFile/XCOFF/ObjectFileXCOFF.h | 58 ++++++++
2 files changed, 181 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 3be900f9a4bc9f..c06ece4347822d 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -81,9 +81,44 @@ ObjectFile *ObjectFileXCOFF::CreateInstance(const lldb::ModuleSP &module_sp,
if (!objfile_up)
return nullptr;
+ // Cache xcoff binary.
+ if (!objfile_up->CreateBinary())
+ return nullptr;
+
+ if (!objfile_up->ParseHeader())
+ return nullptr;
+
return objfile_up.release();
}
+bool ObjectFileXCOFF::CreateBinary() {
+ if (m_binary)
+ return true;
+
+ Log *log = GetLog(LLDBLog::Object);
+
+ auto binary = llvm::object::XCOFFObjectFile::createObjectFile(
+ llvm::MemoryBufferRef(toStringRef(m_data.GetData()),
+ m_file.GetFilename().GetStringRef()),
+ file_magic::xcoff_object_64);
+ if (!binary) {
+ LLDB_LOG_ERROR(log, binary.takeError(),
+ "Failed to create binary for file ({1}): {0}", m_file);
+ return false;
+ }
+
+ // Make sure we only handle XCOFF format.
+ m_binary =
+ llvm::unique_dyn_cast<llvm::object::XCOFFObjectFile>(std::move(*binary));
+ if (!m_binary)
+ return false;
+
+ LLDB_LOG(log, "this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
+ this, GetModule().get(), GetModule()->GetSpecificationDescription(),
+ m_file.GetPath(), m_binary.get());
+ return true;
+}
+
ObjectFile *ObjectFileXCOFF::CreateMemoryInstance(
const lldb::ModuleSP &module_sp, WritableDataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
@@ -136,13 +171,92 @@ bool ObjectFileXCOFF::MagicBytesMatch(DataBufferSP &data_sp,
return XCOFFHeaderSizeFromMagic(magic) != 0;
}
-bool ObjectFileXCOFF::ParseHeader() { return false; }
+bool ObjectFileXCOFF::ParseHeader() {
+ ModuleSP module_sp(GetModule());
+ if (module_sp) {
+ std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
+ lldb::offset_t offset = 0;
+
+ if (ParseXCOFFHeader(m_data, &offset, m_xcoff_header)) {
+ m_data.SetAddressByteSize(GetAddressByteSize());
+ if (m_xcoff_header.auxhdrsize > 0)
+ ParseXCOFFOptionalHeader(m_data, &offset);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+bool ObjectFileXCOFF::ParseXCOFFHeader(lldb_private::DataExtractor &data,
+ lldb::offset_t *offset_ptr,
+ xcoff_header_t &xcoff_header) {
+ // FIXME: data.ValidOffsetForDataOfSize
+ xcoff_header.magic = data.GetU16(offset_ptr);
+ xcoff_header.nsects = data.GetU16(offset_ptr);
+ xcoff_header.modtime = data.GetU32(offset_ptr);
+ xcoff_header.symoff = data.GetU64(offset_ptr);
+ xcoff_header.auxhdrsize = data.GetU16(offset_ptr);
+ xcoff_header.flags = data.GetU16(offset_ptr);
+ xcoff_header.nsyms = data.GetU32(offset_ptr);
+ return true;
+}
+
+bool ObjectFileXCOFF::ParseXCOFFOptionalHeader(
+ lldb_private::DataExtractor &data, lldb::offset_t *offset_ptr) {
+ lldb::offset_t init_offset = *offset_ptr;
+ // FIXME: data.ValidOffsetForDataOfSize
+ m_xcoff_aux_header.AuxMagic = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.Version = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.ReservedForDebugger = data.GetU32(offset_ptr);
+ m_xcoff_aux_header.TextStartAddr = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.DataStartAddr = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.TOCAnchorAddr = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.SecNumOfEntryPoint = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.SecNumOfText = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.SecNumOfData = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.SecNumOfTOC = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.SecNumOfLoader = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.SecNumOfBSS = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.MaxAlignOfText = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.MaxAlignOfData = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.ModuleType = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.CpuFlag = data.GetU8(offset_ptr);
+ m_xcoff_aux_header.CpuType = data.GetU8(offset_ptr);
+ m_xcoff_aux_header.TextPageSize = data.GetU8(offset_ptr);
+ m_xcoff_aux_header.DataPageSize = data.GetU8(offset_ptr);
+ m_xcoff_aux_header.StackPageSize = data.GetU8(offset_ptr);
+ m_xcoff_aux_header.FlagAndTDataAlignment = data.GetU8(offset_ptr);
+ m_xcoff_aux_header.TextSize = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.InitDataSize = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.BssDataSize = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.EntryPointAddr = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.MaxStackSize = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.MaxDataSize = data.GetU64(offset_ptr);
+ m_xcoff_aux_header.SecNumOfTData = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.SecNumOfTBSS = data.GetU16(offset_ptr);
+ m_xcoff_aux_header.XCOFF64Flag = data.GetU16(offset_ptr);
+ lldb::offset_t last_offset = *offset_ptr;
+ if ((last_offset - init_offset) < m_xcoff_header.auxhdrsize)
+ *offset_ptr += (m_xcoff_header.auxhdrsize - (last_offset - init_offset));
+ return true;
+}
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;
+}
+
+AddressClass ObjectFileXCOFF::GetAddressClass(addr_t file_addr) {
+ return AddressClass::eUnknown;
+}
void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
@@ -162,7 +276,13 @@ UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
uint32_t ObjectFileXCOFF::GetDependentModules(FileSpecList &files) { return 0; }
-ObjectFile::Type ObjectFileXCOFF::CalculateType() { return eTypeExecutable; }
+ObjectFile::Type ObjectFileXCOFF::CalculateType() {
+ if (m_xcoff_header.flags & XCOFF::F_EXEC)
+ return eTypeExecutable;
+ else if (m_xcoff_header.flags & XCOFF::F_SHROBJ)
+ return eTypeSharedLibrary;
+ return eTypeUnknown;
+}
ObjectFile::Strata ObjectFileXCOFF::CalculateStrata() { return eStrataUnknown; }
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
index 3a33b97b9e8da1..a155441135bfcb 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -70,6 +70,8 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
uint32_t GetAddressByteSize() const override;
+ lldb_private::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
+
void ParseSymtab(lldb_private::Symtab &symtab) override;
bool IsStripped() override;
@@ -98,9 +100,65 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
protected:
+ typedef struct xcoff_header {
+ uint16_t magic;
+ uint16_t nsects;
+ uint32_t modtime;
+ uint64_t symoff;
+ uint32_t nsyms;
+ uint16_t auxhdrsize;
+ uint16_t flags;
+ } xcoff_header_t;
+
+ typedef struct xcoff_aux_header {
+ uint16_t AuxMagic;
+ uint16_t Version;
+ uint32_t ReservedForDebugger;
+ uint64_t TextStartAddr;
+ uint64_t DataStartAddr;
+ uint64_t TOCAnchorAddr;
+ uint16_t SecNumOfEntryPoint;
+ uint16_t SecNumOfText;
+ uint16_t SecNumOfData;
+ uint16_t SecNumOfTOC;
+ uint16_t SecNumOfLoader;
+ uint16_t SecNumOfBSS;
+ uint16_t MaxAlignOfText;
+ uint16_t MaxAlignOfData;
+ uint16_t ModuleType;
+ uint8_t CpuFlag;
+ uint8_t CpuType;
+ uint8_t TextPageSize;
+ uint8_t DataPageSize;
+ uint8_t StackPageSize;
+ uint8_t FlagAndTDataAlignment;
+ uint64_t TextSize;
+ uint64_t InitDataSize;
+ uint64_t BssDataSize;
+ uint64_t EntryPointAddr;
+ uint64_t MaxStackSize;
+ uint64_t MaxDataSize;
+ uint16_t SecNumOfTData;
+ uint16_t SecNumOfTBSS;
+ uint16_t XCOFF64Flag;
+ } xcoff_aux_header_t;
+
+ static bool ParseXCOFFHeader(lldb_private::DataExtractor &data,
+ lldb::offset_t *offset_ptr,
+ xcoff_header_t &xcoff_header);
+ bool ParseXCOFFOptionalHeader(lldb_private::DataExtractor &data,
+ lldb::offset_t *offset_ptr);
+
static lldb::WritableDataBufferSP
MapFileDataWritable(const lldb_private::FileSpec &file, uint64_t Size,
uint64_t Offset);
+
+private:
+ bool CreateBinary();
+
+ xcoff_header_t m_xcoff_header;
+ xcoff_aux_header_t m_xcoff_aux_header;
+ std::unique_ptr<llvm::object::XCOFFObjectFile> m_binary;
};
#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_XCOFF_OBJECTFILE_H
>From 132418ff433eb684b23dcb7d6fa8374b774bb06c Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 15 Nov 2024 02:50:45 -0600
Subject: [PATCH 2/5] Added XCOFF Header Parsing
---
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index c06ece4347822d..b4b1603330d05d 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -191,6 +191,7 @@ bool ObjectFileXCOFF::ParseHeader() {
bool ObjectFileXCOFF::ParseXCOFFHeader(lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr,
xcoff_header_t &xcoff_header) {
+
// FIXME: data.ValidOffsetForDataOfSize
xcoff_header.magic = data.GetU16(offset_ptr);
xcoff_header.nsects = data.GetU16(offset_ptr);
@@ -199,12 +200,14 @@ bool ObjectFileXCOFF::ParseXCOFFHeader(lldb_private::DataExtractor &data,
xcoff_header.auxhdrsize = data.GetU16(offset_ptr);
xcoff_header.flags = data.GetU16(offset_ptr);
xcoff_header.nsyms = data.GetU32(offset_ptr);
+
return true;
}
bool ObjectFileXCOFF::ParseXCOFFOptionalHeader(
lldb_private::DataExtractor &data, lldb::offset_t *offset_ptr) {
lldb::offset_t init_offset = *offset_ptr;
+
// FIXME: data.ValidOffsetForDataOfSize
m_xcoff_aux_header.AuxMagic = data.GetU16(offset_ptr);
m_xcoff_aux_header.Version = data.GetU16(offset_ptr);
@@ -236,9 +239,11 @@ bool ObjectFileXCOFF::ParseXCOFFOptionalHeader(
m_xcoff_aux_header.SecNumOfTData = data.GetU16(offset_ptr);
m_xcoff_aux_header.SecNumOfTBSS = data.GetU16(offset_ptr);
m_xcoff_aux_header.XCOFF64Flag = data.GetU16(offset_ptr);
+
lldb::offset_t last_offset = *offset_ptr;
if ((last_offset - init_offset) < m_xcoff_header.auxhdrsize)
*offset_ptr += (m_xcoff_header.auxhdrsize - (last_offset - init_offset));
+
return true;
}
>From d1ee9b8754c109b58244b164a180f06e18e9daa7 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 15 Nov 2024 03:10:13 -0600
Subject: [PATCH 3/5] Added XCOFF Header Parsing
---
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 3 ---
1 file changed, 3 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index b4b1603330d05d..255171997db399 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -200,7 +200,6 @@ bool ObjectFileXCOFF::ParseXCOFFHeader(lldb_private::DataExtractor &data,
xcoff_header.auxhdrsize = data.GetU16(offset_ptr);
xcoff_header.flags = data.GetU16(offset_ptr);
xcoff_header.nsyms = data.GetU32(offset_ptr);
-
return true;
}
@@ -239,11 +238,9 @@ bool ObjectFileXCOFF::ParseXCOFFOptionalHeader(
m_xcoff_aux_header.SecNumOfTData = data.GetU16(offset_ptr);
m_xcoff_aux_header.SecNumOfTBSS = data.GetU16(offset_ptr);
m_xcoff_aux_header.XCOFF64Flag = data.GetU16(offset_ptr);
-
lldb::offset_t last_offset = *offset_ptr;
if ((last_offset - init_offset) < m_xcoff_header.auxhdrsize)
*offset_ptr += (m_xcoff_header.auxhdrsize - (last_offset - init_offset));
-
return true;
}
>From e9322c439ae5037d6fcfe54a67c7f9ea32d92ffa Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Thu, 28 Nov 2024 01:51:10 -0600
Subject: [PATCH 4/5] Using llvm XCOFF structures
---
.../ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 28 ++++++------
.../ObjectFile/XCOFF/ObjectFileXCOFF.h | 45 ++-----------------
2 files changed, 17 insertions(+), 56 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 255171997db399..8b541036d253a2 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -179,7 +179,7 @@ bool ObjectFileXCOFF::ParseHeader() {
if (ParseXCOFFHeader(m_data, &offset, m_xcoff_header)) {
m_data.SetAddressByteSize(GetAddressByteSize());
- if (m_xcoff_header.auxhdrsize > 0)
+ if (m_xcoff_header.AuxHeaderSize > 0)
ParseXCOFFOptionalHeader(m_data, &offset);
}
return true;
@@ -193,13 +193,13 @@ bool ObjectFileXCOFF::ParseXCOFFHeader(lldb_private::DataExtractor &data,
xcoff_header_t &xcoff_header) {
// FIXME: data.ValidOffsetForDataOfSize
- xcoff_header.magic = data.GetU16(offset_ptr);
- xcoff_header.nsects = data.GetU16(offset_ptr);
- xcoff_header.modtime = data.GetU32(offset_ptr);
- xcoff_header.symoff = data.GetU64(offset_ptr);
- xcoff_header.auxhdrsize = data.GetU16(offset_ptr);
- xcoff_header.flags = data.GetU16(offset_ptr);
- xcoff_header.nsyms = data.GetU32(offset_ptr);
+ xcoff_header.Magic = data.GetU16(offset_ptr);
+ xcoff_header.NumberOfSections = data.GetU16(offset_ptr);
+ xcoff_header.TimeStamp = data.GetU32(offset_ptr);
+ xcoff_header.SymbolTableOffset = data.GetU64(offset_ptr);
+ xcoff_header.AuxHeaderSize = data.GetU16(offset_ptr);
+ xcoff_header.Flags = data.GetU16(offset_ptr);
+ xcoff_header.NumberOfSymTableEntries = data.GetU32(offset_ptr);
return true;
}
@@ -239,8 +239,8 @@ bool ObjectFileXCOFF::ParseXCOFFOptionalHeader(
m_xcoff_aux_header.SecNumOfTBSS = data.GetU16(offset_ptr);
m_xcoff_aux_header.XCOFF64Flag = data.GetU16(offset_ptr);
lldb::offset_t last_offset = *offset_ptr;
- if ((last_offset - init_offset) < m_xcoff_header.auxhdrsize)
- *offset_ptr += (m_xcoff_header.auxhdrsize - (last_offset - init_offset));
+ if ((last_offset - init_offset) < m_xcoff_header.AuxHeaderSize)
+ *offset_ptr += (m_xcoff_header.AuxHeaderSize - (last_offset - init_offset));
return true;
}
@@ -249,9 +249,9 @@ ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
bool ObjectFileXCOFF::IsExecutable() const { return true; }
uint32_t ObjectFileXCOFF::GetAddressByteSize() const {
- if (m_xcoff_header.magic == XCOFF::XCOFF64)
+ if (m_xcoff_header.Magic == XCOFF::XCOFF64)
return 8;
- else if (m_xcoff_header.magic == XCOFF::XCOFF32)
+ else if (m_xcoff_header.Magic == XCOFF::XCOFF32)
return 4;
return 4;
}
@@ -279,9 +279,9 @@ UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
uint32_t ObjectFileXCOFF::GetDependentModules(FileSpecList &files) { return 0; }
ObjectFile::Type ObjectFileXCOFF::CalculateType() {
- if (m_xcoff_header.flags & XCOFF::F_EXEC)
+ if (m_xcoff_header.Flags & XCOFF::F_EXEC)
return eTypeExecutable;
- else if (m_xcoff_header.flags & XCOFF::F_SHROBJ)
+ else if (m_xcoff_header.Flags & XCOFF::F_SHROBJ)
return eTypeSharedLibrary;
return eTypeUnknown;
}
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
index a155441135bfcb..d45a0a18ff59a1 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -100,48 +100,9 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
protected:
- typedef struct xcoff_header {
- uint16_t magic;
- uint16_t nsects;
- uint32_t modtime;
- uint64_t symoff;
- uint32_t nsyms;
- uint16_t auxhdrsize;
- uint16_t flags;
- } xcoff_header_t;
-
- typedef struct xcoff_aux_header {
- uint16_t AuxMagic;
- uint16_t Version;
- uint32_t ReservedForDebugger;
- uint64_t TextStartAddr;
- uint64_t DataStartAddr;
- uint64_t TOCAnchorAddr;
- uint16_t SecNumOfEntryPoint;
- uint16_t SecNumOfText;
- uint16_t SecNumOfData;
- uint16_t SecNumOfTOC;
- uint16_t SecNumOfLoader;
- uint16_t SecNumOfBSS;
- uint16_t MaxAlignOfText;
- uint16_t MaxAlignOfData;
- uint16_t ModuleType;
- uint8_t CpuFlag;
- uint8_t CpuType;
- uint8_t TextPageSize;
- uint8_t DataPageSize;
- uint8_t StackPageSize;
- uint8_t FlagAndTDataAlignment;
- uint64_t TextSize;
- uint64_t InitDataSize;
- uint64_t BssDataSize;
- uint64_t EntryPointAddr;
- uint64_t MaxStackSize;
- uint64_t MaxDataSize;
- uint16_t SecNumOfTData;
- uint16_t SecNumOfTBSS;
- uint16_t XCOFF64Flag;
- } xcoff_aux_header_t;
+ typedef struct XCOFFFileHeader64 xcoff_header_t;
+
+ typedef struct XCOFFAuxiliaryHeader64 xcoff_aux_header_t;
static bool ParseXCOFFHeader(lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr,
>From b5c0110381b61ef5cdb97d2172a4c8fd2f11bcfa Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 29 Nov 2024 12:31:24 -0600
Subject: [PATCH 5/5] Adding llvm structure
---
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 1 +
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h | 8 ++++----
lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 8b541036d253a2..8416ba37970c39 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -177,6 +177,7 @@ bool ObjectFileXCOFF::ParseHeader() {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
lldb::offset_t offset = 0;
+ m_data.SetByteOrder(eByteOrderBig);
if (ParseXCOFFHeader(m_data, &offset, m_xcoff_header)) {
m_data.SetAddressByteSize(GetAddressByteSize());
if (m_xcoff_header.AuxHeaderSize > 0)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
index d45a0a18ff59a1..4740be755dcb0b 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -100,9 +100,9 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
protected:
- typedef struct XCOFFFileHeader64 xcoff_header_t;
+ typedef struct llvm::object::XCOFFFileHeader64 xcoff_header_t;
- typedef struct XCOFFAuxiliaryHeader64 xcoff_aux_header_t;
+ typedef struct llvm::object::XCOFFAuxiliaryHeader64 xcoff_aux_header_t;
static bool ParseXCOFFHeader(lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr,
@@ -117,8 +117,8 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
private:
bool CreateBinary();
- xcoff_header_t m_xcoff_header;
- xcoff_aux_header_t m_xcoff_aux_header;
+ xcoff_header_t m_xcoff_header = {};
+ xcoff_aux_header_t m_xcoff_aux_header = {};
std::unique_ptr<llvm::object::XCOFFObjectFile> m_binary;
};
diff --git a/lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml b/lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml
index 761d66a6045d93..3c0037db36dbbc 100644
--- a/lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml
+++ b/lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml
@@ -13,7 +13,7 @@ FileHeader:
MagicNumber: 0x1F7
NumberOfSections: 1
CreationTime: 000000000
- Flags: 0x0000
+ Flags: 0x0002
Sections:
- Name: .text
Address: 0x100000438
More information about the lldb-commits
mailing list