From patchwork Tue May 18 14:25:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43457 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 49BF239574B9; Tue, 18 May 2021 14:26:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49BF239574B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621347995; bh=L6hFsEPqW1faEasYpaqFZ1cZK258F4hrAUz3PHkUgAI=; 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=O/Gm748A3XTwrPwQZN7QkZCitiKiCnV6mi6MNtXm467BpmjQY4u4NWorS5QiisSQp DWrVHtUO1kllLk7O23YBnMMxObU5KXnLY2kDkVxbMyAtz2gB1j2bD/Pq55Lz/d1LgM Ew7SMxfAWMXCVuSdytYg7xiE2yiQDVTqLgqvhv90= 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 D780339574E0 for ; Tue, 18 May 2021 14:26:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D780339574E0 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-534-Y4eo5plqPE6MANw39EoKyQ-1; Tue, 18 May 2021 10:26:23 -0400 X-MC-Unique: Y4eo5plqPE6MANw39EoKyQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70A05804766 for ; Tue, 18 May 2021 14:25:37 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-137.ams2.redhat.com [10.36.112.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAB115D6A1 for ; Tue, 18 May 2021 14:25:36 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 09/10] elf: Add facility to create stub DSOs in elf/stub-dsos In-Reply-To: References: X-From-Line: 4ea2bdaebef66c6646aa0f8df13b4108d7933b7d Mon Sep 17 00:00:00 2001 Message-Id: <4ea2bdaebef66c6646aa0f8df13b4108d7933b7d.1621347402.git.fweimer@redhat.com> Date: Tue, 18 May 2021 16:25:34 +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.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.7 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@sourceware.org Sender: "Libc-alpha" And reference the elf/stub-dsos directory when linking installed programs. --- Makeconfig | 10 ++++++++-- elf/Makefile | 18 +++++++++++++++++- elf/lib-stub.S | 22 ++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 elf/lib-stub.S diff --git a/Makeconfig b/Makeconfig index 1d5e45926c..3ef71cc02b 100644 --- a/Makeconfig +++ b/Makeconfig @@ -425,7 +425,8 @@ ifndef +link-pie $(link-extra-libs) +link-pie-after-libc = $(+postctorS) $(+postinit) define +link-pie -$(CC) $(link-libc-rpath-link) $(+link-pie-before-libc) $(rtld-LDFLAGS) \ +$(CC) $(link-libc-rpath-link)$(rpath-link-stubs) \ + $(+link-pie-before-libc) $(rtld-LDFLAGS) \ $(link-extra-flags) $(link-libc) $(+link-pie-after-libc) $(call after-link,$@) endef @@ -487,7 +488,8 @@ else # not build-pie-default $(link-extra-libs) +link-after-libc = $(+postctor) $(+postinit) define +link -$(CC) $(link-libc-rpath-link) $(+link-before-libc) $(rtld-LDFLAGS) \ +$(CC) $(link-libc-rpath-link)$(rpath-link-stubs) \ + $(+link-before-libc) $(rtld-LDFLAGS) \ $(link-extra-flags) $(link-libc) $(+link-after-libc) $(call after-link,$@) endef @@ -581,6 +583,10 @@ link-libc-printers-tests = $(link-libc-rpath) \ rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support rpath-link = \ $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))) + +# See $(elf-stub-dso-files) in elf/Makefile. +rpath-link-stubs=:$(common-objdir)/elf/stub-dsos + else # build-static link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib) link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests) diff --git a/elf/Makefile b/elf/Makefile index 834ec858a8..5f179bae19 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -505,7 +505,23 @@ ifeq (yes,$(build-shared)) # to run programs during the `make others' pass. lib-noranlib: $(objpfx)$(rtld-installed-name) \ $(addprefix $(objpfx),$(extra-objs)) -endif + +# The system may have installed DSO that no longer exist as separate +# DSOs in the current glibc version. The link editor will try to +# resolve versioned GLIBC_PRIVATE symbol references in them against +# libc.so, but these exports do not exist anymore. Supplying these +# stub DSOs in a directory searched by -rpath-link prevents the link +# editor from picking up the installed system files. +ifneq ($(strip $(elf-stub-dsos)),) +elf-stub-dso-files :=\ +$(foreach L,$(elf-stub-dsos),$(objpfx)/stub-dsos/lib$L.so$(lib$L.so-version)) +$(elf-stub-dso-files): lib-stub.S + $(make-target-directory) + $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \ + -Wl,-soname=$(@F) -nostdlib $< +subdir_lib: $(elf-stub-dso-files) +endif # $(elf-stub-dsos) +endif # $(build-shared) # Command to link into a larger single relocatable object. reloc-link = $(LINK.o) -nostdlib -nostartfiles -r diff --git a/elf/lib-stub.S b/elf/lib-stub.S new file mode 100644 index 0000000000..2b5ae2010e --- /dev/null +++ b/elf/lib-stub.S @@ -0,0 +1,22 @@ +/* Assembler source file for creating stub libraries. + 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 + . */ + + /* Produce an invalid init function, so that loading the stub + crashes. */ + .section .init_array,"a",%init_array + .dc.a 4096