hotspot/src/share/vm/utilities/elfFile.cpp
changeset 15926 8e87d545195f
parent 13963 e5b53c306fb5
child 22857 2167396cfc83
child 22234 da823d78ad65
--- a/hotspot/src/share/vm/utilities/elfFile.cpp	Tue Mar 05 08:50:59 2013 +0100
+++ b/hotspot/src/share/vm/utilities/elfFile.cpp	Tue Mar 05 13:55:56 2013 -0800
@@ -197,4 +197,28 @@
   return NULL;
 }
 
+#ifdef LINUX
+bool ElfFile::specifies_noexecstack() {
+  Elf_Phdr phdr;
+  if (!m_file)  return true;
+
+  if (!fseek(m_file, m_elfHdr.e_phoff, SEEK_SET)) {
+    for (int index = 0; index < m_elfHdr.e_phnum; index ++) {
+      if (fread((void*)&phdr, sizeof(Elf_Phdr), 1, m_file) != 1) {
+        m_status = NullDecoder::file_invalid;
+        return false;
+      }
+      if (phdr.p_type == PT_GNU_STACK) {
+        if (phdr.p_flags == (PF_R | PF_W))  {
+          return true;
+        } else {
+          return false;
+        }
+      }
+    }
+  }
+  return false;
+}
+#endif
+
 #endif // _WINDOWS