From mboxrd@z Thu Jan 1 00:00:00 1970 From: "John David Anglin" To: binutils@sourceware.cygnus.com, gdb@sourceware.cygnus.com Subject: VAX PC RELATIVE JMP: gas and gdb perform incorrect sign extension Date: Mon, 21 Aug 2000 11:58:00 -0000 Message-id: <200008211858.OAA02260@hiauly1.hia.nrc.ca> X-SW-Source: 2000-08/msg00097.html 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)