Lies in education [was Re: The "loop and a half"]
bartc
bc at freeuk.com
Fri Oct 13 09:00:53 EDT 2017
On 13/10/2017 12:49, Peter J. Holzer wrote:
> On 2017-10-13 10:37, Steve D'Aprano <steve+python at pearwood.info> wrote:
>> or written by a dedicated hardware device:
>>
>> https://en.wikipedia.org/wiki/Programmable_read-only_memory
>
> And in this case there will be a tool which will read the object file
> and send the contents of the read-only sections to the device which
> writes the ((E)E)PROM.
First time I did this was with a home-made programmer directly connected
to a keyboard. I had to press the right key to generate the 7-bit
pattern I wanted (I can't remember what I did about the 8th bit), burn
it into the current location then step the address counter to the next.
No mistakes were tolerated. It worked.
> And finally, the most frequent case: The OS will will read the
> executable into RAM, mark those pages from the read-only sections as
> read-only in the page table and start it.
Or as I did it, on a home-made computer with two banks of 16KB RAM, one
bank had the editor, compiler and source code, the other the generated
code. Just before running it, I would flip a switch to write-protect the
first bank in case something went wrong. (I didn't have floppies only
slow, unreliable tape, so things had to be memory-resident as much as
possible.)
And, actually, even now machines don't have that much control: you
create a large table of data at runtime, but it is still in writeable
memory, and accidental or malicious code could write into it.
No matter that the C source may have had a few consts sprinkled about.
(It's bit like those incredibly annoying anti-piracy messages and videos
you get on DVDS. No actual pirate would ever see them, only honest
people who have no intention of copying!)
Even if data is actually in write-protected memory, attempts to write to
it will cause a crash. On my home-made system, they just did nothing.
Much more graceful.
--
bartc
More information about the Python-list
mailing list