From patchwork Fri May 16 18:45:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Bilka X-Patchwork-Id: 978 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 2AD0E360098 for ; Fri, 16 May 2014 11:46:07 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14307373) id B1D5D5A2A73D; Fri, 16 May 2014 11:46:06 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 90C8D5A2A76C for ; Fri, 16 May 2014 11:46:06 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=aAlF zP8eHb0CTnAxeHkwmUoxacV/CnmhdreduhjDlF3XWHmvvmEVGGP7+AHYaYV3s9Jx scKbc/Q7am15DzvzfFRmKvHCYpG2yLZeCZle+DgaguYzV9S0/PlWXR0/OtpR7cp9 af15o2ikGLChtFl1VpbYEBdIF14jzZdKjdqnwG4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=V+1MtNBRnM L3RJGqgH/hrHgFqO8=; b=Jis9t0BBdyEedNaKDEzgefjvm/upOOyCo5uFvj3tdu 5sAb+QFNCedLVKRxljHGrJAe3vR8mRRluTapwMNldYJUmn3QwqT+xq2ZSpIp13vd 71tGn+2Bl3shdqzFNLEhSJKcKFFxfuGPjdEjESCKHENSbj2PXp1QE7wn11UYvIL5 g= Received: (qmail 24282 invoked by alias); 16 May 2014 18:45:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 24195 invoked by uid 89); 16 May 2014 18:45:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Fri, 16 May 2014 20:45:37 +0200 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: "Joseph S. Myers" Cc: Roland McGrath , libc-alpha@sourceware.org Subject: Re: [PATCH v1.2] Deprecate malloc_(sg)et state. Message-ID: <20140516184537.GA5856@domone.podge> References: <20140304123542.GA12375@domone.podge> <20140314170541.EF58A74495@topped-with-meat.com> <20140324092658.GA3973@domone.podge> <20140324221550.649EA74484@topped-with-meat.com> <20140428110349.GA23227@domone.podge> <20140428150007.GA5597@domone.podge> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-DH-Original-To: glibc@patchwork.siddhesh.in On Mon, Apr 28, 2014 at 03:07:20PM +0000, Joseph S. Myers wrote: > On Mon, 28 Apr 2014, Ondrej Bilka wrote: > > > On Mon, Apr 28, 2014 at 02:55:18PM +0000, Joseph S. Myers wrote: > > > On Mon, 28 Apr 2014, Ondrej Bilka wrote: > > > > > > > + malloc_get_state = dlvsym (RTLD_NEXT, "malloc_get_state", "GLIBC_2.2.5"); > > > > + malloc_set_state = dlvsym (RTLD_NEXT, "malloc_set_state", "GLIBC_2.2.5"); > > > > > > That's not correct. GLIBC_2.2.5 is what GLIBC_2.0 maps to on x86_64, but > > > on other architectures it maps to other versions; you need the correct > > > version depending on the architecture. > > > > > Any macro for that? > > Try stringizing the expansion of VERSION_libc_GLIBC_2_0 from > abi-versions.h. > Here is new version. Is there some other concern? * malloc/malloc.c: Make malloc_get_state and malloc_set_state compatibility symbols. * malloc/hooks.c: Likewise. * malloc/tst-mallocstate.c (main): Use dynamic loader to get malloc_get_state and malloc_set_state symbols. * malloc/Makefile: Link tst-mallocstate with libdl. diff --git a/malloc/Makefile b/malloc/Makefile index d962331..2c3bf06 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -149,6 +149,7 @@ $(objpfx)memusage: memusage.sh # The implementation uses `dlsym' $(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so +$(objpfx)tst-mallocstate: $(common-objpfx)dlfcn/libdl.so # Extra dependencies $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c diff --git a/malloc/hooks.c b/malloc/hooks.c index 00ee6be..442983e 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -474,6 +474,8 @@ struct malloc_save_state unsigned long narenas; }; +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_20) + void * __malloc_get_state (void) { @@ -644,6 +646,7 @@ __malloc_set_state (void *msptr) (void) mutex_unlock (&main_arena.mutex); return 0; } +#endif /* * Local variables: diff --git a/malloc/malloc.c b/malloc/malloc.c index 1120d4d..575a241 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -5181,9 +5181,16 @@ strong_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt) weak_alias (__malloc_stats, malloc_stats) weak_alias (__malloc_usable_size, malloc_usable_size) weak_alias (__malloc_trim, malloc_trim) + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_20) + weak_alias (__malloc_get_state, malloc_get_state) weak_alias (__malloc_set_state, malloc_set_state) +compat_symbol (libc, malloc_get_state, malloc_get_state, GLIBC_2_0); +compat_symbol (libc, malloc_set_state, malloc_set_state, GLIBC_2_0); + +#endif /* ------------------------------------------------------------ History: diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c index 69c4500..709aaba 100644 --- a/malloc/tst-mallocstate.c +++ b/malloc/tst-mallocstate.c @@ -16,9 +16,16 @@ License along with the GNU C Library; if not, see . */ +#define _GNU_SOURCE +#include #include #include #include "malloc.h" +#include + +#define STRINGIFY(x) #x +#define STR_GLIBC_2_0 STRINGIFY (VERSION_libc_GLIBC_2_0) + static int errors = 0; @@ -36,6 +43,12 @@ main (void) void *save_state; long i; + void *(*malloc_get_state)(); + void *(*malloc_set_state)(void ()); + + malloc_get_state = dlvsym (RTLD_NEXT, "malloc_get_state", STR_GLIBC_2_0); + malloc_set_state = dlvsym (RTLD_NEXT, "malloc_set_state", STR_GLIBC_2_0); + errno = 0; p1 = malloc (10);