Lies in education [was Re: The "loop and a half"]

Peter J. Holzer hjp-usenet3 at hjp.at
Fri Oct 13 07:49:07 EDT 2017


On 2017-10-13 10:37, Steve D'Aprano <steve+python at pearwood.info> wrote:
> On Fri, 13 Oct 2017 05:16 pm, Gregory Ewing wrote:
>> Steve D'Aprano wrote:
>>> On Fri, 13 Oct 2017 03:37 pm, Gregory Ewing wrote:
>>> 
>>>>If the compiler can tell where p is initially pointing, it could
>>>>put the pointer in read-only memory.
>>> 
>>> If it's read-only, how can the compiler write to it?
>>> 
>>> (I come from the days when ROM was actual ROM, burned in at the factory.)
>> 
>> So, the factory is allowed to write to it. Possibly
>> it's writing data that came from... a compiler?
>
> The data could come from anywhere, including a scanner:
>
> https://hackaday.com/2012/08/24/uncovering-easter-eggs-in-old-mac-roms/
>
> I wasn't questioning where the data came from, but how the compiler can write
> to READ ONLY MEMORY which might not even be in the same continent as the
> compiler that generated the code.

A compiler rarely writes into the final destination memory (JIT
compilers are the exception). It writes into a file. This file often has
sections like "code", "read-only data", etc. Another tool (maybe the
OS, maybe an EPROM burner) will later read this file and take
appropriate actions.

"the compiler could put the pointer in read-only memory" is just
shorthand for "the compile could put the pointer into one of the
read-only sections of the object file".


> Read-only memory (ROM) is typically burned into the silicon by the integrated
> chip manufacturer at the factory:
>
> https://en.wikipedia.org/wiki/Mask_ROM

In this case there will be tool (or more likely a whole tool-chain)
which takes the read-only sections of the object file and converts them
into a lithographic mask which will then be used to create chips. The
pointer will end up as a bunch of transistors.


> 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.

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.

> Whether the data is burned into the silicon or electrically written by a
> dedicated device, it isn't written by the compiler, and once written the data
> is permanent.

Did anyone claim that?

>> A memory that couldn't be written to at all, ever, would be a bit
>> useless!
>
> Macs used a ROM for at least a decade and probably more. The ROM contained
> data such as mouse cursors, toolbox routines, icons, sounds, and a
> bootloader. No Mac was capable of writing to their ROMs any more than they
> could write to their mouse or a CD-ROM.

Did anyone claim that?

        hp


-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp at hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel



More information about the Python-list mailing list