Re: using mprotect to write to .text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/10/2011 01:02 PM, Joe Buehler wrote:
I intend to use mprotect in a running binary to allow it to modify its .text
section.  The detailed behavior of mprotect for a multithreaded program on SMP
hardware is not documented as far as I can tell.

It is well documented. What is not well defined is what happens if you modify the code and then try to execute it.


Can I depend on the LINUX mprotect call to take care of icache flushing,
handling of hazards, etc.?

No, it does nothing of the sort.  You need cacheflush() for that.

 I am using Octeon CN5650 on 2.6.21.7 and 2.6.27.7 if
it matters.

It doesn't really matter.

What you need is something like:

#include <sys/cachectl.h>
.
.
.


cacheflush(location, size, ICACHE);
.
.
.

David Daney



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux