From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by sourceware.org (Postfix) with ESMTPS id 2500B385841E for ; Mon, 8 Apr 2024 16:45:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2500B385841E 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 2500B385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712594740; cv=none; b=hxvasc3v2rvLeqbaSZ0oHBle/cxN0pSakgjMcJ1UnNNuWD+bHMf8fATt2xZsTlCxrLuRzQI9bRvDyjYJF8rqIb79W9QoD40XckDm3ZIOe7m52Gvq1CSd2kJtx/rVfy2CPwgMXSiS+rthyOlCWb+hAK4ikvmHaVIoNpiAifRFO1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712594740; c=relaxed/simple; bh=wToR7ZOZPGckGkuCxUgICBo91tYM6cRG+XhTepEa4L0=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=xryPAWaFHIoHqDiicYFVYy/6Ak/JhqjcqJdifMHDpv8SXahRLSD5XhhnFtrPqSgNICYKTYHpP02WHjd7ApuurG6RRHDoUutP0NA+3/qQ9xWqPxE1yCWAm2rgpUDn9l6/jnSoh8q+M4ZMH4TeCQLNVe7dd/nSvBtb63pkQjAB4DU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-61804067da0so12999417b3.0 for ; Mon, 08 Apr 2024 09:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712594737; x=1713199537; 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=exq7BWrwxHNQXtATREuSDN1yBsrwbUTSL+FVK++btuI=; b=YYNUhteEsaY0Wdc602TTThQH0zhxezg/Y0SnoXZsgitVrPTojF3R13ifJdmLWAAUaW dYX6Er62DQyTOyIL5qIw8zY4HYy+PBdO9aqGuWnFx4LjwpwvXPUYv9J7dv0dIzGhaGiu KP3Kkb0w/fGXH7TLTp1Q/PisIR0IGFoX3HeO5GrBh1/e9Cuni/pXu26fNUzY5pugV3Hh zNfS5Ch1KegIxTn7kChQdfLMLxne2JEdEk8fNqcFm/10iJPUU2lLMi1+58wOIFStuk7f 9qgfeUALa1GnRk72laZ9Lh8J8KjpTMariq6KhwR/lsIyyXQ2WKcfF+ss3jxWUrKzczz0 rVnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712594737; x=1713199537; 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=exq7BWrwxHNQXtATREuSDN1yBsrwbUTSL+FVK++btuI=; b=ahB1AHbe1l01vTBz8qVRTE631CT8RDS0UoAe5aDm29/vC3I0TpaYz03p89Grz15jdh Vj8aLmd3cZXxC6Veypym3hgGU6uc8RdH3ywGG/UpGAPjWmZp0Lehlcg+dYUztNOdLMHz 6dd8MWOobNFdfET0P8fnPh60cn58i5wcJYU27123eGLyhuYfMo419y2ePm5RBdhfOdAx RX/xajFm0x7k1KpA9eWLkNEwyzGiLx/Izm9uaeFyOMhUcBDs6tlLSjGhmrwREidDXyAz 37DMz2f5nTEMgq1exLTq9xmhi2ORFIBKM3NfFibeci9ni2cguXxzkXHh+ykgpJYohtAJ HMxg== X-Gm-Message-State: AOJu0YzYstvqs0yuGQv5ypbMiY14KM7PFUMVpwOEVNfBva8XbZv0cCN8 /Ae+WU7de4YVX6OvrEqTBEEUM9kozJIN6E3qXXQjtfM1QtUB2tlUqJj2saJNeLBLSVe/JPzvFc4 d0D0lxjSTf8NfXkj1YZrZvHpVv+yURhr4 X-Google-Smtp-Source: AGHT+IGKmrUy8oxecszYMEyL3SZFZNTemajEy5txW9RB98KjunngRdX0hAz7MHjOEVK5LbcsWnUZVTQsGyKmEw85I4M= X-Received: by 2002:a25:81c9:0:b0:dc6:b088:e742 with SMTP id n9-20020a2581c9000000b00dc6b088e742mr8253899ybm.8.1712594737437; Mon, 08 Apr 2024 09:45:37 -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:45:01 -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.6 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)" > Does this construct require bash? > +$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 > --=20 H.J.