Subject: RE: C++ compiler wackyness. - hack
To: None <port-pmax@netbsd.org>
From: Michael L. Hitch <mhitch@lightning.oscs.montana.edu>
List: port-pmax
Date: 08/15/1998 20:37:48
On Aug 12, 10:44pm, mjbedy wrote:
> 
>   Ok, here's my hack to get c++ to work (your gonna love it).
> 
>   First, though, I have to say that this could screw something up - I
> don't know if it will mess things up if you're linking a shared library or
> not. (if someone could try it and let me know, I'd appreciate it.)
> 
>   Now for the hack:
...
>   When it breaks something, let me know. (It works for simple programs,
> and doesn't seem to adversly effect gcc, but it certainy doesn't mean it
> won't break something else.)

  There is a library routine someplace [I think it's __main.o in libgcc.a]
that contains _do_global_ctors() and __do_global_dtors(), which is where
the segment violation occurs.  A "simple" work-around that wouldn't be much
worse than defining dummy CTOR and DTOR lists would be to replace that
file with dummy routines that don't do anything.

  The work-arounds will most likely cause problems when trying to do
anything that requires the constructors and destructors routines.  The
only way I can see to currently have this work right is to create
static executables [-static linker option].  Replacing the existing
_do_global_?tors() routines would also cause this to fail, although it
may work to keep a copy of the __main.o file around to explicitly include
in the static link.

  The real fix will probalby require some significant changes to ld,
which is a bit beyond my expertise at the moment.  [I've tried a few things
with the shared libraries, but I wasn't able to get any of them to work.]

Michael

-- 
Michael L. Hitch			mhitch@montana.edu
Computer Consultant
Information Technology Center
Montana State University	Bozeman, MT	USA