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

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 14 14:46:35 PDT 2017


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.

Regards,
chenwj

2017-07-15 0:10 GMT+08:00 Michal Srb via llvm-dev <llvm-dev at lists.llvm.org>:
> Hi,
>
> I am studying the llvm code and I noticed something that looks like a bug. If
> it is intentional for some reason, it is not obvious why.
>
> In lib/ExecutionEngine/SectionMemoryManager.cpp in
> SectionMemoryManager::finalizeMemory method:
>
> // Make code memory executable.
> ec = applyMemoryGroupPermissions(CodeMem,
>                                  sys::Memory::MF_READ | sys::Memory::MF_EXEC);
>
> ...
>
> // Make read-only data memory read-only.
> ec = applyMemoryGroupPermissions(RODataMem,
>                                  sys::Memory::MF_READ | sys::Memory::MF_EXEC);
>
>                                                         ^^^^^^^^^^^^^^^^^^^^^
>                                                      Why is this also MF_EXEC?
>
> Best regards,
> Michal Srb
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



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


More information about the llvm-dev mailing list