data in text segment and 4BSD

Chris Torek chris at mimsy.UUCP
Sat May 28 14:40:26 AEST 1988


In article <688 at vsi.UUCP> friedl at vsi.UUCP (Stephen J. Friedl) writes:
>Be careful with [cc -R in 4BSD]: as I recall, *all* initialized statics
>go into the .text and are readonly.

Actually, all initialised data.  The `-R' flag is passed through to
the assembler, where it turns the four data segments into four
additional text segments.  I would like to see a compiler option
for readonly strings, which might put "string"s (but not variables
such as `static str[] = "stuff";') into `.text 1'.  In fact, I think
this should have been the default all along.  (So much for what I
think having any effect :-) .)

>...  My solution was to declare:
>
>        static int been_here;
>
>and rely on the initialization to zero; an uninitialized static
>always goes into the .bss.  This may have changed since 4.2.

No, it still works the same.

I like to write my own code so that it can be compiled with `-R',
but it does impose some rather unreasonable constraints for general
use.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list