This is the mail archive of the gcc-patches@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] |
Other format: | [Raw text] |
I came across this last night on an application I built with gcc-3.3 The code sequence for calling via a function pointer on ARM is normally mov lr, pc ldr pc, [address] This works fine unless ADDRESS references the link register (LR). To work around this we copy LR into IP if it is referenced (since IP will be clobbered by the call). Unfortunately, if IP was also live (ie part of the address) then we get corrupt code, something like mov ip, lr mov lr, pc ldr pc, [ip, ip] // Ooops This patch fixes things so that we do the load in the first instruction, thus guaranteeing that we don't earlyclobber anything... ldr ip, [lr, ip] mov lr, pc mov pc, ip // Kills ip Checking back through some archives I find that I added the original code for this in October 93! It's amazing how long some bugs can lie dormant. 2003-06-13 Richard Earnshaw <rearnsha@arm.com> * arm.c (output_call_mem): If the address references the link-register use an instruction sequence that avoids early-clobbering IP. (eliminate_lr2ip): Delete.
Attachment:
call-mem.patch
Description: call-mem.patch
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |