From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by sourceware.org (Postfix) with ESMTPS id 907563858405 for ; Mon, 15 Nov 2021 19:28:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 907563858405 Received: by mail-qv1-xf2c.google.com with SMTP id bu11so12145857qvb.0 for ; Mon, 15 Nov 2021 11:28:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=2mDassv6UzS2f5MzhiLrrNB7XvuELOGtM9h6nKPIlvA=; b=v4PKLdxJC8Jw/RRTaIyrmG7NfzEKms8v0zvRNWlpUnVLCyBjCVMCZGOCRHL3cWOI80 U6x8x8yzBDqDE4x6a8uZESR/bfSwHbAQetR6JV/WE4J4EGv9EmR/4hBfavdxzgkGq+Ya X9I4XKldbA+FJ6i3HI89wdSmwDAdGXqvzhXm5KkMAz/Bc9fp4fqmR11nPULPGfLC4WRq /QRbTX4Ztuqk9i3v4ZSK+AZMmun6wkFdSXmth4HfSceGQ7J/aj75Kh5wb4YSrowkafIN 7WLMlzbhGuqyPJa3o0zJxMQaKeLaHUw06OY+yUe2J3IZH5EA1GUbu+MT6eay0G3R+/Tl oF/Q== X-Gm-Message-State: AOAM532plZjYaOi5sSmxZycOFu1O7HkFzrjxi/3oA7yiGZTao2H8/fQv yczUNxfGB8MDwgzP9xXfeJTAug== X-Google-Smtp-Source: ABdhPJw5fkCRJw3kmD8WLlvJT1UKkaBC6mhKHs8KirhA27bdq4ohzLtz+k0D2FB1IdMeBSe+CrejSw== X-Received: by 2002:ad4:5f4c:: with SMTP id p12mr40353771qvg.11.1637004489182; Mon, 15 Nov 2021 11:28:09 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:66dc:13f5:e2fb:5a0d:90? ([2804:431:c7ca:66dc:13f5:e2fb:5a0d:90]) by smtp.gmail.com with ESMTPSA id i6sm7631900qkn.26.2021.11.15.11.28.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Nov 2021 11:28:09 -0800 (PST) Message-ID: <5111c6fb-eb97-d447-f553-a6a524ae0b10@linaro.org> Date: Mon, 15 Nov 2021 16:28:06 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH 2/3] elf: Introduce GLRO (dl_libc_freeres), called from __libc_freeres Content-Language: en-US To: Florian Weimer , libc-alpha@sourceware.org Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org References: <0722a1636d8ad26381b8e7092715d81749037f40.1635954168.git.fweimer@redhat.com> From: Adhemerval Zanella In-Reply-To: <0722a1636d8ad26381b8e7092715d81749037f40.1635954168.git.fweimer@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-15.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Nov 2021 19:28:11 -0000 Maybe add a comment why this is will be used. Reviewed-by: Adhemerval Zanella On 03/11/2021 13:27, Florian Weimer via Gcc-patches wrote: > --- > elf/Makefile | 2 +- > elf/dl-libc_freeres.c | 24 ++++++++++++++++++++++++ > elf/rtld.c | 1 + > malloc/set-freeres.c | 5 +++++ > sysdeps/generic/ldsodefs.h | 7 +++++++ > 5 files changed, 38 insertions(+), 1 deletion(-) > create mode 100644 elf/dl-libc_freeres.c > > diff --git a/elf/Makefile b/elf/Makefile > index cb9bcfb799..1c768bdf47 100644 > --- a/elf/Makefile > +++ b/elf/Makefile > @@ -68,7 +68,7 @@ elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \ > rtld-routines = rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal \ > dl-error-minimal dl-conflict dl-hwcaps dl-hwcaps_split dl-hwcaps-subdirs \ > dl-usage dl-diagnostics dl-diagnostics-kernel dl-diagnostics-cpu \ > - dl-mutex > + dl-mutex dl-libc_freeres > all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines) > > CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables Ok. > diff --git a/elf/dl-libc_freeres.c b/elf/dl-libc_freeres.c > new file mode 100644 > index 0000000000..68f305a6f9 > --- /dev/null > +++ b/elf/dl-libc_freeres.c > @@ -0,0 +1,24 @@ > +/* Deallocating malloc'ed memory from the dynamic loader. > + Copyright (C) 2021 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 > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > + > +void > +__rtld_libc_freeres (void) > +{ > +} Ok. > diff --git a/elf/rtld.c b/elf/rtld.c > index be2d5d8e74..847141e21d 100644 > --- a/elf/rtld.c > +++ b/elf/rtld.c > @@ -378,6 +378,7 @@ struct rtld_global_ro _rtld_global_ro attribute_relro = > ._dl_catch_error = _rtld_catch_error, > ._dl_error_free = _dl_error_free, > ._dl_tls_get_addr_soft = _dl_tls_get_addr_soft, > + ._dl_libc_freeres = __rtld_libc_freeres, > #ifdef HAVE_DL_DISCOVER_OSVERSION > ._dl_discover_osversion = _dl_discover_osversion > #endif Ok. > diff --git a/malloc/set-freeres.c b/malloc/set-freeres.c > index 5c19a2725c..856ff7831f 100644 > --- a/malloc/set-freeres.c > +++ b/malloc/set-freeres.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include "../nss/nsswitch.h" > #include "../libio/libioP.h" > @@ -67,6 +68,10 @@ __libc_freeres (void) > > call_function_static_weak (__libc_dlerror_result_free); > > +#ifdef SHARED > + GLRO (dl_libc_freeres) (); > +#endif > + > for (p = symbol_set_first_element (__libc_freeres_ptrs); > !symbol_set_end_p (__libc_freeres_ptrs, p); ++p) > free (*p); OK. > diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h > index 1318c36dce..c26860430c 100644 > --- a/sysdeps/generic/ldsodefs.h > +++ b/sysdeps/generic/ldsodefs.h > @@ -712,6 +712,10 @@ struct rtld_global_ro > namespace. */ > void (*_dl_error_free) (void *); > void *(*_dl_tls_get_addr_soft) (struct link_map *); > + > + /* Called from __libc_shared to deallocate malloc'ed memory. */ > + void (*_dl_libc_freeres) (void); > + > #ifdef HAVE_DL_DISCOVER_OSVERSION > int (*_dl_discover_osversion) (void); > #endif > @@ -1416,6 +1420,9 @@ __rtld_mutex_init (void) > } > #endif /* !PTHREAD_IN_LIBC */ > > +/* Implementation of GL (dl_libc_freeres). */ > +void __rtld_libc_freeres (void) attribute_hidden; > + > void __thread_gscope_wait (void) attribute_hidden; > # define THREAD_GSCOPE_WAIT() __thread_gscope_wait () > > OK.