Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lldb/include/lldb/Core/Section.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ class Section : public std::enable_shared_from_this<Section>,
/// return true.
bool ContainsOnlyDebugInfo() const;

/// Returns true if this is a global offset table section.
bool IsGOTSection() const;

protected:
ObjectFile *m_obj_file; // The object file that data for this section should
// be read from
Expand Down
6 changes: 6 additions & 0 deletions lldb/include/lldb/Symbol/ObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,12 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
return false;
}

/// Returns true if the section is a global offset table section.
virtual bool IsGOTSection(const lldb_private::Section &section) const {
assert(section.GetObjectFile() == this && "Wrong object file!");
return false;
}

/// Get a hash that can be used for caching object file releated information.
///
/// Data for object files can be cached between runs of debug sessions and
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Core/Section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ bool Section::ContainsOnlyDebugInfo() const {
return false;
}

bool Section::IsGOTSection() const {
return GetObjectFile()->IsGOTSection(*this);
}

#pragma mark SectionList

SectionList &SectionList::operator=(const SectionList &rhs) {
Expand Down
14 changes: 14 additions & 0 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5922,6 +5922,20 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
return nullptr;
}

bool ObjectFileMachO::IsGOTSection(const lldb_private::Section &section) const {
assert(section.GetObjectFile() == this && "Wrong object file!");
SectionSP segment = section.GetParent();
if (!segment)
return false;

const bool is_data_const_got =
segment->GetName() == "__DATA_CONST" && section.GetName() == "__got";
const bool is_auth_const_ptr =
segment->GetName() == "__AUTH_CONST" &&
(section.GetName() == "__auth_got" || section.GetName() == "__auth_ptr");
return is_data_const_got || is_auth_const_ptr;
}

bool ObjectFileMachO::SectionIsLoadable(const Section *section) {
if (!section)
return false;
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class ObjectFileMachO : public lldb_private::ObjectFile {

lldb_private::Section *GetMachHeaderSection();

bool IsGOTSection(const lldb_private::Section &section) const override;

// PluginInterface protocol
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }

Expand Down
Loading