home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!auspex-gw!guy
- From: guy@Auspex.COM (Guy Harris)
- Newsgroups: comp.unix.wizards
- Subject: Re: What is text, data & bss anyway?
- Message-ID: <15907@auspex-gw.auspex.com>
- Date: 15 Dec 92 19:34:30 GMT
- References: <1992Dec14.234221.6644@saifr00.cfsat.honeywell.com> <1992Dec15.085938.5975@ericsson.se>
- Sender: news@auspex-gw.auspex.com
- Organization: Auspex Systems, Santa Clara
- Lines: 37
- Nntp-Posting-Host: auspex.auspex.com
-
- >In gcc the following applies:
- >
- >/* data */ char *s =
- >/* text */ "abcd";
- >/* bss */ int i;
-
- What does GCC do with
-
- const char foo[] = "abcd";
-
- I.e., does it put it in the text or data segments? (Text segment, I
- hope.)
-
- >copy-on-write is a cheating system where data, heap, stack or, bss
- >segments are marked read only on forking and copied only when one or
- >the other process writes to them. It is used to avoid copying data on
- >forking as the child process usually doesn't do much work, it basically
- >just exec's another program.
-
- Actually, copy-on-write is, at least in some systems, not directly
- related to forking; that just happens to be one place where it buys you
- something. It may also be used, for example, to:
-
- 1) let you set a breakpoint in a process running a shared-text
- program or using a shared library, without screwing over
- anybody else using that program or library (the attempt to
- write the breakpoint causes a copy to be made; the process
- with the breakpoint uses the modified copy, and everybody
- else uses the unmodified copy);
-
- 2) allow the run-time loader to do relocation by modifying the
- text of a program or shared library (SunOS 4.x, SVR4 - you
- want to try to avoid having this happen, in general, as it
- reduces the amount of sharing).
-
- Also, in most systems these days, the entire segment isn't copied, just
- the pages that are actually written to.
-