Re: instruction-space modification

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

 



Gerard Visser writes:

 > I was wondering if you could help me with a problem. I can't seem to find an
 > answer anywhere.
 > When I try to alter data in instruction space in a c-programme, like:
 > call 0
 > pop bx
 > mov byte ptr [bx+7], 3

This writes to memory at %ebx.  But %ebx points to write-protected
memory.

If you want to write-enable that memory, you have to ask your
operating system to make it possible.  That may or may not work: code
segments are usually write protected and shared between processes.

So, this is nothing to do with gcc, but with whatever OS you are
using.

 > shl ax, 2
 > 
 > I get a "segmentation fault" because of the third instruction.
 > Could you tell me how to avoid this, or where I could find literature that
 > explains these kinds of questions.
 > I'm trying to do this, because "shl ax, cl" is not pairable and much slower
 > than a shift with an immediate constant second operand.

Nothing like as slow as altering code segments, I suspect.  This
typically has a large overhead.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux