delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/10/10:06:43

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199707101406.AA246653578@typhoon.rose.hp.com>
Subject: Re: ctor ?
To: Robert DOT Hoehne AT Mathematik DOT TU-Chemnitz DOT DE (Robert Hoehne)
Date: Thu, 10 Jul 1997 7:06:17 PDT
Cc: djgpp AT delorie DOT com
In-Reply-To: <33C4AEF0.3FE9@Mathematik.TU-Chemnitz.DE>; from "Robert Hoehne" at Jul 10, 97 11:44 am

> Your example and the ctor topic have nothing to do with each
> other.
It was my misunderstanding, the example code was meant to be C++
only, in which case ctor is used.
> 
> >  As C the compiler complains that it is using a non-constant initializer.
> Exact, and when I remember correct (I have not POSIX or ANSI documents)
> this is not allowed at all!
> 
> >  First I'm not sure if this is right.  I believe (2nd hand reference),
> >  that this works with linux gcc.  I wouldn't normally code something that
> 
> You are wrong. Here some output from a linux machine:
Yeah, I don't know what I read, checking the message that was sent to
me only c++ is mentioned.

As things turn out, I have gotten around the ctor problem and now 
have one linker related (which I will ask here, oh keeper of binutils :)

After just hearing from Eli about strange linker behaviour and not 
believing it entirely (may I never doubt him again!), 
something quite weird has
happened to me.  The replacement libgcc.a that I use as part of pgcc
has several things in it that the regular DJ does not.  One of them
is a __main.o file with a __main text symbol.  This is the same
symbol name as the function in DJs libc _main.o, which coincidentally
handlers running the ctors.  Anyway, the linker is linking in the 
__main file from libgcc, not libc.  I don't get this.  I am pretty
sure that the link line used in -lc -lgcc -lc, and even more confusing,
the linker map file shows this

Archive member included      because of file(symbol)

/djgpp/lib//libc.a(printf.o) test.o _printf)
/djgpp/lib/libc.a(_main.o)   test.o (___main)
<snip some stuff>
Linker script and memory map

LOAD test.o
LOAD /djgpp/lib/crt0.o
LOAD /djgpp/lib//libc.a
LOAD /djgpp/lib//libgcc.a
LOAD /djgpp/lib//libc.a


I verified that the wrong __main is getting linked in by stepping through
the assembly.  If I manually link in a .o file with the proper __main
in it things work, and if I use ar to replace __main.o in libgcc.a with 
djs _main.o things work.  I just don't understand why the libgcc version
in being picked up.

Thanks for the help

Andrew

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019