LLDB: API for iPermission of object file's sections

Summary:
 - Added an API to public interface that provides permissions (RWX) of
   individual sections of an object file
   
 - Earlier, there was no way to find out this information through SB
   APIs
    
 - A possible use case of this API is:
   when a user wants to know the sections that have executable machine
   instructions and want to write a tool on top of LLDB based on this
   information

 - Differential Revision: https://reviews.llvm.org/D24251

llvm-svn: 280924
This commit is contained in:
Abhishek Aggarwal
2016-09-08 12:22:56 +00:00
parent 2a526feec9
commit 3c7f070956
3 changed files with 27 additions and 0 deletions

View File

@@ -53,6 +53,21 @@ public:
SectionType GetSectionType();
//------------------------------------------------------------------
/// Gets the permissions (RWX) of the section of the object file
///
/// Returns a mask of bits of enum lldb::Permissions for this section.
/// Sections for which permissions are not defined, 0 is returned for
/// them. The binary representation of this value corresponds to [XRW]
/// i.e. for a section having read and execute permissions, the value
/// returned is 6
///
/// @return
/// Returns an unsigned value for Permissions for the section.
//------------------------------------------------------------------
uint32_t
GetPermissions() const;
//------------------------------------------------------------------
/// Return the size of a target's byte represented by this section
/// in numbers of host bytes. Note that certain architectures have

View File

@@ -90,6 +90,9 @@ public:
SectionType
GetSectionType ();
uint32_t
GetPermissions() const;
%feature("docstring", "
//------------------------------------------------------------------
/// Return the size of a target's byte represented by this section

View File

@@ -188,6 +188,15 @@ SectionType SBSection::GetSectionType() {
return eSectionTypeInvalid;
}
uint32_t
SBSection::GetPermissions() const
{
SectionSP section_sp(GetSP());
if (section_sp)
return section_sp->GetPermissions();
return 0;
}
uint32_t SBSection::GetTargetByteSize() {
SectionSP section_sp(GetSP());
if (section_sp.get())