From patchwork Thu Jul 28 19:42:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 107303 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]) by ozlabs.org (Postfix) with SMTP id BA59CB6F64 for ; Fri, 29 Jul 2011 05:43:03 +1000 (EST) Received: (qmail 2641 invoked by alias); 28 Jul 2011 19:42:30 -0000 Received: (qmail 2570 invoked by uid 22791); 28 Jul 2011 19:42:28 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, RP_MATCHES_RCVD, TW_DD, TW_OV X-Spam-Check-By: sourceware.org Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Jul 2011 19:42:11 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 28 Jul 2011 12:42:10 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by azsmga001.ch.intel.com with ESMTP; 28 Jul 2011 12:42:10 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 35656C2600; Thu, 28 Jul 2011 12:42:22 -0700 (PDT) Date: Thu, 28 Jul 2011 12:42:22 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: ian@airs.com Subject: PATCH: Fix config/i386/morestack.S for x32 Message-ID: <20110728194222.GA16287@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi Ian, x32 is similar to x86-64 with 32bit pointer size. This patch adds x32 support to config/i386/morestack.S. Tested on x32. OK for trunk? Thanks. H.J. --- 2011-07-28 H.J. Lu * config/i386/morestack.S: Properly save the x32 new stack boundary. Properly check __x86_64__ and __LP64__. diff --git a/libgcc/config/i386/morestack.S b/libgcc/config/i386/morestack.S index 16279c7..a745230 100644 --- a/libgcc/config/i386/morestack.S +++ b/libgcc/config/i386/morestack.S @@ -353,7 +353,11 @@ __morestack: # FIXME: The offset must match # TARGET_THREAD_SPLIT_STACK_OFFSET in # gcc/config/i386/linux64.h. +#ifdef __LP64__ movq %rax,%fs:0x70 # Save the new stack boundary. +#else + movl %eax,%fs:0x40 # Save the new stack boundary. +#endif call __morestack_unblock_signals @@ -391,7 +395,11 @@ __morestack: subq 0(%rsp),%rax # Subtract available space. addq $BACKOFF,%rax # Back off 1024 bytes. .LEHE0: +#ifdef __LP64__ movq %rax,%fs:0x70 # Save the new stack boundary. +#else + movl %eax,%fs:0x40 # Save the new stack boundary. +#endif addq $16,%rsp # Remove values from stack. @@ -433,7 +441,11 @@ __morestack: movq %rbp,%rcx # Get the stack pointer. subq %rax,%rcx # Subtract available space. addq $BACKOFF,%rcx # Back off 1024 bytes. +#ifdef __LP64__ movq %rcx,%fs:0x70 # Save new stack boundary. +#else + movl %ecx,%fs:0x40 # Save new stack boundary. +#endif movq (%rsp),%rdi # Restore exception data for call. #ifdef __PIC__ call _Unwind_Resume@PLT # Resume unwinding. @@ -493,7 +505,7 @@ __x86.get_pc_thunk.bx: .section .data.DW.ref.__gcc_personality_v0,"awG",@progbits,DW.ref.__gcc_personality_v0,comdat .type DW.ref.__gcc_personality_v0, @object DW.ref.__gcc_personality_v0: -#ifndef __x86_64 +#ifndef __LP64__ .align 4 .size DW.ref.__gcc_personality_v0, 4 .long __gcc_personality_v0 @@ -504,7 +516,7 @@ DW.ref.__gcc_personality_v0: #endif #endif -#ifdef __x86_64__ +#if defined __x86_64__ && defined __LP64__ # This entry point is used for the large model. With this entry point # the upper 32 bits of %r10 hold the argument size and the lower 32 @@ -537,7 +549,7 @@ __morestack_large_model: .size __morestack_large_model, . - __morestack_large_model #endif -#endif /* __x86_64__ */ +#endif /* __x86_64__ && __LP64__ */ # Initialize the stack test value when the program starts or when a # new thread starts. We don't know how large the main stack is, so we @@ -570,7 +582,11 @@ __stack_split_initialize: #else /* defined(__x86_64__) */ leaq -16000(%rsp),%rax # We should have at least 16K. +#ifdef __LP64__ movq %rax,%fs:0x70 +#else + movl %eax,%fs:0x40 +#endif movq %rsp,%rdi movq $16000,%rsi #ifdef __PIC__ @@ -592,7 +608,7 @@ __stack_split_initialize: .section .ctors.65535,"aw",@progbits -#ifndef __x86_64__ +#ifndef __LP64__ .align 4 .long __stack_split_initialize .long __morestack_load_mmap