somewhat OT -- trying to build code on the fly then run it

Chris Friesen cfriesen at nortel.com
Wed Apr 6 03:03:44 EST 2005


Benjamin Herrenschmidt wrote:

> bla can only be used for small addresses (or very high addresses), and
> it doesn't take a register argument but an absolute address. You want
> something different, more like
> 
> 	mtctr %2
> 	bctrl
> 
> Though you also need to add proper "clobber" constraints to indicate to
> the compiler what will be clobbered by the routine you are calling (look
> at the syscall macros of the kernel for an example of rather standard
> clobber lists).


Thanks for the tip.  With those changes, the code runs perfectly.  For 
posterity, the new function looks like this:

int dotest(void *p)
{
         int i=0;
         asm volatile (" \n\
                 mr 3,%1 \n\
		mtctr %2  \n\
		bctrl  \n\
                 mr %0,3 \n"
                 : "=r" (i)
                 : "r" (i), "r" (p)
		: "ctr", "lr");
         return i;
}


The bad news is that it seems to indicate that our kernel code to flush 
the icache doesn't seem to work.  I'll open a new thread for that.

Chris



More information about the Linuxppc-dev mailing list