From patchwork Sun Jul 16 17:50:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 789101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x9YqS0Mh1z9s75 for ; Mon, 17 Jul 2017 03:50:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="UFofwLsA"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:mime-version:content-type:date:subject:cc :to:message-id; q=dns; s=default; b=j3BQh2S77tnx5xtjGvABrNCdDhXr CT9vWmeJAQj8pQL++1Ic8+FcauoLpkrl3FhkkdskhftrV0EwcFHpDqMJRmVRkHXg Px6wiCxR/fnGi9xx2PVgxglczArIWMq60SGWjYIQ3IYYfV0DooTXERbWjja58VRO 5rG1kTOI+aTtjvU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:mime-version:content-type:date:subject:cc :to:message-id; s=default; bh=kElOPBsbN17gDakOy5JcBhB+W84=; b=UF ofwLsAYDs30PPLieuX4sVpakS/uR+MOiAvTLSaCYUsc3N49/+RO6Ui0280+MmsnX itB1yqXh+fifilzH0lcDPUeTiq58UfvD/EpmZ4Tyr7WAcl61HUBlVQA9VftPyyyU 2Hwr/JJK054a0RH0xYy9OBBKTQz3oSdi99Ogb6o94= Received: (qmail 79595 invoked by alias); 16 Jul 2017 17:50:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 79568 invoked by uid 89); 16 Jul 2017 17:50:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=1076, ltp, Hx-languages-length:1747 X-HELO: torfep01.bell.net From: John David Anglin Mime-Version: 1.0 (Apple Message framework v1085) Date: Sun, 16 Jul 2017 13:50:15 -0400 Subject: [committed] Return to caller when _dl_fixup fails on hppa Cc: Carlos O'Donell To: GNU C Library Message-Id: <3C95024E-2059-4D16-B135-EFB4A57D5591@bell.net> The attached change modifies _dl_runtime_resolve to return to its caller when _dl_fixup fails. This can occur on hppa when the caller attempts to call an undefined weak function. The old code would fault when _dl_fixup fails. The most problematic function in this regard is __gmon_start__. Currently, it is linked into every shared object. This breaks the --as-needed ld option. On Debian, we have an additional patch to treat __gmon_start__ as a true weak symbol. I don't plan to apply this change as it becomes tricky to rebuild a distribution. Rebuilding a shared library removes __gmon_start__ and this may break a package using the library. This isn't a problem after everything is rebuilt. Dave --- John David Anglin dave.anglin@bell.net 2017-07-16 John David Anglin * sysdeps/hppa/dl-trampoline.S (_dl_runtime_resolve): Return to caller if _dl_fixup fails. diff --git a/sysdeps/hppa/dl-trampoline.S b/sysdeps/hppa/dl-trampoline.S index 856339bffe..f1294a931f 100644 --- a/sysdeps/hppa/dl-trampoline.S +++ b/sysdeps/hppa/dl-trampoline.S @@ -82,6 +82,11 @@ _dl_runtime_resolve: bl _dl_fixup,%rp copy %r21,%r19 /* set fixup func ltp */ + /* Sometimes a final executable may attempt to call an undefined + weak function (e.g., __gmon_start__). Return if the function + was not resolved by _dl_fixup */ + comib,= 0,%r28,1f + /* Load up the returned func descriptor */ copy %r28, %r22 copy %r29, %r19 @@ -107,6 +112,13 @@ _dl_runtime_resolve: /* Jump to new function, but return to previous function */ bv %r0(%r22) ldw -20(%sp),%rp + +1: + /* Return to previous function */ + ldw -148(%sp),%rp + bv %r0(%rp) + ldo -128(%sp),%sp + .EXIT .PROCEND cfi_endproc