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: 21637 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