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]

pc-relative relocs on alpha


The following test case is currently broken:

.section foo
	.long 0
	.long BAR - .
.section bar
	.globl BAR
BAR:
	.long 0

Current result is

  Offset          Info           Type         Sym. Name + Addend
000000000004  00060000000a R_ALPHA_SREL32     BAR + fffffffffffffffc

Expected result is

000000000004  00060000000a R_ALPHA_SREL32     BAR + 0

I tried working my way through fixup_segment.  The bits around
line 2673 that convert the subtraction to a pc-relative fixup
look ok, but then we get down to line 2718 and apply
MD_PCREL_FROM_SECTION a second time, which is where things appear
to fall over.

I _think_ the following patch may be necessary, but I'm not sure.
(Certainly the last time I fiddled with all this it was via trial
and error.)  The fact to consider here is the branch relocations
need to be relative to the end of the instruction rather than the
beginning.

Guidance with the re-written relocation scheme would be appreciated.


r~


Index: tc-alpha.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.c,v
retrieving revision 1.47
diff -c -p -d -r1.47 tc-alpha.c
*** tc-alpha.c	5 Sep 2002 00:01:16 -0000	1.47
--- tc-alpha.c	18 Sep 2002 16:13:40 -0000
*************** md_pcrel_from (fixP)
*** 1139,1150 ****
    valueT addr = fixP->fx_where + fixP->fx_frag->fr_address;
    switch (fixP->fx_r_type)
      {
!     case BFD_RELOC_ALPHA_GPDISP:
!     case BFD_RELOC_ALPHA_GPDISP_HI16:
!     case BFD_RELOC_ALPHA_GPDISP_LO16:
!       return addr;
      default:
!       return fixP->fx_size + addr;
      }
  }
  
--- 1139,1150 ----
    valueT addr = fixP->fx_where + fixP->fx_frag->fr_address;
    switch (fixP->fx_r_type)
      {
!     case BFD_RELOC_23_PCREL_S2:
!     case BFD_RELOC_ALPHA_HINT:
!     case BFD_RELOC_ALPHA_BRSGP:
!       return addr + 4;
      default:
!       return addr;
      }
  }
  


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