This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: shared library patch for SCO OpenServer 5.0.5 & egcs


Arturo Montes wrote:

> I am sending a patch to fix SCO shared library problem static
> constructor/destructor.

This patch is incomplete but it does summarize the problem.   

The problem is that ctors and dtors in .so's that are dlopened are never
executed.  The correct .init and .fini sections are built in the ELF
images but since there are no symbols for _init and _fini the dynamic
linker (startups?) will never execute the code.

Arturo fixed this by taking a tiny .S, linking it first, and sticking
the symbols at the front of the sections when linking.

        .section        .init
        .globl _init
_init:
        .section        .fini
        .globl _fini
_fini:

*** sco5.h      Fri Feb 19 16:52:00 1999
--- sco5.h.ori  Mon Feb  8 20:38:03 1999
***************
*** 816,823 ****

  #undef STARTFILE_SPEC
  #define STARTFILE_SPEC \
!  "%{shared: crt1begin.o%s} \
!   %{!shared:\               
     %{!symbolic: \
      %{pg:gcrt.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}} \
    %{ansi:values-Xc.o%s} \                                
--- 816,822 ----           

  #undef STARTFILE_SPEC
  #define STARTFILE_SPEC \
!  "%{!shared:\           
     %{!symbolic: \
      %{pg:gcrt.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}} \
    %{ansi:values-Xc.o%s} \                                

In SVR{4,5}, this seems to be exactly what's done by 'crti.o'.  It seems
to be what's done in sol2-ci.asm.  (Arturo, do your test cases work
under EGCS for UnixWare on UnixWare or EGCS for UDK on OpenServer?)

Should we just modify the OpenServer build environment to build
sol2-ci.asm and install it as crti.o in our libdir?  Should we include
Arturo's .asm as a separate file and wire that into the builds?  Should
we just get these symbols slipped into crtstuff.o via INIT_SECTION_ASM_OP
perhaps combined with the test that's already there for CRT_BEGIN?

RJL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]