From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25848 invoked by alias); 5 Sep 2011 07:50:37 -0000 Received: (qmail 25839 invoked by uid 22791); 5 Sep 2011 07:50:36 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Sep 2011 07:50:20 +0000 Received: by iagz35 with SMTP id z35so6696348iag.20 for ; Mon, 05 Sep 2011 00:50:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.25.217 with SMTP id a25mr6916124ibc.52.1315209019375; Mon, 05 Sep 2011 00:50:19 -0700 (PDT) Received: by 10.231.199.8 with HTTP; Mon, 5 Sep 2011 00:50:19 -0700 (PDT) Date: Mon, 05 Sep 2011 07:50:00 -0000 Message-ID: Subject: [PLUGIN] dlopen and RTLD_NOW From: Romain Geissler To: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00022.txt.bz2 Hi Is there any particular reason to load plugin with the RTLD_NOW option? This option force .so symbol resolution to be completely made at load time, but this could be done only when a symbol is needed (RTLD_NOW). Here is the dlopen line in plugin.c: dl_handle = dlopen (plugin->full_name, RTLD_NOW | RTLD_GLOBAL); My issue is, I want to load the same plugin.so in both cc1 and cc1plus, but in the C++ case, I may need to reference some cc1plus specific symbols. I can check whether cc1 or cc1plus loaded the plugin and thus use custom C++ symbols only when present. With RTLD_NOW, the plugin fails to load in cc1 as symbol resolution is forced at load time. If RTLD_NOW is removed, dlopen falls back to the RTLD_LAZY mode which fits my need. Moreover, if one can force the complete symbol resolution at load time by defining the environment LD_BIND_NOW variable. So, is RTLD_NOW use justified ? Romain Geissler