🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #460

GCC-2.2.2 modification to make DSEG register offset

#460
From: Tim Wilkinson
Date: Fri, 09 Oct 1992 14:16
38 lines
2044 bytes
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
Technical Details
Message-ID: <1992Oct9.141632.9447@city.cs>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!doc.ic.ac.uk!citycs!tim

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!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