Advertisement
Guest User

gcc-4.5.1 x86 naked patch (experimental)

a guest
Mar 2nd, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.19 KB | None | 0 0
  1. diff -cr gcc.orig/gcc/config/i386/i386.c gcc/gcc/config/i386/i386.c
  2. *** gcc.orig/gcc/config/i386/i386.c   Thu Jul 22 06:42:02 2010
  3. --- gcc/gcc/config/i386/i386.c   Thu Aug 19 17:24:05 2010
  4. ***************
  5. *** 4842,4847 ****
  6. --- 4842,4855 ----
  7.     return false;
  8.   }
  9.  
  10. + static bool
  11. + ix86_function_naked (const_tree fntype)
  12. + {
  13. +   if (lookup_attribute ("naked", DECL_ATTRIBUTES (fntype)))
  14. +     return true;
  15. +   return false;
  16. + }
  17. +
  18.   static enum calling_abi
  19.   ix86_function_abi (const_tree fndecl)
  20.   {
  21. ***************
  22. *** 8478,8483 ****
  23. --- 8486,8494 ----
  24.     struct ix86_frame frame;
  25.     HOST_WIDE_INT allocate;
  26.     int gen_frame_pointer = frame_pointer_needed;
  27. +  
  28. +   if (ix86_function_naked (current_function_decl))
  29. +     return ;
  30.  
  31.     ix86_finalize_stack_realign_flags ();
  32.  
  33. ***************
  34. *** 8978,8983 ****
  35. --- 8989,8997 ----
  36.     HOST_WIDE_INT offset, red_offset;
  37.     struct machine_cfa_state cfa_state_save = *ix86_cfa_state;
  38.     bool using_drap;
  39. +  
  40. +   if (ix86_function_naked (current_function_decl))
  41. +     return ;
  42.  
  43.     ix86_finalize_stack_realign_flags ();
  44.  
  45. ***************
  46. *** 26117,26122 ****
  47. --- 26131,26152 ----
  48.       return NULL_TREE;
  49.   }
  50.  
  51. + static tree
  52. + ix86_handle_naked_attribute (tree *node, tree name,
  53. +                               tree args ATTRIBUTE_UNUSED,
  54. +                               int flags ATTRIBUTE_UNUSED, bool *no_add_attrs)
  55. + {
  56. +   if (TREE_CODE (*node) != FUNCTION_DECL)
  57. +     {
  58. +       warning (OPT_Wattributes, "%qE attribute only applies to functions",
  59. +                name);
  60. +       *no_add_attrs = true;
  61. +       return NULL_TREE;
  62. +     }
  63. +
  64. +     return NULL_TREE;
  65. + }
  66. +
  67.   static bool
  68.   ix86_ms_bitfield_layout_p (const_tree record_type)
  69.   {
  70. ***************
  71. *** 28988,28993 ****
  72. --- 29018,29024 ----
  73.     { "sysv_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
  74.     { "ms_hook_prologue", 0, 0, true, false, false, ix86_handle_fndecl_attribute },
  75.     /* End element.  */
  76. +   { "naked", 0, 0, true, false, false, ix86_handle_naked_attribute },
  77.     { NULL,        0, 0, false, false, false, NULL }
  78.   };
  79.  
  80. diff -cr gcc.orig/gcc/function.c gcc/gcc/function.c
  81. *** gcc.orig/gcc/function.c   Fri Feb 26 15:58:57 2010
  82. --- gcc/gcc/function.c   Thu Aug 19 17:11:26 2010
  83. ***************
  84. *** 5212,5224 ****
  85.         start_sequence ();
  86.         epilogue_end = emit_note (NOTE_INSN_EPILOGUE_BEG);
  87.         seq = gen_epilogue ();
  88. !       emit_jump_insn (seq);
  89. !
  90. !       /* Retain a map of the epilogue insns.  */
  91. !       record_insns (seq, NULL, &epilogue_insn_hash);
  92. !       set_insn_locators (seq, epilogue_locator);
  93.  
  94. !       seq = get_insns ();
  95.         end_sequence ();
  96.  
  97.         insert_insn_on_edge (seq, e);
  98. --- 5212,5228 ----
  99.         start_sequence ();
  100.         epilogue_end = emit_note (NOTE_INSN_EPILOGUE_BEG);
  101.         seq = gen_epilogue ();
  102. !      
  103. !      if (seq)
  104. !       {
  105. !         emit_jump_insn (seq);
  106.  
  107. !         /* Retain a map of the epilogue insns.  */
  108. !           record_insns (seq, NULL, &epilogue_insn_hash);
  109. !         set_insn_locators (seq, epilogue_locator);
  110. !       }
  111. !      
  112. !      seq = get_insns ();
  113.         end_sequence ();
  114.  
  115.         insert_insn_on_edge (seq, e);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement