Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!umd5!eneevax!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: data in text segment and 4BSD Message-ID: <11705@mimsy.UUCP> Date: 28 May 88 04:40:26 GMT References: <3813@lynx.UUCP> <523@unh.UUCP> <688@vsi.UUCP> Distribution: na Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 26 In article <688@vsi.UUCP> friedl@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@mimsy.umd.edu Path: uunet!mimsy!chris