Subject: ELF

From: Matthew Wilcox <[email-masked]>
Date: Fri, 23 May 1997 17:20:48 +0100 (BST)

ELF.  Is the reason for mapping it in twice on the i386 in order to try
and write protect the text while leaving the data writable?  If so, that's
going to fail on the ARM.  In fact, it will fail quite badly. due to the
lack of internal cache snooping type stuff.  If a page is double-mapped,
both pages must be marked as uncacheable which will have a severe
performance hit.  I propose leaving the last page of text writable which
does mean that programs will be able to screw themselves up, but it's
better than having to take a protection violation trap and having to
figure out whether or not it's correct and do the write in the kernel if
it was correct.  The chances are fairly low anyway, i think, any program
which overwrites its own text is more likely to crash shortly than it is
to do something Undefined and Wrong.

One nice solution does present itself though.  On a ARM6+, we have
subpages which are 1k in size (assuming we're using 4k pages?)  It
wouldn't be hard (in fact I believe the RISCiX backend for the binutls
does it already) to persuade 1k alignment and it wouldn't waste too much
space.  Protection levels can be set on an individual subpage.

Oh, I guess that one possibility would be to physically copy the whole of
the last page.  But I'm very unkeen on that idea!