From: Drew Eckhardt (drew@kinglear.cs.colorado.edu)
Date: 08/17/92


From: drew@kinglear.cs.colorado.edu (Drew Eckhardt)
Subject: Re: shared libs - can everyone be happy with this?
Date: 18 Aug 1992 02:30:10 GMT

In article <1992Aug17.152210.23427@riacs.edu> laredo@cc.gatech.edu (Nathan I. Laredo) writes:
>>|> Also, if we ever unbreak Linux, writing to code space should trigger
>>|> a segmentation fault - it's like it is now because the estdio library
>>|> was broken, and wrote to the code.
>> Does linux permit self modifying code (by design or bug)?

It doesn't trigger a segmentation fault if you write
to code - this is by design because allegedly the
estdio library (what we had before we got the BSD
stdio, then glibc) wrote to itS

>> This seems like a pretty bad ``feature''.

Agreed.

>
>Hopefully we won't start another nasty chain here.. but someone correct
>me if I'm wrong, but I've always been from the school that said that
>all static variables went into the code space, otherwise how would

Wrong.

"Static" variables are merely local to a object file, and not
accessable to the other object files at link time. They're
put into either DATA (which should follow on the next page
boundary after Text with an OMAGIC file, is contiguous on
an NMAGIC file and you can't protect code on that), if initialized,
or BSS if not, which follows data and is effectively the
same "segment" (I shouldn't say segment because of the intel
meaning - what I mean is DATA & BSS are treated the
same, only DATA is initialized and BSS is zero filled).

Constants are generally allocated in the CODE segment (or text,
although it's not an Intel segment, but rather a portion
of the process's address space that starts at 0 and runs until DATA
starts) - if you're 'C' compiler that assumes strings are
not writeable, and treats them as constant, you'll
run into problems with code that writes to constant strings.
That could have been the problem with estdio, I don't know
for certain.

-- 
Microsoft is responsible for propogating the evils it calls DOS and Windows, 
IBM for AIX (appropriately called Aches by those having to administer it), but neither is as bad as AT&T.  Boycott AT&T, and let them know how you feel.