From patchwork Fri Nov 24 12:56:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 56424 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 17C0B38582A3 for ; Fri, 24 Nov 2023 12:56:24 +0000 (GMT) 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 0E7D23858D3C for ; Fri, 24 Nov 2023 12:56:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E7D23858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E7D23858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700830571; cv=none; b=q6f9JTseh4Ns/CdWpO6iJPB5Ns3UEvx1giOTMO8cUMY4urj1tx3n8Vc2CEAks13hTHIE4w84CiIm2+LXuMgBNymWMQoQ2ofMoY0EtbQ3rBS3fpw7pFF7NIXgkdHfcSYYtfyglsh6EU7bsDvbbuzXVM6Sg54UmQjXz4HovXPD+C8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700830571; c=relaxed/simple; bh=LabFdjK8+LR4Egd7h+Vhr+1sPh28nrmfT0f4Wj0ERrs=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=GOFaiVA9Rbm5epHO0swCLmheTbd5XYxLyswrUmStUNystC3AdTWLob/wS7Xg7f1MTz+MrinwBIi7RpaVPMaX15p8LGh6FtJ6RIDqXtdDNSSjL18ZMspfalwNEUEL8q8f5hCOfr3/NgH0Q4xSFNG5lEePSrQ3An1UsTKoydSvx4A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700830569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=b93AHCx0thtp5U0+VM6blFBvKuA88E0AHC7qvjDJIIw=; b=TvHeaCZos0ycxNul00BUKW0mYFkQZUT5BRWSt6D1u9NL+enS7H31LAXgawEr+M7/JY4qru KfbKifbO8vXAbAMvppQwrGN5bJ0jOuxd4WPLDKkHcEJrnI6CNRwMGNGwI/KHg8Yi05VSeR DNQm3hipvpPcVRWVmS1SlwZF8r+YEOw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-8BEIuPT3MT2U_hBKM5CzBg-1; Fri, 24 Nov 2023 07:56:08 -0500 X-MC-Unique: 8BEIuPT3MT2U_hBKM5CzBg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39B3D185A780 for ; Fri, 24 Nov 2023 12:56:08 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6AE15028 for ; Fri, 24 Nov 2023 12:56:07 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 0/3] Compatibility improvement for underlinked objects Message-ID: X-From-Line: 7d8d7ed3614d4779f1b20e3acb8a7a5642d260e6 Mon Sep 17 00:00:00 2001 Date: Fri, 24 Nov 2023 13:56:06 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=no 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org The current default dependency sorting may place objects without explicit dependencies differently than before, which results in a relocation order that historically was not used. This in turn may cause an underlinked object without dependencies to be relocated before libc.so.6, which causes problems if the underlinked object refers to IFUNC resolvers. The fix is to use the machinery that was introduced alongside with __libc_early_init to relocate libc.so early. Tested on x86_64-linux-gnu and i686-linux-gnu. Thanks, Florian Florian Weimer (3): elf: In _dl_relocate_object, skip processing if object is relocated elf: Introduce the _dl_open_relocate_one_object function elf: Relocate libc.so early during startup and dlmopen (bug 31083) elf/Makefile | 21 ++++++++++ elf/dl-open.c | 95 ++++++++++++++++++++++++++----------------- elf/dl-reloc.c | 6 +-- elf/rtld.c | 10 ++++- elf/tst-nodeps1-mod.c | 25 ++++++++++++ elf/tst-nodeps1.c | 23 +++++++++++ elf/tst-nodeps2-mod.c | 1 + elf/tst-nodeps2.c | 29 +++++++++++++ 8 files changed, 167 insertions(+), 43 deletions(-) create mode 100644 elf/tst-nodeps1-mod.c create mode 100644 elf/tst-nodeps1.c create mode 100644 elf/tst-nodeps2-mod.c create mode 100644 elf/tst-nodeps2.c base-commit: 2e0c0ff95ca0e3122eb5b906ee26a31f284ce5ab