public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias
@ 2006-06-14  7:52 mbland at google dot com
  2006-06-14 12:40 ` [Bug libc/2765] " dank at kegel dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: mbland at google dot com @ 2006-06-14  7:52 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/2765] malloc.c strong_alias for free, malloc, realloc should be weak_alias
  2006-06-14  7:52 [Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias mbland at google dot com
@ 2006-06-14 12:40 ` dank at kegel dot com
  2006-06-14 13:49 ` ian at airs dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: dank at kegel dot com @ 2006-06-14 12:40 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dank at kegel dot com


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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/2765] malloc.c strong_alias for free, malloc, realloc should be weak_alias
  2006-06-14  7:52 [Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias mbland at google dot com
  2006-06-14 12:40 ` [Bug libc/2765] " dank at kegel dot com
@ 2006-06-14 13:49 ` ian at airs dot com
  2006-06-17 16:56 ` drepper at redhat dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: ian at airs dot com @ 2006-06-14 13:49 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ian at airs dot com


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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/2765] malloc.c strong_alias for free, malloc, realloc should be weak_alias
  2006-06-14  7:52 [Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias mbland at google dot com
  2006-06-14 12:40 ` [Bug libc/2765] " dank at kegel dot com
  2006-06-14 13:49 ` ian at airs dot com
@ 2006-06-17 16:56 ` drepper at redhat dot com
  2006-06-17 19:35 ` dank at kegel dot com
  2009-03-12 22:07 ` geir at cray dot com
  4 siblings, 0 replies; 7+ messages in thread
From: drepper at redhat dot com @ 2006-06-17 16:56 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2006-06-17 16:56 -------
No.  You cannot replace just parts of the implementation.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/2765] malloc.c strong_alias for free, malloc, realloc should be weak_alias
  2006-06-14  7:52 [Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias mbland at google dot com
                   ` (2 preceding siblings ...)
  2006-06-17 16:56 ` drepper at redhat dot com
@ 2006-06-17 19:35 ` dank at kegel dot com
  2009-03-12 22:07 ` geir at cray dot com
  4 siblings, 0 replies; 7+ messages in thread
From: dank at kegel dot com @ 2006-06-17 19:35 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From dank at kegel dot com  2006-06-17 19:35 -------
But what about the use case of hooking malloc?
That requires the requested behavior, and yet it is
not replacing part of the implementation.

-- 


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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/2765] malloc.c strong_alias for free, malloc, realloc should be weak_alias
  2006-06-14  7:52 [Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias mbland at google dot com
                   ` (3 preceding siblings ...)
  2006-06-17 19:35 ` dank at kegel dot com
@ 2009-03-12 22:07 ` geir at cray dot com
  4 siblings, 0 replies; 7+ messages in thread
From: geir at cray dot com @ 2009-03-12 22:07 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From geir at cray dot com  2009-03-12 22:06 -------
This behavior prevents the TotalView memory debugging feature from working with
statically link codes:

$ cat main.c
int main() { }
$ gcc -static -g -L/opt/toolworks/totalview.8.6.0/linux-x86-64/lib
-ltvheap_cnl_static -lpthread main.c
/usr/lib/../lib64/libc.a(malloc.o): In function `free':
(.text+0x1c90): multiple definition of `free'
/opt/toolworks/totalview.8.6.0/linux-x86-64/lib/libtvheap_cnl_static.a:(.text+0x60d5):
first defined here
/usr/lib/../lib64/libc.a(malloc.o): In function `malloc':
(.text+0x3fe0): multiple definition of `malloc'
/opt/toolworks/totalview.8.6.0/linux-x86-64/lib/libtvheap_cnl_static.a:(.text+0x60e3):
first defined here
/usr/lib/../lib64/libc.a(malloc.o): In function `realloc':
(.text+0x4470): multiple definition of `realloc'
/opt/toolworks/totalview.8.6.0/linux-x86-64/lib/libtvheap_cnl_static.a:(.text+0x610d):
first defined here
collect2: ld returned 1 exit status
$

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |geir at cray dot com


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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/2765] malloc.c strong_alias for free, malloc, realloc should be weak_alias
       [not found] <bug-2765-131@http.sourceware.org/bugzilla/>
@ 2012-12-27 17:01 ` neleai at seznam dot cz
  0 siblings, 0 replies; 7+ messages in thread
From: neleai at seznam dot cz @ 2012-12-27 17:01 UTC (permalink / raw)
  To: glibc-bugs

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

Ondrej Bilka <neleai at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |neleai at seznam dot cz
         Resolution|WONTFIX                     |
         AssignedTo|drepper.fsp at gmail dot    |unassigned at sourceware
                   |com                         |dot org

--- Comment #4 from Ondrej Bilka <neleai at seznam dot cz> 2012-12-27 17:00:51 UTC ---
Any insight why is strong alias in malloc et. al. needed?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-12-27 17:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-14  7:52 [Bug libc/2765] New: malloc.c strong_alias for free, malloc, realloc should be weak_alias mbland at google dot com
2006-06-14 12:40 ` [Bug libc/2765] " dank at kegel dot com
2006-06-14 13:49 ` ian at airs dot com
2006-06-17 16:56 ` drepper at redhat dot com
2006-06-17 19:35 ` dank at kegel dot com
2009-03-12 22:07 ` geir at cray dot com
     [not found] <bug-2765-131@http.sourceware.org/bugzilla/>
2012-12-27 17:01 ` neleai at seznam dot cz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).