Mercurial > hg > truffle
comparison src/share/vm/utilities/elfFile.cpp @ 8710:9058789475af
7107135: Stack guard pages are no more protected after loading a shared library with executable stack
Summary: Detect the execstack attribute of the loaded library and attempt to fix the stack guard using Safepoint op.
Reviewed-by: dholmes, zgu
Contributed-by: ioi.lam@oracle.com
author | iklam |
---|---|
date | Tue, 05 Mar 2013 13:55:56 -0800 |
parents | b9a9ed0f8eeb |
children | de6a9e811145 e7cbc95179c4 |
comparison
equal
deleted
inserted
replaced
8709:255c0a4cb4eb | 8710:9058789475af |
---|---|
195 p = p->m_next; | 195 p = p->m_next; |
196 } | 196 } |
197 return NULL; | 197 return NULL; |
198 } | 198 } |
199 | 199 |
200 #ifdef LINUX | |
201 bool ElfFile::specifies_noexecstack() { | |
202 Elf_Phdr phdr; | |
203 if (!m_file) return true; | |
204 | |
205 if (!fseek(m_file, m_elfHdr.e_phoff, SEEK_SET)) { | |
206 for (int index = 0; index < m_elfHdr.e_phnum; index ++) { | |
207 if (fread((void*)&phdr, sizeof(Elf_Phdr), 1, m_file) != 1) { | |
208 m_status = NullDecoder::file_invalid; | |
209 return false; | |
210 } | |
211 if (phdr.p_type == PT_GNU_STACK) { | |
212 if (phdr.p_flags == (PF_R | PF_W)) { | |
213 return true; | |
214 } else { | |
215 return false; | |
216 } | |
217 } | |
218 } | |
219 } | |
220 return false; | |
221 } | |
222 #endif | |
223 | |
200 #endif // _WINDOWS | 224 #endif // _WINDOWS |