]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* config/msp430/msp430.h (LIB_SPEC): Add -lcrt
authordj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Jan 2014 04:17:38 +0000 (04:17 +0000)
committerdj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Jan 2014 04:17:38 +0000 (04:17 +0000)
* config/msp430/msp430.md (msp430_refsym_need_exit): New.
* config/msp430/msp430.c (msp430_expand_epilogue): Call it
whenever main() has an epilogue.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207334 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/msp430/msp430.c
gcc/config/msp430/msp430.h
gcc/config/msp430/msp430.md

index 8939e12abdc19068e7e4c06e1b310251137759a2..158f2d6a12ee91e698c734ad782704f32d099ae2 100644 (file)
@@ -1,3 +1,10 @@
+2014-01-30  DJ Delorie  <dj@redhat.com>
+
+       * 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.
+
 2014-01-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * config/rs6000/rs6000.c (rs6000_expand_vector_init): Remove
index 8b0af1a3e0111afd180a0857295d0def86f59bb7..97fa3f5a18b69890e9080aa9fc2bc75cfd0f0a5a 100644 (file)
@@ -1429,6 +1429,9 @@ msp430_expand_epilogue (int is_eh)
 
   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
index 1afbfd44dbe2140f0677411787b781831bf56e8b..f31247489d297fe0d39e7d4c81abfbc1003a5edc 100644 (file)
@@ -68,6 +68,7 @@ extern bool msp430x;
 --start-group                                          \
 -lc                                                    \
 -lgcc                                                  \
+-lcrt                                                  \
 %{msim:-lsim}                                          \
 %{!msim:-lnosys}                                       \
 --end-group                                            \
index ee01cd1943c3a34be83c6dd1df076e8c0d4a9b74..0037d8b16f86f741f771b4057f54856f9424d5be 100644 (file)
@@ -45,6 +45,8 @@
    UNS_POP_INTR
    UNS_BIC_SR
    UNS_BIS_SR
+
+   UNS_REFSYM_NEED_EXIT
   ])
   
 (include "predicates.md")
   "; 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