From patchwork Wed Feb 8 09:16:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1739361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=SC2IVIPV; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PBZBf1bzWz23y7 for ; Wed, 8 Feb 2023 20:16:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8143838582AC for ; Wed, 8 Feb 2023 09:16:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8143838582AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675847815; bh=BB9QLBBqEmVniPzcYu7OjG4XgumQJPr5+41vvH4Gdj8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=SC2IVIPV1ekZ6CPjqk3uPwo+5vcvOM9XeSWZagvdZ8XmZF2VZFGXlbzKjqeT0ppZh 1KWofcVqEUtCnMHW4e2cuIWRn1XruKi/EmbXH/6qJgVSGh+hvomoe/mxBZyCTRS48C bZtBQo1b91ky3+2Tr4+dkw2/L4KQb5U91l3rjZ2Y= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A92A13858289 for ; Wed, 8 Feb 2023 09:16:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A92A13858289 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-223-bKRb8JgdPsyEe9-1aJnSQQ-1; Wed, 08 Feb 2023 04:16:37 -0500 X-MC-Unique: bKRb8JgdPsyEe9-1aJnSQQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3CDF101AA78 for ; Wed, 8 Feb 2023 09:16:36 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C47440C83B6 for ; Wed, 8 Feb 2023 09:16:36 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Smoke-test ldconfig -p against system /etc/ld.so.cache Date: Wed, 08 Feb 2023 10:16:34 +0100 Message-ID: <87lel8qzyl.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The test is sufficient to detect the ldconfig bug fixed in commit 9fe6f6363886aae6b2b210cae3ed1f5921299083 ("elf: Fix 64 time_t support for installed statically binaries"). Tested on i686-linux-gnu and x86_64-linux-gnu, both with a x86_64-linux-gnu as the host. Reviewed-by: Carlos O'Donell --- elf/Makefile | 6 ++++ elf/tst-ldconfig-p.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) base-commit: 41349f6f67c83e7bafe49f985b56493d2c4c9c77 diff --git a/elf/Makefile b/elf/Makefile index b509b3eada..2fc6391183 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -626,6 +626,7 @@ ifeq ($(run-built-tests),yes) tests-special += \ $(objpfx)noload-mem.out \ $(objpfx)tst-ldconfig-X.out \ + $(objpfx)tst-ldconfig-p.out \ $(objpfx)tst-leaks1-mem.out \ $(objpfx)tst-rtld-help.out \ # tests-special @@ -2396,6 +2397,11 @@ $(objpfx)tst-ldconfig-X.out : tst-ldconfig-X.sh $(objpfx)ldconfig '$(run-program-env)' > $@; \ $(evaluate-test) +$(objpfx)tst-ldconfig-p.out : tst-ldconfig-p.sh $(objpfx)ldconfig + $(SHELL) $< '$(common-objpfx)' '$(test-wrapper-env)' \ + '$(run-program-env)' > $@; \ + $(evaluate-test) + # Test static linking of all the libraries we can possibly link # together. Note that in some configurations this may be less than the # complete list of libraries we build but we try to maxmimize this list. diff --git a/elf/tst-ldconfig-p.sh b/elf/tst-ldconfig-p.sh new file mode 100644 index 0000000000..ec937bf4ec --- /dev/null +++ b/elf/tst-ldconfig-p.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# Test that ldconfig -p prints something useful. +# Copyright (C) 2023 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 +# . + +# Check that the newly built ldconfig -p can dump the system +# /etc/ld.so.cache file. This should always work even if the ABIs are +# not compatible, except in a cross-endian build (that presumably +# involves emulation when running ldconfig). + +common_objpfx=$1 +test_wrapper_env=$2 +run_program_env=$3 + +if ! test -r /etc/ld.so.cache; then + echo "warning: /etc/ld.so.cache does not exist, test skipped" + exit 77 +fi + +testout="${common_objpfx}elf/tst-ldconfig-p.out" +# Truncate file. +: > "$testout" + +${test_wrapper_env} \ +${run_program_env} \ +${common_objpfx}elf/ldconfig -p \ + $testroot/lib >>"$testout" 2>>"$testout" +status=$? +echo "info: ldconfig exit status: $status" >>"$testout" + +errors=0 +case $status in + (0) + if head -n 1 "$testout" | \ + grep -q "libs found in cache \`/etc/ld.so.cache'\$" ; then + echo "info: initial string found" >>"$testout" + else + echo "error: initial string not found" >>"$testout" + errors=1 + fi + if grep -q "^ libc\.so\..* => " "$testout"; then + echo "info: libc.so.* string found" >>"$testout" + else + echo "error: libc.so.* string not found" >>"$testout" + errors=1 + fi + ;; + (1) + if head -n 1 "$testout" | \ + grep -q ": Cache file has wrong endianness\.$" ; then + echo "info: cache file has wrong endianess" >> "$testout" + else + echo "error: unexpected ldconfig error message" >> "$testout" + errors=1 + fi + ;; + (*) + echo "error: unexpected exit status" >> "$testout" + errors=1 + ;; +esac + +exit $errors