I'd like to compile words to alternative memory locations for the
purpose of protecting them from unintended writes. This should never
happen in practice and of course this has _never_ happened to me, but
just in case I want to exclude this possibility for some of my
projects.
I modified Gforth's allot to to ignore the dictionary bounds check
and after that it happily compiles a word to a new mmap'd memory
location. After compilation I memory protect that region with
mprotect (PROT_READ PROT_EXEC or) and writes to that word are no
longer possible and it still works as intended. The code is quite >uninteresting so I'll only post it on request.
Is there anything that would likely break because of this
is there alternatively a better way to
do this, ideally also protecting Gforth's own words too?
Similarily, is there a good use case for modifying words after
they've already been compiled? I'd like to hear your use cases.
I have considered it now and then, but never acted, because I did not >experience such problems, either, so the benefit is small, while the
cost exists.
Better to check the bounds of the new memory section. Development
Gforth definitely has support for that, because that's needed for
Gforth's sections.
I'll assume that you do this only for colon definitions, not for
variables etc.
There are some rarely-used features, such as the stepping debugger and >REPLACE-WORD which write to the code of colon definitions, and which
would break. Nothing else comes to my mind at the moment.
There is no need to use PROT_EXEC for threaded code.
Hello everyone.
I'd like to compile words to alternative memory locations for the
purpose of protecting them from unintended writes. This should never
happen in practice and of course this has _never_ happened to me, but
just in case I want to exclude this possibility for some of my projects.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 35:15:25 |
Calls: | 6,707 |
Files: | 12,239 |
Messages: | 5,353,387 |