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]
Other format: [Raw text]

Re: [PATCH] prevent warnings from -shared-libgcc on mips-irix


Hi Richard,

Back to this issue after a couple of, erm, interrupts.

This started at http://gcc.gnu.org/ml/gcc-patches/2008-06/msg00239.html,
about

    /* t.c */
    int main (void) { return 0; }

    $ gcc -o t t.c -shared-libgcc
    ld32: WARNING 85: definition of __gcc_init in
     .../4.4.0/irix-crti.o preempts that definition in
     .../4.4.0/../../../../lib32/libgcc_s.so.
    
    ld32: WARNING 85: definition of __gcc_fini in [...]
    ld32: WARNING 85: definition of __dso_handle in [...]

The initial suggestion was

   +++ iris6.h	(working copy)
   @@ -51,6 +51,7 @@
    #else
    #define IRIX_SUBTARGET_LINK_SPEC \
      "%{w} -_SYSTYPE_SVR4 -woff 131 \
   +   %{shared:-hidden_symbol __gcc_init,__gcc_fini,__dso_handle} \
       %{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"
    #endif

You answered

  << I'd prefer to add:

        .hidden __gcc_init
        .hidden __gcc_fini

     to irix-crti.asm. [...]

     Why doesn't the normal hiding of __dso_handle work?
  >>

The normal hiding relies on HAVE_GAS_HIDDEN, which requires support
from both the assembler and linker, and the linker was assumed not to
comply.  Claiming the linker is compliant yields to bootstrap failure,
with errors like

  <<    ld32: ERROR 33: Unresolved data symbol "__ctzdi2"
        -- 1st referenced by c-common.o.
  >>

This is caused by libgcc being compiled with -fvisibility=hidden
associated with the fact that the linker apparently doesn't drag
an object out of an archive only to satisfy references to hidden
symbols, unlike GNU ld on linux for instance.

Typically, from

   /* t.c */  
   void foo (void)
   {
   }

   /* m.c */
   extern void foo ();
   int main (void)
   {
     foo ();
     return 0;
   }

 $ gcc -S t.c
 $ [edit t.s to add ".hidden foo"]
 $ gcc -c t.s
 $ ar rv libt.a t.o

 $ gcc -save-temps -o m m.c libt.a
 ld32: WARNING 84: libt.a is not used for resolving any symbol.
 ld32: ERROR 33: Unresolved data symbol "foo" -- 1st referenced by m.o

I'm unclear on the intent here: could/should we compile with
-fvisibility=hidden only in the shared libgcc case ?

And if we do, what kind of linker support do we expect to expose the
symbols of relevance ?

In case you think this is good enough, the attached patch is the
simplest route out for the time being, moving the gcc_init/fini
handling into irix-crti.asm and leaving the dso_handle case as
--hidden argument.

Bootstrapped and regresstion tested on mips-sgi-irix6.5.

Thanks for your feedback,

Olivier

	2008-07-25  Olivier Hainque  <hainque@adacore.com>

	* config/mips/irix-crti.asm: .hide __gcc_init and __gcc_fini.
	* config/mips/iris6.h (IRIX_SUBTARGET_LINK_SPEC, irix ld): Hide
	__dso_handle explicitly here.

Attachment: irix-hidesyms.dif
Description: Text document


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