darwin fix-and-continue support

Roger Sayle roger@eyesopen.com
Sat Aug 21 18:14:00 GMT 2004


On Sat, 21 Aug 2004, Mike Stump wrote:
> I've tried to add enough comments for people not versed in macho, uhm,
> code generation to have a fighting chance in understanding some of
> what's going on...

I suspect that one of the reasons people asked what appeared to be
silly questions, is in an attempt to understand what appears to be
a silly solution...


> !       /* gdb on darwin arranges to forward a function from the old
> ! 	 address by modifying the first 4 instructions of the function
> ! 	 to branch to the overriding function.  This is necessary to
> ! 	 permit function pointers that point to the old function to
> ! 	 actually forward to the new function.  */
> !       emit_insn (gen_nop ());
> !       emit_insn (gen_nop ());
> !       emit_insn (gen_nop ());
> !       emit_insn (gen_nop ());

Is there any reason why you don't just guarantee that a function is
always at least 16 bytes long, rather than add these four NOPs into
every prologue?  If these values get over written during during fix
and continue, and contain either an unconditional jump or a call followed
by a return, there's no reason why you just don't overwrite the first
four words of a function.

This could trivially be handled by increasing the required function
alignment to 16 bytes, which would guarantee this property, or if
function alignment is allowed to be less than this, by tweaking
rs6000_emit_epilogue to add the required padding after the return
for very short functions (which would have no run-time overhead).

Roger
--



More information about the Gcc-patches mailing list