[llvm-dev] SectionMemoryManager::finalizeMemory ... read only data become executable?

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Sat Jul 15 05:55:09 PDT 2017


Hi Michal,

2017-07-15 19:57 GMT+08:00 Michal Srb <msrb at suse.com>:
> On Saturday, 15 July 2017 05:46:35 CEST 陳韋任  wrote:
>> SectionMemoryManager allocates executable memory section for MCJIT
>> (JIT emit code then execute).
>> So the bottomline is making the section sys::Memory::MF_EXEC. As for
>> RODataMem, we also need
>> to make sure it's read-only. You can compare it to RWDataMem, which
>> has write permission.
>
> That makes sense. My question is why is RODataMem made READ and EXEC? It
> sounds like it should be only READ.

I guess my reply is a little bit misleading. Since JIT will emit and
*execute* code in the memory,
the memory should be set as MF_EXEC at least. As RODataMem is
read-only, we should make
it MF_READ as well. I think MF_EXEC and MF_READ will be set after the
code is emitted.

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj


More information about the llvm-dev mailing list