COFF: Set section permissions

Summary:
This enables us to reason about whether a given address can be
executable, for instance during unwinding.

Reviewers: amccarth, mstorsjo

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D69102
This commit is contained in:
Pavel Labath
2019-10-16 17:16:41 +02:00
parent 532815dd5c
commit f1e0ae3420
2 changed files with 13 additions and 3 deletions

View File

@@ -797,6 +797,7 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
/*file_offset*/ 0, m_coff_header_opt.header_size,
m_coff_header_opt.sect_alignment,
/*flags*/ 0);
header_sp->SetPermissions(ePermissionsReadable);
m_sections_up->AddSection(header_sp);
unified_section_list.AddSection(header_sp);
@@ -919,6 +920,15 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
m_coff_header_opt.sect_alignment, // Section alignment
m_sect_headers[idx].flags)); // Flags for this section
uint32_t permissions = 0;
if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
permissions |= ePermissionsExecutable;
if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_READ)
permissions |= ePermissionsReadable;
if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_WRITE)
permissions |= ePermissionsWritable;
section_sp->SetPermissions(permissions);
m_sections_up->AddSection(section_sp);
unified_section_list.AddSection(section_sp);
}