From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64CC9C43387 for ; Sat, 22 Dec 2018 02:35:18 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94B9C218F0 for ; Sat, 22 Dec 2018 02:35:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94B9C218F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=petrovitsch.priv.at Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1gaX7r-00071m-Ph; Fri, 21 Dec 2018 21:34:51 -0500 Received: from esgaroth.petrovitsch.at ([78.47.184.11] helo=esgaroth.tuxoid.at) by shelob.surriel.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.91) (envelope-from ) id 1gaX7p-00071g-OV for kernelnewbies@kernelnewbies.org; Fri, 21 Dec 2018 21:34:50 -0500 Received: from thorin.petrovitsch.priv.at (80-110-99-3.cgn.dynamic.surfer.at [80.110.99.3]) (authenticated bits=0) by esgaroth.tuxoid.at (8.15.2/8.15.2) with ESMTPSA id wBM2YB7A020473 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Sat, 22 Dec 2018 03:34:13 +0100 Subject: Re: How to signal kernel that shared library is not in use by any process anymore ? To: Lev Olshvang , kernelnewbies , linux-il References: <965981545402036@sas1-2b3c3045b736.qloud-c.yandex.net> From: Bernd Petrovitsch Message-ID: <9b7fc566-1a6b-43c5-2ca2-415558533d0d@petrovitsch.priv.at> Date: Sat, 22 Dec 2018 03:34:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <965981545402036@sas1-2b3c3045b736.qloud-c.yandex.net> Content-Language: en-US X-DCC-debian-Metrics: esgaroth.tuxoid.at 1169; Body=3 Fuz1=3 Fuz2=3 X-Virus-Scanned: clamav-milter 0.97 at esgaroth.tuxoid.at X-Virus-Status: Clean X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org Hi all! On 21/12/2018 15:20, Lev Olshvang wrote: [...] > I have an executable (C++) which is the exclusive user of the some shared library that it uses only during the initialization phase. > > I would like to free memory used by this shared library, because I am running on embedded system. > > How can I achieve this? > > I know that dlopen() will load shared library, and hope that following dlclose() will free this lib memory. > > 1. Still I do not know what method should be used to make dynamic linker look again into executable and resolve symbols of the newly appeared symbols ? There is no such method TTBOMK. Since the linker (and thus the shared loader) do not know of this library, they can't do anything (see below). The C++ application has to resolve the symbols with dlsym() (after a successful dlopen()) and call it with an appropriate type cast. After dlclose(), the pointers from dlasym() are invalid (obviously - as the lib is gone/unmapped). > 2. And how to tell the dynamic linker ld-linux.so to postpone the symbol resolution until dlopen() will load the library? Do not mention that library (when linking the application). > 3. Whether to compile and link executable with this library or leave unresolved symbols? You do not call the functions directly (and you cannot as the linker cannot resolve them anyways as the linker doesn't know the library). MfG, Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies