Skip to content

Commit

Permalink
[ObjectFileXCOFF] Fix access to protected member 'GetSectionLoadList'…
Browse files Browse the repository at this point in the history
… in Target

- Added a public method to Target for accessing 'GetSectionLoadList' safely.
- Updated ObjectFileXCOFF to use the new public method, ensuring compliance
  with encapsulation rules.

This resolves the build error caused by direct access to the protected member.

Signed-off-by: ravindra shinde <ravindrarshinde212@ibm.com>
  • Loading branch information
ravindra shinde committed Jan 17, 2025
1 parent 68e0c4c commit 4fe42cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ class Target : public std::enable_shared_from_this<Target>,
eBroadcastBitSymbolsChanged = (1 << 5),
};


// These two functions fill out the Broadcaster interface:

static llvm::StringRef GetStaticBroadcasterClass();
Expand Down Expand Up @@ -1644,6 +1645,10 @@ class Target : public std::enable_shared_from_this<Target>,

TargetStats &GetStatistics() { return m_stats; }

public:
SectionLoadList &GetSectionLoadListPublic() {
return GetSectionLoadList();
}
protected:
/// Construct with optional file and arch.
///
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ bool ObjectFileXCOFF::SetLoadAddress(Target &target, lldb::addr_t value,
strcmp(section_sp->GetName().AsCString(), ".bss") == 0)
use_offset = true;

if (target.GetSectionLoadList().SetSectionLoadAddress(
if (target.GetSectionLoadListPublic().SetSectionLoadAddress(
section_sp, (use_offset ?
(section_sp->GetFileOffset() + value) : (section_sp->GetFileAddress() + value))))
++num_loaded_sections;
Expand Down Expand Up @@ -369,13 +369,13 @@ bool ObjectFileXCOFF::SetLoadAddressByType(Target &target, lldb::addr_t value,
SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
if (type_id == 1 && section_sp && strcmp(section_sp->GetName().AsCString(), ".text") == 0) {
if (!section_sp->IsThreadSpecific()) {
if (target.GetSectionLoadList().SetSectionLoadAddress(
if (target.GetSectionLoadListPublic().SetSectionLoadAddress(
section_sp, section_sp->GetFileOffset() + value))
++num_loaded_sections;
}
} else if (type_id == 2 && section_sp && strcmp(section_sp->GetName().AsCString(), ".data") == 0) {
if (!section_sp->IsThreadSpecific()) {
if (target.GetSectionLoadList().SetSectionLoadAddress(
if (target.GetSectionLoadListPublic().SetSectionLoadAddress(
section_sp, section_sp->GetFileAddress() + value))
++num_loaded_sections;
}
Expand Down

0 comments on commit 4fe42cd

Please sign in to comment.