Saving Legacy Software: DLXView (reload) in Ubuntu 10.4 x64

DLXView is a software simulator which let you execute dlx-assembly code over different simulated processor architectures (among them, the famous static planning DLX proccessor, Tomasulo, etc.). This is  used manly for academic proposes by our department. Unfortunately this software quite old. It seems to be quite abandoned since its last modification was in 1997. AFAIK is now obsolete and unusable in several actual systems like Ubuntu 10.4 with x64.

Saving Legacy Software is always a challenge and it’s sometimes funny. This evening, after be struggling a bit with the source code, makefile and debugging with ddd I achieved make it run again properly on Ubuntu 10.4 in a x64 bit processor.

There were several problems:

  • Some pieces of code uses some deprecated system functionality related with error handling.
  • Some data types names overlapped others actual standard data structures.
  • Used libraries were quite old.

Hence in such situation building the code wasn’t possible. However some precompiled versions exist on the internet. They apparently worked fine in my system, but when an dlx-assembly file was loaded the program crashed. It was due to a buffer overflow in his code (specifically in the ReadFile function in the asm.c file). I’m not sure if this is related with the use of 64-bit processor or if it’s related with some changes of Tcl/Tk libraries for using unicode strings. Anyways it was solved making a  specific buffer bigger and using the function snprintf.

Of course these changes don’t assert that old or news problem appear. However it seems to be working fine, as it used to be.
Corrections and suggestions are welcome.

The old and official tarball
• The diff File:

diff -crB dlxview0.9/asm.c dlxview0.9b/asm.c
*** dlxview0.9/asm.c    1997-09-27 00:00:08.000000000 +0200
— dlxview0.9b/asm.c    2010-12-07 19:13:40.000000000 +0100
***************
*** 1368,1375 ****
register LoadInfo *infoPtr;    /* Information about the state of the
* assembly process. */
{
! #define MAX_LINE_SIZE 200
! #define MAX_NAME_SIZE 10
char line[MAX_LINE_SIZE];
char pseudoOp[MAX_NAME_SIZE+1];
FILE *f;
— 1368,1375 —-
register LoadInfo *infoPtr;    /* Information about the state of the
* assembly process. */
{
! #define MAX_LINE_SIZE 2000
! #define MAX_NAME_SIZE 100
char line[MAX_LINE_SIZE];
char pseudoOp[MAX_NAME_SIZE+1];
FILE *f;
***************
*** 1377,1383 ****
int i, nullTerm;
char *end, *curToken;
char savedChar;
!     char msg[40];
double strtod();

f = fopen(fileName, “r”);
— 1377,1383 —-
int i, nullTerm;
char *end, *curToken;
char savedChar;
!     char msg[255];
double strtod();

f = fopen(fileName, “r”);
Only in dlxview0.9: dlxview
diff -crB dlxview0.9/Makefile dlxview0.9b/Makefile
*** dlxview0.9/Makefile    1997-09-27 00:00:08.000000000 +0200
— dlxview0.9b/Makefile    2010-12-07 19:00:28.000000000 +0100
***************
*** 1,8 ****
# environment dependent variables; change these to their appropriate
# directory paths for the X11 and tcl/tk library and header paths
# Solaris paths
! TCL_LIB = /usr/local/lib
! TCL_INC = /usr/local/include
X_LIB = /opt/x11r5/lib
X_INC = /usr/local/X11R5/include
# Linux paths
— 1,8 —-
# environment dependent variables; change these to their appropriate
# directory paths for the X11 and tcl/tk library and header paths
# Solaris paths
! TCL_LIB = /usr/lib
! TCL_INC = /usr/include/tcl
X_LIB = /opt/x11r5/lib
X_INC = /usr/local/X11R5/include
# Linux paths
***************
*** 20,26 ****

# Solaris may need the -lsocket and -lnsl flags added.  Tk4.1 and newer
# also require the -ldl flag.
! LLIBS = ${TCL_LIB}/libtcl7.6.a ${TCL_LIB}/libtk4.2.a -L${X_LIB} -lX11 -lnsl -lsocket -lm -ldl
# LLIBS = ${TCL_LIB}/libtcl.so ${TCL_LIB}/libtk.so -L${X_LIB} -lX11 -lm -ldl
# LLIBS = ${TCL_LIB}/libtcl.a ${TCL_LIB}/libtk.a -L${X_LIB} -lX11 -lm

— 20,26 —-

# Solaris may need the -lsocket and -lnsl flags added.  Tk4.1 and newer
# also require the -ldl flag.
! LLIBS = -g ${TCL_LIB}/libtcl.a ${TCL_LIB}/libtk.a ${TCL_LIB}/libpthread.so ${TCL_LIB}/libc.so -L${X_LIB} -lX11 -lnsl -lm -ldl
# LLIBS = ${TCL_LIB}/libtcl.so ${TCL_LIB}/libtk.so -L${X_LIB} -lX11 -lm -ldl
# LLIBS = ${TCL_LIB}/libtcl.a ${TCL_LIB}/libtk.a -L${X_LIB} -lX11 -lm

***************
*** 30,36 ****
###########################################################################

CC = gcc
! CFLAGS = ${CPPFLAGS} -O -I. -I${TCL_INC} -I${X_INC}
TARGET = dlxview

OBJS = asm.o cop0.o getput.o io.o issue.o main.o script.o sim.o stop.o sym.o trap.o
— 30,36 —-
###########################################################################

CC = gcc
! CFLAGS = ${CPPFLAGS} -O -I. -I${TCL_INC} -I${X_INC} -g
TARGET = dlxview

OBJS = asm.o cop0.o getput.o io.o issue.o main.o script.o sim.o stop.o sym.o trap.o
Only in dlxview0.9: .project
diff -crB dlxview0.9/script.h dlxview0.9b/script.h
*** dlxview0.9/script.h    1997-09-27 00:00:08.000000000 +0200
— dlxview0.9b/script.h    2010-12-07 17:16:15.000000000 +0100
***************
*** 927,934 ****
set help_cmd_stack \”HelpGeneral\”\n\
$t delete 1.0 end\n\
HelpIn help_title {\n\
!                        DLXview: Interactive Animated DLX Pipeline
!                Visualization\n\
}\n\
HelpIn HelpInfo {\n\
1. General Information\n\
— 927,933 —-
set help_cmd_stack \”HelpGeneral\”\n\
$t delete 1.0 end\n\
HelpIn help_title {\n\
!                        DLXview: Interactive Animated DLX Pipeline Visualization\n\
}\n\
HelpIn HelpInfo {\n\
1. General Information\n\
diff -crB dlxview0.9/sim.c dlxview0.9b/sim.c
*** dlxview0.9/sim.c    1997-09-27 00:00:08.000000000 +0200
— dlxview0.9b/sim.c    2010-12-07 17:30:43.000000000 +0100
***************
*** 27,32 ****
— 27,33 —-
#include <string.h>
#include <stdlib.h>
#include <tcl.h>
+ #include <errno.h>
#include “dlx.h”
#include “sym.h”

***************
*** 1033,1049 ****
static char *
errstring(void)
{
!     extern int errno, sys_nerr;
!     extern char *sys_errlist[];
static char msgbuf[64];

if( !errno )
return “no error”;
!     if( errno >= sys_nerr ) {
sprintf( msgbuf, “unknown error %d”, errno );
return msgbuf;
}
!     return sys_errlist[ errno ];
}

— 1034,1051 —-
static char *
errstring(void)
{
!     extern int errno;
!     char * strerror_msg;
static char msgbuf[64];

+     strerror_msg=strerror( errno);
if( !errno )
return “no error”;
!     if( strerror_msg == 0 ) {
sprintf( msgbuf, “unknown error %d”, errno );
return msgbuf;
}
!     return strerror_msg ;
}

3 Responses to Saving Legacy Software: DLXView (reload) in Ubuntu 10.4 x64

  1. Jacano dice:

    Oleeeé!
    Me has salvado la vida, eres el mejor!!!
    Gracias Pablo!!

    • geus dice:

      waa tío genial. En realidad sería interesante que pudiera subir el tar a algún sitio para que la gente lo pudiera descargar y recompilar. A ver si veo algún sitio.

      Saludos.

  2. grizzly dice:

    You are the hero!
    Unfortunatelly the “old and official” tarball is now gone😦

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: