On Jan 17, 2008 8:21 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Thu, Jan 17, 2008 at 04:15:23PM +0800, Bean wrote: > > > > You need to add NESTED_FUNC_ATTR to nested callback function that use > > local variable. here is the patch: > > Glad to see you found the reason! > > But I don't get it. I see that: > > #define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2))) > > so does this mean in one of the calls the caller and callee disagreed about > how the third param is passed? > > Also, we have a lot of nested functions without this macro. How does one > distinguish the ones that need it from the ones that don't?
Embedded function used %ecx to store the pointer to it's parent's stack. However, the program is compiled using option -mregparm=3, which means it can use up to 3 registry to pass parameter.In grub_elf32_load_segment, there are three parameter elf, phdr and hook, which will take up %eax, %edx and %ecx. The value of %ecx, hook, will be overwritten. Use NESTED_FUNC_ATTR ensure that only the first two parameter will be passed using registry This problem can occur when the following conditions are true: 1, Use embedded function as callback. 2, The embedded function use local variable in it's parent's stack. 3, The embedded function has at least three parameters. -- Bean _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel