generate read-only code image in bootimage build

This avoids the requirement of putting the code image in a
section/segment which is both writable and executable, which is good
for security and avoids trouble with systems like iOS which disallow
such things.

The implementation relies on relative addressing such that the offset
of the desired address is fixed as a compile-time constant relative to
the start of the memory area of interest (e.g. the code image, heap
image, or thunk table).  At runtime, the base pointer to the memory
area is retrieved from the thread structure and added to the offset to
compute the final address.  Using the thread pointer allows us to
generate read-only, position-independent code while avoiding the use
of IP-relative addressing, which is not available on all
architectures.
This commit is contained in:
Joel Dice
2011-09-20 16:30:30 -06:00
parent 349d381d95
commit c537dcfd34
15 changed files with 478 additions and 416 deletions

View File

@ -3083,8 +3083,8 @@ class MyProcessor: public Processor {
abort(s);
}
virtual void boot(vm::Thread*, BootImage* image) {
expect(s, image == 0);
virtual void boot(vm::Thread*, BootImage* image, uint8_t* code) {
expect(s, image == 0 and code == 0);
}