public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix thumb calls via PLT on ARM/SymbianOS
@ 2005-03-16 14:52 Julian Brown
  2005-03-16 14:56 ` Richard Earnshaw
  0 siblings, 1 reply; 18+ messages in thread
From: Julian Brown @ 2005-03-16 14:52 UTC (permalink / raw)
  To: binutils; +Cc: julian

[-- Attachment #1: Type: text/plain, Size: 645 bytes --]

Hi,

This patch fixes calls made from thumb mode via the PLT on SymbianOS. 
PLT entries are written in ARM mode, but previously they were being 
called in thumb mode, with their address incorrectly offset by -4 
(PLT_THUMB_STUB_SIZE).

Now, the target address has been corrected and the thumb BL instruction 
is rewritten as BLX to perform the mode switch before attempting to 
execute the PLT entry. (BLX is an armv5t instruction, but as SymbianOS 
is only targeted at armv5t+, this should always be OK.)

The hardwired "4" for the thumb stub size on non-SymbianOS targets has 
also been rewritten as PLT_THUMB_STUB_SIZE.

OK to apply?

Julian

[-- Attachment #2: patch-3 --]
[-- Type: text/plain, Size: 1191 bytes --]

Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.22
diff -c -p -r1.22 elf32-arm.c
*** bfd/elf32-arm.c	11 Feb 2005 16:41:09 -0000	1.22
--- bfd/elf32-arm.c	16 Mar 2005 12:38:29 -0000
*************** elf32_arm_final_link_relocate (reloc_how
*** 2692,2699 ****
  	    value = (splt->output_section->vma
  		     + splt->output_offset
  		     + h->plt.offset);
! 	    /* Target the Thumb stub before the ARM PLT entry.  */
! 	    value -= 4;
  	  }
  
  	relocation = value + signed_addend;
--- 2692,2708 ----
  	    value = (splt->output_section->vma
  		     + splt->output_offset
  		     + h->plt.offset);
! 	    if (globals->symbian_p)
! 	      {
! 		/* On SymbianOS, we are guaranteed to be using at least ARMv5t.
! 		   Convert the BL to a BLX instruction to call the ARM-mode PLT
! 		   entry.  */
! 		if ((lower_insn & (0x3 << 11)) == 0x3 << 11)
! 		  lower_insn = (lower_insn & ~(0x3 << 11)) | 0x1 << 11;
! 	      }
! 	    else
! 	      /* Target the Thumb stub before the ARM PLT entry.  */
! 	      value -= PLT_THUMB_STUB_SIZE;
  	  }
  
  	relocation = value + signed_addend;

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2005-03-23 14:41 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-16 14:52 [PATCH] Fix thumb calls via PLT on ARM/SymbianOS Julian Brown
2005-03-16 14:56 ` Richard Earnshaw
2005-03-16 15:27   ` Daniel Jacobowitz
2005-03-16 16:10     ` Julian Brown
2005-03-16 16:29       ` Richard Earnshaw
2005-03-16 16:34         ` Julian Brown
2005-03-16 16:42       ` Ian Lance Taylor
2005-03-16 16:54         ` Richard Earnshaw
2005-03-16 17:16           ` Ian Lance Taylor
2005-03-16 17:34             ` Richard Earnshaw
2005-03-16 22:00               ` Ian Lance Taylor
2005-03-17  0:13                 ` Richard Earnshaw
2005-03-18 19:59                   ` Julian Brown
2005-03-17 20:58           ` [PATCH] Fix thumb calls via PLT on ARM/SymbianOS (rfc) Julian Brown
2005-03-17 21:03             ` Question! NK
2005-03-23 20:11               ` Question! Nick Clifton
2005-03-17 21:25             ` [PATCH] Fix thumb calls via PLT on ARM/SymbianOS (rfc) Paul Brook
2005-03-16 16:16     ` [PATCH] Fix thumb calls via PLT on ARM/SymbianOS Richard Earnshaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).