[Lldb-commits] [lldb] [lldb][AIX] XCOFF clang-format and other minor changes (PR #119892)
Dhruv Srivastava via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 13 08:11:11 PST 2024
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/119892
>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 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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
>From c4cf612d7a7c6fae876fdc05f92cb974c3825788 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Sun, 8 Dec 2024 12:47:01 -0600
Subject: [PATCH 06/12] Added parsing functions
---
.../ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 85 ++++---------------
.../ObjectFile/XCOFF/ObjectFileXCOFF.h | 12 +--
2 files changed, 17 insertions(+), 80 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 8416ba37970c39..bf142a13c3979a 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -8,12 +8,6 @@
//===----------------------------------------------------------------------===//
#include "ObjectFileXCOFF.h"
-
-#include <algorithm>
-#include <cassert>
-#include <cstring>
-#include <unordered_map>
-
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -35,6 +29,10 @@
#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/Object/XCOFFObjectFile.h"
#include "llvm/Support/MemoryBuffer.h"
+#include <algorithm>
+#include <cassert>
+#include <cstring>
+#include <unordered_map>
using namespace llvm;
using namespace lldb;
@@ -172,77 +170,24 @@ bool ObjectFileXCOFF::MagicBytesMatch(DataBufferSP &data_sp,
}
bool ObjectFileXCOFF::ParseHeader() {
+
+ bool retVal = false;
ModuleSP module_sp(GetModule());
if (module_sp) {
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)
- ParseXCOFFOptionalHeader(m_data, &offset);
+ 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 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.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;
-}
-
-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.AuxHeaderSize)
- *offset_ptr += (m_xcoff_header.AuxHeaderSize - (last_offset - init_offset));
- return true;
+ return retVal;
}
ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
index 4740be755dcb0b..0744e1c123ce60 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -10,16 +10,14 @@
#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_XCOFF_OBJECTFILEXCOFF_H
#define LLDB_SOURCE_PLUGINS_OBJECTFILE_XCOFF_OBJECTFILEXCOFF_H
-#include <cstdint>
-
-#include <vector>
-
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/UUID.h"
#include "lldb/lldb-private.h"
#include "llvm/Object/XCOFFObjectFile.h"
+#include <cstdint>
+#include <vector>
/// \class ObjectFileXCOFF
/// Generic XCOFF object file reader.
@@ -104,12 +102,6 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
typedef struct llvm::object::XCOFFAuxiliaryHeader64 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);
>From 2301092b77aa8c325f724ee6effb7e2781089575 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Wed, 11 Dec 2024 09:56:33 -0600
Subject: [PATCH 07/12] Addressing comments 1
---
.../ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 25 ++++++-------------
.../ObjectFile/XCOFF/ObjectFileXCOFF.h | 6 -----
2 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index bf142a13c3979a..b06926d842f55b 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -114,6 +114,7 @@ bool ObjectFileXCOFF::CreateBinary() {
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;
}
@@ -174,17 +175,8 @@ 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;
- }
+ if (m_binary->fileHeader64()->Magic == XCOFF::XCOFF64)
retVal = true;
- }
}
return retVal;
@@ -195,11 +187,10 @@ ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
bool ObjectFileXCOFF::IsExecutable() const { return true; }
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;
+
+ /* TODO: Need to handle 32-bit support, until then
+ * return 8 for 64-bit XCOFF::XCOFF64 */
+ return 8;
}
AddressClass ObjectFileXCOFF::GetAddressClass(addr_t file_addr) {
@@ -225,9 +216,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_binary->fileHeader64()->Flags & XCOFF::F_EXEC)
return eTypeExecutable;
- else if (m_xcoff_header.Flags & XCOFF::F_SHROBJ)
+ else if (m_binary->fileHeader64()->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 0744e1c123ce60..2d4f9f3f2dab80 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -98,10 +98,6 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
protected:
- typedef struct llvm::object::XCOFFFileHeader64 xcoff_header_t;
-
- typedef struct llvm::object::XCOFFAuxiliaryHeader64 xcoff_aux_header_t;
-
static lldb::WritableDataBufferSP
MapFileDataWritable(const lldb_private::FileSpec &file, uint64_t Size,
uint64_t Offset);
@@ -109,8 +105,6 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
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;
};
>From 5f6083a2b533facba36faf7853c53439354ff92f Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 13 Dec 2024 08:34:30 -0600
Subject: [PATCH 08/12] Comments
---
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index b06926d842f55b..22748cd92406a3 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -164,6 +164,8 @@ 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);
@@ -175,6 +177,7 @@ 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;
}
>From 1aef26058b83a78700a2e64bebccecc8127e6b7e Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 13 Dec 2024 09:46:30 -0600
Subject: [PATCH 09/12] Added clang-format changes
---
.../ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 67 ++-----------------
.../ObjectFile/XCOFF/ObjectFileXCOFF.h | 7 --
.../Shell/ObjectFile/XCOFF/basic-info.yaml | 2 +-
3 files changed, 7 insertions(+), 69 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 22748cd92406a3..e89bc3ec179ed1 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -79,45 +79,9 @@ 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) {
@@ -144,10 +108,9 @@ size_t ObjectFileXCOFF::GetModuleSpecifications(
static uint32_t XCOFFHeaderSizeFromMagic(uint32_t magic) {
switch (magic) {
- /* TODO: 32bit not supported yet
- case XCOFF::XCOFF32:
- return sizeof(struct llvm::object::XCOFFFileHeader32);
- */
+ // TODO: 32bit not supported yet
+ // case XCOFF::XCOFF32:
+ // return sizeof(struct llvm::object::XCOFFFileHeader32);
case XCOFF::XCOFF64:
return sizeof(struct llvm::object::XCOFFFileHeader64);
@@ -172,18 +135,7 @@ bool ObjectFileXCOFF::MagicBytesMatch(DataBufferSP &data_sp,
return XCOFFHeaderSizeFromMagic(magic) != 0;
}
-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;
-}
+bool ObjectFileXCOFF::ParseHeader() { return false; }
ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
@@ -191,8 +143,7 @@ bool ObjectFileXCOFF::IsExecutable() const { return true; }
uint32_t ObjectFileXCOFF::GetAddressByteSize() const {
- /* TODO: Need to handle 32-bit support, until then
- * return 8 for 64-bit XCOFF::XCOFF64 */
+ // 32-bit not supprted. return 8 for 64-bit XCOFF::XCOFF64
return 8;
}
@@ -218,13 +169,7 @@ UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
uint32_t ObjectFileXCOFF::GetDependentModules(FileSpecList &files) { return 0; }
-ObjectFile::Type ObjectFileXCOFF::CalculateType() {
- if (m_binary->fileHeader64()->Flags & XCOFF::F_EXEC)
- return eTypeExecutable;
- else if (m_binary->fileHeader64()->Flags & XCOFF::F_SHROBJ)
- return eTypeSharedLibrary;
- return eTypeUnknown;
-}
+ObjectFile::Type ObjectFileXCOFF::CalculateType() { return eTypeExecutable; }
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 2d4f9f3f2dab80..c0ce885f704241 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -68,8 +68,6 @@ 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;
@@ -101,11 +99,6 @@ class ObjectFileXCOFF : public lldb_private::ObjectFile {
static lldb::WritableDataBufferSP
MapFileDataWritable(const lldb_private::FileSpec &file, uint64_t Size,
uint64_t Offset);
-
-private:
- bool CreateBinary();
-
- std::unique_ptr<llvm::object::XCOFFObjectFile> m_binary;
};
#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_XCOFF_OBJECTFILE_H
diff --git a/lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml b/lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml
index 3c0037db36dbbc..761d66a6045d93 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: 0x0002
+ Flags: 0x0000
Sections:
- Name: .text
Address: 0x100000438
>From 675a4e198994ac2b9df6aa5ed04ec2f2fe02a714 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 13 Dec 2024 09:54:56 -0600
Subject: [PATCH 10/12] Cleanup
---
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index e89bc3ec179ed1..b82b6124d8eb3b 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -143,14 +143,10 @@ bool ObjectFileXCOFF::IsExecutable() const { return true; }
uint32_t ObjectFileXCOFF::GetAddressByteSize() const {
- // 32-bit not supprted. return 8 for 64-bit XCOFF::XCOFF64
+ // 32-bit not supported. return 8 for 64-bit XCOFF::XCOFF64
return 8;
}
-AddressClass ObjectFileXCOFF::GetAddressClass(addr_t file_addr) {
- return AddressClass::eUnknown;
-}
-
void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
bool ObjectFileXCOFF::IsStripped() { return false; }
>From da0e55ec2f2c9cb11d60d1eeb18864717cddf4c6 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 13 Dec 2024 10:05:26 -0600
Subject: [PATCH 11/12] Cleanup
---
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index b82b6124d8eb3b..f8b1017dbb56ff 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -127,7 +127,6 @@ 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;
@@ -142,7 +141,6 @@ ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
bool ObjectFileXCOFF::IsExecutable() const { return true; }
uint32_t ObjectFileXCOFF::GetAddressByteSize() const {
-
// 32-bit not supported. return 8 for 64-bit XCOFF::XCOFF64
return 8;
}
>From 88242f281237d82e263efa535ab7d4a062412beb Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Fri, 13 Dec 2024 10:09:38 -0600
Subject: [PATCH 12/12] Cleanup
---
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index f8b1017dbb56ff..564e92f3934be7 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -127,7 +127,6 @@ 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);
@@ -140,10 +139,7 @@ ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
bool ObjectFileXCOFF::IsExecutable() const { return true; }
-uint32_t ObjectFileXCOFF::GetAddressByteSize() const {
- // 32-bit not supported. return 8 for 64-bit XCOFF::XCOFF64
- return 8;
-}
+uint32_t ObjectFileXCOFF::GetAddressByteSize() const { return 8; }
void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
More information about the lldb-commits
mailing list