This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: ARM interworking with different linker sections


Hi Eric,

> Attached you will find interwork.zip. After a make, I did an
> "arm-unknown-elf-objdump -d a.out > a.s"
> If you look in the file 'a.s' at line 182 you will see:
> 
> 1c6: f831f000  bl 22c <LedLoop_rom_thumb+0x88>
> 
> The last address in 'a.s' is 0x20a, 0x22c does not exist.

Thanks - using this test case I was able to track down the problem:
When thumb-to-arm stubs are generated the code forgot to take into
account the fact that the stub might be located in a different section
to the BL instruction.  The patch below takes care of this problem.

Cheers
        Nick

2003-02-13  Nick Clifton  <nickc@redhat.com>

	* elf32-arm.h (elf32_thumb_to_arm_stub): Include section VMAs
	in computation of offset to insert into BL instruction.

Index: bfd/elf32-arm.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.h,v
retrieving revision 1.102
diff -c -3 -p -w -r1.102 elf32-arm.h
*** bfd/elf32-arm.h	10 Feb 2003 11:21:19 -0000	1.102
--- bfd/elf32-arm.h	13 Feb 2003 19:30:59 -0000
*************** elf32_thumb_to_arm_stub (info, name, inp
*** 929,941 ****
  
    BFD_ASSERT (my_offset <= globals->thumb_glue_size);
  
!   /* Now go back and fix up the original BL insn to point
!      to here.  */
!   ret_offset = (s->output_offset
! 		+ my_offset
! 		- (input_section->output_offset
! 		   + offset + addend)
! 		- 8);
  
    tmp = bfd_get_32 (input_bfd, hit_data
  		    - input_section->vma);
--- 929,944 ----
  
    BFD_ASSERT (my_offset <= globals->thumb_glue_size);
  
!   /* Now go back and fix up the original BL insn to point to here.  */
!   ret_offset =
!     /* Address of where the stub is located.  */
!     (s->output_section->vma + s->output_offset + my_offset)
!      /* Address of where the BL is located.  */
!     - (input_section->output_section->vma + input_section->output_offset + offset)
!     /* Addend in the relocation.  */
!     - addend
!     /* Biassing for PC-relative addressing.  */
!     - 8;
  
    tmp = bfd_get_32 (input_bfd, hit_data
  		    - input_section->vma);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]