home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / gnu / gcc / help / 2289 < prev    next >
Encoding:
Text File  |  1992-10-09  |  1.9 KB  |  50 lines

  1. Newsgroups: gnu.gcc.help
  2. Path: sparky!uunet!stanford.edu!agate!doc.ic.ac.uk!citycs!tim
  3. From: tim@cs.city.ac.uk (Tim Wilkinson)
  4. Subject: GCC-2.2.2 modification to make DSEG register offset
  5. Message-ID: <1992Oct9.141632.9447@city.cs>
  6. Sender: news@city.cs (News)
  7. Organization: SARC, City University
  8. X-Newsreader: Tin 1.1 PL5
  9. Date: Fri, 9 Oct 92 14:16:32 GMT
  10. Lines: 38
  11.  
  12. Myself and others at City University are working on an operating system
  13. project and are using GCC and G++ to develop our applications.  However,
  14. we need to convert the compiler to make all references to data (ie. the
  15. stuff in the .data section) to be made relative to a global register.  This
  16. allows us to execute the same program many times in the same address space
  17. whilst sharing the code.  The data is duplicated to different address, the
  18. global register being altered as appropriate.
  19.  
  20. All works well except for one case.  For example:
  21.  
  22. file.c:-
  23. =========================================================================
  24. int a;
  25. int *b = &a;
  26.  
  27. func()
  28. {
  29.     ....
  30. }
  31. =========================================================================
  32.  
  33. In the above, the address of external `a' should be compiled into the program
  34. in external `b'.  However, this cannot now be done because the data segments
  35. actual address is unknown until the program is executed.
  36. The solution is to make `int *b = &a' into a global constructor (even in C!)
  37. so the assigment is done when the program is executed.  Unfortunately, I
  38. am not sufficiently familure with GCC to know how to do this (and I have
  39. made an attempt but considered it to be a hack so removed it again), and
  40. the documentation I have says little about changing anything but the
  41. compiler back-end.
  42.  
  43. Any suggestions of where/how to look/start/do it would be greatly appreciated.
  44.  
  45. Tim
  46. --
  47.   Tim Wilkinson                              E-mail: tim@cs.city.ac.uk
  48.   Systems Architecture Research Centre,         Fax: +44 71 477 8587
  49.   City University, London, UK.                  Tel: +44 71 477 8551
  50.