Nick Maclaren writes: > SandeepThorat <sathorat2003@xxxxxxxxx> wrote: > > > > i want to make some modification to prolouge(& epilouge) function of > > gcc compiler. I m using version 4.1.0. > > > > Can anybody tel me out- which file contain these functions, How to make > > changes & how to recompile it to take effect. > > I can tell you quite a lot of that, at least for the Intel x86, but > I failed to reverse engineer the source enough to make the changes > I wanted (even with help), and didn't have time to reverse engineer > the code generation. Try this. It won't work if __limit and __failure are in different shared objects, but it should be OK otherwise. Andrew. Index: i386.c =================================================================== --- i386.c (revision 124185) +++ i386.c (working copy) @@ -1536,6 +1536,7 @@ static void ix86_compute_frame_layout (struct ix86_frame *); static bool ix86_expand_vector_init_one_nonzero (bool, enum machine_mode, rtx, rtx, int); +static rtx ix86_expand_int_compare (enum rtx_code code, rtx op0, rtx op1); /* The svr4 ABI for the i386 says that records and unions are returned @@ -5831,6 +5832,9 @@ /* Expand the prologue into a bunch of separate insns. */ +static GTY(()) rtx limit; +static GTY(()) rtx failure_function; + void ix86_expand_prologue (void) { @@ -6020,6 +6024,38 @@ REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_MAYBE_DEAD, const0_rtx, NULL); } + { + if (limit == NULL_RTX) + { + tree foo = build_decl (VAR_DECL, get_identifier ("__limit"), + build_pointer_type (void_type_node)); + DECL_EXTERNAL (foo) = true; + layout_decl (foo, 0); + rest_of_decl_compilation (foo, true, 0); + limit = DECL_RTL (foo); + + foo = build_decl (FUNCTION_DECL, get_identifier ("__failure"), + build_function_type (void_type_node, void_list_node)); + DECL_EXTERNAL (foo) = true; + rest_of_decl_compilation (foo, true, 0); + failure_function = DECL_RTL (foo); + } + + { + rtx label = gen_label_rtx (); + rtx tmp = ix86_expand_int_compare (GEU, stack_pointer_rtx, limit); + tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp, + gen_rtx_LABEL_REF (VOIDmode, label), + pc_rtx); + tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp)); + JUMP_LABEL (tmp) = label; + ix86_expand_call (NULL_RTX, failure_function, const0_rtx, constm1_rtx, + NULL_RTX, 0); + emit_label (label); + LABEL_NUSES (label) = 1; + } + } + /* Prevent function calls from be scheduled before the call to mcount. In the pic_reg_used case, make sure that the got load isn't deleted. */ if (current_function_profile)