From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 566E3385482F for ; Sat, 19 Jun 2021 07:23:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 566E3385482F Received: by mail-ot1-x333.google.com with SMTP id h24-20020a9d64180000b029036edcf8f9a6so12062645otl.3 for ; Sat, 19 Jun 2021 00:23:55 -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=2zITfVe2pUWguDBqZeXiQM+OV38yf4S13xRX6DGqBng=; b=bBcyx54Y5f+pafoo34Z/0ReWZHwMiz7vMiuhxzldvaRuiwHR3cH7uCaRwswig+4eKq mv2O5m1j29uz8HBeL8StR18DUuXZpjSyHygw4A/jm6x/vQhlNoOS4t3CnLv9zbthS2vu Vor3U+qTmAVV0WXzrF9Zboch+nKORuDPmgL/1BO4252mIMo2xN36J8zHOXhi/gp0Ff8n LaJzJrt19/yXuUQdsglv+UsJJXzArzXU8w3+9+y04FvoZ8zsU6PsKUvzQvSBhb86U+He dO6p3dxcNB+2el/AVtm51N7ceDfnu+2bz5t/EexsCFshHnXCdhlwJ8/rXGX4g29A+iFM IpAg== X-Gm-Message-State: AOAM532WTTJ3keTEvqYpObV6zCAgbPxhEkgWRkJ9FM1vjtkKqIPtDkGs x38waR5ZtVXVapyPn3m39tnueoXfEW3gF3ek50ypAE9EoY8= X-Google-Smtp-Source: ABdhPJwe6qj1v1409QmroGWOLWC+Dk+5wuDpd/BIpcbDqWnNWwNJ5eXMVwr/OpR9vFoG5gXK2f1Uoc6uJZe8n9ZQFF4= X-Received: by 2002:a9d:6c4d:: with SMTP id g13mr12291424otq.321.1624087434253; Sat, 19 Jun 2021 00:23:54 -0700 (PDT) MIME-Version: 1.0 From: Jakob Skaar Date: Sat, 19 Jun 2021 09:23:43 +0200 Message-ID: Subject: [Feature Request] dlopen_from function To: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, 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 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: Sat, 19 Jun 2021 07:23:56 -0000 Hi, The behaviour of certain functions in libdl[^2] like the `dlopen` function is dependent on where it is called from. This is normally what you want, but sometimes you may want to specify the caller address yourself, for example when intercepting/hooking the `dlopen` function itself. For this reason, Apple has added the `dlopen_from` function in macOS Big Sur. `dlopen_from` has an extra parameter, `void *caller`, that specifies the "fake" caller address to be used instead of `RETURN_ADDRESS(0)`[^3]. Using `dlopen_from` significantly simplifies intercepting `dlopen` calls (see [here][1] for an example). So my feature request is to implement `dlopen_from` in glibc too. [1]: [^2]: The same logic also applies to `dlmopen`, `dlsym`, and `dlvsym`. [^3]: Header file where `dlopen_from` is declared: