[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/22762] New: missing static variable constructor calls

From: ssbssa at yahoo dot de
Subject: [Bug ld/22762] New: missing static variable constructor calls
Date: Tue, 30 Jan 2018 17:00:43 +0000


            Bug ID: 22762
           Summary: missing static variable constructor calls
           Product: binutils
           Version: 2.30
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: ssbssa at yahoo dot de
  Target Milestone: ---

When trying a program as simple as that:
> #include <stdio.h>
> class Printer
> {
>   public:
>     Printer()
>     {
>       printf("Printer()\n");
>     }
> };
> static Printer printer;
> int main()
> {
>   return 0;
> }
No output is visible, because the static constructors are no longer called.

My investigation got me to this commit:

This added PROVIDE() to both __CTOR_LIST__ and __DTOR_LIST__, and the docu
(https://sourceware.org/binutils/docs/ld/PROVIDE.html) states:
> The PROVIDE keyword may be used to define a symbol, such as ‘etext’, only if 
> it is referenced but not defined.

But since it's already defined, it's no longer added by ld:
> $ g++ -ostatic-var.exe static-var.cpp -Wl,-T,static-var-ld.txt 
> -Wl,-y,___CTOR_LIST__
> c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.2.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-gccmain.o):
>  reference to ___CTOR_LIST__
> c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.2.0/libgcc.a(_ctors.o): 
> definition of ___CTOR_LIST__

I didn't find _ctors.c, but I think the definition is from here:

You are receiving this mail because:
You are on the CC list for the bug.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]