QUESTION ON 2.95.2

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Fri Dec 31 23:54:00 GMT 1999


> Actually , as I was never very good in C++ I am reading a book 
> i.e. Deitel & Deitel as well as the classic book of 
> Stroustrup. But I am still unable to find why this is
> happening in the mozilla code. Maybe my linker doesnt 
> initialize correctly constrcutors some times? That is
> why I am asking about the issue of building gcc -2.95.2
> with -fgnu-linker or not.

I know nothing about DG/UX, I don't even know whether you are using
ix86-dg-dgux or m88k-dg-dgux.

Looking at the gcc sources, it seems that this is a standard SVR4
system, so constructions of globals should proceed in the following
way:

- the compiler emits into each file fragments of the .ctors and .dtors
  sections. Please inspect the assembler file in questions to verify
  that this is the case. Each fragment is a pointer to a function,
  performing some initialization.

- the system linker combines all these fragments into a single .ctors
  section. The compiler-supplied crtbegin.o and crtend.o also
  contribute to these sections, and provide the additional symbol
  __CTOR_LIST_. Using gcc -v, please verify that these objects are
  indeed linked into the executable. Using objdump (from binutils) or
  similar, please verify that the .ctors sections is correctly
  constructed, and that a .init section is present.

- At run-time, the operating system invokes the .init section. For
  gcc, this will run all constructors in the .ctors section.

As a first test, you might want to verify that the program

#include <stdio.h>

int flag;
struct A{
  A();
};

A a;

A::A(){
  flag = 1;
}

int main()
{
  if (flag)
    printf("PASS\n");
  else
    printf("FAIL\n");
}

prints "PASS". Then you might want to run the entire gcc testsuite to
see whether it works.

Please do not attempt to use collect2, unless you fully understand
what it is good for. As I've explained above, it should not be needed.

You may also want to contact DG/UX support groups; apparently gcc has
not been used for quite some time on this system.

Regards,
Martin



More information about the Gcc mailing list