This is the mail archive of the glibc-bugs@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]

[Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias


Building a static libc using 2.3.5 causes symbols from malloc.c (namely free,
malloc, and realloc) to be exported as non-weak due to the use of strong_alias.
 This causes problems when trying to interpose these functions during a static
link with definitions from another object.  For example:

mbland:~/test/static_interpose$ cat > foo.c
#include <stddef.h>

void *
malloc (size_t unused)
{
  return 0;
}

int
main (void)
{
  (void) malloc (0);
  return 0;
}
mbland:~/test/static_interpose$ gcc foo.c
mbland:~/test/static_interpose$ gcc -static foo.c
/usr/lib/gcc/i486-linux-gnu/4.0.2/../../../../lib/libc.a(malloc.o): In function
`malloc':
: multiple definition of `malloc'
/tmp/ccCJFGaW.o:foo.c:(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `malloc' changed from 10 in /tmp/ccCJFGaW.o
to 397 in /usr/lib/gcc/i486-linux-gnu/4.0.2/../../../../lib/libc.a(malloc.o)
collect2: ld returned 1 exit status

This example works in both cases with glibc-2.3.2, as these symbols were defined
as weak in the 2.3.2 libc.a.  Though I'm currently using glibc-2.3.5, I've
noticed that the strong_alias instances still persist in the current CVS.

I've built a static glibc with all the strong_alias instances changed to
weak_alias, and successfully built a statically-linked executable with these
symbols interposed.

--- glibc-2.3.5-orig/malloc/malloc.c    2006-06-13 13:49:00.000000000 -0700
+++ glibc-2.3.5/malloc/malloc.c         2006-06-13 15:35:20.000000000 -0700
@@ -5566,11 +5566,11 @@ weak_alias (__posix_memalign, posix_mema

 strong_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc)
 strong_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree)
-strong_alias (__libc_free, __free) strong_alias (__libc_free, free)
-strong_alias (__libc_malloc, __malloc) strong_alias (__libc_malloc, malloc)
+strong_alias (__libc_free, __free) weak_alias (__libc_free, free)
+strong_alias (__libc_malloc, __malloc) weak_alias (__libc_malloc, malloc)
 strong_alias (__libc_memalign, __memalign)
 weak_alias (__libc_memalign, memalign)
-strong_alias (__libc_realloc, __realloc) strong_alias (__libc_realloc, realloc)
+strong_alias (__libc_realloc, __realloc) weak_alias (__libc_realloc, realloc)
 strong_alias (__libc_valloc, __valloc) weak_alias (__libc_valloc, valloc)
 strong_alias (__libc_pvalloc, __pvalloc) weak_alias (__libc_pvalloc, pvalloc)
 strong_alias (__libc_mallinfo, __mallinfo)

-- 
           Summary: malloc.c strong_alias for free, malloc, realloc should
                    be weak_alias
           Product: glibc
           Version: 2.3.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: mbland at google dot com
                CC: glibc-bugs at sources dot redhat dot com,mec at google
                    dot com
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i486-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=2765

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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