From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28990 invoked from network); 11 Apr 2022 12:24:48 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 11 Apr 2022 12:24:48 -0000 Received: (qmail 26278 invoked by uid 550); 11 Apr 2022 12:24:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26246 invoked from network); 11 Apr 2022 12:24:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=jakf4Vb6aKi755887WGGlOOp/ZSHdQTfAiHPUFYMc84=; b=E7HsMFQhhXrJngx+i2ykvh6d4hGsrQAeGrqbbP/76Iiu7oJSg07eZCshYyEXzb0yrl QEaSkLl3seTi58QCzZxU362W2YYbbORWxNSGZR0o8vSo0TChC/SWQP0ejMQ5FGuWqt2M OEn2Z/xKG4T9ZSwA5OA0hOHG6S/TiDJVR+DCjHA8wWpevD/IhYytnEFXHi4qHFkm32Q9 0P0hZy5DpOKVXkT6v7KM7VWEHghh4vYlOLuymxZPHpeYqf9eSp0VYrdpC2s1FXz39il8 0pBQ1B7l/4wwfYByxMyBGDEAvJ2pvMZIKf0Tyt9zIxdgwDB4FYKlid2FuuBaSSbx99wM psFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=jakf4Vb6aKi755887WGGlOOp/ZSHdQTfAiHPUFYMc84=; b=mxavd/tcFpYr2Gx/7AoXQkXnuwaDwxXG9esW+qVBF1rkd++JyQv4glJ4vmc+pyzuWN b8p8GJK9ut/zNdOkwhLWfFpBLvF8uzCwo50PEb4cf4anwS1jQ1CRB6FY7dvSGU4sGLh0 JGKmaNNIehlL4Xcnr73pQUQSTDHP4MwUVrW+AeVTBSYBrGKYfWiHBuisqKXGhYTItyho BA52M7Fdym9CB+LOnqNE6RyghKrTrpqf7qMOlSgbM+P3U9NLS9yREvpxGTx+nex8ehM1 /IimpVFpv8Dc7GbpU5xOmRDst18UfktNlgcvaoSJQ2hjfr1U7n+3y8pHoiWQJ5rThU8F ahDA== X-Gm-Message-State: AOAM530Z0yjoVlZu7/OnU5EwSzPHzZRj7KVWmR7ge6H/80hg5ipne8z5 +Sa8VzKDQupecqhIv4VbQIVnJlogX0u/QiAQZqJZzAK8RxE= X-Google-Smtp-Source: ABdhPJzrV5rlWyAYdEGL+2eKt1W76NBUWUloYWAQtvvKt2vgwVEuUqE8R/I4M+8Na/S8rk/vlNvZ61DYAOa61UAKwmU= X-Received: by 2002:a2e:5cc6:0:b0:24b:3bfd:bc11 with SMTP id q189-20020a2e5cc6000000b0024b3bfdbc11mr14204404ljb.318.1649679872825; Mon, 11 Apr 2022 05:24:32 -0700 (PDT) MIME-Version: 1.0 References: <20220405031859.17673-1-ccross@google.com> In-Reply-To: From: Jeffrey Walton Date: Mon, 11 Apr 2022 08:24:21 -0400 Message-ID: To: musl@lists.openwall.com Cc: Colin Cross Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] [PATCH] dl_iterate_phdr: return empty string for the name of the main program On Mon, Apr 4, 2022 at 11:57 PM Michael Forney wrote: > > On 2022-04-04, Colin Cross wrote: > > The glibc man page for dl_iterate_phdr states: > > The first object visited by callback is the main program. For the main > > program, the > > dlpi_name field will be an empty string. > > > > This is relied upon by the LLVM ASAN runtime: > > https://github.com/llvm/llvm-project/blob/72ec2f76396fe5de5397bfb898993fdb22e2b0da/compiler-rt/lib/asan/asan_linux.cpp#L135 > > > > Without this patch, running a binary that has been instrumented with > > ASAN fails with: > > ==4156919==ASan runtime does not come first in initial library list; you > > should either link runtime to your application or manually preload it with > > LD_PRELOAD. > > > > Use a constant empty string instead of the DSO name field for the first > > entry in the DSO list. > > I believe glibc is the exception here, not musl. When I looked at > this, every other operating system I tried used the program name for > the first object. I may be splitting hairs, but the dl_iterate_phdr(3) man page does not say a program is returned during the enumeration. It says shared objects are returned. $ man 3 dl_iterate_phdr DL_ITERATE_PHDR(3) Linux Programmer's Manual DL_ITERATE_PHDR(3) NAME dl_iterate_phdr - walk through list of shared objects SYNOPSIS #define _GNU_SOURCE /* See feature_test_macros(7) */ #include int dl_iterate_phdr( int (*callback) (struct dl_phdr_info *info, size_t size, void *data), void *data); DESCRIPTION The dl_iterate_phdr() function allows an application to inquire at run time to find out which shared objects it has loaded, and the order in which they were loaded. The dl_iterate_phdr() function walks through the list of an application's shared objects and calls the function callback once for each object, until either all shared objects have been processed or callback returns a nonzero value. ... Jeff