[Lldb-commits] [PATCH] D69102: COFF: Set section permissions

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 30 06:23:14 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1e0ae3420b6: COFF: Set section permissions (authored by labath).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D69102?vs=225403&id=227077#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69102/new/

https://reviews.llvm.org/D69102

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/ObjectFile/PECOFF/sections.yaml


Index: lldb/test/Shell/ObjectFile/PECOFF/sections.yaml
===================================================================
--- lldb/test/Shell/ObjectFile/PECOFF/sections.yaml
+++ lldb/test/Shell/ObjectFile/PECOFF/sections.yaml
@@ -7,7 +7,7 @@
 # CHECK-NEXT:   ID: 0xffffffffffffffff
 # CHECK-NEXT:   Name: PECOFF header
 # CHECK-NEXT:   Type: regular
-# CHECK-NEXT:   Permissions: ---
+# CHECK-NEXT:   Permissions: r--
 # CHECK-NEXT:   Thread specific: no
 # CHECK-NEXT:   VM address: 0x40000000
 # CHECK-NEXT:   VM size: 512
@@ -17,7 +17,7 @@
 # CHECK-NEXT:   ID: 0x1
 # CHECK-NEXT:   Name: .text
 # CHECK-NEXT:   Type: code
-# CHECK-NEXT:   Permissions: ---
+# CHECK-NEXT:   Permissions: r-x
 # CHECK-NEXT:   Thread specific: no
 # CHECK-NEXT:   VM address: 0x40001000
 # CHECK-NEXT:   VM size: 64
@@ -27,7 +27,7 @@
 # CHECK-NEXT:   ID: 0x2
 # CHECK-NEXT:   Name: .data
 # CHECK-NEXT:   Type: data
-# CHECK-NEXT:   Permissions: ---
+# CHECK-NEXT:   Permissions: r--
 # CHECK-NEXT:   Thread specific: no
 # CHECK-NEXT:   VM address: 0x40002000
 # CHECK-NEXT:   VM size: 64
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -797,6 +797,7 @@
         /*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 @@
           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);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69102.227077.patch
Type: text/x-patch
Size: 2332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191030/321ae630/attachment.bin>


More information about the lldb-commits mailing list