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