This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

__gmon_start__ symbol vs. dependencies between shared libraries


There is a problem in the SH code, illustrated here in context of the
elf/order2 test.  A false dependency is induced that later on prevents
dlclose from unloading shared libraries.

    $ LD_DEBUG=all ./order2 --direct
    [...]
         27997:     calling init: ./order2mod3.so
         27997:     
         27997:     symbol=__gmon_start__;  lookup in file=/home/thomas/tmp/order2-sh/order2 [0]
         27997:     symbol=__gmon_start__;  lookup in file=/lib/libdl.so.2 [0]
         27997:     symbol=__gmon_start__;  lookup in file=/lib/libc.so.6 [0]
         27997:     symbol=__gmon_start__;  lookup in file=/lib/ld-linux.so.2 [0]
         27997:     symbol=__gmon_start__;  lookup in file=/home/thomas/tmp/order2-sh/order2mod1.so [0]
         27997:     
         27997:     file=/home/thomas/tmp/order2-sh/order2mod1.so [0];  needed by ./order2mod3.so [0] (relocation dependency)
         27997:     
         27997:     binding file ./order2mod3.so [0] to /home/thomas/tmp/order2-sh/order2mod1.so [0]: normal symbol `__gmon_start__'
    [...]

That is, __gmon_start__ is required for order2mod3.so, and is bound to
order2mod1.so's (weak) definition.  Correct would be that order2mod3.so
falls back to its *own* (weak) definition of it, unless the real
definition of this symbol is linked in through gcrt1.o.

The following tiny patch fixes this, and makes the following tests pass,
which failed previously: elf/reldep3.out, elf/neededtest.out,
elf/order2.out.


2009-12-01  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/sh/elf/initfini.c (__gmon_start__): Make it hidden.

Index: sysdeps/sh/elf/initfini.c
===================================================================
--- sysdeps/sh/elf/initfini.c	(revision 267788)
+++ sysdeps/sh/elf/initfini.c	(working copy)
@@ -1,5 +1,5 @@
 /* Special .init and .fini section support for SH.
-   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -106,6 +106,7 @@
 	.section .text\n\
 	.align 5\n\
 	.weak	__gmon_start__\n\
+	.hidden	__gmon_start__\n\
 	.type	__gmon_start__,@function\n\
 __gmon_start__:\n\
 	mov.l	r14,@-r15\n\


Regards,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


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