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: SH @(expr,pc) fix-ups broken


>>> IMO, the `-4' should be taken out

Agreed; I've only seen this thread after you already decided that, so
I reasoned that there was no point in engaging in further discussion
about it.

However, this is just a red herring when it comes to the impact of the
patch.  You make @(expr, pc) work consistently so that it makes no
difference anymore if you say @(num, pc) or @(symbol-., pc), assuming
the difference between symbol and . is num.

However, gas used to support @(symbol, pc) so that

        ld @(L0, pc)
meant the same as
        ld L0,r0

.  This is indeed redundant, but some code actually uses the former syntax,
as it is closer to the syntax used in the processor description.  While it
might be a good idea to change it eventually, it is not a good idea to
change it apruptly and without warning.  I have made a patch that will
allow both @(sym,pc) and @(sym-.),pc to work.
It could be a permanent solution, except that sym might be a forward or
external reference, and the symbol eventually defined to be the difference
of two symbols or a symbol and the program counter, so that in the end it is
a scalar offset.  We could handle this correctly by emitting special relocations
and then fixing it up in the linker, but I think that would be overkill; the
mentioned problem areas are unlikely to occur by accident and easy to avoid.
I've added a warning for the @(sym,pc) construct, and after this has been in
a few releases, I think we can switch again to the current state.  

-- 
--------------------------
SuperH
2430 Aztec West / Almondsbury / BRISTOL / BS32 4AQ
T:+44 1454 462330
Thu Jun  6 17:42:12 2002  J"orn Rennecke <joern.rennecke@superh.com>

	* config/tc-sh.c (parse_at): @(symbol,pc) is A_DISP_PC again,
	but warn about it.
	* testsuite/gas/sh/pcrel.s: Also test @(symbol,pc).
	* testsuite/gas/sh/pcrel.d: Update.
	* testsuite/gas/sh/pcrel.l: New file.

Index: config/tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.62
diff -p -r1.62 tc-sh.c
*** config/tc-sh.c	11 May 2002 11:31:17 -0000	1.62
--- config/tc-sh.c	6 Jun 2002 16:42:00 -0000
*************** parse_at (src, op)
*** 1383,1392 ****
  		}
  	      else if (mode == A_PC)
  		{
! 		  op->type = A_DISP_PC_ABS;
! 		  /* Such operands don't get corrected for PC==.+4, so
! 		     make the correction here.  */
! 		  op->immediate.X_add_number -= 4;
  		}
  	      else
  		{
--- 1383,1400 ----
  		}
  	      else if (mode == A_PC)
  		{
! 		  if (op->immediate.X_op == O_symbol)
! 		    {
! 		      op->type = A_DISP_PC;
! 		      as_warn (_("Deprecated syntax."));
! 		    }
! 		  else
! 		    {
! 		      op->type = A_DISP_PC_ABS;
! 		      /* Such operands don't get corrected for PC==.+4, so
! 			 make the correction here.  */
! 		      op->immediate.X_add_number -= 4;
! 		    }
  		}
  	      else
  		{
Index: testsuite/gas/sh/pcrel.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/sh/pcrel.d,v
retrieving revision 1.1
diff -p -r1.1 pcrel.d
*** testsuite/gas/sh/pcrel.d	4 Feb 2002 12:29:32 -0000	1.1
--- testsuite/gas/sh/pcrel.d	6 Jun 2002 16:42:00 -0000
***************
*** 1,21 ****
  #as: -big
  #objdump: -d
  #name: PC-relative loads
  
  .*:     file format .*sh.*
  
  Disassembly of section .text:
  
  00000000 <code>:
!    0:	d1 03       	mov\.l	10 <litpool>,r1	! 0xfffffff0
!    2:	d1 03       	mov\.l	10 <litpool>,r1	! 0xfffffff0
!    4:	c7 02       	mova	10 <litpool>,r0
!    6:	61 02       	mov\.l	@r0,r1
!    8:	d1 01       	mov\.l	10 <litpool>,r1	! 0xfffffff0
!    a:	01 03       	bsrf	r1
!    c:	00 09       	nop	
!    e:	00 09       	nop	
  
! 00000010 <litpool>:
!   10:	ff ff       	\.word 0xffff
!   12:	ff f0       	\.word 0xfff0
--- 1,24 ----
  #as: -big
  #objdump: -d
  #name: PC-relative loads
+ #stderr: pcrel.l
  
  .*:     file format .*sh.*
  
  Disassembly of section .text:
  
  00000000 <code>:
!    0:	d0 04       	mov\.l	14 <litpool>,r0	! 0xffffffec
!    2:	d1 05       	mov\.l	18 <litpool\+0x4>,r1
!    4:	d1 03       	mov\.l	14 <litpool>,r1	! 0xffffffec
!    6:	d1 03       	mov\.l	14 <litpool>,r1	! 0xffffffec
!    8:	c7 02       	mova	14 <litpool>,r0
!    a:	61 02       	mov\.l	@r0,r1
!    c:	d1 01       	mov\.l	14 <litpool>,r1	! 0xffffffec
!    e:	01 03       	bsrf	r1
!   10:	00 09       	nop	
!   12:	00 09       	nop	
  
! 00000014 <litpool>:
!   14:	ff ff       	\.word 0xffff
!   16:	ff ec       	\.word 0xffec
Index: testsuite/gas/sh/pcrel.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/sh/pcrel.s,v
retrieving revision 1.1
diff -p -r1.1 pcrel.s
*** testsuite/gas/sh/pcrel.s	4 Feb 2002 12:29:32 -0000	1.1
--- testsuite/gas/sh/pcrel.s	6 Jun 2002 16:42:00 -0000
***************
*** 2,7 ****
--- 2,9 ----
  
  	.p2align 2
  code:
+ 	mov.l	@(litpool,pc), r0
+ 	mov.l	@(litpool+4,pc), r1
  	mov.l	litpool, r1
  	mov.l	@(14,pc), r1
  	mova	@(litpool-.,pc), r0
*** /dev/null	Thu Aug 30 21:30:55 2001
--- testsuite/gas/sh/pcrel.l	Thu Jun  6 17:41:15 2002
***************
*** 0 ****
--- 1,3 ----
+ [^:]*pcrel.s: Assembler messages:
+ [^:]*pcrel(-coff)?\.s:5: Warning: Deprecated syntax.
+ [^:]*pcrel(-coff)?\.s:6: Warning: Deprecated syntax.

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