From patchwork Wed Jun 9 11:16:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43779 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C2DA39574CD for ; Wed, 9 Jun 2021 11:16:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C2DA39574CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623237404; bh=ODLwshrqFHkaul14J0FM9Jna1SMed62VNZOvSRvoGkY=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NdqqQpF9U+RlNZ1/x0qSlPJ42NVpm1NwGbx7T35gN4auRD5pwntJEMtvfvyADCQEc jwqCxzo2mmyyyg6tIR2LqrctaYln1cB26UuOCb/atcMLZ52g08shiCfM0kfqUGZcBf lLSALHxZOCe4iwXdaOY6ebtGMM79i0KSsbdnvAbA= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 83700395A832 for ; Wed, 9 Jun 2021 11:16:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83700395A832 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-IvvdfkxdOEmbN4f_ykAPHw-1; Wed, 09 Jun 2021 07:16:05 -0400 X-MC-Unique: IvvdfkxdOEmbN4f_ykAPHw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E49718049C5 for ; Wed, 9 Jun 2021 11:16:04 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-60.ams2.redhat.com [10.36.115.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E8E819D7C for ; Wed, 9 Jun 2021 11:16:04 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name In-Reply-To: References: X-From-Line: 1607ec771f986790345c458b1cda4504d8dfcba3 Mon Sep 17 00:00:00 2001 Message-Id: <1607ec771f986790345c458b1cda4504d8dfcba3.1623237082.git.fweimer@redhat.com> Date: Wed, 09 Jun 2021 13:16:02 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Currently, the name is always libthread_db-1.0.so. It does not change with the glibc version, like the other libraries. GDB hard-codes libthread_db.so.1 (the soname), so this change does not affect loading libthread_db. Tested on x86_64-linux-gnu, in an environment where the nptl GDB tests actually run. --- nptl_db/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/nptl_db/Makefile b/nptl_db/Makefile index ea721c1dcf..1f79c018a1 100644 --- a/nptl_db/Makefile +++ b/nptl_db/Makefile @@ -21,8 +21,6 @@ subdir := nptl_db include ../Makeconfig -nptl_db-version = 1.0 - extra-libs = libthread_db extra-libs-others := $(extra-libs) From patchwork Wed Jun 9 11:16:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43780 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E09BF39574CD for ; Wed, 9 Jun 2021 11:17:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E09BF39574CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623237454; bh=ud+/FOYUPzAD4cP/FMTIiVSepapuR0lmTAizs3ow3x0=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WbRCPjtOW9GGlw8qbH3DWjT51eHLCpt3kXcxfwHaagZ/GNbPPgFp8tDx/qv0fLITW QN8oCJdu+Q9JgeyETwMvfoX2PNrn0eTOXVVG7Uc/U6GjtGyfKM80beLmsKUqGLQ/Ay z7tQqpGkxS5MP4ocfrJYQvZ/zRd9qdvOV3WOY95A= 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.133.124]) by sourceware.org (Postfix) with ESMTP id F004F3971C35 for ; Wed, 9 Jun 2021 11:16:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F004F3971C35 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-438-nEbtP8KxPoyGIB5FEK4cOg-1; Wed, 09 Jun 2021 07:16:11 -0400 X-MC-Unique: nEbtP8KxPoyGIB5FEK4cOg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA2C08049D0 for ; Wed, 9 Jun 2021 11:16:10 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-60.ams2.redhat.com [10.36.115.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E99EF10016F4 for ; Wed, 9 Jun 2021 11:16:09 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version) In-Reply-To: References: X-From-Line: 4dc82c663bec7646cbb8e2fe52c413f6a6259acf Mon Sep 17 00:00:00 2001 Message-Id: <4dc82c663bec7646cbb8e2fe52c413f6a6259acf.1623237082.git.fweimer@redhat.com> Date: Wed, 09 Jun 2021 13:16:07 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Also clarify that the “versioned” term refers to the soname, not the glibc version (which also ends up in the installed file name). I verified on x86_64-linux-gnu that “make install” produces the same files. --- Makerules | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/Makerules b/Makerules index ca9885436e..d3f29d0b89 100644 --- a/Makerules +++ b/Makerules @@ -982,22 +982,21 @@ install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so)) install-lib := $(filter-out %.so %_pic.a,$(install-lib)) ifeq (yes,$(build-shared)) -# Find which .so's have versions. +# Find which .so's have a version number in their soname. versioned := $(strip $(foreach so,$(install-lib.so),\ $(patsubst %,$(so),$($(so)-version)))) install-lib.so-versioned := $(filter $(versioned), $(install-lib.so)) install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so)) -# For versioned libraries, we install three files: +# For libraries whose soname have version numbers, we install three files: # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file -lib-version := $(firstword $($(subdir)-version) $(version)) install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \ $(foreach L,$(install-lib.so-versioned),\ $(inst_libdir)/$L \ - $(inst_slibdir)/$(L:.so=)-$(lib-version).so \ + $(inst_slibdir)/$(L:.so=)-$(version).so \ $(inst_slibdir)/$L$($L-version)) # Install all the unversioned shared libraries. @@ -1125,7 +1124,6 @@ include $(o-iterator) generated += $(foreach o,$(versioned),$o$($o-version)) -ifeq (,$($(subdir)-version)) define o-iterator-doit $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \ $(+force); @@ -1140,23 +1138,7 @@ $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force); endef object-suffixes-left := $(versioned) include $(o-iterator) -else -define o-iterator-doit -$(inst_slibdir)/$o$($o-version): \ - $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force); - $$(make-shlib-link) -endef -object-suffixes-left := $(versioned) -include $(o-iterator) - -define o-iterator-doit -$(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force); - $$(do-install-program) -endef -object-suffixes-left := $(versioned) -include $(o-iterator) -endif -endif +endif # ifneq (,$(versioned)) define do-install-so $(do-install-program) From patchwork Wed Jun 9 11:16:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43781 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 161023971C3C for ; Wed, 9 Jun 2021 11:18:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 161023971C3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623237499; bh=+zdVhTc446kr4gKThi/Qj6ldRjE7CbmEar1C0hQ765M=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=lDY3VZ+8qokN7Me+XqBH/YAbLzJj5h8sEywMl3xeSMT+pnJ6sCflY3nwKDHcleBYY iWOstQAjs0YesWB8rhCzaYMh58U/wCQ394QCrBa6HCQaJyaTUbETpRApA6ccVc2OHp 6l51LDvJMRJTE+sNVATm4mKqJ9tBcoux8PPT9xWw= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 421B6395C826 for ; Wed, 9 Jun 2021 11:16:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 421B6395C826 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-w6s-s1AMM4a6d8QruzwYwg-1; Wed, 09 Jun 2021 07:16:16 -0400 X-MC-Unique: w6s-s1AMM4a6d8QruzwYwg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 50A811850608 for ; Wed, 9 Jun 2021 11:16:15 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-60.ams2.redhat.com [10.36.115.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 715FF17C5F for ; Wed, 9 Jun 2021 11:16:14 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig In-Reply-To: References: X-From-Line: 937116e1b6e669fa0d679bf677ceefd145735e9c Mon Sep 17 00:00:00 2001 Message-Id: <937116e1b6e669fa0d679bf677ceefd145735e9c.1623237082.git.fweimer@redhat.com> Date: Wed, 09 Jun 2021 13:16:12 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This introduces and the _dl_is_dso function. A test ensures that the official names of libc.so, ld.so, and their versioned names are recognized. --- elf/Makefile | 2 +- elf/dl-is_dso.h | 33 +++++++++++++++++++++++++++++++++ elf/ldconfig.c | 5 ++--- elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 elf/dl-is_dso.h create mode 100644 elf/tst-dl-is_dso.c diff --git a/elf/Makefile b/elf/Makefile index e9788d3d4f..5389c35536 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -223,7 +223,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \ tst-single_threaded tst-single_threaded-pthread \ tst-tls-ie tst-tls-ie-dlmopen argv0test \ tst-glibc-hwcaps tst-glibc-hwcaps-prepend tst-glibc-hwcaps-mask \ - tst-tls20 tst-tls21 tst-dlmopen-dlerror + tst-tls20 tst-tls21 tst-dlmopen-dlerror tst-dl-is_dso # reldep9 tests-internal += loadtest unload unload2 circleload1 \ neededtest neededtest2 neededtest3 neededtest4 \ diff --git a/elf/dl-is_dso.h b/elf/dl-is_dso.h new file mode 100644 index 0000000000..94e00966a1 --- /dev/null +++ b/elf/dl-is_dso.h @@ -0,0 +1,33 @@ +/* Heuristic for recognizing DSO file names. + Copyright (C) 2021 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 + . */ + +#include +#include + +/* Returns true if the file name looks like a DSO name. */ +static bool +_dl_is_dso (const char *name) +{ + /* Recognize lib*.so*, ld-*.so*, ld.so.*, ld64.so.*. ld-*.so* + matches both platform dynamic linker names like ld-linux.so.2, + and versioned dynamic loader names like ld-2.12.so. */ + return (((strncmp (name, "lib", 3) == 0 || strncmp (name, "ld-", 3) == 0) + && strstr (name, ".so") != NULL) + || strncmp (name, "ld.so.", 6) == 0 + || strncmp (name, "ld64.so.", 8) == 0); +} diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 96bf7700b2..1037e8d0cf 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -842,9 +843,7 @@ search_dir (const struct dir_entry *entry) subdirectory (if not already processing a glibc-hwcaps subdirectory)? The dynamic linker is also considered as shared library. */ - if (((strncmp (direntry->d_name, "lib", 3) != 0 - && strncmp (direntry->d_name, "ld-", 3) != 0) - || strstr (direntry->d_name, ".so") == NULL) + if (!_dl_is_dso (direntry->d_name) && (direntry->d_type == DT_REG || (entry->hwcaps == NULL && !is_hwcap_platform (direntry->d_name)))) diff --git a/elf/tst-dl-is_dso.c b/elf/tst-dl-is_dso.c new file mode 100644 index 0000000000..48d2cc9fbe --- /dev/null +++ b/elf/tst-dl-is_dso.c @@ -0,0 +1,35 @@ +/* Test heuristic for recognizing DSO file names. + Copyright (C) 2021 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 + . */ + +#include +#include +#include + +static int +do_test (void) +{ + /* Official ABI names. */ + TEST_VERIFY (_dl_is_dso (LIBC_SO)); + TEST_VERIFY (_dl_is_dso (LD_SO)); + /* Version-based names. The version number does not matter. */ + TEST_VERIFY (_dl_is_dso ("libc-2.12.so")); + TEST_VERIFY (_dl_is_dso ("ld-2.12.so")); + return 0; +} + +#include From patchwork Wed Jun 9 11:16:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43782 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 924A43951C71 for ; Wed, 9 Jun 2021 11:19:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 924A43951C71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623237543; bh=G+KQFkVAq1J4wVYrloBfnURMWkX5MTKbHycahgH61Cc=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=INHEUkU2JDlqj3CGt4Q95N7sojIE8mseghcVSb1VGNbIjxWzuofPXDpvjFQ5x6dJi KIS+wHugW/dZgUIFpS85G/YP0kw2/zgEjhkv7cZ+rXivneR2uASWlD2pI1QbeIXGzK EsVUIbReDRm7FhTeI3R+U61Qn6lKHDtwD5ClFm9E= 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.133.124]) by sourceware.org (Postfix) with ESMTP id 5004E395A832 for ; Wed, 9 Jun 2021 11:16:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5004E395A832 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-ywUfomx_PLmScmPJVp4CiA-1; Wed, 09 Jun 2021 07:16:29 -0400 X-MC-Unique: ywUfomx_PLmScmPJVp4CiA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D676C802575 for ; Wed, 9 Jun 2021 11:16:28 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-60.ams2.redhat.com [10.36.115.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12A2C17C5F for ; Wed, 9 Jun 2021 11:16:27 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 4/4] Add --disable-major-minor-libraries configure option In-Reply-To: References: X-From-Line: 476bfc2e0c41a91a37d945ae2af29e931801b0f7 Mon Sep 17 00:00:00 2001 Message-Id: <476bfc2e0c41a91a37d945ae2af29e931801b0f7.1623237082.git.fweimer@redhat.com> Date: Wed, 09 Jun 2021 13:16:26 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This option can be used to increase compatibility with package managers. The name was choosen to avoid confusion with all the different versions (glibc release, soname versions, symbol versions). This patch makes all uses of -$(version).so conditional on the new $(major-minor-libraries) flag. The alternative install targets write the implementation DSOs directly to the locations determined by their sonames, skipping the creation of an intermediate symbolic link. install-symbolic-link in Makerules is updated not to require the $(symbolic-link-list) file because it may not exist in --disable-major-minor-libraries mode. --- INSTALL | 10 ++++++++++ Makefile | 4 +++- Makerules | 26 +++++++++++++++++++++++++- config.make.in | 1 + configure | 15 +++++++++++++++ configure.ac | 7 +++++++ elf/Makefile | 8 +++++++- manual/install.texi | 9 +++++++++ 8 files changed, 77 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index bc761ab98b..ed5f66489b 100644 --- a/INSTALL +++ b/INSTALL @@ -199,6 +199,16 @@ if 'CFLAGS' is specified it must enable optimization. For example: RELRO and a read-only global offset table (GOT), at the cost of slightly increased program load times. +'--disable-major-minor-libraries' + Do not install shared objects under file names that contain the + major and minor version of the GNU C Library. By default, such + names are used, and the names defined by the ABI are provided as + symbolic links only. This causes problems with certain package + managers during library upgrades and (in particular) downgrades, so + this option can be used to install these shared objects directly + under their ABI-defined names, without an additional indirection + via symbolic links. + '--enable-pt_chown' The file 'pt_chown' is a helper binary for 'grantpt' (*note Pseudo-Terminals: Allocation.) that is installed setuid root to fix diff --git a/Makefile b/Makefile index 242d36de91..4cf422adce 100644 --- a/Makefile +++ b/Makefile @@ -112,7 +112,9 @@ ifeq (yes,$(build-shared)) install: install-symbolic-link .PHONY: install-symbolic-link install-symbolic-link: subdir_install - $(symbolic-link-prog) $(symbolic-link-list) + if test -e $(symbolic-link-list) ; then \ + $(symbolic-link-prog) $(symbolic-link-list); \ + fi rm -f $(symbolic-link-list) install: diff --git a/Makerules b/Makerules index d3f29d0b89..162b92a4c2 100644 --- a/Makerules +++ b/Makerules @@ -989,6 +989,14 @@ versioned := $(strip $(foreach so,$(install-lib.so),\ install-lib.so-versioned := $(filter $(versioned), $(install-lib.so)) install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so)) +# $(install-major-minor-libraries) is used within install-lib-nosubdir +# to trigger installation of the actual implementation file. +ifeq (yes,$(major-minor-libraries)) +install-major-minor-libraries = $(inst_slibdir)/$(L:.so=)-$(version).so +else +install-major-minor-libraries = +endif + # For libraries whose soname have version numbers, we install three files: # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink @@ -996,7 +1004,7 @@ install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so)) install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \ $(foreach L,$(install-lib.so-versioned),\ $(inst_libdir)/$L \ - $(inst_slibdir)/$(L:.so=)-$(version).so \ + $(install-major-minor-libraries) \ $(inst_slibdir)/$L$($L-version)) # Install all the unversioned shared libraries. @@ -1049,6 +1057,7 @@ endef endif ifdef libc.so-version +ifeq (yes,$(major-minor-libraries)) # For a library specified to be version N, install three files: # libc.so -> libc.so.N (e.g. libc.so.6) # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so) @@ -1058,6 +1067,11 @@ $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \ $(make-shlib-link) $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force) $(do-install-program) +else # !$(major-minor-libraries) +$(inst_slibdir)/libc.so$(libc.so-version): $(common-objpfx)libc.so $(+force) + $(do-install-program) +endif # !$(major-minor-libraries) + install: $(inst_slibdir)/libc.so$(libc.so-version) # This fragment of linker script gives the OUTPUT_FORMAT statement @@ -1124,6 +1138,7 @@ include $(o-iterator) generated += $(foreach o,$(versioned),$o$($o-version)) +ifeq (yes,$(major-minor-libraries)) define o-iterator-doit $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \ $(+force); @@ -1138,6 +1153,15 @@ $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force); endef object-suffixes-left := $(versioned) include $(o-iterator) + +else # !$(major-minor-libraries) +define o-iterator-doit +$(inst_slibdir)/$o$($o-version): $(objpfx)$o $(+force); + $$(do-install-program) +endef +object-suffixes-left := $(versioned) +include $(o-iterator) +endif # !$(major-minor-libraries) endif # ifneq (,$(versioned)) define do-install-so diff --git a/config.make.in b/config.make.in index cbf59114b0..55a8351dd2 100644 --- a/config.make.in +++ b/config.make.in @@ -71,6 +71,7 @@ have-libcap = @have_libcap@ have-cc-with-libunwind = @libc_cv_cc_with_libunwind@ fno-unit-at-a-time = @fno_unit_at_a_time@ bind-now = @bindnow@ +major-minor-libraries = @major_minor_libraries@ have-hash-style = @libc_cv_hashstyle@ use-default-link = @use_default_link@ have-cxx-thread_local = @libc_cv_cxx_thread_local@ diff --git a/configure b/configure index a86bcf7671..cb98b4c047 100755 --- a/configure +++ b/configure @@ -681,6 +681,7 @@ experimental_malloc enable_werror all_warnings force_install +major_minor_libraries bindnow hardcoded_path_in_tests enable_timezone_tools @@ -774,6 +775,7 @@ enable_hidden_plt enable_bind_now enable_stack_protector enable_static_nss +enable_major_minor_libraries enable_force_install enable_maintainer_mode enable_kernel @@ -1435,6 +1437,10 @@ Optional Features: Use -fstack-protector[-all|-strong] to detect glibc buffer overflows --enable-static-nss build static NSS modules [default=no] + --enable-major-minor-libraries + install most shared objects under names based on the + glibc version, with symbolic links to them + [default=yes] --disable-force-install don't force installation of files from this package, even if they are older than the installed files --enable-maintainer-mode @@ -3480,6 +3486,15 @@ if test x"$static_nss" = xyes || test x"$shared" = xno; then fi +# Check whether --enable-major-minor-libraries was given. +if test "${enable_major_minor_libraries+set}" = set; then : + enableval=$enable_major_minor_libraries; major_minor_libraries=$enableval +else + major_minor_libraries=yes +fi + + + # Check whether --enable-force-install was given. if test "${enable_force_install+set}" = set; then : enableval=$enable_force_install; force_install=$enableval diff --git a/configure.ac b/configure.ac index f2588f394f..91d54e6926 100644 --- a/configure.ac +++ b/configure.ac @@ -242,6 +242,13 @@ if test x"$static_nss" = xyes || test x"$shared" = xno; then AC_DEFINE(DO_STATIC_NSS) fi +AC_ARG_ENABLE([major-minor-libraries], + AC_HELP_STRING([--enable-major-minor-libraries], + [install most shared objects under names based on the glibc version, with symbolic links to them @<:@default=yes@:>@]), + [major_minor_libraries=$enableval], + [major_minor_libraries=yes]) +AC_SUBST(major_minor_libraries) + AC_ARG_ENABLE([force-install], AS_HELP_STRING([--disable-force-install], [don't force installation of files from this package, even if they are older than the installed files]), diff --git a/elf/Makefile b/elf/Makefile index 5389c35536..3211dbfd64 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -628,6 +628,7 @@ $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx). ifeq (yes,$(build-shared)) +ifeq (yes,$(major-minor-libraries)) $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force) $(make-target-directory) $(do-install-program) @@ -637,11 +638,16 @@ $(inst_rtlddir)/$(rtld-installed-name): \ $(inst_slibdir)/libc-$(version).so $(make-target-directory) $(make-shlib-link) +else # !$(major-minor-libraries) +$(inst_rtlddir)/$(rtld-installed-name): $(objpfx)ld.so $(+force) + $(make-target-directory) + $(do-install-program) +endif # !$(major-minor-libraries) # Special target called by parent to install just the dynamic linker. .PHONY: ldso_install ldso_install: $(inst_rtlddir)/$(rtld-installed-name) -endif +endif # $(build-shared) # Workarounds for ${exec_prefix} expansion in configure variables. diff --git a/manual/install.texi b/manual/install.texi index f1d858fb78..3e0ae46285 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -226,6 +226,15 @@ provides additional security hardening because it enables full RELRO and a read-only global offset table (GOT), at the cost of slightly increased program load times. +@item --disable-major-minor-libraries +Do not install shared objects under file names that contain the major +and minor version of @theglibc. By default, such names are used, and +the names defined by the ABI are provided as symbolic links only. This +causes problems with certain package managers during library upgrades +and (in particular) downgrades, so this option can be used to install +these shared objects directly under their ABI-defined names, without an +additional indirection via symbolic links. + @pindex pt_chown @findex grantpt @item --enable-pt_chown