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]

VAX PC RELATIVE JMP: gas and gdb perform incorrect sign extension


In trying to build the current cvs version of gcc, I discovered an
obviously long standing bug in the treatment of long pc relative
branches on the vax.  The following code snippet from expand_expr
is incorrectly assembled by gas:

		tstl	r9
		jeql	L2956
		clrl	-(sp)

L2956 is more than 32K bytes back in the code.  After linking, I
see the following with adb:

		tstl	r9
		bneq	0xb4f06
		jmp	0xbf867	; wrong location
0xb4f06:	clrl	-(sp)

The `jmp' actually goes to 0xbf867, so I believe the adb disassembly.
However, when I look with gdb, I get:

                tstl    r9
		bneq    0xb4f06
		jmp     0xaf867 ; location of L2956
0xb4f06:        clrl    -(sp)

The hex value of the pc relative address is 0xa961 (0xb4f06 + 0xa961 =
0xbf867).  However, gas and gdb seem to think that the vax will sign
extend the word 0xa961 to the long word 0xffffa961 (0xb4f06 + 0xffffa961 =
0xaf867).  This is clearly wrong.  The correct offset is 0xffffa961.

The error is present in expr.o, so it is not the linker which causes it.
I am looking at the binutils code.  Suggestions on where to look are welcome.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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