From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by sourceware.org (Postfix) with ESMTPS id B508D3858CD1 for ; Mon, 8 Apr 2024 16:59:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B508D3858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B508D3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712595561; cv=none; b=C9si8zMjGG+sUV5O5eCeP78r4VLGx9yGwzKJ39bAqLZY/Qi44eQZHjxax6AIwk0WnTbTgV9mTHsLR9hzSHxkAYmOtJJFQS1GIcvmeA5oVTtvBndOPBg2KWWr+KyZafhPLhdLvMJ76Wf/TPqsUhCXpn1YsvRXIBwAMsabrxWkkT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712595561; c=relaxed/simple; bh=xTbAp6HKHMS2a3+Zv7dXIcZgwYd3QYNi0FvaH/wS+Fc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=quq/fLK4r7FvPS+hZarMz7lfdnoBsv8efofW4yse3/3EMpf+5LZ4DayiSUnWyIGQQHVAtOpe/Tz2tVzapwPkFdcGbcK3SmIJGQ2z0TQSZSpdZmkBar+pkiNu0r+wVYWKtX1/uCsZizLpFaiHwTuI4UbEGs8fR8cj+8lwpRMz+Yc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-61500da846fso36750377b3.1 for ; Mon, 08 Apr 2024 09:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712595559; x=1713200359; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+QC4G1cTPQTRjlgguMzzSpKwKl7swM4FJ/yk7wz5mMo=; b=C8A9/ExfScAv5vIa4TQxCtyDhKt1e+SRBwxtzNGbSIaUolsQPe1s+rMmbjgfGNSvp+ EYYOZugL8gvtYJp3VQGId4fwRyYVoyfyligOzwmPsIHt3ZZTFcNZyGesZa5eNO65idoq BWSWZpDnIwIdn5dPcng/ti/n/co9GnNXvwsLMTufHB6a2390zhxnymHgDHMqo//r5wv2 O6IIfBjB/Z8zDT6WchAr2SzrnYZrfpbzjlrjKWbCp94Kxe7Xfy/vDqdOE2jh471GkqJm ur45c7/oO5qpmZqjhIJ+fXdQ4d3ajWzrpJ+0FXKGmNeFiEUaicMjdwcLg5wBsJH/G85U +Vqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712595559; x=1713200359; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+QC4G1cTPQTRjlgguMzzSpKwKl7swM4FJ/yk7wz5mMo=; b=Zvg9DTFbrXbdNDTxuKaVULpmiavitIgaPjhXl+33K9x7HWmdpvRIumOgDRpjrPzh2j LFUYIQtWxeNa54Jsq4S39CVxVlNb97jZofueLo1wZ2p+TQjzps05n+Ei/GwspQV4Fw5R ++Cy21gsQzssPc24Yw4wFNnAQqqoZjfVRnuE/4PR0YuEJAO1N4Ztxe4XsV1DNZGQcX4H GA3v2VuUMPp3vFuh1FAP9csJiLxCRA0KFdpvizga7Xdo7pnoaUL1R0gRRZsZWFQWBknO 1oMtTdYnNUUzXXUwet239P/IBZz4nIAf5Bm7LHvzdv3iOOlaXa3zLt0TaMSW7cw+ewUQ 1Ttg== X-Gm-Message-State: AOJu0YylU8K3XvNefTTYziKL8aWs4syxeY8FRMEjYEjSHLQ7/vtW8cQr yNFyFQ+fCx1CYflHO2H8kzlHpaUssnmB0wqkhxDay+0MKEUhYp23oMpZj478veF5v/YDS2tNbOX 72QrGJHNG4uDcQG309yKhnii/eXU= X-Google-Smtp-Source: AGHT+IElxUJbCAawAXO7X++XCg4+Hd6FEjmYUOo4gfyZoQRWHXK0Y27ZxzkR0+4o3yRYaYPugiNR7kPAn9BAzFAbXnk= X-Received: by 2002:a25:9c42:0:b0:dcf:30dc:127c with SMTP id x2-20020a259c42000000b00dcf30dc127cmr7275978ybo.18.1712595558979; Mon, 08 Apr 2024 09:59:18 -0700 (PDT) MIME-Version: 1.0 References: <877ch7vmab.fsf@oldenburg.str.redhat.com> In-Reply-To: <877ch7vmab.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Mon, 8 Apr 2024 09:58:43 -0700 Message-ID: Subject: Re: [PATCH v2] elf: Add ld.so test with non-existing program name To: Florian Weimer Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3019.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Apr 8, 2024 at 9:43=E2=80=AFAM Florian Weimer = wrote: > > None of the existing tests seem to cover the case where > _dl_signal_error is called without an active error handler. > The new elf/tst-rtld-does-not-exist test triggers such a > _dl_signal_error call from _dl_map_object. > > --- > v2: Delete temporary file. > > elf/Makefile | 7 +++++++ > elf/tst-rtld-does-not-exist.sh | 39 ++++++++++++++++++++++++++++++++++++= +++ > 2 files changed, 46 insertions(+) > > diff --git a/elf/Makefile b/elf/Makefile > index 4f1903391a..6dad11bcfb 100644 > --- a/elf/Makefile > +++ b/elf/Makefile > @@ -621,6 +621,13 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.= sh $(objpfx)ld.so $(objpfx)v > '$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-te= st \ > '$(valgrind-suppressions-tst-valgrind-smoke)' > $@; $(eva= luate-test) > > +ifeq ($(run-built-tests),yes) > +tests-special +=3D $(objpfx)tst-rtld-does-not-exist.out > +endif > +$(objpfx)tst-rtld-does-not-exist.out: tst-rtld-does-not-exist.sh $(objpf= x)ld.so > + $(SHELL) $< $(objpfx)ld.so > $@; \ > + $(evaluate-test) > + > tests +=3D $(tests-execstack-$(have-z-execstack)) > ifeq ($(run-built-tests),yes) > tests-special +=3D \ > diff --git a/elf/tst-rtld-does-not-exist.sh b/elf/tst-rtld-does-not-exist= .sh > new file mode 100644 > index 0000000000..a4a781ccfd > --- /dev/null > +++ b/elf/tst-rtld-does-not-exist.sh > @@ -0,0 +1,39 @@ > +#!/bin/sh > +# Check that running ld.so with a non-existing file prints an error. > +# Copyright (C) 2024 Free Software Foundation, Inc. > +# This file is part of the GNU C Library. > + > +# The GNU C Library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU Lesser General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > + > +# The GNU C Library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# Lesser General Public License for more details. > + > +# You should have received a copy of the GNU Lesser General Public > +# License along with the GNU C Library; if not, see > +# . > + > +export LC_ALL=3DC > + > +rtld=3D"$1" > +tmp_out=3D"$(mktemp)" > + > +$rtld program-does-not-exist 2>"$tmp_out" > +status=3D$? > +echo "$rtld exit status: $status" > +echo "output (with expected error):" > +cat "$tmp_out" > + > +if test $status -eq 127 \ > + && grep -q "^program-does-not-exist: error while loading shared l= ibraries: program-does-not-exist: cannot open shared object file$" "$tmp_ou= t" \ > + && test "$(wc -l < "$tmp_out")" -eq 1 ; then > + status=3D0 > +else > + status=3D1 > +fi > +rm "$tmp_out" > +exit $status > > base-commit: f8d8b1b1e6d3b8b93f224efc796b7ea083fdb83f > LGTM. Reviewed-by: H.J. Lu Thanks. --=20 H.J.