------- Comment #3 from lessen42+gcc at gmail dot com 2009-07-28 08:45 ------- (In reply to comment #2) > The point made is correct but there is something you've missed in your patch ! > loading lr with the address of the function you want to call, destroys the > return address ,- so your code is never going to return ! > > Instead you want - > > ldr r3,[r3] > blx r3 > > Or better still bx r3 but that is PR19599 :)
blx sets the link register to the correct return address as a part of the instruction, and the return address of the calling function has to already have been saved before this point or the mov lr, pc would destroy it already. Though perhaps the code should just always use ip with armv5+ like on the other side of the if() since that's callee saved and the tail-optimized "bx lr" would be suboptimal, since that's considered a function return. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40887