🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.misc.discuss
Article #2285

How do I add a new calling convention?

#2285
From: Greg Gerard
Date: Sun, 31 May 1998 00:00
31 lines
2188 bytes
I would like to experiment with calling conventions on the i386
architecture using GCC.  I'm not sure where to start, though I've looked
over the code.

Basically, I wish to create a new shared library scheme for the i386,
modelling it very much after the MacOS PowerPC calling conventions and
shared library system.  This system allows a separate global data section
for an instance of a module, or can map the globals back to a shared set
of globals.  It looks very much like a call into a C++ object.  There is a
hidden data pointer passed along with the function call and any global
references that that function makes are made off of the pointer passed
in.  This data pointer may point to data among instantiations or it could
be individual.

In PowerPC, there is the notion of a TVector (transition vector) which is
a tuple consisting of a function pointer and a data pointer (one more is
allowed in the general case, but no one uses it.)  PPC ABIs declare a
specific register for putting this data pointer (RTOC -- Register Table of
Contents) which the x86 lacks (I'd just put it on the stack).  I'm not
terribly worried about efficiency (it is, after all, an experiment).  The
linker sets up the glue so the TOCs line up and the compiler generates
glue code which the linker fills in (typically at runtime).

Where do I start adding changes?  A function ptr is no longer a static
reference to code, but a reference to a TVector.  How do I make GCC fully
aware of things?   It's very similar to a C++ method call, but I'm not
sure how deep the similarities are.

thanks,
greg
Technical Details
Message-ID: <ggerard-3105981706540001@paltc4-194.flash.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,4f14f36914da03b9,start
X-Google-Attributes: gid11318c,public
X-Google-Thread: 1025b4,4f14f36914da03b9,start
X-Google-Attributes: gid1025b4,public
From: ggerard@flash.net (Greg Gerard)
Subject: How do I add a new calling convention?
Date: 1998/05/31
Message-ID: <ggerard-3105981706540001@paltc4-194.flash.net>
X-Deja-AN: 358301131
X-Face: 8b[O#_YSJ$C:ZMh\DC?"A`o]Q?"dT`YVBG~"#WND}\I0sYR,,M0]MC
Organization: Flashnet Communications, http://www.flash.net
Newsgroups: gnu.misc.discuss,gnu.gcc.help