From patchwork Fri Jan 31 04:18:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 315509 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 ECCEA2C00A5 for ; Fri, 31 Jan 2014 15:18:54 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; q=dns; s=default; b=t5Pg9rmGrJp2Qlt 2G0sCbLjtyLRLNJJDyVHxtpX9xLbBwlV2XXb44COShzYSy/X/em+1IpErWOcO8Oy cV1nXkCGxyfu7WeVKWGqL4tW1ACCYEMuEBVj/itjEZ88bU0+0uL7a1vN4Y/7Am7f s2mW4fZ6q3tTUL+I62VaVrIQck10= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; s=default; bh=T406BWJGhUTFq4wSG8DNd cuRjt4=; b=a59WHH9wzRa0Itc7hYbKViTWeedhXojqCn6wQZswZM3ks6FV/Ve1G ASAZL0Q2Iff9c4XFVFrwKK8n5+nChiKMyj/a7Ssd3FsFRGVHQ9mqKR1cFNhXoZbD tjzbnP0C8/aMp/GJpV2+d1o+pFaUYjcukMlOxQJTrKJ8dFQbAWhmpg= Received: (qmail 8955 invoked by alias); 31 Jan 2014 04:18:46 -0000 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 Received: (qmail 8944 invoked by uid 89); 31 Jan 2014 04:18:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 Jan 2014 04:18:45 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0V4Iht4020072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 Jan 2014 23:18:43 -0500 Received: from greed.delorie.com (ovpn-113-173.phx2.redhat.com [10.3.113.173]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0V4IfpB023139 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 30 Jan 2014 23:18:42 -0500 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id s0V4Ie2x020847 for ; Thu, 30 Jan 2014 23:18:40 -0500 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id s0V4IeQk020841; Thu, 30 Jan 2014 23:18:40 -0500 Date: Thu, 30 Jan 2014 23:18:40 -0500 Message-Id: <201401310418.s0V4IeQk020841@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: [msp430] more new libgloss feature support X-IsSubscribed: yes More code to support new libgloss features. This one lets the linker leave out the call to exit() in crt0 (and thus all the exit() code also) if main() doesn't exit. Committed. * config/msp430/msp430.h (LIB_SPEC): Add -lcrt * config/msp430/msp430.md (msp430_refsym_need_exit): New. * config/msp430/msp430.c (msp430_expand_epilogue): Call it whenever main() has an epilogue. Index: config/msp430/msp430.md =================================================================== --- config/msp430/msp430.md (revision 207333) +++ config/msp430/msp430.md (working copy) @@ -42,12 +42,14 @@ UNS_DINT UNS_EINT UNS_PUSH_INTR UNS_POP_INTR UNS_BIC_SR UNS_BIS_SR + + UNS_REFSYM_NEED_EXIT ]) (include "predicates.md") (include "constraints.md") (define_mode_iterator QHI [QI HI PSI]) @@ -935,12 +937,20 @@ (define_insn "epilogue_start_marker" [(unspec_volatile [(const_int 0)] UNS_EPILOGUE_START_MARKER)] "" "; start of epilogue" ) +;; This makes the linker add a call to exit() after the call to main() +;; in crt0 +(define_insn "msp430_refsym_need_exit" + [(unspec_volatile [(const_int 0)] UNS_REFSYM_NEED_EXIT)] + "" + ".refsym\t__crt0_call_exit" + ) + ;;------------------------------------------------------------ ;; Jumps (define_expand "call" [(call:HI (match_operand 0 "") (match_operand 1 ""))] Index: config/msp430/msp430.c =================================================================== --- config/msp430/msp430.c (revision 207333) +++ config/msp430/msp430.c (working copy) @@ -1426,12 +1426,15 @@ msp430_expand_epilogue (int is_eh) break; } } emit_insn (gen_epilogue_start_marker ()); + if (cfun->decl && strcmp (IDENTIFIER_POINTER (DECL_NAME (cfun->decl)), "main") == 0) + emit_insn (gen_msp430_refsym_need_exit ()); + if (is_wakeup_func ()) /* Clear the SCG1, SCG0, OSCOFF and CPUOFF bits in the saved copy of the status register current residing on the stack. When this function executes its RETI instruction the SR will be updated with this saved value, thus ensuring that the processor is woken up from any low power state in which it may be residing. */ Index: config/msp430/msp430.h =================================================================== --- config/msp430/msp430.h (revision 207333) +++ config/msp430/msp430.h (working copy) @@ -65,12 +65,13 @@ extern bool msp430x; #undef LIB_SPEC #define LIB_SPEC " \ --start-group \ -lc \ -lgcc \ +-lcrt \ %{msim:-lsim} \ %{!msim:-lnosys} \ --end-group \ %{!T*:%{!msim:%{mmcu=*:--script=%*.ld}}} \ %{!T*:%{!msim:%{!mmcu=*:%Tmsp430.ld}}} \ %{!T*:%{msim:%{mlarge:%Tmsp430xl-sim.ld}%{!mlarge:%Tmsp430-sim.ld}}} \