home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / wizards / 5230 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.9 KB  |  54 lines

  1. Newsgroups: comp.unix.wizards
  2. Path: sparky!uunet!mcsun!sunic!ericom!eos.ericsson.se!etxmesa
  3. From: etxmesa@eos.ericsson.se (Michael Salmon)
  4. Subject: Re: What is text, data & bss anyway?
  5. Message-ID: <1992Dec15.085938.5975@ericsson.se>
  6. Sender: news@ericsson.se
  7. Nntp-Posting-Host: eos6c02.ericsson.se
  8. Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
  9. Organization: Ericsson Telecom AB
  10. References:  <1992Dec14.234221.6644@saifr00.cfsat.honeywell.com>
  11. Date: Tue, 15 Dec 1992 08:59:38 GMT
  12. Lines: 40
  13.  
  14. In article <1992Dec14.234221.6644@saifr00.cfsat.honeywell.com>
  15. klaus@saifr00.cfsat.honeywell.com (Todd Klaus) writes:
  16. |> My collegues and I are experiencing some confusion as to the exact definition
  17. |> of the text, data and bss segments of a executable image on disk and how this
  18. |> changes when it is loaded into core memory.  My understanding (simplistic) is
  19. |> that the text segment is executable instructions, data is initialized data, and 
  20. |> bss is uinitialized data.  Is this correct?  Could someone please show me a code
  21. |> fragment showing what types of variables would fall into each category?  As an
  22. |> aside, does copy-on-write have anything to do with this scheme?
  23.  
  24. You are nearly correct:
  25.  
  26. text is read-only, loaded from disk
  27. data is read-write, loaded from disk
  28. bss is read-write, cleared at program start.
  29.  
  30. In gcc the following applies:
  31.  
  32. /* data */ char *s =
  33. /* text */           "abcd";
  34. /* bss  */ int i;
  35.  
  36. /* text */ main() { return 0; }
  37.  
  38. copy-on-write is a cheating system where data, heap, stack or, bss
  39. segments are marked read only on forking and copied only when one or
  40. the other process writes to them. It is used to avoid copying data on
  41. forking as the child process usually doesn't do much work, it basically
  42. just exec's another program.
  43.  
  44. -- 
  45.  
  46. Michael Salmon
  47.  
  48. #include    <standard.disclaimer>
  49. #include    <witty.saying>
  50. #include    <fancy.pseudo.graphics>
  51.  
  52. Ericsson Telecom AB
  53. Stockholm
  54.