delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/09/22:10:11

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199707100209.AA214490589@typhoon.rose.hp.com>
Subject: ctor ?
To: djgpp AT delorie DOT com
Date: Wed, 09 Jul 1997 19:09:48 PDT


 
 Hello - 
 
 Could someone explain how the .ctor section works for DJGPP 
 and if it actually works OK?
 
 I can see from the linker script /lib/djgpp.djl that 
 it appears to expect (or allow) a .ctor section to be present in the coff 
 file and that it does move it into the djgpp_ctor section.  However, 
 it can't get it to (or tell if it is) work properly.
 
 If I compile the following code
 
 #include <stdio.h>
 int f()
 {
 return 5;
 }
 
 int x = f();
 
 main()
 {
 printf("x = %d\n",x);
 return 0;
 }
 
 As C the compiler complains that it is using a non-constant initializer.
 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
 like, just to test ctor.

 But if I use the c++ parser then I do get a 
 
 __GLOBAL_$I$f__Fv 
 
 function defined with proper code and a corresponding
 
 .section .ctor
 .long __GLOBAL_$I$f__Fv 
 
 At the end of the assembly file.

 My tests by running the executable and looking at the results (x = 0)
 and by loading into gdb and trying to break on the function (never broke)
 seem to indicate that the ctor is not being called.

 Thanks in advance
 
 Andrew
 
 
 
 
 

 
 

- Raw text -


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