From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id EA764385802A for ; Tue, 25 May 2021 02:35:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EA764385802A Received: by mail-lf1-x12f.google.com with SMTP id r5so43558479lfr.5 for ; Mon, 24 May 2021 19:35:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=W0SV+sor/JY8beApDAUolFP/ScQvWC78Nb5xewW1YKE=; b=bxrFzD6Ry7zkAFTLa+Sj8FbVzxaw9cBWL/XlOjBFvpccehc+2P9GOa8TZFx/yab8Ht UPBm+FK5SixZZRW9S8JcFYSMq6SuH8eeMChI6zSknif/y1qEryCJSuAoGGd6ZJhwDSaN 9qK2JYRjpSdTywZdlq9HsQm3GGn14q0NlcAQosTZEV25Q34RBqQn45A594HL33iHSeCW wcBIPh8QIA3tWV+dsNKhg4LZ0zu2ScCXf5GYm2+7oFYxwx2jeT4/SGcMQP6GlS3lplzO kVVkCfY1dFfiyJmbO2eWZ4SrUbnURavNGSEteGBntXLqDaEVegBUsfHowCqAVOigy9lc g4dA== X-Gm-Message-State: AOAM532nOl6IGjQ4moJmOf6daFUlwGX7JEb16W4YD13S1OFBmzXXuMS/ eXX1cojMc29vdJbhWonXWBkFRVba3LrRjYhSh78M+gRJ9Y8= X-Google-Smtp-Source: ABdhPJzXZBB1XTD/9wXIceMHCjz26RWdACUzXfzDYKqtHLr5CRDTYj+bYFmBsRlazZkQr4CKdfR+LVUHJaqDMxasjq4= X-Received: by 2002:a19:6a0b:: with SMTP id u11mr8329545lfu.274.1621910129616; Mon, 24 May 2021 19:35:29 -0700 (PDT) MIME-Version: 1.0 From: Fengkai Sun Date: Tue, 25 May 2021 10:35:20 +0800 Message-ID: Subject: Can LD_PRELOAD set different symbol definitions for shared objects and executable? To: libc-help@sourceware.org X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2021 02:35:32 -0000 Hi list, I've done some research on elf/rtld.c, and found that the dynamic linker only handles the preload list in dl_main, that is, there is no other way to change it later. Does that mean there is no way to give different symbol definitions to shared objects and executable? For example, if I set LD_PRELOAD="./mymalloc.so", then all references to malloc will be interposed. There is no way to specify a custom allocator only for shared objects(maybe I can make a difference in the source code of custom malloc, but that's off topic). I wonder if there is any way to do this, or if I missed out some fundamental ideas. Best, Fengkai