spim: octal escape character bug

sxr xiaoruoruo at gmail.com
Tue Mar 11 03:03:32 UTC 2008


Package: spim
Version: 7.3-1
Severity: minor

The lexical parser wrongly parses octal escape character in a string.

For example:
$ cat test.s
.data
hello:	.asciiz	"\100"

.text
main:
	li $v0, 1
	lbu $a0, hello
	syscall #BUG: should output 64 instead of 0

	li $v0, 10
	syscall # exit
$ spim test.s
SPIM Version 7.3. of August 28, 2006
Copyright 1990-2004 by James R. Larus (larus at cs.wisc.edu).
All Rights Reserved.
See the file README for a full copyright notice.
Loaded: /usr/lib/spim/exceptions.s
0
$

I suggest the following patch. 
--- CPU/scanner.l~	2006-08-29 10:23:17.000000000 +0800
+++ CPU/scanner.l	2008-03-11 10:33:42.000000000 +0800
@@ -454,7 +454,7 @@
 	    int b = (*(str + 1) - '0') << 3;
 
 	    if ('0' <= c2 && c2 <= '7')
-	      b = (c2 - '0') << 3;
+	      b = (b + (c2 - '0')) << 3;
 	    else
 	      yyerror ("Bad character in \\ooo construct in string");

-- System Information:
Debian Release: lenny/sid
  APT prefers gutsy-updates
  APT policy: (500, 'gutsy-updates'), (500, 'gutsy-security'), (500, 'gutsy-proposed'), (500, 'gutsy-backports'), (500, 'gutsy')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-14-generic (SMP w/1 CPU core)
Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages spim depends on:
ii  libc6                   2.6.1-1ubuntu10  GNU C Library: Shared libraries
ii  libice6                 2:1.0.3-3        X11 Inter-Client Exchange library
ii  libsm6                  2:1.0.3-1        X11 Session Management library
ii  libx11-6                2:1.1.1-1ubuntu4 X11 client-side library
ii  libxaw7                 2:1.0.3-3ubuntu1 X11 Athena Widget library
ii  libxext6                2:1.0.3-2build1  X11 miscellaneous extension librar
ii  libxmu6                 2:1.0.3-1ubuntu1 X11 miscellaneous utility library
ii  libxpm4                 1:3.5.6-3        X11 pixmap library
ii  libxt6                  1:1.0.5-3        X11 toolkit intrinsics library

spim recommends no packages.

-- no debconf information




More information about the ubuntu-users mailing list