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

Michal Srb via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 14 09:10:05 PDT 2017


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



More information about the llvm-dev mailing list