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.3 required=5.0 tests=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 31119 invoked from network); 11 Apr 2022 12:42:35 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 11 Apr 2022 12:42:35 -0000 Received: (qmail 1752 invoked by uid 550); 11 Apr 2022 12:42:33 -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 1714 invoked from network); 11 Apr 2022 12:42:32 -0000 Date: Mon, 11 Apr 2022 08:42:19 -0400 From: Rich Felker To: Jeffrey Walton Cc: musl@lists.openwall.com, Colin Cross Message-ID: <20220411124218.GP7074@brightrain.aerifal.cx> References: <20220405031859.17673-1-ccross@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] dl_iterate_phdr: return empty string for the name of the main program On Mon, Apr 11, 2022 at 08:24:21AM -0400, Jeffrey Walton wrote: > 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. You are. The intent, actual practice -- and absolute necessity for this function to serve its purpose, which includes admiting the implementation of exception handling -- is that it be included. And in this context, the (dynamic linked) program *is* a shared object. Rich