This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linux/PPC gcc 2.95.2 - bad access generated when using inline func


At 14:44 30.06.00, Richard Earnshaw wrote:
>You need to provide an eh_epilogue insn when using this technique.

Hmm, we have a eh_epilogue define_expand on PPC, but I guess I trigger 
something that isn't handled so far.

Find appended the current patch I'm working with and a testcase. Currently 
the testcase still aborts with even my patch, but this is due to bug in 
label handling in the current mainline, the buggy code looks like that on PPC:

.L10:
.L11:
         slwi 0,30,2
         lwzx 0,31,0
         mtlr 0
         blrl
         lis 11,ret_addr@ha
         lwz 0,ret_addr@l(11)
         lis 9,.L11@ha
         la 9,.L11@l(9)
         cmpw 0,0,9
         beq+ 0,.L9
         bl abort
.L9:

Label .L11 has been moved in front of the function call :-(. It should be 
placed immediately after the blrl.

It will be a few hours until I can look at that in depth again.

Franz.


extern void exit (int);
extern void abort (void);
extern void *alloca (int);

void * ret_addr;
char * dummy (void);

void test1 (void)
{
   ret_addr = __builtin_return_address (0);
   return;
}

void test2 (void)
{
   dummy ();
   ret_addr = __builtin_return_address (0);
   return;
}

void test3 (void)
{
   ret_addr = __builtin_return_address (0);
   dummy ();
   return;
}

char * dummy (void)
{
   char * save = (char*) alloca (4);

   return save;
}

int main (void)
{
#ifndef NO_LABEL_VALUES
   void (*func[3])(void) = { test1, test2, test3 };
   int i;

   for (i = 0; i < 3; i++) {
     func[i]();
     ret_label:
     if (&&ret_label != ret_addr)
       abort ();
   }
#endif
   exit (0);
}

return_addr-try1.patch

20000630-1.c


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]