From patchwork Wed Nov 29 01:16:53 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: 24586 Received: (qmail 73200 invoked by alias); 29 Nov 2017 01:16:58 -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 73191 invoked by uid 89); 29 Nov 2017 01:16:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=6th, Hx-languages-length:2611, ldo, H*r:192.168.2 X-HELO: mtlfep01.bell.net From: John David Anglin Mime-Version: 1.0 (Apple Message framework v1085) Date: Tue, 28 Nov 2017 20:16:53 -0500 Subject: [COMMITTED] hppa: Fix gmon static test failures Cc: Carlos O'Donell To: GNU C Library Message-Id: <07ECBF19-3185-4C07-8DD7-7F9D01B48B45@bell.net> The attached change fixes the following two test failures on hppa: FAIL: gmon/tst-gmon-static FAIL: gmon/tst-gmon-static-gprof These tests do links using the -static option. They also link using the PIC startup file Scrt1.o. On hppa in static links, the linker converts linkage table references using the PIC register, %r19, to references using the global pointer, %dp. However, %dp hasn't been initialized and the tests fault. The attached patch fixes this problem. We need to setup %dp earlier. In the PIC case, we also need to use a PIC pc-relative sequence that doesn't use dynamic relocations. Committed to trunk. Dave --- John David Anglin dave.anglin@bell.net 2017-11-28 John David Anglin * sysdeps/hppa/start.S (_start): Check PIC instead of SHARED. Load address of $global$ into %dp register earlier. Use pc-relative instruction sequence for PIC case. diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S index 5db1ba960b..1d69ae8a4b 100644 --- a/sysdeps/hppa/start.S +++ b/sysdeps/hppa/start.S @@ -42,7 +42,7 @@ /* Have the linker create plabel words so we get PLABEL32 relocs and not 21/14. The use of 21/14 relocs is only supported in the latest dynamic linker. */ -#ifdef SHARED +#ifdef PIC .section .data.rel.ro,"aw",@progbits #else .section .rodata,"a",@progbits @@ -56,10 +56,6 @@ .word P%__libc_csu_fini .Lp__libc_csu_init: .word P%__libc_csu_init -#ifdef SHARED -.Lp__global: - .word $global$ -#endif .text .align 4 @@ -99,9 +95,15 @@ _start: /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */ /* void (*rtld_fini) (void) (6th argument) */ stw %r23, -56(%sp) + /* Need to setup 1, 4, 5, and 7th arguments */ -#ifdef SHARED +#ifdef PIC + /* Load $global$ address into %dp */ + bl .+8, %dp + addil L'$global$-$PIC_pcrel$0+1, %dp + ldo R'$global$-$PIC_pcrel$0+5(%r1), %dp + /* load main (1st argument) */ addil LT'.Lpmain, %r19 ldw RT'.Lpmain(%r1), %r26 @@ -115,6 +117,10 @@ _start: ldw RT'.Lp__libc_csu_fini(%r1), %r22 ldw 0(%r22), %r22 #else + /* Load $global$ address into %dp */ + ldil L%$global$, %dp + ldo R%$global$(%dp), %dp + /* load main (1st argument) */ ldil LR'.Lpmain, %r26 ldw RR'.Lpmain(%r26), %r26 @@ -129,17 +135,6 @@ _start: stw %r22, -52(%sp) /* void *stack_end (7th argument) */ stw %sp, -60(%sp) - -#ifdef SHARED - /* load global */ - addil LT'.Lp__global, %r19 - ldw RT'.Lp__global(%r1), %dp - ldw 0(%dp), %dp -#else - /* load global */ - ldil L%$global$, %dp - ldo R%$global$(%dp), %dp -#endif bl __libc_start_main,%r2 nop /* die horribly if it returned (it shouldn't) */