home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.wizards
- Path: sparky!uunet!mcsun!sunic!ericom!eos.ericsson.se!etxmesa
- From: etxmesa@eos.ericsson.se (Michael Salmon)
- Subject: Re: What is text, data & bss anyway?
- Message-ID: <1992Dec15.085938.5975@ericsson.se>
- Sender: news@ericsson.se
- Nntp-Posting-Host: eos6c02.ericsson.se
- Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
- Organization: Ericsson Telecom AB
- References: <1992Dec14.234221.6644@saifr00.cfsat.honeywell.com>
- Date: Tue, 15 Dec 1992 08:59:38 GMT
- Lines: 40
-
- In article <1992Dec14.234221.6644@saifr00.cfsat.honeywell.com>
- klaus@saifr00.cfsat.honeywell.com (Todd Klaus) writes:
- |> My collegues and I are experiencing some confusion as to the exact definition
- |> of the text, data and bss segments of a executable image on disk and how this
- |> changes when it is loaded into core memory. My understanding (simplistic) is
- |> that the text segment is executable instructions, data is initialized data, and
- |> bss is uinitialized data. Is this correct? Could someone please show me a code
- |> fragment showing what types of variables would fall into each category? As an
- |> aside, does copy-on-write have anything to do with this scheme?
-
- You are nearly correct:
-
- text is read-only, loaded from disk
- data is read-write, loaded from disk
- bss is read-write, cleared at program start.
-
- In gcc the following applies:
-
- /* data */ char *s =
- /* text */ "abcd";
- /* bss */ int i;
-
- /* text */ main() { return 0; }
-
- 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.
-
- --
-
- Michael Salmon
-
- #include <standard.disclaimer>
- #include <witty.saying>
- #include <fancy.pseudo.graphics>
-
- Ericsson Telecom AB
- Stockholm
-