PATCH: Symbian OS handling of R_ARM_RELATIVE

Mark Mitchell mark@codesourcery.com
Thu Nov 4 19:12:00 GMT 2004


Symbian OS can relocate the data segement and text segment sparately.
So, when generating an R_ARM_RELATIVE relocation we must say to which
segment the relocation is relative.  The BPABI lets us pick any symbol
in the segement to use for that purpose.

OK?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-11-04  Mark Mitchell  <mark@codesourcery.com>

	* elf32-arm.c (elf32_arm_final_link_relocate): When generating an
	R_ARM_RELATIVE relocation for Symbian OS, mention the section
	symbol in the relocation.

Index: elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.2
diff -c -5 -p -r1.2 elf32-arm.c
*** elf32-arm.c	4 Nov 2004 18:57:34 -0000	1.2
--- elf32-arm.c	4 Nov 2004 19:05:23 -0000
*************** elf32_arm_final_link_relocate (reloc_how
*** 2374,2386 ****
  		       || !info->symbolic
  		       || !h->def_regular))
  	    outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
  	  else
  	    {
  	      /* This symbol is local, or marked to become local.  */
  	      relocate = TRUE;
! 	      outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
  	    }
  
  	  loc = sreloc->contents;
  	  loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
  	  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
--- 2374,2403 ----
  		       || !info->symbolic
  		       || !h->def_regular))
  	    outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
  	  else
  	    {
+ 	      int symbol;
+ 
  	      /* This symbol is local, or marked to become local.  */
  	      relocate = TRUE;
! 	      if (globals->symbian_p)
! 		/* On Symbian OS, the data segment and text segement
! 		   can be relocated independently.  Therefore, we must
! 		   indicate the segment to which this relocation is
! 		   relative.  The BPABI allows us to use any symbol in
! 		   the right segment; we just the section symbol as it
! 		   is convenient.  (We cannot use the symbol given by
! 		   "h" directly as it will not appear in the dynamic
! 		   symbol table.)  */
! 		symbol = input_section->output_section->target_index;
! 	      else
! 		/* On SVR4-ish systems, the dynamic loader cannot
! 		   relocate the text and data segments independently,
! 		   so the symbol does not matter.  */
! 		symbol = 0;
! 	      outrel.r_info = ELF32_R_INFO (symbol, R_ARM_RELATIVE);
  	    }
  
  	  loc = sreloc->contents;
  	  loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
  	  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);



More information about the Binutils mailing list